From 2de96003a48ae1ed91c853f38c72374a832824de Mon Sep 17 00:00:00 2001 From: Vivien Maisonneuve Date: Wed, 23 Jul 2014 17:07:41 +0200 Subject: [PATCH 1/1] Fix indentation of docstrings --- pypol/domains.py | 15 ++++----- pypol/geometry.py | 76 ++++++++++++++++++++++++---------------------- pypol/polyhedra.py | 37 +++++++++++----------- 3 files changed, 66 insertions(+), 62 deletions(-) diff --git a/pypol/domains.py b/pypol/domains.py index 1c400bd..122d428 100644 --- a/pypol/domains.py +++ b/pypol/domains.py @@ -392,7 +392,7 @@ class Domain(GeometricObject): coordinates[symbol] = coordinate points.append(Point(coordinates)) return points - + @classmethod def _polygon_inner_point(cls, points): symbols = points[0].symbols @@ -445,9 +445,9 @@ class Domain(GeometricObject): return sorted(points, key=angles.get) def faces(self): - """ - Returns the vertices of the faces of a polyhedra. - """ + """ + Returns the vertices of the faces of a polyhedra. + """ faces = [] for polyhedron in self.polyhedra: vertices = polyhedron.vertices() @@ -529,9 +529,10 @@ class Domain(GeometricObject): return False def subs(self, symbol, expression=None): - """ - Subsitute the given value into an expression and return the resulting expression. - """ + """ + Subsitute the given value into an expression and return the resulting + expression. + """ polyhedra = [polyhedron.subs(symbol, expression) for polyhedron in self.polyhedra] return Domain(*polyhedra) diff --git a/pypol/geometry.py b/pypol/geometry.py index 520a1ec..1db5710 100644 --- a/pypol/geometry.py +++ b/pypol/geometry.py @@ -107,27 +107,27 @@ class Point(Coordinates, GeometricObject): """ def isorigin(self): - """ - Return True if a Point is the origin. - """ + """ + Return True if a Point is the origin. + """ return not bool(self) def __hash__(self): return super().__hash__() def __add__(self, other): - """ - Adds a Point to a Vector and returns the result as a Point. - """ + """ + Adds a Point to a Vector and returns the result as a Point. + """ if not isinstance(other, Vector): return NotImplemented coordinates = self._map2(other, operator.add) return Point(coordinates) def __sub__(self, other): - """ - Returns the difference between two Points as a Vector. - """ + """ + Returns the difference between two Points as a Vector. + """ coordinates = [] if isinstance(other, Point): coordinates = self._map2(other, operator.sub) @@ -139,16 +139,16 @@ class Point(Coordinates, GeometricObject): return NotImplemented def __eq__(self, other): - """ - Compares two Points for equality. - """ + """ + Compares two Points for equality. + """ return isinstance(other, Point) and \ self._coordinates == other._coordinates def aspolyhedron(self): - """ - Return a Point as a polyhedron. - """ + """ + Return a Point as a polyhedron. + """ from .polyhedra import Polyhedron equalities = [] for symbol, coordinate in self.coordinates(): @@ -173,18 +173,18 @@ class Vector(Coordinates): return super().__new__(cls, coordinates) def isnull(self): - """ - Returns true if a Vector is null. - """ + """ + Returns true if a Vector is null. + """ return not bool(self) def __hash__(self): return super().__hash__() def __add__(self, other): - """ - Adds either a Point or Vector to a Vector. - """ + """ + Adds either a Point or Vector to a Vector. + """ if isinstance(other, (Point, Vector)): coordinates = self._map2(other, operator.add) return other.__class__(coordinates) @@ -192,7 +192,9 @@ class Vector(Coordinates): def angle(self, other): """ - Retrieve the angle required to rotate the vector into the vector passed in argument. The result is an angle in radians, ranging between -pi and pi. + Retrieve the angle required to rotate the vector into the vector passed + in argument. The result is an angle in radians, ranging between -pi and + pi. """ if not isinstance(other, Vector): raise TypeError('argument must be a Vector instance') @@ -238,9 +240,9 @@ class Vector(Coordinates): return result def __eq__(self, other): - """ - Compares two Vectors for equality. - """ + """ + Compares two Vectors for equality. + """ return isinstance(other, Vector) and \ self._coordinates == other._coordinates @@ -248,9 +250,9 @@ class Vector(Coordinates): return hash(tuple(self.coordinates())) def __mul__(self, other): - """ - Multiplies a Vector by a scalar value. - """ + """ + Multiplies a Vector by a scalar value. + """ if not isinstance(other, numbers.Real): return NotImplemented coordinates = self._map(lambda coordinate: other * coordinate) @@ -259,16 +261,16 @@ class Vector(Coordinates): __rmul__ = __mul__ def __neg__(self): - """ - Returns the negated form of a Vector. - """ + """ + Returns the negated form of a Vector. + """ coordinates = self._map(operator.neg) return Vector(coordinates) def norm(self): - """ - Normalizes a Vector. - """ + """ + Normalizes a Vector. + """ return math.sqrt(self.norm2()) def norm2(self): @@ -281,9 +283,9 @@ class Vector(Coordinates): return self / self.norm() def __sub__(self, other): - """ - Subtract a Point or Vector from a Vector. - """ + """ + Subtract a Point or Vector from a Vector. + """ if isinstance(other, (Point, Vector)): coordinates = self._map2(other, operator.sub) return other.__class__(coordinates) diff --git a/pypol/polyhedra.py b/pypol/polyhedra.py index fe143d4..b0b5d0e 100644 --- a/pypol/polyhedra.py +++ b/pypol/polyhedra.py @@ -56,23 +56,23 @@ class Polyhedron(Domain): @property def equalities(self): - """ - Return a list of the equalities in a set. - """ + """ + Return a list of the equalities in a set. + """ return self._equalities @property def inequalities(self): - """ - Return a list of the inequalities in a set. - """ + """ + Return a list of the inequalities in a set. + """ return self._inequalities @property def constraints(self): - """ - Return ta list of the constraints of a set. - """ + """ + Return ta list of the constraints of a set. + """ return self._constraints @property @@ -115,9 +115,10 @@ class Polyhedron(Domain): return True def subs(self, symbol, expression=None): - """ - Subsitute the given value into an expression and return the resulting expression. - """ + """ + Subsitute the given value into an expression and return the resulting + expression. + """ equalities = [equality.subs(symbol, expression) for equality in self.equalities] inequalities = [inequality.subs(symbol, expression) @@ -242,18 +243,18 @@ class Polyhedron(Domain): @classmethod def fromsympy(cls, expr): - """ - Convert a sympy object to an expression. - """ + """ + Convert a sympy object to an expression. + """ domain = Domain.fromsympy(expr) if not isinstance(domain, Polyhedron): raise ValueError('non-polyhedral expression: {!r}'.format(expr)) return domain def tosympy(self): - """ - Return an expression as a sympy object. - """ + """ + Return an expression as a sympy object. + """ import sympy constraints = [] for equality in self.equalities: -- 2.20.1