Skip to content

Commit

Permalink
Merge pull request #787 from QuTech-Delft/searchsorted2
Browse files Browse the repository at this point in the history
Optimize unsafe_sample
  • Loading branch information
terrorfisch authored Aug 24, 2023
2 parents 3d5d96d + 58a3471 commit e36e4cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qupulse/program/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ def unsafe_sample(self,
entries = self._table

for entry1, entry2 in pairwise(entries):
indices = slice(np.searchsorted(sample_times, entry1.t, 'left'),
np.searchsorted(sample_times, entry2.t, 'right'))
indices = slice(sample_times.searchsorted(entry1.t, 'left'),
sample_times.searchsorted(entry2.t, 'right'))
output_array[indices] = \
entry2.interp((float(entry1.t), entry1.v),
(float(entry2.t), entry2.v),
Expand Down Expand Up @@ -626,7 +626,7 @@ def unsafe_sample(self,
# indexing in numpy and their copy/reference behaviour
end = time + subwaveform.duration

indices = slice(*np.searchsorted(sample_times, (float(time), float(end)), 'left'))
indices = slice(*sample_times.searchsorted((float(time), float(end)), 'left'))
subwaveform.unsafe_sample(channel=channel,
sample_times=sample_times[indices]-np.float64(time),
output_array=output_array[indices])
Expand Down Expand Up @@ -843,7 +843,7 @@ def unsafe_sample(self,
time = 0
for _ in range(self._repetition_count):
end = time + body_duration
indices = slice(*np.searchsorted(sample_times, (float(time), float(end)), 'left'))
indices = slice(*sample_times.searchsorted((float(time), float(end)), 'left'))
self._body.unsafe_sample(channel=channel,
sample_times=sample_times[indices] - float(time),
output_array=output_array[indices])
Expand Down

0 comments on commit e36e4cc

Please sign in to comment.