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

Update repr of pauli strings #5444

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

dstrain115
Copy link
Collaborator

@dstrain115 dstrain115 commented Jun 3, 2022

  • The repr of pauli strings with coefficient of one
    used to truncate the one.
  • The old way is prettier but does not actually repr to the same thing,
    ie. type(eval('cirq.Z.on(cirq.LineQubit(0))')
    != type(eval('1*cirq.Z.on(cirq.LineQubit(0))')

Fixes: #2771

- The repr of pauli strings with coefficient of one
used to truncate the one.
- This is prettier but does not actually repr to the same thing,
ie.  type(eval('cirq.Z.on(cirq.LineQubit(0))')
!=   type(eval('1*cirq.Z.on(cirq.LineQubit(0))')

Fixes: quantumlib#2771
@dstrain115 dstrain115 requested review from a team, vtomole and cduck as code owners June 3, 2022 17:24
@CirqBot CirqBot added the Size: XS <10 lines changed label Jun 3, 2022
@CirqBot CirqBot added the size: S 10< lines changed <50 label Jun 3, 2022
Copy link
Collaborator

@dabacon dabacon left a comment

Choose a reason for hiding this comment

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

LGTM

There might be a case for handling the coefficient == 1 case, but I sort of like having the coefficient show up explicitly.

@dstrain115 dstrain115 merged commit 1c6b1b1 into quantumlib:master Jun 3, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Update repr of pauli strings

- The repr of pauli strings with coefficient of one
used to truncate the one.
- This is prettier but does not actually repr to the same thing,
ie.  type(eval('cirq.Z.on(cirq.LineQubit(0))')
!=   type(eval('1*cirq.Z.on(cirq.LineQubit(0))')

Fixes: quantumlib#2771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50 Size: XS <10 lines changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

repr(PauliString) on one qubit doesn't round-trip
3 participants