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
Proposed fix for #3529 (Functionality decoupling for _strat_commutes_… #3548
Conversation
…_commutes_from_operation)
@@ -698,7 +698,10 @@ def zip_paulis( | |||
) -> Iterator[Tuple[pauli_gates.Pauli, pauli_gates.Pauli]]: | |||
return (paulis for qubit, paulis in self.zip_items(other)) | |||
|
|||
def _commutes_(self, other: Any, atol: float) -> Union[bool, NotImplementedType, None]: | |||
def _commutes_( |
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.
this seems unrelated - can you revert this formatting change?
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.
I see an error when I'm doing this
Run check/mypy
cirq/ops/pauli_string.py:701: error: Signature of "_commutes_" incompatible with supertype "Operation"
Found 1 error in 1 file (checked 745 source files)
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.
So I adjusted the
- arguments as in Operation super
- function definition length, since it was too long (I had an error from the git checks)
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.
I see what the problem is. You moved the *
argument with the _strat_commutes_from_operation
method. I think we don't need that for _commutes_
. Can you remove it from all the touched _commutes_
methods?
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.
@balopat please see my answers above, also I adjusted the code |
Hi @balopat, I'm back to Cirq. Could you please check the changes? |
@@ -167,8 +167,14 @@ def _unitary_(self) -> Union[np.ndarray, NotImplementedType]: | |||
return getter() | |||
return NotImplemented | |||
|
|||
def _commutes_(self, other: Any, atol: float) -> Union[bool, NotImplementedType, None]: | |||
return self.gate._commutes_on_qids_(self.qubits, other, atol=atol) | |||
def _commutes_( |
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.
We should be consistent within the PR at least and add the * parameter before atol.
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.
OK, I'll merge this, and then we can fix the inconsistency in #3695
Automerge cancelled: A required status check is not present. Missing statuses: ['cla/google'] |
protocols/commutes_protocol.py
toops/raw_types.py:Operator
_commute_
functionality to check if the parent class commutes)