Skip to content

Commit

Permalink
Fix incorrect stop time bug #8729 (#11097) (#13843)
Browse files Browse the repository at this point in the history
* 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]>
(cherry picked from commit 6842268)

Co-authored-by: Justin Woodring <[email protected]>
  • Loading branch information
mergify[bot] and JustinWoodring authored Feb 14, 2025
1 parent 91e694a commit acc9cec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6646,7 +6646,10 @@ def qubit_stop_time(self, *qubits: Union[Qubit, int]) -> float:
if len(qubits) == len([done for done in dones.values() if done]): # all done
return max(stop for stop in stops.values())

return 0 # If there are no instructions over bits
if len(stops) > 0: # not all but some qubits has instructions
return max(stops.values())
else:
return 0 # If there are no instructions over bits


class _OuterCircuitScopeInterface(CircuitScopeInterface):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
An issue where :meth:`.QuantumCircuit.qubit_stop_time` and
:meth:`.QuantumCircuit.qubit_duration` returned incorrect time (duration) was fixed.
It was triggered when some qubits have instructions but other qubits are idle.
Fixes `#8729 <https://github.com/Qiskit/qiskit/issues/8729>`__.
1 change: 1 addition & 0 deletions test/python/circuit/test_scheduled_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def test_per_qubit_durations_loose_constrain(self):
self.assertEqual(sc.qubit_stop_time(2), 0)
self.assertEqual(sc.qubit_start_time(0, 1), 300)
self.assertEqual(sc.qubit_stop_time(0, 1), 1400)
self.assertEqual(sc.qubit_stop_time(0, 1, 2), 1400)

qc.measure_all()

Expand Down

0 comments on commit acc9cec

Please sign in to comment.