Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a9e987

Browse files
author
Matthias Koeppe
committedNov 8, 2023
sage -fixdoctests --only-tags src/doc
1 parent 6251ad5 commit 4a9e987

File tree

4 files changed

+67
-57
lines changed

4 files changed

+67
-57
lines changed
 

‎src/doc/en/developer/coding_basics.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,9 @@ framework. Here is a comprehensive list:
12511251
12521252
Consider the following calculation::
12531253
1254-
sage: a = AA(2).sqrt() # needs sage.rings.number_field
1255-
sage: b = sqrt(3) # needs sage.symbolic
1256-
sage: a + AA(b) # needs sage.rings.number_field sage.symbolic
1254+
sage: a = AA(2).sqrt() # needs sage.rings.number_field
1255+
sage: b = sqrt(3) # needs sage.symbolic
1256+
sage: a + AA(b) # needs sage.rings.number_field sage.symbolic
12571257
3.146264369941973?
12581258
12591259
.. NOTE::

‎src/doc/en/prep/Quickstarts/Statistics-and-Distributions.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ the examples in ``r.kruskal_test?`` in the notebook.
142142

143143
::
144144

145-
sage: x=r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects # optional - rpy2
146-
sage: y=r([3.8, 2.7, 4.0, 2.4]) # with obstructive airway disease # optional - rpy2
147-
sage: z=r([2.8, 3.4, 3.7, 2.2, 2.0]) # with asbestosis # optional - rpy2
148-
sage: a = r([x,y,z]) # make a long R vector of all the data # optional - rpy2
149-
sage: b = r.factor(5*[1]+4*[2]+5*[3]) # create something for R to tell # optional - rpy2
145+
sage: # optional - rpy2
146+
sage: x=r([2.9, 3.0, 2.5, 2.6, 3.2]) # normal subjects
147+
sage: y=r([3.8, 2.7, 4.0, 2.4]) # with obstructive airway disease
148+
sage: z=r([2.8, 3.4, 3.7, 2.2, 2.0]) # with asbestosis
149+
sage: a = r([x,y,z]) # make a long R vector of all the data
150+
sage: b = r.factor(5*[1]+4*[2]+5*[3]) # create something for R to tell
150151
....: # which subjects are which
151-
sage: a; b # show them # optional - rpy2
152+
sage: a; b # show them
152153
[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
153154
[1] 1 1 1 1 1 2 2 2 2 3 3 3 3 3
154155
Levels: 1 2 3

‎src/doc/en/thematic_tutorials/geometry/polyhedra_tutorial.rst

+25-20
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ It is also possible to define a polyhedron over algebraic numbers.
199199

200200
::
201201

202-
sage: sqrt_2 = AA(2)^(1/2) # needs sage.rings.number_field
203-
sage: cbrt_2 = AA(2)^(1/3) # needs sage.rings.number_field
204-
sage: timeit('Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]])') # needs sage.rings.number_field
202+
sage: # needs sage.rings.number_field
203+
sage: sqrt_2 = AA(2)^(1/2)
204+
sage: cbrt_2 = AA(2)^(1/3)
205+
sage: timeit('Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]])')
205206
5 loops, best of 3: 43.2 ms per loop
206-
sage: P4 = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]]); P4 # needs sage.rings.number_field
207+
sage: P4 = Polyhedron(vertices = [[sqrt_2, 0], [0, cbrt_2]]); P4
207208
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
208209

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

213214
::
214215

215-
sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2)) # needs sage.rings.number_field
216-
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3)) # needs sage.rings.number_field
217-
sage: timeit('Polyhedron(vertices = [[a, 0], [0, b]])') # needs sage.rings.number_field
216+
sage: # needs sage.rings.number_field
217+
sage: K.<a> = NumberField(x^2 - 2, embedding=AA(2)**(1/2))
218+
sage: L.<b> = NumberField(x^3 - 2, embedding=AA(2)**(1/3))
219+
sage: timeit('Polyhedron(vertices = [[a, 0], [0, b]])')
218220
5 loops, best of 3: 39.9 ms per loop
219-
sage: P5 = Polyhedron(vertices = [[a, 0], [0, b]]); P5 # needs sage.rings.number_field
221+
sage: P5 = Polyhedron(vertices = [[a, 0], [0, b]]); P5
220222
A 1-dimensional polyhedron in AA^2 defined as the convex hull of 2 vertices
221223

222224
.. end of output
@@ -691,13 +693,14 @@ backend :code:`field` is called.
691693

692694
::
693695

694-
sage: P4.parent() # needs sage.rings.number_field
696+
sage: # needs sage.rings.number_field
697+
sage: P4.parent()
695698
Polyhedra in AA^2
696-
sage: P5.parent() # needs sage.rings.number_field
699+
sage: P5.parent()
697700
Polyhedra in AA^2
698-
sage: type(P4) # needs sage.rings.number_field
701+
sage: type(P4)
699702
<class 'sage.geometry.polyhedron.parent.Polyhedra_field_with_category.element_class'>
700-
sage: type(P5) # needs sage.rings.number_field
703+
sage: type(P5)
701704
<class 'sage.geometry.polyhedron.parent.Polyhedra_field_with_category.element_class'>
702705

703706
.. end of output
@@ -709,13 +712,14 @@ The fourth backend is :code:`normaliz` and is an optional Sage package.
709712

710713
::
711714

712-
sage: P1_normaliz = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]], backend='normaliz') # optional - pynormaliz
713-
sage: type(P1_normaliz) # optional - pynormaliz
715+
sage: # optional - pynormaliz
716+
sage: P1_normaliz = Polyhedron(vertices = [[1, 0], [0, 1]], rays = [[1, 1]], backend='normaliz')
717+
sage: type(P1_normaliz)
714718
<class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_normaliz_with_category.element_class'>
715-
sage: P2_normaliz = Polyhedron(vertices = [[1/2, 0, 0], [0, 1/2, 0]], # optional - pynormaliz
719+
sage: P2_normaliz = Polyhedron(vertices = [[1/2, 0, 0], [0, 1/2, 0]],
716720
....: rays = [[1, 1, 0]],
717721
....: lines = [[0, 0, 1]], backend='normaliz')
718-
sage: type(P2_normaliz) # optional - pynormaliz
722+
sage: type(P2_normaliz)
719723
<class 'sage.geometry.polyhedron.parent.Polyhedra_QQ_normaliz_with_category.element_class'>
720724

721725
.. end of output
@@ -753,12 +757,13 @@ The backend :code:`normaliz` provides other methods such as
753757

754758
::
755759

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

764769
.. end of output

‎src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst

+32-28
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ by
2828

2929
::
3030

31-
sage: import numpy # needs cvxopt
32-
sage: from cvxopt.base import spmatrix # needs cvxopt
33-
sage: from cvxopt.base import matrix as m # needs cvxopt
34-
sage: from cvxopt import umfpack # needs cvxopt
35-
sage: Integer = int # needs cvxopt
36-
sage: V = [2,3, 3,-1,4, 4,-3,1,2, 2, 6,1] # needs cvxopt
37-
sage: I = [0,1, 0, 2,4, 1, 2,3,4, 2, 1,4] # needs cvxopt
38-
sage: J = [0,0, 1, 1,1, 2, 2,2,2, 3, 4,4] # needs cvxopt
39-
sage: A = spmatrix(V,I,J) # needs cvxopt
31+
sage: # needs cvxopt
32+
sage: import numpy
33+
sage: from cvxopt.base import spmatrix
34+
sage: from cvxopt.base import matrix as m
35+
sage: from cvxopt import umfpack
36+
sage: Integer = int
37+
sage: V = [2,3, 3,-1,4, 4,-3,1,2, 2, 6,1]
38+
sage: I = [0,1, 0, 2,4, 1, 2,3,4, 2, 1,4]
39+
sage: J = [0,0, 1, 1,1, 2, 2,2,2, 3, 4,4]
40+
sage: A = spmatrix(V,I,J)
4041

4142
To solve an equation :math:`AX=B`, with :math:`B=[1,1,1,1,1]`,
4243
we could do the following.
@@ -55,15 +56,16 @@ we could do the following.
5556
[1.]]
5657

5758

58-
sage: print(A) # needs cvxopt
59+
sage: # needs cvxopt
60+
sage: print(A)
5961
[ 2.00e+00 3.00e+00 0 0 0 ]
6062
[ 3.00e+00 0 4.00e+00 0 6.00e+00]
6163
[ 0 -1.00e+00 -3.00e+00 2.00e+00 0 ]
6264
[ 0 0 1.00e+00 0 0 ]
6365
[ 0 4.00e+00 2.00e+00 0 1.00e+00]
64-
sage: C = m(B) # needs cvxopt
65-
sage: umfpack.linsolve(A,C) # needs cvxopt
66-
sage: print(C) # needs cvxopt
66+
sage: C = m(B)
67+
sage: umfpack.linsolve(A,C)
68+
sage: print(C)
6769
[ 5.79e-01]
6870
[-5.26e-02]
6971
[ 1.00e+00]
@@ -81,13 +83,14 @@ We could compute the approximate minimum degree ordering by doing
8183

8284
::
8385

84-
sage: RealNumber = float # needs cvxopt
85-
sage: Integer = int # needs cvxopt
86-
sage: from cvxopt.base import spmatrix # needs cvxopt
87-
sage: from cvxopt import amd # needs cvxopt
88-
sage: A = spmatrix([10,3,5,-2,5,2],[0,2,1,2,2,3],[0,0,1,1,2,3]) # needs cvxopt
89-
sage: P = amd.order(A) # needs cvxopt
90-
sage: print(P) # needs cvxopt
86+
sage: # needs cvxopt
87+
sage: RealNumber = float
88+
sage: Integer = int
89+
sage: from cvxopt.base import spmatrix
90+
sage: from cvxopt import amd
91+
sage: A = spmatrix([10,3,5,-2,5,2],[0,2,1,2,2,3],[0,0,1,1,2,3])
92+
sage: P = amd.order(A)
93+
sage: print(P)
9194
[ 1]
9295
[ 0]
9396
[ 2]
@@ -108,14 +111,15 @@ For a simple linear programming example, if we want to solve
108111
109112
::
110113

111-
sage: RealNumber = float # needs cvxopt
112-
sage: Integer = int # needs cvxopt
113-
sage: from cvxopt.base import matrix as m # needs cvxopt
114-
sage: from cvxopt import solvers # needs cvxopt
115-
sage: c = m([-4., -5.]) # needs cvxopt
116-
sage: G = m([[2., 1., -1., 0.], [1., 2., 0., -1.]]) # needs cvxopt
117-
sage: h = m([3., 3., 0., 0.]) # needs cvxopt
118-
sage: sol = solvers.lp(c,G,h) # random # needs cvxopt
114+
sage: # needs cvxopt
115+
sage: RealNumber = float
116+
sage: Integer = int
117+
sage: from cvxopt.base import matrix as m
118+
sage: from cvxopt import solvers
119+
sage: c = m([-4., -5.])
120+
sage: G = m([[2., 1., -1., 0.], [1., 2., 0., -1.]])
121+
sage: h = m([3., 3., 0., 0.])
122+
sage: sol = solvers.lp(c,G,h) # random
119123
pcost dcost gap pres dres k/t
120124
0: -8.1000e+00 -1.8300e+01 4e+00 0e+00 8e-01 1e+00
121125
1: -8.8055e+00 -9.4357e+00 2e-01 1e-16 4e-02 3e-02

0 commit comments

Comments
 (0)
Please sign in to comment.