Skip to content

Commit

Permalink
Trac #28851: Polar of integer polytopes does not respect backend
Browse files Browse the repository at this point in the history
Currently, polytopes over the integers have there own method for
`polar`, which does not respect the given backend:
{{{
sage: polytopes.cube(backend='normaliz').polar().backend()
'ppl'
}}}

We add the backend to the constructor to fix this. Any backend that can
handle `ZZ` can also handle `QQ`.

URL: https://trac.sagemath.org/28851
Reported by: gh-kliem
Ticket author(s): Jonathan Kliem
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Dec 11, 2019
2 parents fe85d6f + 50bbb76 commit 4147813
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/sage/geometry/polyhedron/base_ZZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __dir__(self):
r"""
TESTS:
Removes the Ehrhart quasipolynomial from the list of methods for the
Removes the Ehrhart quasipolynomial from the list of methods for the
lattice polyhedron::
sage: P = polytopes.cube()
Expand Down Expand Up @@ -491,16 +491,24 @@ def polar(self):
<class 'sage.geometry.polyhedron.parent.Polyhedra_ZZ_ppl_with_category.element_class'>
sage: p.polar().base_ring()
Integer Ring
TESTS:
Test that :trac:`28551` is fixed::
sage: polytopes.cube(backend='normaliz').polar().backend() # optional - pynormaliz
'normaliz'
"""
if not self.has_IP_property():
raise ValueError('The polytope must have the IP property.')

vertices = [ ieq.A()/ieq.b() for
ieq in self.inequality_generator() ]

if all( all(v_i in ZZ for v_i in v) for v in vertices):
return Polyhedron(vertices=vertices, base_ring=ZZ)
return Polyhedron(vertices=vertices, base_ring=ZZ, backend=self.backend())
else:
return Polyhedron(vertices=vertices, base_ring=QQ)
return Polyhedron(vertices=vertices, base_ring=QQ, backend=self.backend())

@cached_method
def is_reflexive(self):
Expand Down

0 comments on commit 4147813

Please sign in to comment.