Skip to content

Commit

Permalink
Fix bug and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SooluThomas committed Jan 24, 2020
1 parent 9763c27 commit 7a2d677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qiskit/scheduler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def measure(qubits: List[int],
"""
schedule = Schedule(name="Default measurement schedule for qubits {}".format(qubits))
try:
inst_map = inst_map or backend.defaults().circuit_instruction_map
inst_map = inst_map or backend.defaults().instruction_schedule_map
meas_map = meas_map or backend.configuration().meas_map
except AttributeError:
raise PulseError('inst_map or meas_map, and backend cannot be None simultaneously')
Expand All @@ -98,7 +98,7 @@ def measure(qubits: List[int],
mem_slots=mem_slots)
schedule = schedule.insert(time, new_acquire)
# Measurement pulses should only be added if its qubit was measured by the user
elif inst.channels[0].index in qubits:
elif {channel.index for channel in inst.channels} & set(qubits):
schedule = schedule.insert(time, inst)
return schedule

Expand Down
3 changes: 3 additions & 0 deletions test/python/scheduler/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def test_measure(self):
Acquire(duration=10)([AcquireChannel(0), AcquireChannel(1)],
[MemorySlot(0), MemorySlot(1)]))
self.assertEqual(sched.instructions, expected.instructions)
sched = measure(qubits=[0],
backend=self.backend)
self.assertEqual(sched.instructions, expected.instructions)

def test_fail_measure(self):
"""Test failing measure."""
Expand Down

0 comments on commit 7a2d677

Please sign in to comment.