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

Commit

Permalink
subsequent calls for f_vector fail if first attempt fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Oct 18, 2019
1 parent acd671d commit bf85a62
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ cdef class CombinatorialPolyhedron(SageObject):
(A vertex at (0, 0),)
sage: CombinatorialPolyhedron(3r)
A 3-dimensional combinatorial polyhedron with 0 facets
Check that on wrong input subsequent calls of ``f_vector`` fail::
sage: data = P.incidence_matrix()
sage: vert = P.Vrepresentation()
sage: C = CombinatorialPolyhedron(data, Vrepr=vert)
sage: C.f_vector()
Traceback (most recent call last):
...
ValueError: not all vertices are intersections of facets
sage: C.f_vector()
Traceback (most recent call last):
...
ValueError: not all vertices are intersections of facets
"""
def __init__(self, data, Vrepr=None, facets=None, unbounded=False, far_face=None):
r"""
Expand Down Expand Up @@ -1458,21 +1472,23 @@ cdef class CombinatorialPolyhedron(SageObject):

# Copy ``f_vector``.
if dual:
if dim > 1 and f_vector[1] < self._n_facets:
# The input seemed to be wrong.
raise ValueError("not all facets are joins of vertices")

# We have computed the ``f_vector`` of the dual.
# Reverse it:
self._f_vector = \
tuple(smallInteger(f_vector[dim+1-i]) for i in range(dim+2))

# The input seemed to be wrong.
if dim > 1 and self._f_vector[dim] < self._n_facets:
raise ValueError("not all facets are joins of vertices")
else:
self._f_vector = tuple(smallInteger(f_vector[i]) for i in range(dim+2))

if not self._unbounded and dim > 1 \
and self._f_vector[1] < self._length_Vrepr - len(self.far_face_tuple):
and f_vector[1] < self._length_Vrepr - len(self.far_face_tuple):
# The input seemed to be wrong.
raise ValueError("not all vertices are intersections of facets")

self._f_vector = tuple(smallInteger(f_vector[i]) for i in range(dim+2))

cdef int _compute_edges(self, dual) except -1:
r"""
Compute the edges of the polyhedron.
Expand Down

0 comments on commit bf85a62

Please sign in to comment.