Coordinate().__eq__: enable comparison with tuples
This commit is contained in:
parent
2bec56eb1c
commit
42cbf6f85c
@ -261,6 +261,12 @@ class Coordinate(tuple):
|
|||||||
else:
|
else:
|
||||||
return self.__class__(-self[0], -self[1], -self[2])
|
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:
|
def __add__(self, other: Coordinate | tuple) -> Coordinate:
|
||||||
if self[2] is None:
|
if self[2] is None:
|
||||||
return self.__class__(self[0] + other[0], self[1] + other[1])
|
return self.__class__(self[0] + other[0], self[1] + other[1])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user