Return NotImplemented in Point special methods
[linpy.git] / linpy / geometry.py
index 1a56269..a0a7b7c 100644 (file)
@@ -185,16 +185,16 @@ class Point(Coordinates, GeometricObject):
         """
         Translate the point by a Vector object and return the resulting point.
         """
         """
         Translate the point by a Vector object and return the resulting point.
         """
-        if not isinstance(other, Vector):
-            return NotImplemented
-        coordinates = self._map2(other, operator.add)
-        return Point(coordinates)
+        if isinstance(other, Vector):
+            coordinates = self._map2(other, operator.add)
+            return Point(coordinates)
+        return NotImplemented
 
     def __sub__(self, other):
         """
 
     def __sub__(self, other):
         """
-        If other is a point, substract a point from another and returns the
-        resulting vector. If other is a vector, translate the point by the
-        opposite vector and returns the resulting point.
+        If other is a point, substract it from self and return the resulting
+        vector. If other is a vector, translate the point by the opposite vector
+        and returns the resulting point.
         """
         coordinates = []
         if isinstance(other, Point):
         """
         coordinates = []
         if isinstance(other, Point):
@@ -203,15 +203,15 @@ class Point(Coordinates, GeometricObject):
         elif isinstance(other, Vector):
             coordinates = self._map2(other, operator.sub)
             return Point(coordinates)
         elif isinstance(other, Vector):
             coordinates = self._map2(other, operator.sub)
             return Point(coordinates)
-        else:
-            return NotImplemented
+        return NotImplemented
 
     def __eq__(self, other):
         """
         Test whether two points are equal.
         """
 
     def __eq__(self, other):
         """
         Test whether two points are equal.
         """
-        return isinstance(other, Point) and \
-            self._coordinates == other._coordinates
+        if isinstance(other, Point):
+            return self._coordinates == other._coordinates
+        return NotImplemented
 
     def aspolyhedron(self):
         from .polyhedra import Polyhedron
 
     def aspolyhedron(self):
         from .polyhedra import Polyhedron