Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect stop time bug #8729 #11097

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6875,7 +6875,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(stop for stop in 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:
- |
Fixed an issue where :meth:`.QuantumCircuit.qubit_stop_time` and
:meth:`.QuantumCircuit.qubit_duration` returned incorrect time (duration)
when some qubits have instructions but the others idle.
Fixed `#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