-
Notifications
You must be signed in to change notification settings - Fork 990
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 _circuit_diagram_info_ to cirq.PauliString #3094
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.
LGTM with minor comments.
cirq/ops/pauli_string.py
Outdated
symbols = list(str(self.get(q)) for q in qs) | ||
prefix = ('+' if self.coefficient == +1 else '-' if | ||
self.coefficient == -1 else 'i' if self.coefficient == 1j else | ||
'-i' if self.coefficient == -1j else repr(self.coefficient) + |
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.
The case of PauliStrings outside the Pauli group, i.e. with coefficients not in {1, -1, i, -i} may render a long ugly floating point number. Perhaps add explicit format string, e.g. limiting to three or four decimal places.
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.
Done.
-cirq.PauliString({a: cirq.X}), | ||
cirq.X(a) * cirq.Z(c), | ||
1j * cirq.X(a) * cirq.Y(b), | ||
), """ |
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.
Cover the case outside the Pauli group, e.g. cirq.PauliString({a: cirq.X}, coefficient=np.sqrt(1j))
.
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.
Done.
- Also adds `CircuitDiagramInfoArgs.format_complex` ``` 0: ───PauliString(+X)───PauliString(-X)───PauliString(+X)───PauliString(iX)─── │ │ 1: ───────────────────────────────────────┼─────────────────Y───────────────── │ 2: ───────────────────────────────────────Z─────────────────────────────────── ```
CircuitDiagramInfoArgs.format_complex