Skip to content

Commit ae3c078

Browse files
author
Release Manager
committed
gh-37607: src/sage/matrix: 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. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] 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: #37607 Reported by: Matthias Köppe Reviewer(s): Frédéric Chapoton
2 parents 3ee8402 + 2b064e1 commit ae3c078

File tree

11 files changed

+396
-325
lines changed

11 files changed

+396
-325
lines changed

src/sage/matrix/action.pyx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ Actions used by the coercion model for matrix and vector multiplications
1919
sage: MSZ = MatrixSpace(ZZ['x'], 2)
2020
sage: A = MSQ.get_action(MSZ)
2121
sage: A
22-
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field on Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
22+
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field
23+
on Full MatrixSpace of 2 by 2 dense matrices
24+
over Univariate Polynomial Ring in x over Integer Ring
2325
sage: import gc
2426
sage: _ = gc.collect()
2527
sage: A
26-
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field on Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
28+
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field
29+
on Full MatrixSpace of 2 by 2 dense matrices
30+
over Univariate Polynomial Ring in x over Integer Ring
2731
2832
.. NOTE::
2933
@@ -83,13 +87,17 @@ cdef class MatrixMulAction(Action):
8387
sage: MSQ = MatrixSpace(QQ, 2)
8488
sage: MSZ = MatrixSpace(ZZ['x'], 2)
8589
sage: A = MSQ.get_action(MSZ); A
86-
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field on Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
90+
Left action by Full MatrixSpace of 2 by 2 dense matrices over Rational Field
91+
on Full MatrixSpace of 2 by 2 dense matrices
92+
over Univariate Polynomial Ring in x over Integer Ring
8793
sage: A.actor()
8894
Full MatrixSpace of 2 by 2 dense matrices over Rational Field
8995
sage: A.domain()
90-
Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
96+
Full MatrixSpace of 2 by 2 dense matrices
97+
over Univariate Polynomial Ring in x over Integer Ring
9198
sage: A.codomain()
92-
Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
99+
Full MatrixSpace of 2 by 2 dense matrices
100+
over Univariate Polynomial Ring in x over Rational Field
93101
"""
94102
def __init__(self, G, S, is_left):
95103
if not is_MatrixSpace(G):
@@ -130,9 +138,13 @@ cdef class MatrixMatrixAction(MatrixMulAction):
130138
sage: MSQ = MatrixSpace(QQ, 3, 2)
131139
sage: from sage.matrix.action import MatrixMatrixAction
132140
sage: A = MatrixMatrixAction(MSR, MSQ); A
133-
Left action by Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Integer Ring on Full MatrixSpace of 3 by 2 dense matrices over Rational Field
141+
Left action
142+
by Full MatrixSpace of 3 by 3 dense matrices
143+
over Univariate Polynomial Ring in x over Integer Ring
144+
on Full MatrixSpace of 3 by 2 dense matrices over Rational Field
134145
sage: A.codomain()
135-
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
146+
Full MatrixSpace of 3 by 2 dense matrices
147+
over Univariate Polynomial Ring in x over Rational Field
136148
sage: A(matrix(R, 3, 3, x), matrix(QQ, 3, 2, range(6)))
137149
[ 0 x]
138150
[2*x 3*x]
@@ -183,7 +195,8 @@ cdef class MatrixMatrixAction(MatrixMulAction):
183195
sage: MSR = MatrixSpace(R, 3, 3)
184196
sage: MSQ = MatrixSpace(QQ, 3, 2)
185197
sage: A = MatrixMatrixAction(MSR, MSQ); A
186-
Left action by Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Integer Ring on Full MatrixSpace of 3 by 2 dense matrices over Rational Field
198+
Left action by Full MatrixSpace of 3 by 3 dense matrices over Univariate Polynomial Ring in x over Integer Ring
199+
on Full MatrixSpace of 3 by 2 dense matrices over Rational Field
187200
sage: A.codomain()
188201
Full MatrixSpace of 3 by 2 dense matrices over Univariate Polynomial Ring in x over Rational Field
189202
@@ -303,7 +316,8 @@ cdef class MatrixVectorAction(MatrixMulAction):
303316
sage: M = MatrixSpace(QQ, 5, 3)
304317
sage: V = VectorSpace(CDF, 3) # strong reference prevents garbage collection
305318
sage: A = MatrixVectorAction(M, V); A
306-
Left action by Full MatrixSpace of 5 by 3 dense matrices over Rational Field on Vector space of dimension 3 over Complex Double Field
319+
Left action by Full MatrixSpace of 5 by 3 dense matrices over Rational Field
320+
on Vector space of dimension 3 over Complex Double Field
307321
sage: A.codomain()
308322
Vector space of dimension 5 over Complex Double Field
309323
"""
@@ -354,7 +368,8 @@ cdef class VectorMatrixAction(MatrixMulAction):
354368
sage: V = VectorSpace(CDF, 3)
355369
sage: A = VectorMatrixAction(M, V)
356370
sage: A
357-
Right action by Full MatrixSpace of 3 by 5 dense matrices over Rational Field on Vector space of dimension 3 over Complex Double Field
371+
Right action by Full MatrixSpace of 3 by 5 dense matrices over Rational Field
372+
on Vector space of dimension 3 over Complex Double Field
358373
sage: A.codomain()
359374
Vector space of dimension 5 over Complex Double Field
360375
"""

src/sage/matrix/args.pyx

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,33 @@ cdef class MatrixArgs:
156156
sage: ma = MatrixArgs(2, 2, (x for x in range(4))); ma
157157
<MatrixArgs for None; typ=UNKNOWN; entries=<generator ...>>
158158
sage: ma.finalized()
159-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 3]>
159+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
160+
over Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 3]>
160161
161162
Many types of input are possible::
162163
163-
sage: ma = MatrixArgs(2, 2, entries=None); ma.finalized(); ma.matrix()
164-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=ZERO; entries=None>
164+
sage: ma = MatrixArgs(2, 2, entries=None); ma.finalized()
165+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
166+
over Integer Ring; typ=ZERO; entries=None>
167+
sage: ma.matrix()
165168
[0 0]
166169
[0 0]
167-
sage: ma = MatrixArgs(2, 2, entries={}); ma.finalized(); ma.matrix()
168-
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over Integer Ring; typ=SEQ_SPARSE; entries=[]>
170+
sage: ma = MatrixArgs(2, 2, entries={}); ma.finalized()
171+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices
172+
over Integer Ring; typ=SEQ_SPARSE; entries=[]>
173+
sage: ma.matrix()
169174
[0 0]
170175
[0 0]
171-
sage: ma = MatrixArgs(2, 2, entries=[1,2,3,4]); ma.finalized(); ma.matrix()
172-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
176+
sage: ma = MatrixArgs(2, 2, entries=[1,2,3,4]); ma.finalized()
177+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
178+
over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
179+
sage: ma.matrix()
173180
[1 2]
174181
[3 4]
175-
sage: ma = MatrixArgs(2, 2, entries=math.pi); ma.finalized(); ma.matrix()
176-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Real Double Field; typ=SCALAR; entries=3.141592653589793>
182+
sage: ma = MatrixArgs(2, 2, entries=math.pi); ma.finalized()
183+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
184+
over Real Double Field; typ=SCALAR; entries=3.141592653589793>
185+
sage: ma.matrix()
177186
[3.141592653589793 0.0]
178187
[ 0.0 3.141592653589793]
179188
sage: ma = MatrixArgs(2, 2, entries=pi); ma.finalized() # needs sage.symbolic
@@ -182,16 +191,22 @@ cdef class MatrixArgs:
182191
sage: ma.matrix() # needs sage.symbolic
183192
[pi 0]
184193
[ 0 pi]
185-
sage: ma = MatrixArgs(ZZ, 2, 2, entries={(0,0):7}); ma.finalized(); ma.matrix()
186-
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 0, 7)]>
194+
sage: ma = MatrixArgs(ZZ, 2, 2, entries={(0,0): 7}); ma.finalized()
195+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices
196+
over Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 0, 7)]>
197+
sage: ma.matrix()
187198
[7 0]
188199
[0 0]
189-
sage: ma = MatrixArgs(ZZ, 2, 2, entries=((1,2),(3,4))); ma.finalized(); ma.matrix()
190-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_SEQ; entries=((1, 2), (3, 4))>
200+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=((1,2), (3,4))); ma.finalized()
201+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
202+
over Integer Ring; typ=SEQ_SEQ; entries=((1, 2), (3, 4))>
203+
sage: ma.matrix()
191204
[1 2]
192205
[3 4]
193-
sage: ma = MatrixArgs(ZZ, 2, 2, entries=(1,2,3,4)); ma.finalized(); ma.matrix()
194-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_FLAT; entries=(1, 2, 3, 4)>
206+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=(1,2,3,4)); ma.finalized()
207+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
208+
over Integer Ring; typ=SEQ_FLAT; entries=(1, 2, 3, 4)>
209+
sage: ma.matrix()
195210
[1 2]
196211
[3 4]
197212
@@ -215,17 +230,23 @@ cdef class MatrixArgs:
215230
[3/5 0]
216231
[ 0 3/5]
217232
218-
sage: ma = MatrixArgs(entries=matrix(2,2)); ma.finalized(); ma.matrix()
219-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=MATRIX; entries=[0 0]
220-
[0 0]>
233+
sage: ma = MatrixArgs(entries=matrix(2,2)); ma.finalized()
234+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
235+
over Integer Ring; typ=MATRIX; entries=[0 0]
236+
[0 0]>
237+
sage: ma.matrix()
221238
[0 0]
222239
[0 0]
223-
sage: ma = MatrixArgs(2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized(); ma.matrix()
224-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
240+
sage: ma = MatrixArgs(2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized()
241+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
242+
over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
243+
sage: ma.matrix()
225244
[1 2]
226245
[3 4]
227-
sage: ma = MatrixArgs(ZZ, 2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized(); ma.matrix()
228-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=CALLABLE; entries=<function ...>>
246+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized()
247+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
248+
over Integer Ring; typ=CALLABLE; entries=<function ...>>
249+
sage: ma.matrix()
229250
[1 2]
230251
[3 4]
231252
@@ -263,9 +284,12 @@ cdef class MatrixArgs:
263284
[1 0 1]
264285
[1 1 0]
265286
266-
sage: ma = MatrixArgs([vector([0,1], sparse=True), vector([0,0], sparse=True)], sparse=True)
267-
sage: ma.finalized(); ma.matrix()
268-
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 1, 1)]>
287+
sage: ma = MatrixArgs([vector([0,1], sparse=True),
288+
....: vector([0,0], sparse=True)], sparse=True)
289+
sage: ma.finalized()
290+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over
291+
Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 1, 1)]>
292+
sage: ma.matrix()
269293
[0 1]
270294
[0 0]
271295
@@ -633,7 +657,8 @@ cdef class MatrixArgs:
633657
::
634658
635659
sage: ma = MatrixArgs(M); ma.finalized()
636-
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices over Integer Ring; typ=MATRIX; entries=[0 1 2]
660+
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices
661+
over Integer Ring; typ=MATRIX; entries=[0 1 2]
637662
[3 4 5]>
638663
sage: ma.matrix()
639664
[0 1 2]
@@ -642,17 +667,19 @@ cdef class MatrixArgs:
642667
::
643668
644669
sage: ma = MatrixArgs(M, sparse=False); ma.finalized()
645-
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices over Integer Ring; typ=MATRIX; entries=[0 1 2]
646-
[3 4 5]>
670+
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices
671+
over Integer Ring; typ=MATRIX; entries=[0 1 2]
672+
[3 4 5]>
647673
sage: ma.matrix()
648674
[0 1 2]
649675
[3 4 5]
650676
651677
::
652678
653679
sage: ma = MatrixArgs(RDF, M); ma.finalized()
654-
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices over Real Double Field; typ=MATRIX; entries=[0 1 2]
655-
[3 4 5]>
680+
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices
681+
over Real Double Field; typ=MATRIX; entries=[0 1 2]
682+
[3 4 5]>
656683
sage: ma.matrix(convert=False)
657684
[0 1 2]
658685
[3 4 5]
@@ -810,7 +837,8 @@ cdef class MatrixArgs:
810837
sage: S = MatrixSpace(QQ, 3, 2, sparse=True)
811838
sage: _ = ma.set_space(S)
812839
sage: ma.finalized()
813-
<MatrixArgs for Full MatrixSpace of 3 by 2 sparse matrices over Rational Field; typ=ZERO; entries=None>
840+
<MatrixArgs for Full MatrixSpace of 3 by 2 sparse matrices
841+
over Rational Field; typ=ZERO; entries=None>
814842
sage: M = ma.matrix(); M
815843
[0 0]
816844
[0 0]
@@ -848,7 +876,8 @@ cdef class MatrixArgs:
848876
...
849877
TypeError: the dimensions of the matrix must be specified
850878
sage: MatrixArgs(2, 3, 0.0).finalized()
851-
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices over Real Field with 53 bits of precision; typ=ZERO; entries=0.000000000000000>
879+
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices over Real
880+
Field with 53 bits of precision; typ=ZERO; entries=0.000000000000000>
852881
sage: MatrixArgs(RR, 2, 3, 1.0).finalized()
853882
Traceback (most recent call last):
854883
...
@@ -1020,19 +1049,21 @@ cdef class MatrixArgs:
10201049
EXAMPLES::
10211050
10221051
sage: from sage.matrix.args import MatrixArgs
1023-
sage: ma = MatrixArgs({(2,5):1/2, (4,-3):1/3})
1024-
sage: ma = MatrixArgs(2, 2, {(-1,0):2, (0,-1):1}, sparse=True)
1052+
sage: ma = MatrixArgs({(2,5): 1/2, (4,-3): 1/3})
1053+
sage: ma = MatrixArgs(2, 2, {(-1,0): 2, (0,-1): 1}, sparse=True)
10251054
sage: ma.finalized()
1026-
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(...), SparseEntry(...)]>
1027-
sage: ma = MatrixArgs(2, 2, {(-1,0):2, (0,-1):1}, sparse=False)
1055+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over
1056+
Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(...), SparseEntry(...)]>
1057+
sage: ma = MatrixArgs(2, 2, {(-1,0): 2, (0,-1): 1}, sparse=False)
10281058
sage: ma.finalized()
1029-
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 0]>
1030-
sage: ma = MatrixArgs(2, 1, {(1,0):88, (0,1):89})
1059+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over
1060+
Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 0]>
1061+
sage: ma = MatrixArgs(2, 1, {(1,0): 88, (0,1): 89})
10311062
sage: ma.finalized()
10321063
Traceback (most recent call last):
10331064
...
10341065
IndexError: invalid column index 1
1035-
sage: ma = MatrixArgs(1, 2, {(1,0):88, (0,1):89})
1066+
sage: ma = MatrixArgs(1, 2, {(1,0): 88, (0,1): 89})
10361067
sage: ma.finalized()
10371068
Traceback (most recent call last):
10381069
...

src/sage/matrix/compute_J_ideal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ def mccoy_column(self, p, t, nu):
541541
sage: x = polygen(ZZ, 'x')
542542
sage: nu_4 = x^2 + 3*x + 2
543543
sage: g = C.mccoy_column(2, 2, nu_4)
544-
sage: b = matrix(9, 1, (x-B).adjugate().list())
545-
sage: M = matrix.block([[b , -B.charpoly(x)*matrix.identity(9)]])
544+
sage: b = matrix(9, 1, (x - B).adjugate().list())
545+
sage: M = matrix.block([[b, -B.charpoly(x)*matrix.identity(9)]])
546546
sage: (M*g % 4).is_zero()
547547
True
548548

0 commit comments

Comments
 (0)