Fix: Initialize.inverse() now raises CircuitError immediately#15782
Fix: Initialize.inverse() now raises CircuitError immediately#15782ShellyGarion merged 5 commits intoQiskit:mainfrom
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
0645cac to
5194046
Compare
ShellyGarion
left a comment
There was a problem hiding this comment.
Hi @dinuthierycosminpro-debug - thanks for your contribution to qiskit and for fixing this bug.
Could you please handle the Docs and Lint formatting errors?
Other than some more formatting, this PR looks OK to me.
|
|
||
| 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." |
There was a problem hiding this comment.
| raise CircuitError ("Initialize is not unitary thus can not be inverted." | |
| raise CircuitError ("Initialize is not unitary thus can not be inverted. " |
|
|
||
| See `#15595 <https://github.com/Qiskit/qiskit/issues/15595>`__. | ||
|
|
||
|
|
There was a problem hiding this comment.
I think that 2 lines of space are not needed.
0d29b76 to
055a56f
Compare
055a56f to
9424527
Compare
Co-authored-by: Julien Gacon <gaconju@gmail.com>
12905b3 to
0fe1d00
Compare
|
This looks good to me, thanks for the addition @dinuthierycosminpro-debug. We're currently in release freeze for Qiskit v2.4, but once we split the stable branch for that release out we can merge your PR into |
|
LGTM too, thanks @dinuthierycosminpro-debug for your contribution to qiskit! |
|
Thank you for your reviews! |
ShellyGarion
left a comment
There was a problem hiding this comment.
Thanks! and your PR is the first to merge in Qiskit 2.5
* Fix: Initialize.inverse() now raises CircuitError immediately * move importations to the beggining * Fix: apply black formatting * Apply suggestions from code review by Cryoris Co-authored-by: Julien Gacon <gaconju@gmail.com> --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Shelly Garion <46566946+ShellyGarion@users.noreply.github.com> (cherry picked from commit 1aeb988)
#15848) * Fix: Initialize.inverse() now raises CircuitError immediately * move importations to the beggining * Fix: apply black formatting * Apply suggestions from code review by Cryoris --------- (cherry picked from commit 1aeb988) Co-authored-by: Cosmin Dinu-Thiery <dinu.thiery.cosmin.pro@gmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Shelly Garion <46566946+ShellyGarion@users.noreply.github.com>
Summary
Fixes #15595 by raising CircuitError immediately when inverse() is called on a circuit containing Initialize.
Previously, calling inverse() on such circuits would let the computation unfold until crashing with a cryptic and uninformative error.
Details and comments
A new inverse() method is added to the Initialize class to override the default inverse() method inherited from the Instruction class.
This fix comes with a test verifying that the correct error is raised, and a release note.