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 ComposedOp.to_matrix #9316

Merged
merged 6 commits into from
Jan 9, 2023
Merged

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Dec 21, 2022

Summary

Fixes #9283.

Details and comments

The to_matrix method previously applied the global coefficient to each element in the ComposedOp -- which it shouldn't have as the combo function is multiplicative. Also, the dot-product should be taken of individual numpy arrays, not of one massive numpy array with all operators inside, which fixed the Matrix-Vector product bug.

@Cryoris Cryoris added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: opflow Related to the Opflow module labels Dec 21, 2022
@qiskit-bot
Copy link
Collaborator

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 the following people are requested to review this:

@Cryoris Cryoris added this to the 0.22.4 milestone Dec 21, 2022
@coveralls
Copy link

coveralls commented Dec 21, 2022

Pull Request Test Coverage Report for Build 3875649126

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.007%) to 84.576%

Totals Coverage Status
Change from base Build 3875236136: -0.007%
Covered Lines: 64036
Relevant Lines: 75714

💛 - Coveralls

@mergify mergify bot merged commit 244400a into Qiskit:main Jan 9, 2023
mergify bot pushed a commit that referenced this pull request Jan 9, 2023
* Fix ComposedOp.to_matrix

* lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 244400a)
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request Jan 11, 2023
* Fix ComposedOp.to_matrix

* lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Cryoris added a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
* Fix ComposedOp.to_matrix

* lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot added a commit that referenced this pull request Jan 12, 2023
* Fix ComposedOp.to_matrix

* lint

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 244400a)

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: opflow Related to the Opflow module stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComposedOp's to_matrix() returns a wrong answer.
4 participants