Closed
Description
It used to be that you could check whether an operation had a gate using a type check
isinstance(gate_op, cirq.GateOperation)
But if you tag an op
it loses that signature.
isinstance(gate_op.with_tags('you are it'), cirq.GateOperation) == False
Note that there are a lot of these checks throughout Cirq that will presumably break when you tag an operation. For example look at cirq.EjectPhasedPaulis()
.
eject = cirq.EjectPhasedPaulis()
q = cirq.NamedQubit('a')
circuit = cirq.Circuit(cirq.PhasedXPowGate(phase_exponent=0.125)(q), cirq.Z(q))
eject.optimize_circuit(circuit)
print(circuit)
does the correct optimization
a: ───PhX(0.625)───────
Put if you tag the Z, it doesn't do the optimization
circuit = cirq.Circuit(cirq.PhasedXPowGate(phase_exponent=0.125)(q), cirq.Z(q).with_tags('you are it')
eject.optimize_circuit(circuit)
print(circuit)
prints
a: ───PhX(0.125)───Z['you are it']───