-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix for issue #4087 #4103
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 for issue #4087 #4103
Conversation
Hi, thank you for taking this up! Can you please add a test that demonstrates and protects this functionality? |
Hi, I added a test, please let me know of any suggestions :) |
@balopat any updates ? |
This looks good, but it seems that there are failing tests... |
@balopat
but after fixing the addition operator it gives
so before I dive deeper in debugging Is this the intended behaviour ? |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@balopat I restricted the casting to only happen for gate operations, this should fix the issue |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
1 similar comment
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
… a PauliSum is a valid operation
a8136aa
to
4889170
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Ref: #4087 |
2852567
to
9c55a61
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@@ -570,6 +570,8 @@ def __iadd__(self, other): | |||
return self | |||
|
|||
def __add__(self, other): | |||
if isinstance(other, (gate_operation.GateOperation)): |
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.
As discussed on the Cirq Cynque, we'll need to make this more specific.
Namely, the instance check should be about checking whether this is an instance of identity.IdentityGate
. After this I think we're done with this PR :)
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.
but that won't fix the issue in #4087 , the identity there is constructed as cirq.I(cirq.LineQubit(0))
which has type cirq.ops.gate_operation.GateOperation
not cirq.ops.identity.IdentityGate
, so checking the instance type will fail.
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.
Oh, yes, I meant instance GateOperation, other.gate is instance of IdentityGate.
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.
updated (y).
0645026
to
312d175
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
312d175
to
cea6c7a
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
cea6c7a
to
d3a09b6
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
d3a09b6
to
21c813d
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Problem: the PauliSum add function checks that the type of the other operand is one of numbers.Complex, PauliString, PauliSum and raises NotImplemented otherwise. Fix: if the other operand is not one of the types try to cast it to PauliString and raise error only if that fails Fixes quantumlib#4087.
Problem: the PauliSum add function checks that the type of the other operand is one of numbers.Complex, PauliString, PauliSum and raises NotImplemented otherwise. Fix: if the other operand is not one of the types try to cast it to PauliString and raise error only if that fails Fixes quantumlib#4087.
Problem: the PauliSum add function checks that the type of the other operand is one of numbers.Complex, PauliString, PauliSum and raises NotImplemented otherwise.
Fix: if the other operand is not one of the types try to cast it to PauliString and raise error only if that fails
Fixes #4087.