cirq.merge_single_qubit_gates_to_phxz_symbolized

Merges consecutive single qubit gates as PhasedXZ Gates.

Symbolizes if any of the consecutive gates is symbolized.

>>> q0, q1 = cirq.LineQubit.range(2)
>>> c = cirq.Circuit(                    cirq.X(q0),                    cirq.CZ(q0,q1)**sympy.Symbol("cz_exp"),                    cirq.Y(q0)**sympy.Symbol("y_exp"),                    cirq.X(q0))
>>> print(c)
</td>
</tr>
<tr>
<td>
`0`<a id="0"></a>
</td>
<td>
───X───@──────────Y^y_exp───X───

</td>
</tr><tr>
<td>
`1`<a id="1"></a>
</td>
<td>
───────@^cz_exp─────────────────
>>> new_circuit, new_sweep = cirq.merge_single_qubit_gates_to_phxz_symbolized(                c, sweep=cirq.Zip(cirq.Points(key="cz_exp", points=[0, 1]),                                  cirq.Points(key="y_exp",  points=[0, 1])))
>>> print(new_circuit)
</td>
</tr><tr>
<td>
`0`<a id="0"></a>
</td>
<td>
───PhXZ(a=-1,x=1,z=0)───@──────────PhXZ(a=a0,x=x0,z=z0)───

</td>
</tr><tr>
<td>
`1`<a id="1"></a>
</td>
<td>
────────────────────────@^cz_exp──────────────────────────
>>> assert new_sweep[0] == cirq.ParamResolver({'a0': -1, 'x0': 1, 'z0': 0, 'cz_exp': 0})
>>> assert new_sweep[1] == cirq.ParamResolver({'a0': -0.5, 'x0': 0, 'z0': -1, 'cz_exp': 1})

circuit Input circuit to transform. It will not be modified.
context cirq.TransformerContext storing common configurable options for transformers.
sweep Sweep of the symbols in the input circuit. An updated Sweep will be returned based on the transformation.
atol Absolute tolerance to angle error. Larger values allow more negligible gates to be dropped, smaller values increase accuracy.

Copy of the transformed input circuit.