Skip to content

Fix PauliString.pass_operations_over not supporting common gates #2351

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

Merged
merged 10 commits into from
Oct 29, 2019

Conversation

Strilanc
Copy link
Contributor

@Strilanc Strilanc commented Oct 15, 2019

  • Add _decompose_into_clifford_ method to GateOperation
  • Add _decompose_into_clifford_with_qubits_ method to several common gates
  • Add PauliString.conjugated_by, which accepts an OP_TREE defining a composite Clifford operation in Circuit order. This differs from pass_ops_over, because pass_ops_over takes a list of operations in reverse circuit order (which is confusing).
  • Fix op_gate_isinstance type annotation not allowing type tuples
  • Add PauliString.dense method

Code such as the following now works:

a, b = cirq.LineQubit.range(2)
print(cirq.X(a).pass_operations_over([cirq.H(a)]))
print(cirq.X(a).conjugated_by(cirq.Circuit(cirq.H(a), cirq.CNOT(a, b))))
Z(0)
Z(0)*X(1)

Fixes #2179

- Add `_decompose_into_clifford_` method to `GateOperation`
- Add `_decompose_into_clifford_with_qubits_` method to several common gates
- Add `PauliString.conjugated_by`, which accepts an `OP_TREE` defining a composite Clifford operation in Circuit order. This differs from `pass_ops_over`, because `pass_ops_over` which takes a list of operations in reverse circuit order (which is confusing).
- Fix op_gate_isinstance type annotation not allowing type tuples
- Add `PauliString.dense` method

Code such as the following now works:

```
a, b = cirq.LineQubit.range(2)
print(cirq.X(a).pass_operations_over([cirq.H(a)]))
print(cirq.X(a).conjugated_by([cirq.H(a), cirq.CNOT(a, b)]))
```

```
Z(0)
Z(0)*X(1)
```

Fixes #2179
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Oct 15, 2019
@Strilanc
Copy link
Contributor Author

Reviewers: please check that conjugated_by does the thing that you would expect based on the name. Ideally, predict it before reading the code or the tests.

@mpharrigan
Copy link
Collaborator

I'm excited for PauliString.conjugated_by

The various decompose methods: this seems like it could be simplified/generalized with the long-talked-about notion of gatesets

@Strilanc
Copy link
Contributor Author

Yes, I kept the decompose methods private without a publicly exposed method because I didn't want to commit to the interface yet.

@Strilanc Strilanc requested a review from cduck October 18, 2019 23:37
@mpharrigan
Copy link
Collaborator

is anything blocking this?

@Strilanc
Copy link
Contributor Author

@mpharrigan Nothing except actually getting a review of it.

# Conflicts:
#	cirq/ops/common_gates.py
#	cirq/ops/gate_operation.py
#	cirq/ops/pauli_string.py
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Oct 29, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Oct 29, 2019
@CirqBot CirqBot merged commit fb42718 into master Oct 29, 2019
@CirqBot CirqBot deleted the clifford3 branch October 29, 2019 01:29
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Oct 29, 2019
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.

PauliString.pass_operations_over doesn't accept Pauli
4 participants