quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.24k stars 1.01k forks source link

equal_up_to_global_phase on gates doesn't work as expected #6574

Open babacry opened 5 months ago

babacry commented 5 months ago

Description of the issue Test cases

        (
            cirq.PhasedXPowGate(phase_exponent=1.5, exponent=1.0),
            cirq.PhasedXPowGate(phase_exponent=0.5, exponent=1.0),
            True,
        ),
        (cirq.XPowGate(exponent=2.0), cirq.I, True),

should pass the test suite IIUC?

If I apply equal_up_to_global_phase to matrices of gates, the test can pass:

cirq.equal_up_to_global_phase(cirq.PhasedXPowGate(phase_exponent=1.5, exponent=1.0),cirq.PhasedXPowGate(phase_exponent=0.5, exponent=1.0))

-> False

cirq.equal_up_to_global_phase(cirq.unitary(cirq.PhasedXPowGate(phase_exponent=1.5, exponent=1.0)),cirq.unitary(cirq.PhasedXPowGate(phase_exponent=0.5, exponent=1.0)))

-> True

How to reproduce the issue

Run the test cases above.

Cirq version

1.4.0.dev