Open
Description
Currently, only three gates: PauliString
, PhasedXPowGate
and PhasedISwapPowGate
override the _value_equality_values_cls_
method to return different class types for comparison based on the phase exponent / number of elements in the pauli string.
For phased* gates specifically, This is not ideal and causes confusion because of multiple reasons:
- Equality across types is a complex problem is not consistent across Cirq. There are numerous other pairs of gates which are compatible which each other but do not currently support equality across types. For example:
cirq.FSimGate
andcirq.ISwapPowGate
(and other related pairs);cirq.PhasedXZGate
and pauli gates; etc. - With the advent of
cirq.GateFamily
class; equality across types is supposed to be handled by specialized gate families which understand the different types. For example, I'm currently writing acirq_google.FSimGateFamily
which can be used to check and convert types between any fsim compatible gate (i.e. fsim, phasedfsim, czpow, iswappow and phasediswap).
Therefore, I propose that we remove equality across types from PhasedXPowGate
and PhasedISwapPowGate
and use specialized gate families where such cross type equality checks are needed.
cc #3243