Find file History
Strilanc and CirqBot Polish kak output and refactor optimizer package layout (#1155)
- Merge cirq/google/decompositions.py and cirq/decompositions.py into cirq/optimizers/decompositions.py
- Move cirq/decompositions.py into cirq/optimizers
- Fix kak decomposition not optimizing single-qubit gates it outputs
- Refactor MergeSingleQubitGates to take flexible arguments
- Refactor cirq.google.MergeRotations into cirq.merge_single_qubit_gates_into_phased_x_z using cirq.MergeSingleQubitGates
- Simplify imports in several cirq/optimizers files
- Use `Callable[[Circuit], None]` instead of `cirq.Optimizer` in a few places (will eventually delete `cirq.Optimizer`, which is a contentless class)
- Delete some unused decomposition methods (controlled operation to gates)

Example code:

```python
import cirq
c = cirq.Circuit.from_ops(cirq.CNOT(*cirq.LineQubit.range(2)))
cirq.google.ConvertToXmonGates().optimize_circuit(c) 
print(c)
```

Before:

```
0: ───Z^0.75────X^0.5────S^-1───Y^-0.5───@───S^-1───Y^0.5───Y^0.5─────Z^-0.75───
                                         │
1: ───X^-0.25───Y^-0.5───────────────────@───S^-1───Y^0.5───X^-0.25─────────────
```

After:
```
0: ───────────────────────@──────────────────────
                          │
1: ───PhasedX(-0.5)^0.5───@───PhasedX(0.5)^0.5───
```

Still not perfect; the `PhasedX` is so close to a `Y` that it should probably round. But overall fine.
Latest commit 278f958 Nov 20, 2018

README.rst

The software in this directory (Cirq/examples/) is not included in the packaged library. Anyone is free to copy, modify, use, or publish this example code.