Coordinate().__eq__: enable comparison with tuples

This commit is contained in:
Stefan Harmuth 2023-12-17 07:21:00 +01:00
parent 2bec56eb1c
commit 42cbf6f85c

View File

@ -261,6 +261,12 @@ class Coordinate(tuple):
else:
return self.__class__(-self[0], -self[1], -self[2])
def __eq__(self, other: Coordinate | tuple) -> bool:
if self[2] is None:
return self[0] == other[0] and self[1] == other[1]
else:
return self[0] == other[0] and self[1] == other[1] and self[2] == other[2]
def __add__(self, other: Coordinate | tuple) -> Coordinate:
if self[2] is None:
return self.__class__(self[0] + other[0], self[1] + other[1])