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

Commit

Permalink
raise index error for index error; fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jan 6, 2021
1 parent 530d85c commit 73a8be1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6891,6 +6891,12 @@ def facets(self):
return ()
return self.faces(self.dimension()-1)

def join_of_Vrep(self, *Vrepresentatives):
return self.face_generator().join_of_Vrep(*Vrepresentatives)

def meet_of_facets(self, *facets):
return self.face_generator().meet_of_facets(*facets)

@cached_method(do_pickle=True)
def f_vector(self):
r"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2262,8 +2262,8 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: C = CombinatorialPolyhedron(P)
sage: C.join_of_Vrep(0,1)
A 1-dimensional face of a 3-dimensional combinatorial polyhedron
sage: C.join_of_Vrep(0,3).ambient_V_indices()
(0, 1, 2, 3, 4, 5)
sage: C.join_of_Vrep(0,11).ambient_V_indices()
(0, 1, 10, 11, 12, 13)
sage: C.join_of_Vrep(8).ambient_V_indices()
(8,)
sage: C.join_of_Vrep().ambient_V_indices()
Expand All @@ -2289,8 +2289,8 @@ cdef class CombinatorialPolyhedron(SageObject):
(0,)
sage: C.meet_of_facets(0,1).ambient_H_indices()
(0, 1)
sage: C.meet_of_facets(0,3).ambient_H_indices()
(0, 3)
sage: C.meet_of_facets(0,2).ambient_H_indices()
(0, 2)
sage: C.meet_of_facets(0,2,3).ambient_H_indices()
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
sage: C.meet_of_facets().ambient_H_indices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ cdef class FaceIterator_base(SageObject):
sage: it.meet_of_facets(1,2,3).ambient_H_indices()
Traceback (most recent call last):
...
AssertionError: index out of range
IndexError: coatoms out of range
If the iterator has already been used, it must be reseted before::
Expand Down Expand Up @@ -587,7 +587,7 @@ cdef class FaceIterator_base(SageObject):
sage: it.join_of_Vrep(8)
Traceback (most recent call last):
...
AssertionError: index out of range
IndexError: coatoms out of range
If the iterator has already been used, it must be reseted before::
Expand Down Expand Up @@ -699,7 +699,7 @@ cdef class FaceIterator_base(SageObject):
sage: it._meet_of_coatoms(100)
Traceback (most recent call last):
...
AssertionError: index out of range
IndexError: coatoms out of range
The empty face is detected correctly, even with lines or rays::
Expand Down Expand Up @@ -737,7 +737,8 @@ cdef class FaceIterator_base(SageObject):
face_add_atom(face, i)

for i in indices:
assert 0 <= i < n_coatoms, "index out of range"
if not 0 <= i < n_coatoms:
raise IndexError("coatoms out of range")
face_intersection(face, face, coatoms.data.faces[i])

if not self._bounded and face_issubset(face, self.structure.visited_all[self.structure.dimension-1].faces[0]):
Expand Down Expand Up @@ -817,11 +818,11 @@ cdef class FaceIterator_base(SageObject):
sage: it._join_of_atoms(-1)
Traceback (most recent call last):
...
AssertionError: index out of range
IndexError: atoms out of range
sage: it._join_of_atoms(100)
Traceback (most recent call last):
...
AssertionError: index out of range
IndexError: atoms out of range
"""
if unlikely(self.structure.face_status != 0):
raise ValueError("please reset the face iterator")
Expand All @@ -837,7 +838,8 @@ cdef class FaceIterator_base(SageObject):
cdef face_t pseudo_face = face_mem.data.faces[1]
cdef size_t i

assert all(i in range(n_atoms) for i in indices), "index out of range"
if not all(i in range(n_atoms) for i in indices):
raise IndexError("atoms out of range")

# Initialize a pseudo_face as indicated by the indices.
for i in indices:
Expand Down

0 comments on commit 73a8be1

Please sign in to comment.