projects
/
linpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix error message
[linpy.git]
/
linpy
/
geometry.py
diff --git
a/linpy/geometry.py
b/linpy/geometry.py
index
0b05493
..
80f7771
100644
(file)
--- a/
linpy/geometry.py
+++ b/
linpy/geometry.py
@@
-19,8
+19,8
@@
import math
import numbers
import operator
import numbers
import operator
-from abc import ABC, abstract
property, abstractmethod
-from collections import
OrderedDict, Mapping
+from abc import ABC, abstract
method, abstractproperty
+from collections import
Mapping, OrderedDict
from .linexprs import Symbol
from .linexprs import Symbol
@@
-79,8
+79,8
@@
class Coordinates:
def __new__(cls, coordinates):
"""
def __new__(cls, coordinates):
"""
- Create a coordinate system from a dictionary or a sequence that maps
the
- symbols to their coordinates. Coordinates must be rational numbers.
+ Create a coordinate system from a dictionary or a sequence that maps
+
the
symbols to their coordinates. Coordinates must be rational numbers.
"""
if isinstance(coordinates, Mapping):
coordinates = coordinates.items()
"""
if isinstance(coordinates, Mapping):
coordinates = coordinates.items()
@@
-155,7
+155,7
@@
class Coordinates:
def __repr__(self):
string = ', '.join(['{!r}: {!r}'.format(symbol, coordinate)
def __repr__(self):
string = ', '.join(['{!r}: {!r}'.format(symbol, coordinate)
- for symbol, coordinate in self.coordinates()])
+
for symbol, coordinate in self.coordinates()])
return '{}({{{}}})'.format(self.__class__.__name__, string)
def _map(self, func):
return '{}({{{}}})'.format(self.__class__.__name__, string)
def _map(self, func):
@@
-202,8
+202,8
@@
class Point(Coordinates, GeometricObject):
def __sub__(self, other):
"""
If other is a point, substract it from self and return the resulting
def __sub__(self, other):
"""
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.
+ 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):
@@
-231,8
+231,8
@@
class Vector(Coordinates):
def __new__(cls, initial, terminal=None):
"""
def __new__(cls, initial, terminal=None):
"""
- Create a vector from a dictionary or a sequence that maps the symbols
to
- their coordinates, or as the displacement between two points.
+ Create a vector from a dictionary or a sequence that maps the symbols
+ t
o t
heir coordinates, or as the displacement between two points.
"""
if not isinstance(initial, Point):
initial = Point(initial)
"""
if not isinstance(initial, Point):
initial = Point(initial)
@@
-341,9
+341,6
@@
class Vector(Coordinates):
result += coordinate1 * coordinate2
return result
result += coordinate1 * coordinate2
return result
- def __hash__(self):
- return super().__hash__()
-
def norm(self):
"""
Return the norm of the vector.
def norm(self):
"""
Return the norm of the vector.
@@
-361,7
+358,7
@@
class Vector(Coordinates):
def asunit(self):
"""
def asunit(self):
"""
- Return the normalized vector, i.e. the vector of same direction but
with
- norm 1.
+ Return the normalized vector, i.e. the vector of same direction but
+
with
norm 1.
"""
return self / self.norm()
"""
return self / self.norm()