Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Aug 21, 2024
1 parent 6c45843 commit 9031fd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/qibolab/pulses/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def sequence(ps: PulseSequence, freq: dict[str, float], filename=None):
import matplotlib.pyplot as plt
from matplotlib import gridspec

# compile ``Align`` to delays as it is not supported here
ps = ps.align_to_delays()
num_pulses = len(ps)
_ = plt.figure(figsize=(14, 2 * num_pulses), dpi=200)
gs = gridspec.GridSpec(ncols=1, nrows=num_pulses)
Expand Down
9 changes: 2 additions & 7 deletions src/qibolab/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,9 @@ def channel_duration(self, channel: ChannelId) -> float:
"""Duration of the given channel."""
return sum(pulse.duration for pulse in self.channel(channel))

def pulse_channels(self, pulse_id: int) -> ChannelId:
def pulse_channels(self, pulse_id: int) -> list[ChannelId]:
"""Find channels on which a pulse with a given id plays."""
channels = [channel for channel, pulse in self if pulse.id == pulse_id]
if len(channels) == 0:
raise ValueError(
f"Pulse with id {pulse_id} does not exist in the sequence."
)
return channels
return [channel for channel, pulse in self if pulse.id == pulse_id]

def concatenate(self, other: "PulseSequence") -> None:
"""Juxtapose two sequences.
Expand Down
5 changes: 5 additions & 0 deletions tests/pulses/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def test_align_to_delay():
for (ch1, p1), (ch2, p2) in zip(sequence[7:], delay_sequence[6:]):
assert ch1 == ch2
assert p1 is p2
# assert that pulses after align start simultaneously
sequence_without_last = PulseSequence(delay_sequence[:-2])
ch1_start = sequence_without_last.channel_duration("ch1")
ch2_start = sequence_without_last.channel_duration("ch2")
assert ch1_start == ch2_start


def test_trim():
Expand Down

0 comments on commit 9031fd5

Please sign in to comment.