Skip to content

Commit edeb26c

Browse files
author
Release Manager
committed
gh-37608: src/sage/modules: Doctest cosmetics <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Standard reformatting of doctests and their outputs Split out from #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37608 Reported by: Matthias Köppe Reviewer(s): Frédéric Chapoton
2 parents ae3c078 + a456cdc commit edeb26c

13 files changed

+225
-209
lines changed

src/sage/modules/free_module.py

Lines changed: 87 additions & 72 deletions
Large diffs are not rendered by default.

src/sage/modules/free_module_element.pyx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ field.
8282
8383
Matrix vector multiply::
8484
85-
sage: MS = MatrixSpace(QQ,3)
85+
sage: MS = MatrixSpace(QQ, 3)
8686
sage: A = MS([0,1,0,1,0,0,0,0,1])
8787
sage: V = QQ^3
8888
sage: v = V([1,2,3])
@@ -1033,36 +1033,36 @@ cdef class FreeModuleElement(Vector): # abstract base class
10331033
10341034
sage: F = FreeModule(ZZ, 2, inner_product_matrix=matrix(ZZ, 2, 2, [1, 0, 0, -1]))
10351035
sage: v = F([1, 2])
1036-
sage: M = magma(v); M # optional - magma
1036+
sage: M = magma(v); M # optional - magma
10371037
(1 2)
1038-
sage: M.Type() # optional - magma
1038+
sage: M.Type() # optional - magma
10391039
ModTupRngElt
1040-
sage: M.Parent() # optional - magma
1040+
sage: M.Parent() # optional - magma
10411041
Full RSpace of degree 2 over Integer Ring
10421042
Inner Product Matrix:
10431043
[ 1 0]
10441044
[ 0 -1]
1045-
sage: M.sage() # optional - magma
1045+
sage: M.sage() # optional - magma
10461046
(1, 2)
1047-
sage: M.sage() == v # optional - magma
1047+
sage: M.sage() == v # optional - magma
10481048
True
1049-
sage: M.sage().parent() is v.parent() # optional - magma
1049+
sage: M.sage().parent() is v.parent() # optional - magma
10501050
True
10511051
10521052
::
10531053
10541054
sage: v = vector(QQ, [1, 2, 5/6])
1055-
sage: M = magma(v); M # optional - magma
1055+
sage: M = magma(v); M # optional - magma
10561056
( 1 2 5/6)
1057-
sage: M.Type() # optional - magma
1057+
sage: M.Type() # optional - magma
10581058
ModTupFldElt
1059-
sage: M.Parent() # optional - magma
1059+
sage: M.Parent() # optional - magma
10601060
Full Vector space of degree 3 over Rational Field
1061-
sage: M.sage() # optional - magma
1061+
sage: M.sage() # optional - magma
10621062
(1, 2, 5/6)
1063-
sage: M.sage() == v # optional - magma
1063+
sage: M.sage() == v # optional - magma
10641064
True
1065-
sage: M.sage().parent() is v.parent() # optional - magma
1065+
sage: M.sage().parent() is v.parent() # optional - magma
10661066
True
10671067
"""
10681068
# Get a reference to Magma version of parent.
@@ -2332,7 +2332,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
23322332
Three-dimensional examples::
23332333
23342334
sage: v = vector(RDF, (1,2,1))
2335-
sage: plot(v) # defaults to an arrow plot # needs sage.plot
2335+
sage: plot(v) # defaults to an arrow plot # needs sage.plot
23362336
Graphics3d Object
23372337
23382338
::
@@ -2348,7 +2348,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
23482348
23492349
::
23502350
2351-
sage: plot(v, plot_type='step') # calls v.plot_step() # needs sage.plot
2351+
sage: plot(v, plot_type='step') # calls v.plot_step() # needs sage.plot
23522352
Graphics object consisting of 1 graphics primitive
23532353
23542354
::
@@ -2377,7 +2377,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
23772377
TESTS::
23782378
23792379
sage: u = vector([1,1]); v = vector([2,2,2]); z=(3,3,3)
2380-
sage: plot(u) #test when start=None # needs sage.plot
2380+
sage: plot(u) #test when start=None # needs sage.plot
23812381
Graphics object consisting of 1 graphics primitive
23822382
23832383
::

src/sage/modules/free_module_homspace.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
We create `\mathrm{End}(\ZZ^2)` and compute a basis. ::
77
8-
sage: M = FreeModule(IntegerRing(),2)
8+
sage: M = FreeModule(IntegerRing(), 2)
99
sage: E = End(M)
1010
sage: B = E.basis()
1111
sage: len(B)
@@ -14,22 +14,21 @@
1414
Free module morphism defined by the matrix
1515
[1 0]
1616
[0 0]
17-
Domain: Ambient free module of rank 2 over the principal ideal domain ...
17+
Domain: Ambient free module of rank 2 over the principal ideal domain ...
1818
Codomain: Ambient free module of rank 2 over the principal ideal domain ...
1919
2020
We create `\mathrm{Hom}(\ZZ^3, \ZZ^2)` and compute a basis. ::
2121
22-
sage: V3 = FreeModule(IntegerRing(),3)
23-
sage: V2 = FreeModule(IntegerRing(),2)
24-
sage: H = Hom(V3,V2)
22+
sage: V3 = FreeModule(IntegerRing(), 3)
23+
sage: V2 = FreeModule(IntegerRing(), 2)
24+
sage: H = Hom(V3, V2)
2525
sage: H
26-
Set of Morphisms from Ambient free module of rank 3 over
27-
the principal ideal domain Integer Ring
28-
to Ambient free module of rank 2
29-
over the principal ideal domain Integer Ring
30-
in Category of finite dimensional modules with basis over
31-
(Dedekind domains and euclidean domains
32-
and infinite enumerated sets and metric spaces)
26+
Set of Morphisms
27+
from Ambient free module of rank 3 over the principal ideal domain Integer Ring
28+
to Ambient free module of rank 2 over the principal ideal domain Integer Ring
29+
in Category of finite dimensional modules with basis over
30+
(Dedekind domains and euclidean domains
31+
and infinite enumerated sets and metric spaces)
3332
sage: B = H.basis()
3433
sage: len(B)
3534
6
@@ -168,10 +167,10 @@ def __call__(self, A, **kwds):
168167
[0 0 0]
169168
[0 0 0]
170169
[0 0 0]
171-
Domain: Free module of degree 3 and rank 3 over Integer Ring
172-
Echelon ...
170+
Domain: Free module of degree 3 and rank 3 over Integer Ring
171+
Echelon ...
173172
Codomain: Free module of degree 3 and rank 3 over Integer Ring
174-
Echelon ...
173+
Echelon ...
175174
176175
The following tests the bug fixed in :issue:`31818`. If there is no
177176
coercion between base rings, one can only define the zero morphism,
@@ -189,7 +188,7 @@ def __call__(self, A, **kwds):
189188
Free module morphism defined by the matrix
190189
[0 0]
191190
[0 0]
192-
Domain: Vector space of dimension 2 over Rational Field
191+
Domain: Vector space of dimension 2 over Rational Field
193192
Codomain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
194193
sage: [h(v) for v in V.gens()]
195194
[(0, 0), (0, 0)]
@@ -237,7 +236,7 @@ def zero(self, side="left"):
237236
Free module morphism defined by the matrix
238237
[0 0 0]
239238
[0 0 0]
240-
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
239+
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
241240
Codomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring
242241
sage: f(E.an_element())
243242
(0, 0, 0)
@@ -248,7 +247,7 @@ def zero(self, side="left"):
248247
[0 0]
249248
[0 0]
250249
[0 0]
251-
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
250+
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
252251
Codomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring
253252
254253
@@ -260,7 +259,7 @@ def zero(self, side="left"):
260259
Free module morphism defined by the matrix
261260
[0 0 0]
262261
[0 0 0]
263-
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
262+
Domain: Ambient free module of rank 2 over the principal ideal domain Integer Ring
264263
Codomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring
265264
"""
266265
return self(lambda x: self.codomain().zero(), side=side)
@@ -311,24 +310,24 @@ def basis(self, side="left"):
311310
sage: H = Hom(ZZ^2, ZZ^1)
312311
sage: H.basis()
313312
(Free module morphism defined by the matrix
314-
[1]
315-
[0]
316-
Domain: Ambient free module of rank 2 over the principal ideal domain ...
317-
Codomain: Ambient free module of rank 1 over the principal ideal domain ...,
318-
Free module morphism defined by the matrix
319-
[0]
320-
[1]
321-
Domain: Ambient free module of rank 2 over the principal ideal domain ...
322-
Codomain: Ambient free module of rank 1 over the principal ideal domain ...)
313+
[1]
314+
[0]
315+
Domain: Ambient free module of rank 2 over the principal ideal domain ...
316+
Codomain: Ambient free module of rank 1 over the principal ideal domain ...,
317+
Free module morphism defined by the matrix
318+
[0]
319+
[1]
320+
Domain: Ambient free module of rank 2 over the principal ideal domain ...
321+
Codomain: Ambient free module of rank 1 over the principal ideal domain ...)
323322
sage: H.basis("right")
324323
(Free module morphism defined as left-multiplication by the matrix
325-
[1 0]
326-
Domain: Ambient free module of rank 2 over the principal ideal domain ...
327-
Codomain: Ambient free module of rank 1 over the principal ideal domain ...,
324+
[1 0]
325+
Domain: Ambient free module of rank 2 over the principal ideal domain ...
326+
Codomain: Ambient free module of rank 1 over the principal ideal domain ...,
328327
Free module morphism defined as left-multiplication by the matrix
329-
[0 1]
330-
Domain: Ambient free module of rank 2 over the principal ideal domain ...
331-
Codomain: Ambient free module of rank 1 over the principal ideal domain ...)
328+
[0 1]
329+
Domain: Ambient free module of rank 2 over the principal ideal domain ...
330+
Codomain: Ambient free module of rank 1 over the principal ideal domain ...)
332331
"""
333332
M = self._matrix_space(side)
334333
B = M.basis()
@@ -353,7 +352,7 @@ def identity(self, side="left"):
353352
[0 0 1 0 0]
354353
[0 0 0 1 0]
355354
[0 0 0 0 1]
356-
Domain: Ambient free module of rank 5 over the principal ideal domain ...
355+
Domain: Ambient free module of rank 5 over the principal ideal domain ...
357356
Codomain: Ambient free module of rank 5 over the principal ideal domain ...
358357
"""
359358
if self.is_endomorphism_set():

src/sage/modules/free_module_integer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ def voronoi_cell(self, radius=None):
662662
The volume of the Voronoi cell is the square root of the
663663
discriminant of the lattice::
664664
665-
sage: L = IntegerLattice(Matrix(ZZ, 4, 4, [[0,0,1,-1],[1,-1,2,1],[-6,0,3,3,],[-6,-24,-6,-5]])); L
665+
sage: L = IntegerLattice(Matrix(ZZ, 4, 4, [[0,0,1,-1], [1,-1,2,1],
666+
....: [-6,0,3,3,], [-6,-24,-6,-5]])); L
666667
Free module of degree 4 and rank 4 over Integer Ring
667668
User basis matrix:
668669
[ 0 0 1 -1]

src/sage/modules/free_module_morphism.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def __init__(self, parent, A, side="left"):
7373
7474
EXAMPLES::
7575
76-
sage: V = ZZ^3; W = span([[1,2,3],[-1,2,8]], ZZ)
77-
sage: phi = V.hom(matrix(ZZ,3,[1..9]))
76+
sage: V = ZZ^3; W = span([[1,2,3], [-1,2,8]], ZZ)
77+
sage: phi = V.hom(matrix(ZZ, 3, [1..9]))
7878
sage: type(phi)
7979
<class 'sage.modules.free_module_morphism.FreeModuleMorphism'>
8080
"""
@@ -91,8 +91,8 @@ def pushforward(self, x):
9191
9292
EXAMPLES::
9393
94-
sage: V = QQ^3; W = span([[1,2,3],[-1,2,5/3]], QQ)
95-
sage: phi = V.hom(matrix(QQ,3,[1..9]))
94+
sage: V = QQ^3; W = span([[1,2,3], [-1,2,5/3]], QQ)
95+
sage: phi = V.hom(matrix(QQ, 3, [1..9]))
9696
sage: phi.rank()
9797
2
9898
sage: phi(V) #indirect doctest
@@ -104,12 +104,12 @@ def pushforward(self, x):
104104
We compute the image of a submodule of a ZZ-module embedded in
105105
a rational vector space::
106106
107-
sage: V = QQ^3; W = V.span_of_basis([[2,2,3],[-1,2,5/3]], ZZ)
108-
sage: phi = W.hom([W.0, W.0-W.1]); phi
107+
sage: V = QQ^3; W = V.span_of_basis([[2,2,3], [-1,2,5/3]], ZZ)
108+
sage: phi = W.hom([W.0, W.0 - W.1]); phi
109109
Free module morphism defined by the matrix
110110
[ 1 0]
111111
[ 1 -1]...
112-
sage: phi(span([2*W.1],ZZ))
112+
sage: phi(span([2*W.1], ZZ))
113113
Free module of degree 3 and rank 1 over Integer Ring
114114
Echelon basis matrix:
115115
[ 6 0 8/3]
@@ -127,8 +127,8 @@ def _repr_(self):
127127
128128
EXAMPLES::
129129
130-
sage: V = ZZ^3; W = span([[1,2,3],[-1,2,8]], ZZ)
131-
sage: phi = V.hom(matrix(ZZ,3,[1..9]))
130+
sage: V = ZZ^3; W = span([[1,2,3], [-1,2,8]], ZZ)
131+
sage: phi = V.hom(matrix(ZZ, 3, [1..9]))
132132
sage: phi._repr_()
133133
'Free module morphism defined by the matrix\n[1 2 3]\n[4 5 6]\n[7 8 9]\nDomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring\nCodomain: Ambient free module of rank 3 over the principal ideal domain Integer Ring'
134134
@@ -242,8 +242,8 @@ def inverse_image(self, V):
242242
243243
We test computing inverse images over a field::
244244
245-
sage: V = QQ^3; W = span([[1,2,3],[-1,2,5/3]], QQ)
246-
sage: phi = V.hom(matrix(QQ,3,[1..9]))
245+
sage: V = QQ^3; W = span([[1,2,3], [-1,2,5/3]], QQ)
246+
sage: phi = V.hom(matrix(QQ, 3, [1..9]))
247247
sage: phi.rank()
248248
2
249249
sage: I = phi.inverse_image(W); I
@@ -297,7 +297,7 @@ def inverse_image(self, V):
297297
298298
We test that :issue:`24590` is resolved::
299299
300-
sage: A = FreeQuadraticModule(ZZ,1,matrix([2]))
300+
sage: A = FreeQuadraticModule(ZZ, 1, matrix([2]))
301301
sage: f = A.Hom(A).an_element()
302302
sage: f.inverse_image(A)
303303
Free module of degree 1 and rank 1 over Integer Ring
@@ -443,7 +443,7 @@ def lift(self, x):
443443
sage: V = QQ^2; m = matrix(2, [1, 1, 0, 1])
444444
sage: V.hom(m, side="right").lift(V.0 + V.1)
445445
(0, 1)
446-
sage: V.hom(m).lift(V.0+V.1)
446+
sage: V.hom(m).lift(V.0 + V.1)
447447
(1, 0)
448448
"""
449449
from .free_module_element import vector

0 commit comments

Comments
 (0)