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

Add _circuit_diagram_info_ to cirq.PauliString #3094

Merged
merged 3 commits into from
Jun 16, 2020
Merged

Add _circuit_diagram_info_ to cirq.PauliString #3094

merged 3 commits into from
Jun 16, 2020

Conversation

Strilanc
Copy link
Contributor

@Strilanc Strilanc commented Jun 16, 2020

  • Also adds CircuitDiagramInfoArgs.format_complex
0: ───PauliString(+X)───PauliString(-X)───PauliString(+X)───PauliString(iX)───
                                          │                 │
1: ───────────────────────────────────────┼─────────────────Y─────────────────
                                          │
2: ───────────────────────────────────────Z───────────────────────────────────

@Strilanc Strilanc requested review from dabacon and viathor June 16, 2020 00:09
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Jun 16, 2020
Copy link
Collaborator

@viathor viathor left a 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.

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) +
Copy link
Collaborator

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.

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.

-cirq.PauliString({a: cirq.X}),
cirq.X(a) * cirq.Z(c),
1j * cirq.X(a) * cirq.Y(b),
), """
Copy link
Collaborator

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)).

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.

@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 16, 2020
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 16, 2020
@CirqBot CirqBot merged commit b0b398e into master Jun 16, 2020
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 16, 2020
@CirqBot CirqBot deleted the pscs branch June 16, 2020 20:19
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 16, 2020
tonybruguier pushed a commit to tonybruguier/Cirq that referenced this pull request Aug 23, 2020
- Also adds `CircuitDiagramInfoArgs.format_complex`

```
0: ───PauliString(+X)───PauliString(-X)───PauliString(+X)───PauliString(iX)───
                                          │                 │
1: ───────────────────────────────────────┼─────────────────Y─────────────────
                                          │
2: ───────────────────────────────────────Z───────────────────────────────────
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants