From: Vivien Maisonneuve Date: Tue, 5 Aug 2014 16:57:54 +0000 (+0200) Subject: Fix unitary tests X-Git-Tag: 1.0~85 X-Git-Url: https://scm.cri.mines-paristech.fr/git/linpy.git/commitdiff_plain/960f0c252361dfd696359f803aae40a9b13b14a6?ds=inline;hp=9b755b94aa2c8847ffca607de239f5c3bca9984b Fix unitary tests --- diff --git a/doc/domain.rst b/doc/domain.rst index 7098c32..4cd79d9 100644 --- a/doc/domain.rst +++ b/doc/domain.rst @@ -3,155 +3,148 @@ Domains Module .. py:class :: Domain - The properties of a domain can be are found using the following + The properties of a domain can be are found using the following .. py:method:: symbols - + Returns a tuple of the symbols that exsist in a domain. .. py:method:: dimension - + Returns the number of variables that exist in a domain. .. py:method:: disjoint - + Returns a domain as disjoint. - - .. py:method:: num_parameters - - Returns the total number of parameters, input, output or dimensions in a domain. - - .. py:method:: involves_dims(self, dims) - - Returns ``True`` if a domain depends on the given dimensions. - - The unary properties of a domain can be inspected using the following methods. - + + .. py:method:: involves_vars(self, dims) + + Returns ``True`` if a domain depends on the given dimensions. + + The unary properties of a domain can be inspected using the following methods. + .. py:method:: isempty(self) - + Return ``True`` is a domain is empty. - + .. py:method:: isuniverse(self) - + Return ``True`` if a domain is the Universe set. - + .. py:method:: isbounded(self) - - Return ``True`` if a domain is bounded. + + Return ``True`` if a domain is bounded. .. py:method:: disjoint(self) - + It is not guarenteed that a domain is disjoint. If it is necessary, this method will return a domain as disjoint. The following methods compare two domains to find the binary properties. .. py:method:: isdisjoint(self, other) - + Return ``True`` if the intersection of *self* and *other* results in an empty set. - + .. py:method:: issubset(self, other) - + Test whether every element in a domain is in *other*. .. py:method:: __eq__(self, other) self == other - - Test whether a domain is equal to *other*. - + + Test whether a domain is equal to *other*. + .. py:method:: __lt__(self, other) self < other - - Test whether a domain is a strict subset of *other*. - + + Test whether a domain is a strict subset of *other*. + .. py:method:: __le__(self, other) self <= other - - Test whether every element in a domain is in *other*. - + + Test whether every element in a domain is in *other*. + .. py:method:: __gt__(self, other) self > other - - Test whether a domain is a strict superset of *other*. - + + Test whether a domain is a strict superset of *other*. + .. py:method:: __ge__(self, other) self >= other - + Test whether every element in *other* is in a domain. - - The following methods implement unary operations on a domain. + + The following methods implement unary operations on a domain. .. py:method:: complement(self) ¬self - - Return the complement of a domain. - + + Return the complement of a domain. + .. py:method:: simplify(self) Return a new domain without any redundant constraints. .. py:method:: project(self, dims) - + Return a new domain with the given dimensions removed. .. py:method:: aspolyhedron(self) - - Return polyhedral hull of a domain. - + + Return polyhedral hull of a domain. + .. py:method:: sample(self) - + Return a single sample subset of a domain. - The following methods implement binary operations on two domains. + The following methods implement binary operations on two domains. .. py:method:: intersection(self, other) self | other - - Return a new domain with the elements that are common between *self* and *other*. + + Return a new domain with the elements that are common between *self* and *other*. .. py:method:: union(self, other) self & other - - Return a new domain with all the elements from *self* and *other*. - + + Return a new domain with all the elements from *self* and *other*. + .. py:method:: difference(self, other) self - other - - Return a new domain with the elements in a domain that are not in *other* . - + + Return a new domain with the elements in a domain that are not in *other* . + .. py:method:: __add__(self, other) self + other - - Return the sum of two domains. - + + Return the sum of two domains. + The following methods use lexicographical ordering to find the maximum or minimum element in a domain. .. py:method:: lexmin(self) - - Return a new set containing the lexicographic minimum of the elements in the set. - + + Return a new set containing the lexicographic minimum of the elements in the set. + .. py:method:: lexmax(self) - - Return a new set containing the lexicographic maximum of the elements in the set. - - A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions. + Return a new set containing the lexicographic maximum of the elements in the set. + + + A 2D or 3D domain can be plotted using the :meth:`plot` function. The points, verticies, and faces of a domain can be inspected using the following functions. .. py:method:: points(self) - + Return a list of the points contained in a domain as :class:`Points` objects. .. py:method:: vertices(self) - + Return a list of the verticies of a domain. - + .. py:method:: faces(self) - + Return a list of the vertices for each face of a domain. - + .. py:method:: plot(self, plot=None, **kwargs) - - Return a plot of the given domain. - - - + + Return a plot of the given domain. diff --git a/doc/polyhedra.rst b/doc/polyhedra.rst index de0dfd5..736cff6 100644 --- a/doc/polyhedra.rst +++ b/doc/polyhedra.rst @@ -3,56 +3,56 @@ Polyhedra Module .. py:class:: Polyhedron - Polyhedron class allows users to build and inspect polyherons. The following methods provide the properties of a polyhedron. + Polyhedron class allows users to build and inspect polyherons. The following methods provide the properties of a polyhedron. .. py:method:: equalities(self) - + Return a list of the equalities in a polyhedron. - + .. py:method:: inequalities(self) - + Return a list of the inequalities in a polyhedron. .. py:method:: constraints(self) - + Return ta list of the constraints of a polyhedron. The following unary operations can be used to inspect a polyhedron. - + .. py:method:: disjoint(self) - + Returns a polyhedron as a disjoint. - + .. py:method:: isuniverse(self) - - Return ``True`` if a polyhedron is the Universe set. + + Return ``True`` if a polyhedron is the Universe set. .. py:method:: subs(self, symbol, expression=None) - - Subsitutes an expression into a polyhedron and returns the result. + + Subsitutes an expression into a polyhedron and returns the result. To create a polyhedron, the user must use the folloing functions to define equalities and inequalities as the contraints. - + .. py:function:: Eq(left, right) - - Create a constraint by setting *left* equal to *right*. - + + Create a constraint by setting *left* equal to *right*. + .. py:function:: Ne(left, right) Create a constraint by setting *left* not equal to *right*. - + .. py:function:: Lt(left, right) - - Create a constraint by setting *left* less than *right*. - + + Create a constraint by setting *left* less than *right*. + .. py:function:: Le(left, right) - - Create a constraint by setting *left* less than or equal to *right*. - + + Create a constraint by setting *left* less than or equal to *right*. + .. py:function:: Gt(left, right) - - Create a constraint by setting *left* greater than *right*. + + Create a constraint by setting *left* greater than *right*. .. py:function:: Ge(left, right) - - Create a constraint by setting *left* greater than or equal to *right*. + + Create a constraint by setting *left* greater than or equal to *right*. diff --git a/pypol/polyhedra.py b/pypol/polyhedra.py index 8e22602..9bfc64b 100644 --- a/pypol/polyhedra.py +++ b/pypol/polyhedra.py @@ -280,6 +280,7 @@ class Polyhedron(Domain): constraints.append(sympy.Ge(inequality.tosympy(), 0)) return sympy.And(*constraints) + class EmptyType(Polyhedron): __slots__ = Polyhedron.__slots__ diff --git a/pypol/tests/test_domains.py b/pypol/tests/test_domains.py index 9cb3a98..2907f09 100644 --- a/pypol/tests/test_domains.py +++ b/pypol/tests/test_domains.py @@ -169,12 +169,7 @@ class TestDomain(unittest.TestCase): self.assertEqual(self.universe.lexmax(), self.universe) self.assertEqual(self.empty.lexmax(), Empty) - def test_num_parameters(self): - self.assertEqual(self.square1.num_parameters(), 2) - self.assertEqual(self.empty.num_parameters(), 0) - self.assertEqual(self.universe.num_parameters(), 0) - - def test_involves_dims(self): - self.assertTrue(self.square1.involves_dims(symbols('x y'))) - self.assertFalse(self.empty.involves_dims(symbols('x'))) - self.assertFalse(self.universe.involves_dims(symbols('x'))) + def test_involves_vars(self): + self.assertTrue(self.square1.involves_vars(symbols('x y'))) + self.assertFalse(self.empty.involves_vars(symbols('x'))) + self.assertFalse(self.universe.involves_vars(symbols('x')))