Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cirq-core/cirq/circuits/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ def __eq__(self, other) -> bool:
if not isinstance(other, type(self)):
return NotImplemented

return self._sorted_operations_() == other._sorted_operations_()
return self is other or self._sorted_operations_() == other._sorted_operations_()

def _approx_eq_(self, other: Any, atol: Union[int, float]) -> bool:
"""See `cirq.protocols.SupportsApproximateEquality`."""
if not isinstance(other, type(self)):
return NotImplemented

return protocols.approx_eq(
return self is other or protocols.approx_eq(
self._sorted_operations_(), other._sorted_operations_(), atol=atol
)

Expand Down Expand Up @@ -510,13 +510,11 @@ def _from_json_dict_(cls, operations, **kwargs):
return cls.from_ops(*operations)

def __add__(self, other: 'cirq.OP_TREE') -> 'cirq.Moment':

if isinstance(other, circuits.AbstractCircuit):
return NotImplemented # Delegate to Circuit.__radd__.
return self.with_operations(other)

def __sub__(self, other: 'cirq.OP_TREE') -> 'cirq.Moment':

must_remove = set(op_tree.flatten_to_ops(other))
new_ops = []
for op in self.operations:
Expand Down