Open richrines1 opened 6 months ago
cirq csynkque meeting - the false cirq.approx_eq(gate2, gate1)
is a bug that needs to be fixed.
cirq.approx_eq doc gives no guarantees about comparison of different types. I think we should add a trip wire if this == other: return True
to the approx_eq evaluation of the cirq.PhasedXPowGate
, but in general the result of cirq.approx_eq(gate1, cirq.X)
should be False because of different types.
I think we should add a trip wire
if this == other: return True
this would be a big improvement imo (and i think would also fix the Gateset
AssertionError above)
Description of the issue
when its
phase_exponent
is 0 or 0.5,PhasedXPowGate
masquerades as anXPowGate
orYPowGate
for the value_equality protocol. This can lead to various inconsistent/unexpected/broken behaviors for comparisons involving these gates, including an AssertionError when used in acirq.Gateset
How to reproduce the issue
a few of these problems would be fixed just by defining
PhasedXPowGate._value_equality_approximate_values_
, but i'm not sure this is enough to make so e.g. bothapprox_eq(gate1, cirq.X)
andapprox_eq(gate1, gate2)
succeed above. It kinda seems like the ideal fix would be to instead have bothXPowGate
andYPowGate
masquerade asPhasedXPowGate
s for the sake of comparisons (though maybe this is too severe a change?)Cirq version