Skip to content

Commit

Permalink
Add __eq__ function to NXlink
Browse files Browse the repository at this point in the history
This prevents unnecessary calls to `set_changed` when comparing objects
linked to the same parent.
  • Loading branch information
rayosborn committed Jun 27, 2022
1 parent 4a808ff commit 2262e14
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/nexusformat/nexus/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5232,6 +5232,13 @@ def __setitem__(self, idx, value):
else:
self.nxlink.__setitem__(idx, value)

def __eq__(self, other):
if isinstance(other, NXlink):
return ((self._target == other._target) and
(self._filename == other._filename))
else:
return False

def __deepcopy__(self, memo={}):
"""Return a deep copy of the link containing the target information."""
obj = self
Expand Down

0 comments on commit 2262e14

Please sign in to comment.