Skip to content

Commit

Permalink
Fixes Qiskit#7078: Make Acquire.channels only return the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
pollyshaw committed Jul 19, 2022
1 parent 0b1a111 commit 34ffb0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions qiskit/pulse/instructions/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def channel(self) -> AcquireChannel:
return self.operands[1]

@property
def channels(self) -> Tuple[Union[AcquireChannel, MemorySlot, RegisterSlot]]:
def channels(self) -> Tuple[AcquireChannel]:
"""Returns the channels that this schedule uses."""
return tuple(self.operands[ind] for ind in (1, 2, 3) if self.operands[ind] is not None)
return self.channel,

@property
def duration(self) -> Union[int, ParameterExpression]:
Expand Down
8 changes: 5 additions & 3 deletions qiskit/scheduler/lowering.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from qiskit.circuit.measure import Measure
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.exceptions import QiskitError
from qiskit.pulse import Schedule
from qiskit.pulse import Schedule, Acquire
from qiskit.pulse import instructions as pulse_inst
from qiskit.pulse.channels import AcquireChannel, MemorySlot, DriveChannel
from qiskit.pulse.channels import AcquireChannel, DriveChannel
from qiskit.pulse.exceptions import PulseError
from qiskit.pulse.macros import measure
from qiskit.scheduler.config import ScheduleConfig
Expand Down Expand Up @@ -79,7 +79,9 @@ def get_measure_schedule(qubit_mem_slots: Dict[int, int]) -> CircuitPulseDef:
meas_q = target_qobj_transform(meas_q)
acquire_q = meas_q.filter(channels=[AcquireChannel(qubit)])
mem_slot_index = [
chan.index for chan in acquire_q.channels if isinstance(chan, MemorySlot)
acquire[1].mem_slot.index
for acquire in acquire_q.instructions
if isinstance(acquire[1], Acquire) and not (acquire[1].mem_slot is None)
][0]
if mem_slot_index != qubit_mem_slots[qubit]:
raise KeyError(
Expand Down
2 changes: 1 addition & 1 deletion test/python/pulse/test_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_schedule_with_acquire_on_single_qubit(self):
)

self.assertEqual(len(sched_single.instructions), 2)
self.assertEqual(len(sched_single.channels), 6)
self.assertEqual(len(sched_single.channels), 2)

def test_parametric_commands_in_sched(self):
"""Test that schedules can be built with parametric commands."""
Expand Down

0 comments on commit 34ffb0b

Please sign in to comment.