Skip to content

Commit f127113

Browse files
Fix: Allow subtraction of IdentityGate in PauliSum.__sub__
1 parent 7f570b3 commit f127113

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cirq-core/cirq/ops/linear_combinations.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,10 @@ def __isub__(self, other):
798798

799799
def __sub__(self, other):
800800
if not isinstance(other, (numbers.Complex, PauliString, PauliSum)):
801-
return NotImplemented
801+
if hasattr(other, 'gate') and isinstance(other.gate, identity.IdentityGate):
802+
other = PauliString(other)
803+
else:
804+
return NotImplemented
802805
result = self.copy()
803806
result -= other
804807
return result

0 commit comments

Comments
 (0)