Skip to content

paulistring optimize_test.py: Changed Z gate string representation #5546

Closed
@verult

Description

@verult

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.

Metadata

Metadata

Labels

area/contribkind/bug-reportSomething doesn't seem to work.priority/p3Should be done in the next 6 monthstriage/discussNeeds decision / discussion, bring these up during Cirq Cynque

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions