@@ -343,14 +343,14 @@ def __eq__(self, other) -> bool:
343
343
if not isinstance (other , type (self )):
344
344
return NotImplemented
345
345
346
- return self ._sorted_operations_ () == other ._sorted_operations_ ()
346
+ return self is other or self ._sorted_operations_ () == other ._sorted_operations_ ()
347
347
348
348
def _approx_eq_ (self , other : Any , atol : Union [int , float ]) -> bool :
349
349
"""See `cirq.protocols.SupportsApproximateEquality`."""
350
350
if not isinstance (other , type (self )):
351
351
return NotImplemented
352
352
353
- return protocols .approx_eq (
353
+ return self is other or protocols .approx_eq (
354
354
self ._sorted_operations_ (), other ._sorted_operations_ (), atol = atol
355
355
)
356
356
@@ -510,13 +510,11 @@ def _from_json_dict_(cls, operations, **kwargs):
510
510
return cls .from_ops (* operations )
511
511
512
512
def __add__ (self , other : 'cirq.OP_TREE' ) -> 'cirq.Moment' :
513
-
514
513
if isinstance (other , circuits .AbstractCircuit ):
515
514
return NotImplemented # Delegate to Circuit.__radd__.
516
515
return self .with_operations (other )
517
516
518
517
def __sub__ (self , other : 'cirq.OP_TREE' ) -> 'cirq.Moment' :
519
-
520
518
must_remove = set (op_tree .flatten_to_ops (other ))
521
519
new_ops = []
522
520
for op in self .operations :
0 commit comments