Skip to content

Commit cea6c7a

Browse files
restrict identity check to other.gate
1 parent 9c55a61 commit cea6c7a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cirq-core/cirq/ops/linear_combinations.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,12 @@ def __iadd__(self, other):
570570
return self
571571

572572
def __add__(self, other):
573-
if isinstance(other, (gate_operation.GateOperation)):
574-
other = PauliString(other)
575573
if not isinstance(other, (numbers.Complex, PauliString, PauliSum)):
576-
return NotImplemented
574+
try:
575+
if isinstance(other.gate, identity.IdentityGate):
576+
other = PauliString(other)
577+
except:
578+
return NotImplemented
577579
result = self.copy()
578580
result += other
579581
return result

0 commit comments

Comments
 (0)