-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Reject bad values in SparsePauliOp.paulis
setter
#10437
Reject bad values in SparsePauliOp.paulis
setter
#10437
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 the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5875634140
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking at this. I'm not certain that this will be the direction we ought to go with the linked issue: see #10384 (comment).
For what it's worth, it's typically not good to call an __init__
method from anywhere other than a child class's __init__
; it's quite easy for bugs to slip in like this if the child class __init__
prepares some other state before calling up to its parent initialiser. It doesn't happen currently in SparsePauliOp
, but it's something that may well get introduced in the future.
Value error will be raised if: 1. Number of qubits are not equal 2. Number of elements in PauliList are not equal
Value error will be raised if: 1. Number of qubits are not equal 2. Number of elements in PauliList are not equal
b6a2891
to
94df9e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. It looks good to me. Could you add the release note and tests to check this spec?
Sure |
@ikkoham: I've just updated this PR to add the tests and a release note. Could you review / merge? |
SparsePauliOp.paulis
setter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. LGTM! (I believe this is back port stable potential.)
* Fix Sparse pauli setter to update dimension info * Fix Sparse pauli setter to verify dimension info Value error will be raised if: 1. Number of qubits are not equal 2. Number of elements in PauliList are not equal * Add tests * Add release note --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com> (cherry picked from commit fe87015)
* Fix Sparse pauli setter to update dimension info * Fix Sparse pauli setter to verify dimension info Value error will be raised if: 1. Number of qubits are not equal 2. Number of elements in PauliList are not equal * Add tests * Add release note --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com> (cherry picked from commit fe87015) Co-authored-by: atharva-satpute <55058959+atharva-satpute@users.noreply.github.com>
* Fix Sparse pauli setter to update dimension info * Fix Sparse pauli setter to verify dimension info Value error will be raised if: 1. Number of qubits are not equal 2. Number of elements in PauliList are not equal * Add tests * Add release note --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Summary
Updated the sparse pauli setter method to propagate dimension info by calling the parent's (
BaseOperator
)__init__()
Fix: #10384
Details and comments
The dimension info was updated and propagated up via
PauliList
but remained unchanged when accessed viaSparsePauliOp
object