Skip to content

Commit

Permalink
fix: Accept sequence concatenation with more general iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Sep 5, 2024
1 parent 57acca7 commit 8f9248e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/qibolab/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def pulse_channels(self, pulse_id: int) -> list[ChannelId]:
"""Find channels on which a pulse with a given id plays."""
return [channel for channel, pulse in self if pulse.id == pulse_id]

def concatenate(self, other: "PulseSequence") -> None:
def concatenate(self, other: Iterable[_Element]) -> None:
"""Juxtapose two sequences.
Appends ``other`` in-place such that the result is:
- ``self``
- necessary delays to synchronize channels
- ``other``
"""
_synchronize(self, other.channels)
_synchronize(self, PulseSequence(other).channels)
self.extend(other)

def __ior__(self, other: "PulseSequence") -> "PulseSequence":
Expand Down
15 changes: 12 additions & 3 deletions tests/integration/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from qibolab.pulses import Delay


def test_dummy_execute_pulse_sequence_couplers():
def test_sequence_creation():
platform = create_platform("dummy")

single = platform.natives.single_qubit
Expand All @@ -14,10 +14,19 @@ def test_dummy_execute_pulse_sequence_couplers():

p02 = two[(0, 2)]
p12 = two[(1, 2)]
q0 = single[0]
q1 = single[1]
q2 = single[2]

seq = q1.RX() | p12.CZ() | [("", Delay())] | q2.RX() | p02.CZ()
ch1 = platform.qubits[1]

seq = (
q1.RX()
| p12.CZ()
| [(ch1.drive, Delay(duration=6.5))]
| q2.RX()
| q0.RX12()
| p02.CZ()
)
for q in range(3):
seq |= single[q].MZ()

Expand Down

0 comments on commit 8f9248e

Please sign in to comment.