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

Commit 8853122

Browse files
author
Jonathan Kliem
committed
small changes to stacking
1 parent 5095c2e commit 8853122

File tree

1 file changed

+15
-3
lines changed
  • src/sage/geometry/polyhedron

1 file changed

+15
-3
lines changed

src/sage/geometry/polyhedron/base.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4423,18 +4423,30 @@ def stack(self, face, position=None):
44234423
A ray in the direction (1, 1),
44244424
A vertex at (2, 0))
44254425
4426-
TESTS::
4426+
TESTS:
4427+
4428+
Checking that the backend is preserved::
44274429
44284430
sage: Cube = polytopes.cube(backend='field')
44294431
sage: stack = Cube.stack(Cube.faces(2)[0])
44304432
sage: stack.backend()
44314433
'field'
4434+
4435+
Checking that stacked point needs to be in the interior of
4436+
``locus_polyhedron``::
4437+
sage: P = polytopes.octahedron()
4438+
sage: P.stack(P.faces(2)[0],4)
4439+
Traceback (most recent call last):
4440+
...
4441+
ValueError: the chosen position is too large
44324442
"""
44334443
from sage.geometry.polyhedron.face import PolyhedronFace
44344444
if not isinstance(face, PolyhedronFace):
44354445
raise TypeError("{} should be a PolyhedronFace of {}".format(face, self))
44364446
elif face.dim() == 0:
44374447
raise ValueError("can not stack onto a vertex")
4448+
elif face.dim() == -1 or face.dim() == self.dim():
4449+
raise ValueError("can only stack on proper face")
44384450

44394451
if position is None:
44404452
position = 1
@@ -4448,7 +4460,7 @@ def stack(self, face, position=None):
44484460
face_star = set([face.ambient_Hrepresentation()[-1]])
44494461
else:
44504462
face_star = set(facet for facet in self.Hrepresentation() if facet.is_inequality()
4451-
if all(facet.contains(x) and not facet.interior_contains(x) for x in face_vertices))
4463+
if all(not facet.interior_contains(x) for x in face_vertices))
44524464

44534465
neighboring_facets = set()
44544466
for facet in face_star:
@@ -4467,7 +4479,7 @@ def stack(self, face, position=None):
44674479
repr_point = locus_polyhedron.representative_point()
44684480
new_vertex = (1-position)*barycenter + position*repr_point
44694481

4470-
if not locus_polyhedron.contains(new_vertex):
4482+
if not locus_polyhedron.relative_interior_contains(new_vertex):
44714483
raise ValueError("the chosen position is too large")
44724484

44734485
parent = self.parent().base_extend(new_vertex)

0 commit comments

Comments
 (0)