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

Allow measure_single_paulistring to have negative coefficient #6143

Merged

Conversation

skushnir123
Copy link
Contributor

@skushnir123 skushnir123 commented Jun 13, 2023

Previously we had a check to make sure the coefficient of the paulistring passed to measure_single_paulistring had a coefficient of 1 but we support +1 and -1. Check out #6137 for context.

Fixes #6137

@skushnir123 skushnir123 requested review from a team, vtomole and cduck as code owners June 13, 2023 01:22
@skushnir123 skushnir123 requested a review from maffoo June 13, 2023 01:22
with pytest.raises(ValueError, match='must have a coefficient'):
_ = cirq.measure_single_paulistring(-ps)
_ = cirq.measure_single_paulistring(-2*ps)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the example in the original issue as a test for cirq.measure_single_paulistring to show that it now successfully creates the expected PauliMeasurementGate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % nit to simplify the test assertion.

cirq-core/cirq/ops/measure_util_test.py Outdated Show resolved Hide resolved
Co-authored-by: Tanuj Khattar <tanujkhattar@google.com>
@tanujkhattar tanujkhattar merged commit 26af12e into quantumlib:master Jun 13, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cirq.measure_pauli_string rejects negated pauli strings
2 participants