Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Relax cddlib sanity checks
Browse files Browse the repository at this point in the history
sometimes cddlib's output is useful even if it fails to transform back and forth
  • Loading branch information
saraedum committed Jun 21, 2018
1 parent 9a649fc commit c404867
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 38 deletions.
9 changes: 4 additions & 5 deletions src/sage/categories/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,14 @@ def permutahedron(self, point=None, base_ring=None):
If function is too slow, switching the base ring to
:class:`RDF` will almost certainly speed things up.
EXAMPLES:
Unfortunately, an inexact base ring can not always be used::
EXAMPLES::
sage: W = CoxeterGroup(['H',3], base_ring=RDF)
sage: W.permutahedron()
Traceback (most recent call last):
doctest:warning
...
ValueError: polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data
UserWarning: This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.
A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 120 vertices
sage: W = CoxeterGroup(['I',7])
sage: W.permutahedron()
Expand Down
6 changes: 4 additions & 2 deletions src/sage/geometry/polyhedron/backend_cdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def parse(intro, data):
# somewhat random numerical choices. (But I am not an
# expert in that field by any means.) See also
# https://github.com/cddlib/cddlib/pull/7.
raise ValueError("polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data")
from warnings import warn
warn("This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.")
Polyhedron_cdd._parse_block(t.splitlines(), 'V-representation', parse)

def _init_from_Hrepresentation(self, ieqs, eqns, verbose=False):
Expand Down Expand Up @@ -137,7 +138,8 @@ def parse(intro, data):
# optimized for numerical stability, and makes some
# somewhat random numerical choices. (But I am not an
# expert in that field by any means.)
raise ValueError("polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data")
from warnings import warn
warn("This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.")
Polyhedron_cdd._parse_block(t.splitlines(), 'H-representation', parse)

def _run_cdd(self, cdd_input_string, cmdline_arg, verbose=False):
Expand Down
56 changes: 25 additions & 31 deletions src/sage/geometry/polyhedron/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,25 +1106,27 @@ def truncated_dodecahedron(self, exact=True, base_ring=None, backend=None):
sage: td.base_ring()
Number Field in sqrt5 with defining polynomial x^2 - 5
The faster implementation using floating point approximations does not
work unfortunately, see https://github.com/cddlib/cddlib/pull/7 for a
detailed discussion of this case::
sage: td = polytopes.truncated_dodecahedron(exact=False)
Traceback (most recent call last):
...
ValueError: polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data
sage: td.f_vector() # not tested
(1, 60, 90, 32, 1)
sage: td.base_ring() # not tested
Real Double Field
Its faces are 20 triangles and 12 regular decagons::
sage: sum(1 for f in td.faces(2) if len(f.vertices()) == 3)
20
sage: sum(1 for f in td.faces(2) if len(f.vertices()) == 10)
12
The faster implementation using floating point approximations does not
fully work unfortunately, see https://github.com/cddlib/cddlib/pull/7
for a detailed discussion of this case::
sage: td = polytopes.truncated_dodecahedron(exact=False)
doctest:warning
...
UserWarning: This polyhedron data is numerically complicated; cdd could not convert between the inexact V and H representation without loss of data. The resulting object might show inconsistencies.
sage: td.f_vector()
Traceback (most recent call last):
...
KeyError: ...
sage: td.base_ring()
Real Double Field
"""
if base_ring is None and exact:
from sage.rings.number_field.number_field import QuadraticField
Expand Down Expand Up @@ -1328,25 +1330,21 @@ def truncated_icosidodecahedron(self, exact=True, base_ring=None, backend=None):
sage: ti.base_ring() # long time
Number Field in sqrt5 with defining polynomial x^2 - 5
The faster implementation using floating point approximations does not
work unfortunately::
The implementation using floating point approximations is much faster::
sage: ti = polytopes.truncated_icosidodecahedron(exact=False)
Traceback (most recent call last):
...
ValueError: polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data
sage: ti.f_vector() # not tested
sage: ti.f_vector()
(1, 120, 180, 62, 1)
sage: ti.base_ring() # not tested
sage: ti.base_ring()
Real Double Field
Its faces are 30 squares, 20 hexagons and 12 decagons::
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 4) # long time
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 4)
30
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 6) # long time
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 6)
20
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 10) # long time
sage: sum(1 for f in ti.faces(2) if len(f.vertices()) == 10)
12
"""
if base_ring is None and exact:
Expand Down Expand Up @@ -1564,18 +1562,14 @@ def grand_antiprism(self, exact=True, backend=None):
sage: gap # not tested - very long time
A 4-dimensional polyhedron in (Number Field in sqrt5 with defining polynomial x^2 - 5)^4 defined as the convex hull of 100 vertices
Computation with approximated coordinates would be much faster but is
not supported currently::
Computation with approximated coordinates is much faster::
sage: gap = polytopes.grand_antiprism(exact=False)
Traceback (most recent call last):
...
ValueError: polyhedron data is numerically complicated; cdd could not convert between inexact V and H representation without loss of data
sage: gap # not tested
sage: gap
A 4-dimensional polyhedron in RDF^4 defined as the convex hull of 100 vertices
sage: gap.f_vector() # not tested
sage: gap.f_vector()
(1, 100, 500, 720, 320, 1)
sage: len(list(gap.bounded_edges())) # not tested
sage: len(list(gap.bounded_edges()))
500
"""
from itertools import product
Expand Down

0 comments on commit c404867

Please sign in to comment.