diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index c67ebcdde8b..4eb591976ee 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -62,10 +62,10 @@ Face lattice:: Face iterator:: - sage: C.face_iter() + sage: C.face_generator() Iterator over the proper faces of a 4-dimensional combinatorial polyhedron - sage: C.face_iter(2) + sage: C.face_generator(2) Iterator over the 2-faces of a 4-dimensional combinatorial polyhedron AUTHOR: @@ -334,7 +334,7 @@ cdef class CombinatorialPolyhedron(SageObject): Traceback (most recent call last): ... ValueError: the combinatorial polyhedron was not initialized - sage: C.face_iter() + sage: C.face_generator() Traceback (most recent call last): ... ValueError: the combinatorial polyhedron was not initialized @@ -629,8 +629,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.permutahedron(4) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat sage: C1 = loads(C.dumps()) # optional - sage.combinat - sage: it = C.face_iter() # optional - sage.combinat - sage: it1 = C1.face_iter() # optional - sage.combinat + sage: it = C.face_generator() # optional - sage.combinat + sage: it1 = C1.face_generator() # optional - sage.combinat sage: tup = tuple((face.ambient_Vrepresentation(), # optional - sage.combinat ....: face.ambient_Hrepresentation()) for face in it) sage: tup1 = tuple((face.ambient_Vrepresentation(), # optional - sage.combinat @@ -641,8 +641,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.cyclic_polytope(4,10) sage: C = CombinatorialPolyhedron(P) sage: C1 = loads(C.dumps()) - sage: it = C.face_iter() - sage: it1 = C1.face_iter() + sage: it = C.face_generator() + sage: it1 = C1.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it) sage: tup1 = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it1) sage: tup == tup1 @@ -651,8 +651,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = Polyhedron(rays=[[1,0,0], [-1,0,0], [0,-1,0]]) sage: C = CombinatorialPolyhedron(P) sage: C1 = loads(C.dumps()) - sage: it = C.face_iter() - sage: it1 = C1.face_iter() + sage: it = C.face_generator() + sage: it1 = C1.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it) sage: tup1 = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it1) sage: tup == tup1 @@ -662,8 +662,8 @@ cdef class CombinatorialPolyhedron(SageObject): ....: [0,-1,0], [0,1,0]]) sage: C = CombinatorialPolyhedron(P) sage: C1 = loads(C.dumps()) - sage: it = C.face_iter() - sage: it1 = C1.face_iter() + sage: it = C.face_generator() + sage: it1 = C1.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it) sage: tup1 = tuple((face.ambient_Vrepresentation(), face.ambient_Hrepresentation()) for face in it1) sage: tup == tup1 @@ -1320,7 +1320,7 @@ cdef class CombinatorialPolyhedron(SageObject): contained in exactly two facets. To obtain all faces of codimension 1 use - :meth:`CombinatorialPolyhedron.face_iter` instead. + :meth:`CombinatorialPolyhedron.face_generator` instead. The ridges will be given by the facets, they are contained in. @@ -1387,7 +1387,7 @@ cdef class CombinatorialPolyhedron(SageObject): A 1-dimensional combinatorial polyhedron with 1 facet sage: C.ridges() () - sage: it = C.face_iter(0) + sage: it = C.face_generator(0) sage: for face in it: face.ambient_Hrepresentation() (An inequality (1, 0) x + 0 >= 0, An equation (0, 1) x + 0 == 0) @@ -2566,7 +2566,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C.join_of_Vrep().ambient_V_indices() # optional - sage.combinat () """ - return self.face_iter().join_of_Vrep(*indices) + return self.face_generator().join_of_Vrep(*indices) def meet_of_Hrep(self, *indices): r""" @@ -2593,18 +2593,23 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C.meet_of_Hrep().ambient_H_indices() # optional - sage.rings.number_field () """ - return self.face_iter().meet_of_Hrep(*indices) + return self.face_generator().meet_of_Hrep(*indices) - def face_iter(self, dimension=None, dual=None): + def face_generator(self, dimension=None, dual=None, algorithm=None): r""" Iterator over all proper faces of specified dimension. INPUT: - ``dimension`` -- if specified, then iterate over only this dimension - - ``dual`` -- if ``True``, iterate starting with the vertices, - if ``False``, iterate starting with the facets, - if ``None``, choose ``True`` or ``False`` for speed + - ``dual`` -- boolean (default ``None``); + if ``True``, pick dual algorithm + if ``False``, pick primal algorithm + - ``algorithm`` -- string (optional); + specify whether to start with facets or vertices: + * ``'primal'`` -- start with the facets + * ``'dual'`` -- start with the vertices + * ``None`` -- choose automatically OUTPUT: @@ -2619,7 +2624,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(dimension=2) # optional - sage.combinat + sage: it = C.face_generator(dimension=2) # optional - sage.combinat sage: face = next(it); face # optional - sage.combinat A 2-dimensional face of a 4-dimensional combinatorial polyhedron sage: face.ambient_Vrepresentation() # optional - sage.combinat @@ -2652,7 +2657,7 @@ cdef class CombinatorialPolyhedron(SageObject): (32, 89, 90, 94) sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: for face in it: face.ambient_Vrepresentation() (1, 2, 3) (0, 2, 3) @@ -2671,7 +2676,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = Polyhedron(rays=[[1,0],[0,1]], vertices=[[1,0],[0,1]]) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(1) + sage: it = C.face_generator(1) sage: for face in it: face.ambient_Vrepresentation() (A vertex at (0, 1), A vertex at (1, 0)) (A ray in the direction (1, 0), A vertex at (1, 0)) @@ -2682,6 +2687,13 @@ cdef class CombinatorialPolyhedron(SageObject): :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator.FaceIterator`, :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace`. """ + if algorithm == 'primal': + dual = False + elif algorithm == 'dual': + dual = True + elif algorithm is not None: + raise ValueError("algorithm must be 'primal', 'dual' or None") + cdef FaceIterator face_iter if dual is None: # Determine the faster way, to iterate through all faces. @@ -2692,6 +2704,8 @@ cdef class CombinatorialPolyhedron(SageObject): return FaceIterator(self, dual, output_dimension=dimension) + face_iter = face_generator + cdef FaceIterator _face_iter(self, bint dual, int dimension): r""" A method to obtain the FaceIterator as Cython object. @@ -3059,7 +3073,7 @@ cdef class CombinatorialPolyhedron(SageObject): # We take a face iterator and do one depth-search. # Depending on whether it is dual or not, # the search will be from the top or bottom. - cdef FaceIterator it = self.face_iter() + cdef FaceIterator it = self.face_generator() chain = [None]*(self.dimension()) dual = it.dual final_dim = 0 if not dual else self.dimension()-1 @@ -3782,7 +3796,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.permutahedron(4) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter() # optional - sage.combinat + sage: it = C.face_generator() # optional - sage.combinat sage: tup = tuple((face.ambient_Vrepresentation(), # optional - sage.combinat ....: face.ambient_Hrepresentation()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) # optional - sage.combinat @@ -3793,7 +3807,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.cyclic_polytope(4,10) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(),face.ambient_Hrepresentation()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) sage: tup2 = tuple((C.face_by_face_lattice_index(i).ambient_Vrepresentation(), @@ -3803,7 +3817,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = Polyhedron(rays=[[1,0,0], [-1,0,0], [0,-1,0]]) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(),face.ambient_Hrepresentation()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) sage: tup2 = tuple((C.face_by_face_lattice_index(i).ambient_Vrepresentation(), @@ -3814,7 +3828,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = Polyhedron(rays=[[1,0,0], [-1,0,0], ....: [0,-1,0], [0,1,0]]) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: tup = tuple((face.ambient_Vrepresentation(),face.ambient_Hrepresentation()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) sage: tup2 = tuple((C.face_by_face_lattice_index(i).ambient_Vrepresentation(), diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx index 9189f587922..5b40ee42cf2 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx @@ -14,7 +14,7 @@ Obtain a face from a face iterator:: sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it); face A 2-dimensional face of a 3-dimensional combinatorial polyhedron @@ -31,7 +31,7 @@ Obtain further information regarding a face:: sage: P = polytopes.octahedron() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(2) + sage: it = C.face_generator(2) sage: face = next(it); face A 2-dimensional face of a 3-dimensional combinatorial polyhedron sage: face.ambient_Vrepresentation() @@ -91,7 +91,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cyclic_polytope(5,8) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it) A 0-dimensional face of a 5-dimensional combinatorial polyhedron @@ -152,7 +152,7 @@ cdef class CombinatorialFace(SageObject): sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3], ....: [0,2,3],[1,2,3]]) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it) # indirect doctest A 2-dimensional face of a 3-dimensional combinatorial polyhedron @@ -260,15 +260,15 @@ cdef class CombinatorialFace(SageObject): EXAMPLES:: - sage: P = polytopes.permutahedron(6) # optional - sage.combinat - sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(dimension=3, dual=False) # optional - sage.combinat - sage: face = next(it) # optional - sage.combinat - sage: face.__repr__() # optional - sage.combinat + sage: P = polytopes.permutahedron(6) # optional - sage.combinat + sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat + sage: it = C.face_generator(dimension=3, algorithm='primal') # optional - sage.combinat + sage: face = next(it) # optional - sage.combinat + sage: face.__repr__() # optional - sage.combinat 'A 3-dimensional face of a 5-dimensional combinatorial polyhedron' - sage: it = C.face_iter(dimension=3, dual=True) # optional - sage.combinat - sage: face = next(it) # optional - sage.combinat - sage: face.__repr__() # optional - sage.combinat + sage: it = C.face_generator(dimension=3, algorithm='dual') # optional - sage.combinat + sage: face = next(it) # optional - sage.combinat + sage: face.__repr__() # optional - sage.combinat 'A 3-dimensional face of a 5-dimensional combinatorial polyhedron' """ return "A {}-dimensional face of a {}-dimensional combinatorial polyhedron"\ @@ -282,7 +282,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.simplex() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) sage: face1 = loads(face.dumps()) Traceback (most recent call last): @@ -312,7 +312,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.simplex(2) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: [hash(face) for face in it] [1, 2, 3, 4, 5, 6] @@ -383,7 +383,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = P.combinatorial_polyhedron() - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) sage: face.ambient_V_indices() (0, 3, 4, 5) @@ -406,7 +406,7 @@ cdef class CombinatorialFace(SageObject): Works for faces of the same combinatorial polyhedron; also from different iterators:: - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: v7 = next(it); v7.ambient_V_indices() (7,) sage: v6 = next(it); v6.ambient_V_indices() @@ -438,7 +438,7 @@ cdef class CombinatorialFace(SageObject): sage: P1 = polytopes.cube() sage: C1 = P1.combinatorial_polyhedron() - sage: it = C1.face_iter() + sage: it = C1.face_generator() sage: other_face = next(it) sage: other_face.ambient_V_indices() (0, 3, 4, 5) @@ -503,7 +503,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.associahedron(['A', 3]) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter() # optional - sage.combinat + sage: it = C.face_generator() # optional - sage.combinat sage: face = next(it) # optional - sage.combinat sage: face.dimension() # optional - sage.combinat 2 @@ -528,7 +528,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) sage: face.ambient_dimension() 3 @@ -547,7 +547,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(dimension=2) # optional - sage.combinat + sage: it = C.face_generator(dimension=2) # optional - sage.combinat sage: face = next(it) # optional - sage.combinat sage: face.ambient_Vrepresentation() # optional - sage.combinat (A vertex at (1, 3, 2, 5, 4), @@ -566,7 +566,7 @@ cdef class CombinatorialFace(SageObject): A vertex at (2, 3, 4, 5, 1)) sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: for face in it: (face.dimension(), face.ambient_Vrepresentation()) (2, (1, 2, 3)) (2, (0, 2, 3)) @@ -611,7 +611,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(dimension=2) # optional - sage.combinat + sage: it = C.face_generator(dimension=2) # optional - sage.combinat sage: face = next(it) # optional - sage.combinat sage: next(it).ambient_V_indices() # optional - sage.combinat (32, 91, 92, 93, 94, 95) @@ -619,7 +619,7 @@ cdef class CombinatorialFace(SageObject): (32, 89, 90, 94) sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: for face in it: (face.dimension(), face.ambient_V_indices()) (2, (1, 2, 3)) (2, (0, 2, 3)) @@ -662,7 +662,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: all(face.n_ambient_Vrepresentation() == len(face.ambient_Vrepresentation()) for face in it) True @@ -670,7 +670,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) """ if self._dual: @@ -690,7 +690,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(2) # optional - sage.combinat + sage: it = C.face_generator(2) # optional - sage.combinat sage: next(it).ambient_Hrepresentation() # optional - sage.combinat (An inequality (1, 1, 1, 0, 0) x - 6 >= 0, An inequality (0, 0, 0, -1, 0) x + 5 >= 0, @@ -702,7 +702,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cyclic_polytope(4,6) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it).ambient_Hrepresentation() (An inequality (-20, 29, -10, 1) x + 0 >= 0, An inequality (60, -47, 12, -1) x + 0 >= 0, @@ -750,7 +750,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(2) # optional - sage.combinat + sage: it = C.face_generator(2) # optional - sage.combinat sage: face = next(it) # optional - sage.combinat sage: face.ambient_H_indices(add_equations=False) # optional - sage.combinat (28, 29) @@ -769,7 +769,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cyclic_polytope(4,6) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: _ = next(it); _ = next(it) sage: next(it).ambient_H_indices() (0, 1, 2, 4, 5, 7) @@ -822,7 +822,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: all(face.n_ambient_Hrepresentation() == len(face.ambient_Hrepresentation()) for face in it) True @@ -830,7 +830,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter(2) # optional - sage.combinat + sage: it = C.face_generator(2) # optional - sage.combinat sage: f = next(it) # optional - sage.combinat sage: f.n_ambient_Hrepresentation(add_equations=True) # optional - sage.combinat 3 @@ -841,7 +841,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) """ cdef size_t n_equations = self._n_equations if add_equations else 0 @@ -869,7 +869,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cyclic_polytope(7,11) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(4) + sage: it = C.face_generator(4) sage: f = next(it); f A 4-dimensional face of a 7-dimensional combinatorial polyhedron sage: F = f.as_combinatorial_polyhedron(); F @@ -894,7 +894,7 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(2) + sage: it = C.face_generator(2) sage: f = next(it) sage: F = f.as_combinatorial_polyhedron() sage: C.Vrepresentation() @@ -932,7 +932,7 @@ cdef class CombinatorialFace(SageObject): The Hrepresentation of the quotient by the face is given by the ambient Hrepresentation of the face in that order:: - sage: it = C.face_iter(1) + sage: it = C.face_generator(1) sage: f = next(it) sage: Q = f.as_combinatorial_polyhedron(quotient=True) sage: C.Hrepresentation() @@ -952,7 +952,7 @@ cdef class CombinatorialFace(SageObject): The first representative of each element strictly containing the face is kept:: - sage: [g.ambient_H_indices() for g in C.face_iter(0)] + sage: [g.ambient_H_indices() for g in C.face_generator(0)] [(3, 4, 5), (0, 4, 5), (2, 3, 5), @@ -961,14 +961,14 @@ cdef class CombinatorialFace(SageObject): (0, 1, 4), (1, 2, 3), (0, 1, 2)] - sage: [g.ambient_H_indices() for g in Q.face_iter(0)] + sage: [g.ambient_H_indices() for g in Q.face_generator(0)] [(1,), (0,)] The method is not implemented for unbounded polyhedra:: sage: P = Polyhedron(rays=[[0,1]])*polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(2) + sage: it = C.face_generator(2) sage: f = next(it) sage: f.as_combinatorial_polyhedron() Traceback (most recent call last): diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index 1b7e0aba790..7490c2a165e 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -213,7 +213,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.permutahedron(4) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: it = C.face_iter() # indirect doctest # optional - sage.combinat + sage: it = C.face_generator() # indirect doctest # optional - sage.combinat sage: f_vector = [1, 0, 0, 0, 1] sage: for face in it: f_vector[face.dimension()+1] += 1 # optional - sage.combinat @@ -379,7 +379,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.cube() sage: C = P.combinatorial_polyhedron() - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it).ambient_V_indices() (0, 3, 4, 5) sage: it.reset() @@ -392,7 +392,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.Birkhoff_polytope(3) sage: C = P.combinatorial_polyhedron() - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: face = next(it) sage: face.ambient_H_indices(add_equations=False) (8,) @@ -454,7 +454,7 @@ cdef class FaceIterator_base(SageObject): EXAMPLES:: sage: P = polytopes.octahedron() - sage: it = P.combinatorial_polyhedron().face_iter() + sage: it = P.combinatorial_polyhedron().face_generator() sage: next(it) A 0-dimensional face of a 3-dimensional combinatorial polyhedron sage: it.current() @@ -472,7 +472,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.simplex() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: [d for d in it] [A 2-dimensional face of a 3-dimensional combinatorial polyhedron, A 2-dimensional face of a 3-dimensional combinatorial polyhedron, @@ -499,7 +499,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.simplex() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: it1 = loads(it.dumps()) Traceback (most recent call last): ... @@ -517,7 +517,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.Gosset_3_21() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: n_non_simplex_faces = 1 sage: for face in it: ....: if face.n_ambient_Vrepresentation() > face.dimension() + 1: @@ -530,7 +530,7 @@ cdef class FaceIterator_base(SageObject): Face iterator must not be in dual mode:: - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: _ = next(it) sage: it.ignore_subfaces() Traceback (most recent call last): @@ -539,7 +539,7 @@ cdef class FaceIterator_base(SageObject): Ignoring the same face as was requested to visit only consumes the iterator:: - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: _ = next(it) sage: it.only_subfaces() sage: it.ignore_subfaces() @@ -548,7 +548,7 @@ cdef class FaceIterator_base(SageObject): Face iterator must be set to a face first:: - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: it.ignore_subfaces() Traceback (most recent call last): ... @@ -568,7 +568,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.Gosset_3_21() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: n_faces_with_non_simplex_quotient = 1 sage: for face in it: ....: n_facets = face.n_ambient_Hrepresentation(add_equations=False) @@ -582,7 +582,7 @@ cdef class FaceIterator_base(SageObject): Face iterator must be in dual mode:: - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: _ = next(it) sage: it.ignore_supfaces() Traceback (most recent call last): @@ -631,7 +631,7 @@ cdef class FaceIterator_base(SageObject): sage: s = cones.schur(4) sage: C = CombinatorialPolyhedron(s) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: it.meet_of_Hrep(1,2).ambient_H_indices() (1, 2) sage: it.meet_of_Hrep(1,2,3).ambient_H_indices() @@ -1093,7 +1093,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.Birkhoff_polytope(4) sage: C = P.combinatorial_polyhedron() - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it).ambient_H_indices(add_equations=False) (15,) sage: next(it).ambient_H_indices(add_equations=False) @@ -1104,7 +1104,7 @@ cdef class FaceIterator_base(SageObject): Face iterator needs to be set to a face first:: - sage: it = C.face_iter() + sage: it = C.face_generator() sage: it.only_subfaces() Traceback (most recent call last): ... @@ -1112,7 +1112,7 @@ cdef class FaceIterator_base(SageObject): Face iterator must not be in dual mode:: - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: _ = next(it) sage: it.only_subfaces() Traceback (most recent call last): @@ -1121,7 +1121,7 @@ cdef class FaceIterator_base(SageObject): Cannot run ``only_subfaces`` after ``ignore_subfaces:: - sage: it = C.face_iter() + sage: it = C.face_generator() sage: _ = next(it) sage: it.ignore_subfaces() sage: it.only_subfaces() @@ -1158,7 +1158,7 @@ cdef class FaceIterator_base(SageObject): sage: P = polytopes.Birkhoff_polytope(4) sage: C = P.combinatorial_polyhedron() - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: next(it).ambient_V_indices() (23,) sage: next(it).ambient_V_indices() @@ -1335,17 +1335,17 @@ cdef class FaceIterator(FaceIterator_base): sage: P = polytopes.cuboctahedron() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: next(it) A 0-dimensional face of a 3-dimensional combinatorial polyhedron Construct faces by the dual or not:: - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: next(it).dimension() 2 - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: next(it).dimension() 0 @@ -1353,7 +1353,7 @@ cdef class FaceIterator(FaceIterator_base): sage: P = Polyhedron(rays=[[0,0,1], [0,1,0], [1,0,0]]) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: [face.ambient_Vrepresentation() for face in it] [(A vertex at (0, 0, 0), A ray in the direction (0, 1, 0), @@ -1368,7 +1368,7 @@ cdef class FaceIterator(FaceIterator_base): (A vertex at (0, 0, 0), A ray in the direction (0, 1, 0)), (A vertex at (0, 0, 0),), (A vertex at (0, 0, 0), A ray in the direction (0, 0, 1))] - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') Traceback (most recent call last): ... ValueError: cannot iterate over dual of unbounded Polyedron @@ -1377,7 +1377,7 @@ cdef class FaceIterator(FaceIterator_base): sage: P = polytopes.permutahedron(5) sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(dimension=2) + sage: it = C.face_generator(dimension=2) sage: counter = 0 sage: for _ in it: counter += 1 sage: print ('permutahedron(5) has', counter, @@ -1390,7 +1390,7 @@ cdef class FaceIterator(FaceIterator_base): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: face = next(it) sage: face.ambient_H_indices() (5,) @@ -1414,7 +1414,7 @@ cdef class FaceIterator(FaceIterator_base): (0, 1, 2), (0, 1)] - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: next(it) A 0-dimensional face of a 3-dimensional combinatorial polyhedron sage: it.ignore_subfaces() @@ -1424,7 +1424,7 @@ cdef class FaceIterator(FaceIterator_base): In dual mode one can ignore all faces that contain the current face:: - sage: it = C.face_iter(dual=True) + sage: it = C.face_generator(algorithm='dual') sage: next(it) A 0-dimensional face of a 3-dimensional combinatorial polyhedron sage: face = next(it) @@ -1456,7 +1456,7 @@ cdef class FaceIterator(FaceIterator_base): (1, 2), (0, 1)] - sage: it = C.face_iter(dual=False) + sage: it = C.face_generator(algorithm='primal') sage: next(it) A 2-dimensional face of a 3-dimensional combinatorial polyhedron sage: it.ignore_supfaces() @@ -1571,10 +1571,10 @@ cdef class FaceIterator(FaceIterator_base): sage: P = polytopes.associahedron(['A',3]) # optional - sage.combinat sage: C = CombinatorialPolyhedron(P) # optional - sage.combinat - sage: C.face_iter() # optional - sage.combinat + sage: C.face_generator() # optional - sage.combinat Iterator over the proper faces of a 3-dimensional combinatorial polyhedron - sage: C.face_iter(1) # optional - sage.combinat + sage: C.face_generator(1) # optional - sage.combinat Iterator over the 1-faces of a 3-dimensional combinatorial polyhedron """ if self.structure.output_dimension != -2: @@ -1596,7 +1596,7 @@ cdef class FaceIterator(FaceIterator_base): sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: [next(it) for _ in range(7)] [A 2-dimensional face of a 3-dimensional combinatorial polyhedron, A 2-dimensional face of a 3-dimensional combinatorial polyhedron, diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx index 2f8edd194de..9fd5e1a2f14 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx @@ -271,7 +271,7 @@ cdef class PolyhedronFaceLattice: sage: P = polytopes.hypercube(4) sage: C = CombinatorialPolyhedron(P) sage: F = PolyhedronFaceLattice(C) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) sage: F._find_face_from_combinatorial_face(face) Traceback (most recent call last): @@ -299,7 +299,7 @@ cdef class PolyhedronFaceLattice: sage: P = polytopes.permutahedron(4) sage: C = CombinatorialPolyhedron(P) sage: F = PolyhedronFaceLattice(C) - sage: it = C.face_iter(dimension=1) + sage: it = C.face_generator(dimension=1) sage: S = set(F._find_face_from_combinatorial_face(f) for f in it) sage: S == set(range(36)) True @@ -332,7 +332,7 @@ cdef class PolyhedronFaceLattice: sage: P = polytopes.permutahedron(4) sage: C = CombinatorialPolyhedron(P) sage: F = PolyhedronFaceLattice(C) - sage: it = C.face_iter(dimension=1) + sage: it = C.face_generator(dimension=1) sage: face = next(it) sage: index = F._find_face_from_combinatorial_face(face) sage: F.get_face(face.dimension(), index).ambient_Vrepresentation() @@ -347,7 +347,7 @@ cdef class PolyhedronFaceLattice: sage: P = polytopes.twenty_four_cell() sage: C = CombinatorialPolyhedron(P) sage: F = PolyhedronFaceLattice(C) - sage: it = C.face_iter() + sage: it = C.face_generator() sage: face = next(it) sage: while (face.dimension() == 3): face = next(it) sage: index = F._find_face_from_combinatorial_face(face)