-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add qubits to PauliStringPhasor #5565
Conversation
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.
Looks good overall. Can you please also mark this PR as a breaking change because it changes the diagrams, repr and json of PauliStringPhasor?
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
Thanks @tanujkhattar for the quick review! |
Nice, +1 to this approach! |
OK, ready for rereview |
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.
LGTM % nits
gate = PauliStringPhasorGate( | ||
pauli_string.dense(pauli_string.qubits), | ||
pauli_string.dense(qubits or pauli_string.qubits), |
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.
pauli_string.dense(qubits or pauli_string.qubits), | |
pauli_string.dense(qubits), |
exponent_neg=exponent_neg, | ||
exponent_pos=exponent_pos, | ||
) | ||
super().__init__(gate, pauli_string.qubits) | ||
super().__init__(gate, qubits or pauli_string.qubits) |
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.
super().__init__(gate, qubits or pauli_string.qubits) | |
super().__init__(gate, qubits) |
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
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.
LGTM after mypy error is resolved.
Automerge cancelled: A status check is failing. |
Currently PauliStringPhasor determines its qubits from the PauliString passed in to it. PauliStringPhasorGate is based on DensePauliString, which allows Pauli Identity gates. When PauliStringPhasorGate is used create a PauliStringPhasor, the DensePauliString is converted to a PauliString, dropping identity gates. This causes #5167, which fails
gate(*qubits).gate == gate
.This fixes this problem by including all of the qubits when going from a PauliStringPhasorGate into the qubits on the PauliStringPhasor operation, and including these in the operation's gate.
This also fixes a #5564 where PauliString does preserve qubit order in it's repr.
Fixes #5167
Fixes #5564
This is a breaking change because it updates the reprs of PauliStringPhasor and PauliString. It also changes the json, though it is backwards compatible in this case.