Closed
Description
Description of the issue
CI coverage check failed in #5445 for cirq-core/cirq/contrib/paulistring/optimize_test.py
:
deftest_optimize():
q0, q1, q2 = cirq.LineQubit.range(3)
c_orig = cirq.Circuit(
cirq.X(q0) ** 0.5,
cirq.X(q1),
cirq.CZ(q1, q2),
cirq.X(q2) ** 0.125,
cirq.Z(q1) ** 0.5,
cirq.Y(q1) ** 0.5,
cirq.CZ(q0, q1),
cirq.Z(q1) ** 0.5,
cirq.CZ(q1, q2),
cirq.Z(q1) ** 0.5,
cirq.X(q2) ** 0.875,
cirq.CZ(q1, q2),
cirq.X(q2) ** 0.125,
)
cirq.testing.assert_has_diagram(
c_orig,
"""
0: ───X^0.5─────────────────────────@───────────────────────────────────
│
1: ───X───────@───S─────────Y^0.5───@───S───@───S─────────@─────────────
│ │ │
2: ───────────@───X^(1/8)───────────────────@───X^(7/8)───@───X^(1/8)───
""",
)
c_opt = optimized_circuit(c_orig)
cirq.testing.assert_allclose_up_to_global_phase(c_orig.unitary(), c_opt.unitary(), atol=1e-6)
> cirq.testing.assert_has_diagram(
c_opt,
"""
0: ───X^0.5────────────@────────────────────────────────────────
│
1: ───@───────X^-0.5───@───@────────────────@───Z^-0.5──────────
│ │ │
2: ───@────────────────────@───[X]^(-7/8)───@───[X]^-0.25───Z───
""",
)
E AssertionError: Circuit's text diagram differs from the desired diagram.
E
E Diagram of actual circuit:
E 0: ───X^0.5────────────@──────────────────────────────────────────────
E │
E 1: ───@───────X^-0.5───@───@────────────────@───Z^-0.5────────────────
E │ │ │
E 2: ───@────────────────────@───[X]^(-7/8)───@───[X]^-0.25───[Z]^(1)───
E
E Desired text diagram:
E 0: ───X^0.5────────────@────────────────────────────────────────
E │
E 1: ───@───────X^-0.5───@───@────────────────@───Z^-0.5──────────
E │ │ │
E 2: ───@────────────────────@───[X]^(-7/8)───@───[X]^-0.25───Z───
E
E Highlighted differences:
E 0: ───X^0.5────────────@────────────────────────────────────────██████
E │
E 1: ───@───────X^-0.5───@───@────────────────@───Z^-0.5──────────██████
E │ │ │
E 2: ───@────────────────────@───[X]^(-7/8)───@───[X]^-0.25───██████████
cirq-core/cirq/contrib/paulistring/optimize_test.py:53: AssertionError
This test only started failing after pulling in Cirq head. The cause is possibly a bad interaction between the latest changes and the swap from `AnyUnitaryGateFamily(1)` to `PhasedXZGate` in `CZTargetGateset`.
Fixing for now by changing the expected Z gate string.