Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/doc: Update # needs #36679

Merged
merged 10 commits into from
Dec 10, 2023
2 changes: 2 additions & 0 deletions src/doc/de/tutorial/tour_plotting.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. sage-doctest: needs sage.plot sage.symbolic

.. _section-plot:

Plotten
Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Apparently it does not in a very substantial way:
merely a heuristic. Looking at the source of "entropy", through
``log`` from :mod:`sage.misc.functional`, a runtime dependency on
symbolics comes in. In fact, for this reason, two doctests there are
already marked as ``# optional - sage.symbolic``.
already marked as ``# needs sage.symbolic``.

So if packaged as **sagemath-coding**, now a domain expert would have
to decide whether these dependencies on symbolics are strong enough to
Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/prep/Calculus.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. -*- coding: utf-8 -*-
.. sage-doctest: needs sage.plot sage.symbolic

.. linkall

Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/prep/Quickstarts/Differential-Equations.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. -*- coding: utf-8 -*-
.. sage-doctest: needs sage.plot sage.symbolic

.. linkall

Expand Down
15 changes: 8 additions & 7 deletions src/doc/en/prep/Quickstarts/Statistics-and-Distributions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ the examples in ``r.kruskal_test?`` in the notebook.

::

sage: x=r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects # optional - rpy2
sage: y=r([3.8, 2.7, 4.0, 2.4]) # with obstructive airway disease # optional - rpy2
sage: z=r([2.8, 3.4, 3.7, 2.2, 2.0]) # with asbestosis # optional - rpy2
sage: a = r([x,y,z]) # make a long R vector of all the data # optional - rpy2
sage: b = r.factor(5*[1]+4*[2]+5*[3]) # create something for R to tell # optional - rpy2
....: # which subjects are which
sage: a; b # show them # optional - rpy2
sage: # optional - rpy2
sage: x = r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects
sage: y = r([3.8, 2.7, 4.0, 2.4]) # with obstructive airway disease
sage: z = r([2.8, 3.4, 3.7, 2.2, 2.0]) # with asbestosis
sage: a = r([x,y,z]) # make a long R vector of all the data
sage: b = r.factor(5*[1] + 4*[2] + 5*[3]) # create something for R to tell
....: # which subjects are which
sage: a; b # show them
[1] 2.9 3.0 2.5 2.6 3.2 3.8 2.7 4.0 2.4 2.8 3.4 3.7 2.2 2.0
[1] 1 1 1 1 1 2 2 2 2 3 3 3 3 3
Levels: 1 2 3
Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/prep/Symbolics-and-Basic-Plotting.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. -*- coding: utf-8 -*-
.. sage-doctest: needs sage.plot sage.symbolic

.. linkall

Expand Down
116 changes: 63 additions & 53 deletions src/doc/en/thematic_tutorials/geometry/polyhedra_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ and some rays.

::

sage: P1 = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]])
sage: P1 = Polyhedron(vertices=[[1, 0], [0, 1]], rays=[[1, 1]])
sage: P1
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices and 1 ray

Expand All @@ -118,9 +118,9 @@ We can also add a lineality space.

::

sage: P2 = Polyhedron(vertices = [[1/2, 0, 0], [0, 1/2, 0]],
....: rays = [[1, 1, 0]],
....: lines = [[0, 0, 1]])
sage: P2 = Polyhedron(vertices=[[1/2, 0, 0], [0, 1/2, 0]],
....: rays=[[1, 1, 0]],
....: lines=[[0, 0, 1]])
sage: P2
A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 2 vertices, 1 ray, 1 line
sage: P2.plot()
Expand All @@ -144,7 +144,7 @@ The chosen ring depends on the input format.

::

sage: P3 = Polyhedron(vertices = [[0.5, 0], [0, 0.5]])
sage: P3 = Polyhedron(vertices=[[0.5, 0], [0, 0.5]])
sage: P3
A 1-dimensional polyhedron in RDF^2 defined as the convex hull of 2 vertices
sage: P3.parent()
Expand All @@ -163,22 +163,22 @@ The following example demonstrates the limitations of :code:`RDF`.

::

sage: D = polytopes.dodecahedron() # optional - sage.rings.number_field
sage: D # optional - sage.rings.number_field
sage: D = polytopes.dodecahedron() # needs sage.rings.number_field
sage: D # needs sage.rings.number_field
A 3-dimensional polyhedron
in (Number Field in sqrt5 with defining polynomial x^2 - 5
with sqrt5 = 2.236067977499790?)^3
defined as the convex hull of 20 vertices

sage: vertices_RDF = [n(v.vector(),digits=6) for v in D.vertices()] # optional - sage.rings.number_field
sage: D_RDF = Polyhedron(vertices=vertices_RDF, base_ring=RDF) # optional - sage.rings.number_field
sage: vertices_RDF = [n(v.vector(),digits=6) for v in D.vertices()] # needs sage.rings.number_field
sage: D_RDF = Polyhedron(vertices=vertices_RDF, base_ring=RDF) # needs sage.rings.number_field
doctest:warning
...
UserWarning: This polyhedron data is numerically complicated; cdd
could not convert between the inexact V and H representation
without loss of data. The resulting object might show
inconsistencies.
sage: D_RDF = Polyhedron(vertices=sorted(vertices_RDF), base_ring=RDF) # optional - sage.rings.number_field
sage: D_RDF = Polyhedron(vertices=sorted(vertices_RDF), base_ring=RDF) # needs sage.rings.number_field
Traceback (most recent call last):
...
ValueError: *Error: Numerical inconsistency is found. Use the GMP exact arithmetic.
Expand All @@ -199,11 +199,12 @@ It is also possible to define a polyhedron over algebraic numbers.

::

sage: sqrt_2 = AA(2)^(1/2) # optional - sage.rings.number_field
sage: cbrt_2 = AA(2)^(1/3) # optional - sage.rings.number_field
sage: timeit('Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]])') # optional - sage.rings.number_field # random
sage: # needs sage.rings.number_field
sage: sqrt_2 = AA(2)^(1/2)
sage: cbrt_2 = AA(2)^(1/3)
sage: timeit('Polyhedron(vertices=[[sqrt_2, 0], [0, cbrt_2]])') # random
5 loops, best of 3: 43.2 ms per loop
mkoeppe marked this conversation as resolved.
Show resolved Hide resolved
sage: P4 = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]]); P4 # optional - sage.rings.number_field
sage: P4 = Polyhedron(vertices=[[sqrt_2, 0], [0, cbrt_2]]); P4
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices

.. end of output
Expand All @@ -212,11 +213,12 @@ There is another way to create a polyhedron over algebraic numbers:

::

sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2)) # optional - sage.rings.number_field
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3)) # optional - sage.rings.number_field
sage: timeit('Polyhedron(vertices = [[a, 0], [0, b]])') # optional - sage.rings.number_field # random
sage: # needs sage.rings.number_field
sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2))
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3))
sage: timeit('Polyhedron(vertices=[[a, 0], [0, b]])') # random
5 loops, best of 3: 39.9 ms per loop
sage: P5 = Polyhedron(vertices = [[a, 0], [0, b]]); P5 # optional - sage.rings.number_field
mkoeppe marked this conversation as resolved.
Show resolved Hide resolved
sage: P5 = Polyhedron(vertices=[[a, 0], [0, b]]); P5
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices

.. end of output
Expand All @@ -225,10 +227,11 @@ If the base ring is known it may be a good option to use the proper :meth:`sage.

::

sage: J = K.composite_fields(L)[0] # optional - sage.rings.number_field
sage: timeit('Polyhedron(vertices = [[J(a), 0], [0, J(b)]])') # optional - sage.rings.number_field # random
sage: # needs sage.rings.number_field
sage: J = K.composite_fields(L)[0]
sage: timeit('Polyhedron(vertices=[[J(a), 0], [0, J(b)]])') # random
25 loops, best of 3: 9.8 ms per loop
sage: P5_comp = Polyhedron(vertices = [[J(a), 0], [0, J(b)]]); P5_comp # optional - sage.rings.number_field
sage: P5_comp = Polyhedron(vertices=[[J(a), 0], [0, J(b)]]); P5_comp
A 1-dimensional polyhedron
in (Number Field in ab with defining polynomial
x^6 - 6*x^4 - 4*x^3 + 12*x^2 - 24*x - 4
Expand All @@ -242,9 +245,9 @@ It is not possible to define a polyhedron over it:

::

sage: sqrt_2s = sqrt(2) # optional - sage.symbolic
sage: cbrt_2s = 2^(1/3) # optional - sage.symbolic
sage: Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]]) # optional - sage.symbolic
sage: sqrt_2s = sqrt(2) # needs sage.symbolic
sage: cbrt_2s = 2^(1/3) # needs sage.symbolic
sage: Polyhedron(vertices=[[sqrt_2s, 0], [0, cbrt_2s]]) # needs sage.symbolic
Traceback (most recent call last):
...
ValueError: no default backend for computations with Symbolic Ring
Expand Down Expand Up @@ -389,7 +392,7 @@ inequalities and equalities as objects.

::

sage: P3_QQ = Polyhedron(vertices = [[0.5, 0], [0, 0.5]], base_ring=QQ)
sage: P3_QQ = Polyhedron(vertices=[[0.5, 0], [0, 0.5]], base_ring=QQ)
sage: HRep = P3_QQ.Hrepresentation()
sage: H1 = HRep[0]; H1
An equation (2, 2) x - 1 == 0
Expand Down Expand Up @@ -527,7 +530,7 @@ In order to use a specific backend, we specify the :code:`backend` parameter.

::

sage: P1_cdd = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]], backend='cdd')
sage: P1_cdd = Polyhedron(vertices=[[1, 0], [0, 1]], rays=[[1, 1]], backend='cdd')
sage: P1_cdd
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices and 1 ray

Expand Down Expand Up @@ -567,7 +570,7 @@ The :code:`cdd` backend accepts also entries in :code:`RDF`:

::

sage: P3_cdd = Polyhedron(vertices = [[0.5, 0], [0, 0.5]], backend='cdd')
sage: P3_cdd = Polyhedron(vertices=[[0.5, 0], [0, 0.5]], backend='cdd')
sage: P3_cdd
A 1-dimensional polyhedron in RDF^2 defined as the convex hull of 2 vertices

Expand All @@ -577,12 +580,12 @@ but not algebraic or symbolic values:

::

sage: P4_cdd = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]], backend='cdd') # optional - sage.rings.number_field
sage: P4_cdd = Polyhedron(vertices=[[sqrt_2, 0], [0, cbrt_2]], backend='cdd') # needs sage.rings.number_field
Traceback (most recent call last):
...
ValueError: No such backend (=cdd) implemented for given basering (=Algebraic Real Field).

sage: P5_cdd = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]], backend='cdd') # optional - sage.symbolic
sage: P5_cdd = Polyhedron(vertices=[[sqrt_2s, 0], [0, cbrt_2s]], backend='cdd') # needs sage.symbolic
Traceback (most recent call last):
...
ValueError: No such backend (=cdd) implemented for given basering (=Symbolic Ring).
Expand Down Expand Up @@ -656,8 +659,8 @@ An example with quadratic field:

::

sage: V = polytopes.dodecahedron().vertices_list() # optional - sage.rings.number_field
sage: Polyhedron(vertices=V, backend='polymake') # optional - jupymake # optional - sage.rings.number_field
sage: V = polytopes.dodecahedron().vertices_list() # needs sage.rings.number_field
sage: Polyhedron(vertices=V, backend='polymake') # optional - jupymake # needs sage.rings.number_field
A 3-dimensional polyhedron
in (Number Field in sqrt5 with defining polynomial x^2 - 5
with sqrt5 = 2.236067977499790?)^3
Expand All @@ -681,7 +684,7 @@ examples.

::

sage: type(D) # optional - sage.rings.number_field
sage: type(D) # needs sage.rings.number_field
<class 'sage.geometry.polyhedron.parent.Polyhedra_field_with_category.element_class'>

.. end of output
Expand All @@ -691,13 +694,14 @@ backend :code:`field` is called.

::

sage: P4.parent() # optional - sage.rings.number_field
sage: # needs sage.rings.number_field
sage: P4.parent()
Polyhedra in AA^2
sage: P5.parent() # optional - sage.rings.number_field
sage: P5.parent()
Polyhedra in AA^2
sage: type(P4) # optional - sage.rings.number_field
sage: type(P4)
<class 'sage.geometry.polyhedron.parent.Polyhedra_field_with_category.element_class'>
sage: type(P5) # optional - sage.rings.number_field
sage: type(P5)
<class 'sage.geometry.polyhedron.parent.Polyhedra_field_with_category.element_class'>

.. end of output
Expand All @@ -709,13 +713,15 @@ The fourth backend is :code:`normaliz` and is an optional Sage package.

::

sage: P1_normaliz = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]], backend='normaliz') # optional - pynormaliz
sage: type(P1_normaliz) # optional - pynormaliz
sage: # optional - pynormaliz
sage: P1_normaliz = Polyhedron(vertices=[[1, 0], [0, 1]], rays=[[1, 1]],
....: backend='normaliz')
sage: type(P1_normaliz)
<class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_normaliz_with_category.element_class'>
sage: P2_normaliz = Polyhedron(vertices = [[1/2, 0, 0], [0, 1/2, 0]], # optional - pynormaliz
....: rays = [[1, 1, 0]],
....: lines = [[0, 0, 1]], backend='normaliz')
sage: type(P2_normaliz) # optional - pynormaliz
sage: P2_normaliz = Polyhedron(vertices=[[1/2, 0, 0], [0, 1/2, 0]],
....: rays=[[1, 1, 0]],
....: lines=[[0, 0, 1]], backend='normaliz')
sage: type(P2_normaliz)
<class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_normaliz_with_category.element_class'>

.. end of output
Expand All @@ -724,7 +730,7 @@ This backend does not work with :code:`RDF` or other inexact fields.

::

sage: P3_normaliz = Polyhedron(vertices = [[0.5, 0], [0, 0.5]], backend='normaliz') # optional - pynormaliz
sage: P3_normaliz = Polyhedron(vertices=[[0.5, 0], [0, 0.5]], backend='normaliz') # optional - pynormaliz
Traceback (most recent call last):
...
ValueError: No such backend (=normaliz) implemented for given basering (=Real Double Field).
Expand All @@ -738,12 +744,14 @@ the computation is done using an embedded number field.

::

sage: P4_normaliz = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]], backend='normaliz') # optional - pynormaliz
sage: P4_normaliz # optional - pynormaliz
sage: # optional - pynormaliz
sage: P4_normaliz = Polyhedron(vertices=[[sqrt_2, 0], [0, cbrt_2]],
....: backend='normaliz')
sage: P4_normaliz
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices

sage: P5_normaliz = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]], backend='normaliz') # optional - pynormaliz
sage: P5_normaliz # optional - pynormaliz
sage: P5_normaliz = Polyhedron(vertices=[[sqrt_2s, 0], [0, cbrt_2s]],
....: backend='normaliz')
sage: P5_normaliz
A 1-dimensional polyhedron in (Symbolic Ring)^2 defined as the convex hull of 2 vertices

.. end of output
Expand All @@ -753,12 +761,14 @@ The backend :code:`normaliz` provides other methods such as

::

sage: P6 = Polyhedron(vertices = [[0, 0], [3/2, 0], [3/2, 3/2], [0, 3]], backend='normaliz') # optional - pynormaliz
sage: IH = P6.integral_hull(); IH # optional - pynormaliz
sage: # optional - pynormaliz
sage: P6 = Polyhedron(vertices=[[0, 0], [3/2, 0], [3/2, 3/2], [0, 3]],
....: backend='normaliz')
sage: IH = P6.integral_hull(); IH
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices
sage: P6.plot(color='blue')+IH.plot(color='red') # optional - pynormaliz
sage: P6.plot(color='blue') + IH.plot(color='red')
Graphics object consisting of 12 graphics primitives
sage: P1_normaliz.integral_hull() # optional - pynormaliz
sage: P1_normaliz.integral_hull()
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices and 1 ray

.. end of output
Expand Down Expand Up @@ -788,7 +798,7 @@ polytope is already defined!

::

sage: A = polytopes.buckyball(); A # can take long # optional - sage.rings.number_field
sage: A = polytopes.buckyball(); A # can take long # needs sage.rings.number_field
A 3-dimensional polyhedron
in (Number Field in sqrt5 with defining polynomial x^2 - 5
with sqrt5 = 2.236067977499790?)^3
Expand Down
Loading