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

Commit

Permalink
src/sage/geometry/polyhedron/representation.py: Update doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Aug 10, 2022
1 parent f79f054 commit 2621322
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/parent.py
Expand Up @@ -30,7 +30,7 @@
from sage.categories.modules import Modules

from sage.geometry.polyhedron.base import is_Polyhedron
from .representation import Inequality, Equation, Vertex, Ray, Line
from .representation import StrictInequality, Inequality, Equation, Vertex, Ray, Line, StrictRay


def Polyhedra(ambient_space_or_base_ring=None, ambient_dim=None, backend=None, *,
Expand Down
46 changes: 31 additions & 15 deletions src/sage/geometry/polyhedron/representation.py
Expand Up @@ -1849,10 +1849,13 @@ def type(self):
EXAMPLES::
sage: p = Polyhedron(ieqs = [[0,0,1],[0,1,0],[1,-1,0]])
sage: repr_obj = next(p.ray_generator())
sage: p = Polyhedron(ieqs=[[0,0,1],[0,1,0],[1,-1,0]])
sage: p._Vrepresentation = [] # make it mutable
sage: p.parent()._make_StrictRay(p, [1, 2])
A strict ray in the direction (1, 2)
sage: repr_obj = next(p.Vrep_generator())
sage: repr_obj.type()
4
5
sage: repr_obj.type() == repr_obj.STRICT_INEQUALITY
False
sage: repr_obj.type() == repr_obj.INEQUALITY
Expand All @@ -1877,22 +1880,28 @@ def is_strict_ray(self):
EXAMPLES::
sage: p = Polyhedron(ieqs = [[0,0,1],[0,1,0],[1,-1,0]])
sage: a = next(p.ray_generator())
sage: p._Vrepresentation = [] # make it mutable
sage: p.parent()._make_StrictRay(p, [1, 2])
A strict ray in the direction (1, 2)
sage: a = next(p.Vrep_generator())
sage: a.is_strict_ray()
False
True
"""
return True

def _repr_(self):
"""
A string representation of the ray.
A string representation of the strict ray.
TESTS::
sage: p = Polyhedron(ieqs = [[0,0,1],[0,1,0],[1,-1,0]])
sage: a = next(p.ray_generator())
sage: p._Vrepresentation = [] # make it mutable
sage: p.parent()._make_StrictRay(p, [1, 2])
A strict ray in the direction (1, 2)
sage: a = next(p.Vrep_generator())
sage: a._repr_()
'A strict ray in the direction (0, 1)'
'A strict ray in the direction (1, 2)'
"""
return 'A strict ray in the direction ' + repr(self.vector())

Expand All @@ -1909,11 +1918,15 @@ def homogeneous_vector(self, base_ring=None):
EXAMPLES::
sage: P = Polyhedron(vertices=[(2,0)], rays=[(1,0)], lines=[(3,2)])
sage: P.rays()[0].homogeneous_vector()
(1, 0, 0)
sage: P.rays()[0].homogeneous_vector(RDF)
(1.0, 0.0, 0.0)
sage: p = Polyhedron(vertices=[(2,0)], rays=[(1,0)], lines=[(3,2)])
sage: p._Vrepresentation = [] # make it mutable
sage: p.parent()._make_StrictRay(p, [1, 2])
A strict ray in the direction (1, 2)
sage: a = next(p.Vrep_generator())
sage: a.homogeneous_vector()
(1, 2, 0)
sage: a.homogeneous_vector(RDF)
(1.0, 2.0, 0.0)
"""
v = list(self._vector) + [0]
return vector(base_ring or self._base_ring, v)
Expand All @@ -1925,10 +1938,13 @@ def evaluated_on(self, Hobj):
EXAMPLES::
sage: p = Polyhedron(ieqs = [[0,0,1],[0,1,0],[1,-1,0]])
sage: a = next(p.ray_generator())
sage: p._Vrepresentation = [] # make it mutable
sage: p.parent()._make_StrictRay(p, [1, 2])
A strict ray in the direction (1, 2)
sage: a = next(p.Vrep_generator())
sage: h = next(p.inequality_generator())
sage: a.evaluated_on(h)
0
-1
"""
return Hobj.A() * self.vector()

Expand Down

0 comments on commit 2621322

Please sign in to comment.