Skip to content

Commit

Permalink
Trac #32652: sage.geometry.polyhedron: Mark doctests # optional - sag…
Browse files Browse the repository at this point in the history
…e.rings.number_field

(cherry-picked from #32432)

URL: https://trac.sagemath.org/32652
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Jonathan Kliem
  • Loading branch information
Release Manager committed Oct 19, 2021
2 parents 5c0ceda + 1400654 commit 4f73d49
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 206 deletions.
84 changes: 42 additions & 42 deletions src/sage/geometry/polyhedron/backend_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
sage: p0 = (0, 0)
sage: p1 = (1, 0)
sage: p2 = (1/2, AA(3).sqrt()/2)
sage: equilateral_triangle = Polyhedron([p0, p1, p2])
sage: equilateral_triangle.vertices()
sage: p2 = (1/2, AA(3).sqrt()/2) # optional - sage.rings.number_field
sage: equilateral_triangle = Polyhedron([p0, p1, p2]) # optional - sage.rings.number_field
sage: equilateral_triangle.vertices() # optional - sage.rings.number_field
(A vertex at (0, 0),
A vertex at (1, 0),
A vertex at (0.500000000000000?, 0.866025403784439?))
sage: equilateral_triangle.inequalities()
sage: equilateral_triangle.inequalities() # optional - sage.rings.number_field
(An inequality (-1, -0.5773502691896258?) x + 1 >= 0,
An inequality (1, -0.5773502691896258?) x + 0 >= 0,
An inequality (0, 1.154700538379252?) x + 0 >= 0)
Expand Down Expand Up @@ -46,22 +46,22 @@ class Polyhedron_field(Polyhedron_base):
EXAMPLES::
sage: p = Polyhedron(vertices=[(0,0),(AA(2).sqrt(),0),(0,AA(3).sqrt())],
sage: p = Polyhedron(vertices=[(0,0),(AA(2).sqrt(),0),(0,AA(3).sqrt())], # optional - sage.rings.number_field
....: rays=[(1,1)], lines=[], backend='field', base_ring=AA)
sage: TestSuite(p).run()
sage: TestSuite(p).run() # optional - sage.rings.number_field
TESTS::
sage: K.<sqrt3> = QuadraticField(3)
sage: p = Polyhedron([(0,0), (1,0), (1/2, sqrt3/2)])
sage: TestSuite(p).run()
sage: K.<sqrt3> = QuadraticField(3) # optional - sage.rings.number_field
sage: p = Polyhedron([(0,0), (1,0), (1/2, sqrt3/2)]) # optional - sage.rings.number_field
sage: TestSuite(p).run() # optional - sage.rings.number_field
Check that :trac:`19013` is fixed::
sage: K.<phi> = NumberField(x^2-x-1, embedding=1.618)
sage: P1 = Polyhedron([[0,1],[1,1],[1,-phi+1]])
sage: P2 = Polyhedron(ieqs=[[-1,-phi,0]])
sage: P1.intersection(P2)
sage: K.<phi> = NumberField(x^2-x-1, embedding=1.618) # optional - sage.rings.number_field
sage: P1 = Polyhedron([[0,1],[1,1],[1,-phi+1]]) # optional - sage.rings.number_field
sage: P2 = Polyhedron(ieqs=[[-1,-phi,0]]) # optional - sage.rings.number_field
sage: P1.intersection(P2) # optional - sage.rings.number_field
The empty polyhedron in (Number Field in phi with defining polynomial x^2 - x - 1 with phi = 1.618033988749895?)^2
Check that :trac:`28654` is fixed::
Expand All @@ -83,10 +83,10 @@ def _is_zero(self, x):
EXAMPLES::
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA)
sage: p._is_zero(0)
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA) # optional - sage.rings.number_field
sage: p._is_zero(0) # optional - sage.rings.number_field
True
sage: p._is_zero(1/100000)
sage: p._is_zero(1/100000) # optional - sage.rings.number_field
False
"""
return x == 0
Expand All @@ -105,10 +105,10 @@ def _is_nonneg(self, x):
EXAMPLES::
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA)
sage: p._is_nonneg(1)
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA) # optional - sage.rings.number_field
sage: p._is_nonneg(1) # optional - sage.rings.number_field
True
sage: p._is_nonneg(-1/100000)
sage: p._is_nonneg(-1/100000) # optional - sage.rings.number_field
False
"""
return x >= 0
Expand All @@ -127,10 +127,10 @@ def _is_positive(self, x):
EXAMPLES::
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA)
sage: p._is_positive(1)
sage: p = Polyhedron([(sqrt(3),sqrt(2))], base_ring=AA) # optional - sage.rings.number_field
sage: p._is_positive(1) # optional - sage.rings.number_field
True
sage: p._is_positive(0)
sage: p._is_positive(0) # optional - sage.rings.number_field
False
"""
return x > 0
Expand All @@ -150,12 +150,12 @@ def _init_from_Vrepresentation_and_Hrepresentation(self, Vrep, Hrep):
sage: from sage.geometry.polyhedron.parent import Polyhedra_field
sage: from sage.geometry.polyhedron.backend_field import Polyhedron_field
sage: parent = Polyhedra_field(AA, 1, 'field')
sage: parent = Polyhedra_field(AA, 1, 'field') # optional - sage.rings.number_field
sage: Vrep = [[[0], [1]], [], []]
sage: Hrep = [[[0, 1], [1, -1]], []]
sage: p = Polyhedron_field(parent, Vrep, Hrep,
....: Vrep_minimal=True, Hrep_minimal=True) # indirect doctest
sage: p
sage: p = Polyhedron_field(parent, Vrep, Hrep, # indirect doctest # optional - sage.rings.number_field
....: Vrep_minimal=True, Hrep_minimal=True)
sage: p # optional - sage.rings.number_field
A 1-dimensional polyhedron in AA^1 defined as the convex hull of 2 vertices
"""
self._init_Vrepresentation(*Vrep)
Expand Down Expand Up @@ -234,12 +234,12 @@ def _init_Vrepresentation(self, vertices, rays, lines):
sage: from sage.geometry.polyhedron.parent import Polyhedra_field
sage: from sage.geometry.polyhedron.backend_field import Polyhedron_field
sage: parent = Polyhedra_field(AA, 1, 'field')
sage: parent = Polyhedra_field(AA, 1, 'field') # optional - sage.rings.number_field
sage: Vrep = [[[0], [1]], [], []]
sage: Hrep = [[[0, 1], [1, -1]], []]
sage: p = Polyhedron_field(parent, Vrep, Hrep, # indirect doctest
sage: p = Polyhedron_field(parent, Vrep, Hrep, # indirect doctest # optional - sage.rings.number_field
....: Vrep_minimal=True, Hrep_minimal=True)
sage: p.vertices_list()
sage: p.vertices_list() # optional - sage.rings.number_field
[[0], [1]]
"""
self._Vrepresentation = []
Expand All @@ -258,13 +258,13 @@ def _init_Vrepresentation_backend(self, Vrep):
EXAMPLES::
sage: p = Polyhedron(vertices=[(0,1/sqrt(2)),(sqrt(2),0),(4,sqrt(5)/6)],
sage: p = Polyhedron(vertices=[(0,1/sqrt(2)),(sqrt(2),0),(4,sqrt(5)/6)], # optional - sage.rings.number_field
....: base_ring=AA, backend='field') # indirect doctest
sage: p.Hrepresentation()
sage: p.Hrepresentation() # optional - sage.rings.number_field
(An inequality (-0.1582178750233332?, 1.097777812326429?) x + 0.2237538646678492? >= 0,
An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
sage: p.Vrepresentation()
sage: p.Vrepresentation() # optional - sage.rings.number_field
(A vertex at (0.?e-15, 0.707106781186548?),
A vertex at (1.414213562373095?, 0),
A vertex at (4.000000000000000?, 0.372677996249965?))
Expand All @@ -279,12 +279,12 @@ def _init_Hrepresentation(self, inequalities, equations):
sage: from sage.geometry.polyhedron.parent import Polyhedra_field
sage: from sage.geometry.polyhedron.backend_field import Polyhedron_field
sage: parent = Polyhedra_field(AA, 1, 'field')
sage: parent = Polyhedra_field(AA, 1, 'field') # optional - sage.rings.number_field
sage: Vrep = [[[0], [1]], [], []]
sage: Hrep = [[[0, 1], [1, -1]], []]
sage: p = Polyhedron_field(parent, Vrep, Hrep, # indirect doctest
sage: p = Polyhedron_field(parent, Vrep, Hrep, # indirect doctest # optional - sage.rings.number_field
....: Vrep_minimal=True, Hrep_minimal=True)
sage: p.inequalities_list()
sage: p.inequalities_list() # optional - sage.rings.number_field
[[0, 1], [1, -1]]
"""
self._Hrepresentation = []
Expand All @@ -301,13 +301,13 @@ def _init_Hrepresentation_backend(self, Hrep):
EXAMPLES::
sage: p = Polyhedron(vertices=[(0,1/sqrt(2)),(sqrt(2),0),(4,sqrt(5)/6)],
sage: p = Polyhedron(vertices=[(0,1/sqrt(2)),(sqrt(2),0),(4,sqrt(5)/6)], # optional - sage.rings.number_field
....: base_ring=AA, backend='field') # indirect doctest
sage: p.Hrepresentation()
sage: p.Hrepresentation() # optional - sage.rings.number_field
(An inequality (-0.1582178750233332?, 1.097777812326429?) x + 0.2237538646678492? >= 0,
An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
sage: p.Vrepresentation()
sage: p.Vrepresentation() # optional - sage.rings.number_field
(A vertex at (0.?e-15, 0.707106781186548?),
A vertex at (1.414213562373095?, 0),
A vertex at (4.000000000000000?, 0.372677996249965?))
Expand All @@ -320,13 +320,13 @@ def _init_empty_polyhedron(self):
TESTS::
sage: empty = Polyhedron(backend='field', base_ring=AA); empty
sage: empty = Polyhedron(backend='field', base_ring=AA); empty # optional - sage.rings.number_field
The empty polyhedron in AA^0
sage: empty.Vrepresentation()
sage: empty.Vrepresentation() # optional - sage.rings.number_field
()
sage: empty.Hrepresentation()
sage: empty.Hrepresentation() # optional - sage.rings.number_field
(An equation -1 == 0,)
sage: Polyhedron(vertices = [], backend='field')
sage: Polyhedron(vertices=[], backend='field')
The empty polyhedron in QQ^0
sage: Polyhedron(backend='field')._init_empty_polyhedron()
"""
Expand Down
Loading

0 comments on commit 4f73d49

Please sign in to comment.