From e8ebee616179da727b335a0ef37732ee19c65b43 Mon Sep 17 00:00:00 2001 From: Vivien Maisonneuve Date: Sat, 12 Jul 2014 09:56:13 +0200 Subject: [PATCH 1/1] Implement methods Point.__hash__(), Vector.__hash__() --- pypol/geometry.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pypol/geometry.py b/pypol/geometry.py index ce055a4..ea751ae 100644 --- a/pypol/geometry.py +++ b/pypol/geometry.py @@ -106,6 +106,9 @@ class Point(Coordinates, GeometricObject): def isorigin(self): return not bool(self) + def __hash__(self): + return super().__hash__() + def __add__(self, other): if not isinstance(other, Vector): return NotImplemented @@ -145,14 +148,18 @@ class Vector(Coordinates): initial = Point(initial) if terminal is None: coordinates = initial._coordinates - elif not isinstance(terminal, Point): - terminal = Point(terminal) + else: + if not isinstance(terminal, Point): + terminal = Point(terminal) coordinates = terminal._map2(initial, operator.sub) return super().__new__(cls, coordinates) def isnull(self): return not bool(self) + def __hash__(self): + return super().__hash__() + def __add__(self, other): if isinstance(other, (Point, Vector)): coordinates = self._map2(other, operator.add) -- 2.20.1