Skip to content

Commit

Permalink
Merge pull request #208 from SpiNNakerManchester/reduce-op-complexity
Browse files Browse the repository at this point in the history
Make Chip support equality/hashing so we can use directly in sets/dicts
  • Loading branch information
Christian-B authored Jun 6, 2023
2 parents b04cc00 + 2c8214f commit 3a7438d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,12 @@ def __str__(self):

def __repr__(self):
return self.__str__()

def __eq__(self, other):
# Equality just on X,Y; that's most useful
if not isinstance(other, Chip):
return NotImplemented
return self._x == other.x and self._y == other.y

def __hash__(self):
return self._x * 256 + self._y

0 comments on commit 3a7438d

Please sign in to comment.