-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect duplicates in
QuantumCircuit.compose
(#11451)
* Detect duplicates in `QuantumCircuit.compose` Previously, `QuantumCircuit.compose` would silently attempt to compose multiple qubits onto the same state, which would fail in weird ways if any multi-qubit instructions were acting on these collapsed qubits. * Ensure error-checking happens before any modification After the move of `QuantumCircuit.data` to Rust-space, some of the state modification had started happening before the error checking, which could potentially leave an in-place modification in a partially applied state if an exception triggered during processing. This also ensures that the qubits and clbits arguments are checked, even if the actual data being composed is empty. * Delay mutation until the last possible time
- Loading branch information
1 parent
3263355
commit d48ba00
Showing
3 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
releasenotes/notes/fix-circuit-compose-duplicate-59de6c1c51f58e54.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
fixes: | ||
- | | ||
:meth:`.QuantumCircuit.compose` will now correctly raise a :exc:`.CircuitError` when there are | ||
duplicates in the ``qubits`` or ``clbits`` arguments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters