Skip to content

Commit 6842268

Browse files
JustinWoodringitoko1ucian0
authored
Fix incorrect stop time bug #8729 (#11097)
* Fix incorrect stop time bug #8729 * Apply suggestions from code review Minor update on the release note * Update qiskit/circuit/quantumcircuit.py Co-authored-by: Luciano Bello <[email protected]> * Update releasenotes/notes/fix-incorrect-qubit-stop-time-d0e056f60a01dd52.yaml Co-authored-by: Luciano Bello <[email protected]> --------- Co-authored-by: Toshinari Itoko <[email protected]> Co-authored-by: Luciano Bello <[email protected]>
1 parent 6169ba4 commit 6842268

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

qiskit/circuit/quantumcircuit.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6916,7 +6916,10 @@ def qubit_stop_time(self, *qubits: Union[Qubit, int]) -> float:
69166916
if len(qubits) == len([done for done in dones.values() if done]): # all done
69176917
return max(stop for stop in stops.values())
69186918

6919-
return 0 # If there are no instructions over bits
6919+
if len(stops) > 0: # not all but some qubits has instructions
6920+
return max(stops.values())
6921+
else:
6922+
return 0 # If there are no instructions over bits
69206923

69216924

69226925
class _OuterCircuitScopeInterface(CircuitScopeInterface):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
An issue where :meth:`.QuantumCircuit.qubit_stop_time` and
5+
:meth:`.QuantumCircuit.qubit_duration` returned incorrect time (duration) was fixed.
6+
It was triggered when some qubits have instructions but other qubits are idle.
7+
Fixes `#8729 <https://github.com/Qiskit/qiskit/issues/8729>`__.

test/python/circuit/test_scheduled_circuit.py

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def test_per_qubit_durations_loose_constrain(self):
352352
self.assertEqual(sc.qubit_stop_time(2), 0)
353353
self.assertEqual(sc.qubit_start_time(0, 1), 300)
354354
self.assertEqual(sc.qubit_stop_time(0, 1), 1400)
355+
self.assertEqual(sc.qubit_stop_time(0, 1, 2), 1400)
355356

356357
qc.measure_all()
357358

0 commit comments

Comments
 (0)