-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix: Initialize.inverse() now raises CircuitError immediately #15782
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
Merged
ShellyGarion
merged 5 commits into
Qiskit:main
from
CosminDinuThiery:fix_initialise.inverse()_error
Mar 22, 2026
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9fd7618
Fix: Initialize.inverse() now raises CircuitError immediately
CosminDinuThiery 5194046
move importations to the beggining
CosminDinuThiery 9424527
Fix: apply black formatting
CosminDinuThiery 0fe1d00
Apply suggestions from code review by Cryoris
CosminDinuThiery 8513e10
Merge branch 'main' into fix_initialise.inverse()_error
ShellyGarion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |||||
| from qiskit.circuit.instruction import Instruction | ||||||
| from qiskit.circuit.library.generalized_gates import Isometry | ||||||
| from .state_preparation import StatePreparation | ||||||
| from qiskit.circuit.exceptions import CircuitError | ||||||
|
|
||||||
| if typing.TYPE_CHECKING: | ||||||
| from qiskit.quantum_info.states.statevector import Statevector | ||||||
|
|
@@ -106,3 +107,8 @@ def params(self, parameters: Statevector | Sequence[complex] | str | int) -> Non | |||||
|
|
||||||
| def broadcast_arguments(self, qargs, cargs): | ||||||
| return self._stateprep.broadcast_arguments(qargs, cargs) | ||||||
|
|
||||||
| def inverse(self, annotated: bool = False): | ||||||
| """Overrides initialize.inverse() and raise a circuit error""" | ||||||
| raise CircuitError ("Initialize is not unitary thus can not be inverted." | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "If you want an invertible state preparation, use StatePreparation instead.") | ||||||
9 changes: 9 additions & 0 deletions
9
releasenotes/notes/fix-initialize.inverse()-late-error-1846fbbae82ec011.yaml
This file contains hidden or 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,9 @@ | ||
| --- | ||
| fixes: | ||
| - | | ||
| Fixed late error appearance when running initialize.inverse() method by overrinding | ||
| the method with :meth:`.Initialize.inverse` . | ||
|
CosminDinuThiery marked this conversation as resolved.
Outdated
|
||
|
|
||
| See `#15595 <https://github.com/Qiskit/qiskit/issues/15595>`__. | ||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that 2 lines of space are not needed. |
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.