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

Commit

Permalink
Improved doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
jplab committed Mar 14, 2019
1 parent ea744a4 commit c3e78c8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 90 deletions.
95 changes: 30 additions & 65 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4062,8 +4062,8 @@ def _make_polyhedron_face(self, Vindices, Hindices):
EXAMPLES::
sage: square = polytopes.hypercube(2)
sage: square._make_polyhedron_face((0,2), (1,))
A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: square._make_polyhedron_face((0,2), (1,)).ambient_V_indices()
(0, 2)
"""
from sage.geometry.polyhedron.face import PolyhedronFace
return PolyhedronFace(self, Vindices, Hindices)
Expand Down Expand Up @@ -4174,68 +4174,33 @@ def face_lattice(self):
sage: polytopes.hypercube(2).face_lattice().plot()
Graphics object consisting of 27 graphics primitives
sage: level_sets = polytopes.cross_polytope(2).face_lattice().level_sets()
sage: level_sets[0], level_sets[-1]
([A -1-dimensional face of a Polyhedron in ZZ^2],
[A 2-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 4 vertices])
sage: level_sets[0][0].ambient_V_indices(), level_sets[-1][0].ambient_V_indices()
((), (0, 1, 2, 3))
Various degenerate polyhedra::
sage: Polyhedron(vertices=[[0,0,0],[1,0,0],[0,1,0]]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^3],
[A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex,
A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex,
A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex],
[A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices],
[A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices]]
sage: Polyhedron(vertices=[(1,0,0),(0,1,0)], rays=[(0,0,1)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^3],
[A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex,
A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex],
[A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 ray,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 ray,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices],
[A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices and 1 ray]]
sage: Polyhedron(rays=[(1,0,0),(0,1,0)], vertices=[(0,0,1)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^3],
[A 0-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex],
[A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 ray,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 ray],
[A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 2 rays]]
sage: Polyhedron(rays=[(1,0),(0,1)], vertices=[(0,0)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^2],
[A 0-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex],
[A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 ray,
A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 ray],
[A 2-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 2 rays]]
sage: Polyhedron(vertices=[(1,),(0,)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^1],
[A 0-dimensional face of a Polyhedron in ZZ^1 defined as the convex hull of 1 vertex,
A 0-dimensional face of a Polyhedron in ZZ^1 defined as the convex hull of 1 vertex],
[A 1-dimensional face of a Polyhedron in ZZ^1 defined as the convex hull of 2 vertices]]
sage: Polyhedron(vertices=[(1,0,0),(0,1,0)], lines=[(0,0,1)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^3],
[A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 line,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 line],
[A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices and 1 line]]
sage: Polyhedron(lines=[(1,0,0)], vertices=[(0,0,1)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^3],
[A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 1 line]]
sage: Polyhedron(lines=[(1,0),(0,1)], vertices=[(0,0)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^2],
[A 2-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 2 lines]]
sage: Polyhedron(lines=[(1,0)], rays=[(0,1)], vertices=[(0,0)])\
....: .face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^2],
[A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 line],
[A 2-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex, 1 ray, 1 line]]
sage: Polyhedron(vertices=[(0,)], lines=[(1,)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^1],
[A 1-dimensional face of a Polyhedron in ZZ^1 defined as the convex hull of 1 vertex and 1 line]]
sage: Polyhedron(lines=[(1,0)], vertices=[(0,0)]).face_lattice().level_sets()
[[A -1-dimensional face of a Polyhedron in ZZ^2],
[A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 line]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(vertices=[[0,0,0],[1,0,0],[0,1,0]]).face_lattice().level_sets()]
[[()], [(0,), (1,), (2,)], [(0, 1), (0, 2), (1, 2)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(vertices=[(1,0,0),(0,1,0)], rays=[(0,0,1)]).face_lattice().level_sets()]
[[()], [(1,), (2,)], [(0, 1), (0, 2), (1, 2)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(rays=[(1,0,0),(0,1,0)], vertices=[(0,0,1)]).face_lattice().level_sets()]
[[()], [(0,)], [(0, 1), (0, 2)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(rays=[(1,0),(0,1)], vertices=[(0,0)]).face_lattice().level_sets()]
[[()], [(0,)], [(0, 1), (0, 2)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(vertices=[(1,),(0,)]).face_lattice().level_sets()]
[[()], [(0,), (1,)], [(0, 1)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(vertices=[(1,0,0),(0,1,0)], lines=[(0,0,1)]).face_lattice().level_sets()]
[[()], [(0, 1), (0, 2)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(lines=[(1,0,0)], vertices=[(0,0,1)]).face_lattice().level_sets()]
[[()], [(0, 1)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(lines=[(1,0),(0,1)], vertices=[(0,0)]).face_lattice().level_sets()]
[[()], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(lines=[(1,0)], rays=[(0,1)], vertices=[(0,0)]).face_lattice().level_sets()]
[[()], [(0, 1)], [(0, 1, 2)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(vertices=[(0,)], lines=[(1,)]).face_lattice().level_sets()]
[[()], [(0, 1)]]
sage: [[ls.ambient_V_indices() for ls in lss] for lss in Polyhedron(lines=[(1,0)], vertices=[(0,0)]).face_lattice().level_sets()]
[[()], [(0, 1)]]
"""
coatom_to_Hindex = [ h.index() for h in self.inequality_generator() ]
Hindex_to_coatom = [None] * self.n_Hrepresentation()
Expand Down Expand Up @@ -4339,10 +4304,10 @@ def faces(self, face_dimension):
sage: pr = Polyhedron(rays = [[1,0,0],[-1,0,0],[0,1,0]], vertices = [[-1,-1,-1]], lines=[(0,0,1)])
sage: pr.faces(4)
()
sage: pr.faces(3)
(A 3-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex, 1 ray, 2 lines,)
sage: pr.faces(2)
(A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 1 vertex and 2 lines,)
sage: pr.faces(3)[0].ambient_V_indices()
(0, 1, 2, 3)
sage: pr.faces(2)[0].ambient_V_indices()
(0, 1, 2)
sage: pr.faces(1)
()
sage: pr.faces(0)
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/polyhedron/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@
(An inequality (1, 0) x + 1 >= 0, An inequality (-1, 0) x + 1 >= 0)
sage: strip.lines()
(A line in the direction (0, 1),)
sage: strip.faces(1)
(A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 line,
A 1-dimensional face of a Polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 line)
sage: [f.ambient_V_indices() for f in strip.faces(1)]
[(0, 1), (0, 2)]
sage: for face in strip.faces(1):
....: print(face.ambient_V_indices())
(0, 1)
Expand Down
44 changes: 22 additions & 22 deletions src/sage/geometry/polyhedron/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
sage: P = polytopes.cross_polytope(3)
sage: P.faces(3)
(A 3-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 6 vertices,)
sage: P.faces(2)
(A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices,
A 2-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 3 vertices)
sage: P.faces(1)
(A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices,
A 1-dimensional face of a Polyhedron in ZZ^3 defined as the convex hull of 2 vertices)
sage: [f.ambient_V_indices() for f in P.faces(2)]
[(0, 1, 2),
(0, 1, 3),
(0, 2, 4),
(0, 3, 4),
(3, 4, 5),
(2, 4, 5),
(1, 3, 5),
(1, 2, 5)]
sage: [f.ambient_V_indices() for f in P.faces(1)]
[(0, 1),
(0, 2),
(1, 2),
(0, 3),
(1, 3),
(0, 4),
(2, 4),
(3, 4),
(2, 5),
(3, 5),
(4, 5),
(1, 5)]
or :meth:`~sage.geometry.polyhedron.base.face_lattice` to get the
whole face lattice as a poset::
Expand Down

0 comments on commit c3e78c8

Please sign in to comment.