Skip to content

Commit

Permalink
Trac #29905: test basic properties of polyhedra
Browse files Browse the repository at this point in the history
We add a method that tests basic properties, when the `TestSuite` is
run.

URL: https://trac.sagemath.org/29905
Reported by: gh-kliem
Ticket author(s): Jonathan Kliem
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager committed Jul 10, 2020
2 parents 04219c9 + 699d4e8 commit 16c2328
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,29 @@ def _delete(self):
"""
self.parent().recycle(self)

def _test_basic_properties(self, tester=None, **options):
"""
Run some basic tests to see, that some general assertion on polyhedra hold.
TESTS::
sage: polytopes.cross_polytope(3)._test_basic_properties()
"""
if tester is None:
tester = self._tester(**options)

tester.assertEqual(self.n_vertices() + self.n_rays() + self.n_lines(), self.n_Vrepresentation())
tester.assertEqual(self.n_inequalities() + self.n_equations(), self.n_Hrepresentation())
tester.assertEqual(self.dim() + self.n_equations(), self.ambient_dim())

tester.assertTrue(all(len(v[::]) == self.ambient_dim() for v in self.Vrep_generator()))
tester.assertTrue(all(len(h[::]) == self.ambient_dim() + 1 for h in self.Hrep_generator()))

if self.n_vertices() + self.n_rays() < 40:
tester.assertEqual(self, Polyhedron(vertices=self.vertices(), rays=self.rays(), lines=self.lines()))
if self.n_inequalities() < 40:
tester.assertEqual(self, Polyhedron(ieqs=self.inequalities(), eqns=self.equations()))

def base_extend(self, base_ring, backend=None):
"""
Return a new polyhedron over a larger base ring.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def regular_polygon(self, n, exact=True, base_ring=None, backend=None):
8
sage: octagon.volume() # optional - pynormaliz
2*a
sage: TestSuite(octagon).run()
sage: TestSuite(octagon).run() # long time
sage: TestSuite(polytopes.regular_polygon(5, exact=False)).run()
"""
n = ZZ(n)
Expand Down

0 comments on commit 16c2328

Please sign in to comment.