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

cirq.measure_pauli_string rejects negated pauli strings #6137

Closed
Strilanc opened this issue Jun 11, 2023 · 2 comments · Fixed by #6143
Closed

cirq.measure_pauli_string rejects negated pauli strings #6137

Strilanc opened this issue Jun 11, 2023 · 2 comments · Fixed by #6143
Assignees
Labels
good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@Strilanc
Copy link
Contributor

import cirq
cirq.measure_single_paulistring(-cirq.Y(cirq.LineQubit(0))*cirq.Y(cirq.LineQubit(1)), key='1')
@Strilanc Strilanc added the kind/bug-report Something doesn't seem to work. label Jun 11, 2023
@tanujkhattar tanujkhattar added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. labels Jun 11, 2023
@tanujkhattar
Copy link
Collaborator

This should be fairly straightforward to fix. We raise an error if the pauli string is does not have a coefficient of 1 here -

if pauli_observable.coefficient != 1:

However, the underlying PauliMeasurementGate does support DensePauliStrings with coefficient +1 and -1. So, instead of passing pauli_observable.values() to construct the PauliMeasurementGate, we can just pass pauli_observable.dense(pauli_observable.keys()) and then remove the check for coefficient being exactly +1.

return PauliMeasurementGate(pauli_observable.values(), key).on(*pauli_observable.keys())

@skushnir123
Copy link
Contributor

I can take this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants