Skip to content

Commit affe03d

Browse files
author
Release Manager
committed
gh-38193: `sage.algebras`...`sage.topology`: Doctest cosmetics, `# needs`, import fixes <!-- ^ 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". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] 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 and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38193 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents ca110c5 + ed9cca5 commit affe03d

File tree

9 files changed

+61
-36
lines changed

9 files changed

+61
-36
lines changed

src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ class FiniteDimensionalAlgebraIdeal(Ideal_generic):
3939
4040
EXAMPLES::
4141
42-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
42+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
43+
....: Matrix([[0, 1], [0, 0]])])
4344
sage: A.ideal(A([0,1]))
4445
Ideal (e1) of Finite-dimensional algebra of degree 2 over Finite Field of size 3
4546
"""
4647
def __init__(self, A, gens=None, given_by_matrix=False):
4748
"""
4849
EXAMPLES::
4950
50-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
51+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
52+
....: Matrix([[0, 1], [0, 0]])])
5153
sage: I = A.ideal(A([0,1]))
52-
sage: TestSuite(I).run(skip="_test_category") # Currently ideals are not using the category framework
54+
sage: TestSuite(I).run(skip="_test_category") # Currently ideals are not using the category framework
5355
"""
5456
k = A.base_ring()
5557
n = A.degree()
@@ -76,7 +78,8 @@ def _richcmp_(self, other, op):
7678
7779
TESTS::
7880
79-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
81+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
82+
....: Matrix([[0, 1], [0, 0]])])
8083
sage: I = A.ideal(A([1,1]))
8184
sage: J = A.ideal(A([0,1]))
8285
sage: I == J
@@ -86,7 +89,8 @@ def _richcmp_(self, other, op):
8689
sage: I == I + J
8790
True
8891
89-
sage: A2 = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
92+
sage: A2 = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
93+
....: Matrix([[0, 1], [0, 0]])])
9094
sage: A is A2
9195
True
9296
sage: A == A2
@@ -130,7 +134,8 @@ def __contains__(self, elt):
130134
"""
131135
EXAMPLES::
132136
133-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
137+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
138+
....: Matrix([[0, 1], [0, 0]])])
134139
sage: J = A.ideal(A([0,1]))
135140
sage: A([0,1]) in J
136141
True
@@ -147,7 +152,8 @@ def basis_matrix(self):
147152
148153
EXAMPLES::
149154
150-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
155+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
156+
....: Matrix([[0, 1], [0, 0]])])
151157
sage: I = A.ideal(A([1,1]))
152158
sage: I.basis_matrix()
153159
[1 0]
@@ -162,7 +168,8 @@ def vector_space(self):
162168
163169
EXAMPLES::
164170
165-
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
171+
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
172+
....: Matrix([[0, 1], [0, 0]])])
166173
sage: I = A.ideal(A([1,1]))
167174
sage: I.vector_space()
168175
Vector space of degree 2 and dimension 2 over Finite Field of size 3

src/sage/arith/functions.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ def lcm(a, b=None):
3939
4040
EXAMPLES::
4141
42-
sage: lcm(97,100)
42+
sage: lcm(97, 100)
4343
9700
44-
sage: LCM(97,100)
44+
sage: LCM(97, 100)
4545
9700
46-
sage: LCM(0,2)
46+
sage: LCM(0, 2)
4747
0
48-
sage: LCM(-3,-5)
48+
sage: LCM(-3, -5)
4949
15
5050
sage: LCM([1,2,3,4,5])
5151
60
52-
sage: v = LCM(range(1,10000)) # *very* fast!
52+
sage: v = LCM(range(1, 10000)) # *very* fast!
5353
sage: len(str(v))
5454
4349
5555

src/sage/arith/misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,9 +3748,9 @@ def binomial(x, m, **kwds):
37483748
Some floating point cases -- see :issue:`7562`, :issue:`9633`, and
37493749
:issue:`12448`::
37503750
3751-
sage: binomial(1., 3)
3751+
sage: binomial(1., 3) # needs sage.rings.real_mpfr
37523752
0.000000000000000
3753-
sage: binomial(-2., 3)
3753+
sage: binomial(-2., 3) # needs sage.rings.real_mpfr
37543754
-4.00000000000000
37553755
sage: binomial(0.5r, 5)
37563756
0.02734375

src/sage/arith/srange.pyx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,21 @@ def srange(*args, **kwds):
234234
235235
sage: srange(1, 10, 1/2)
236236
[1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2, 6, 13/2, 7, 15/2, 8, 17/2, 9, 19/2]
237+
238+
sage: # needs sage.rings.real_mpfr
237239
sage: srange(1, 5, 0.5)
238-
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
240+
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000,
241+
3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
239242
sage: srange(0, 1, 0.4)
240243
[0.000000000000000, 0.400000000000000, 0.800000000000000]
241244
sage: srange(1.0, 5.0, include_endpoint=True)
242-
[1.00000000000000, 2.00000000000000, 3.00000000000000, 4.00000000000000, 5.00000000000000]
245+
[1.00000000000000, 2.00000000000000, 3.00000000000000, 4.00000000000000,
246+
5.00000000000000]
243247
sage: srange(1.0, 1.1)
244248
[1.00000000000000]
245249
sage: srange(1.0, 1.0)
246250
[]
251+
247252
sage: V = VectorSpace(QQ, 2) # needs sage.modules
248253
sage: srange(V([0,0]), V([5,5]), step=V([2,2])) # needs sage.modules
249254
[(0, 0), (2, 2), (4, 4)]
@@ -264,7 +269,8 @@ def srange(*args, **kwds):
264269
sage: srange(0.5, 0.9, 0.1, universe=RDF, include_endpoint=False)
265270
[0.5, 0.6, 0.7, 0.7999999999999999]
266271
sage: srange(0, 1.1, 0.1, universe=RDF, include_endpoint=True)
267-
[0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7, 0.7999999999999999, 0.8999999999999999, 0.9999999999999999, 1.1]
272+
[0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7,
273+
0.7999999999999999, 0.8999999999999999, 0.9999999999999999, 1.1]
268274
sage: srange(0, 0.2, 0.1, universe=RDF, include_endpoint=True)
269275
[0.0, 0.1, 0.2]
270276
sage: srange(0, 0.3, 0.1, universe=RDF, include_endpoint=True)
@@ -275,9 +281,10 @@ def srange(*args, **kwds):
275281
sage: Q = RationalField()
276282
sage: srange(1, 10, Q('1/2'))
277283
[1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2, 6, 13/2, 7, 15/2, 8, 17/2, 9, 19/2]
278-
sage: srange(1, 5, 0.5)
279-
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
280-
sage: srange(0, 1, 0.4)
284+
sage: srange(1, 5, 0.5) # needs sage.rings.real_mpfr
285+
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000,
286+
3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
287+
sage: srange(0, 1, 0.4) # needs sage.rings.real_mpfr
281288
[0.000000000000000, 0.400000000000000, 0.800000000000000]
282289
283290
Negative steps are also allowed::
@@ -512,7 +519,7 @@ def ellipsis_range(*args, step=None):
512519
513520
Examples in which the step determines the parent of the elements::
514521
515-
sage: [1..3, step=0.5]
522+
sage: [1..3, step=0.5] # needs sage.rings.real_mpfr
516523
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000]
517524
sage: v = [1..5, step=1/1]; v
518525
[1, 2, 3, 4, 5]

src/sage/game_theory/matching_game.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.graphs
12
"""
23
Matching games
34
@@ -124,7 +125,7 @@ class MatchingGame(SageObject):
124125
125126
Matchings have a natural representations as bipartite graphs::
126127
127-
sage: plot(m)
128+
sage: plot(m) # needs sage.plot
128129
Graphics object consisting of 13 graphics primitives
129130
130131
The above plots the bipartite graph associated with the matching.
@@ -508,14 +509,14 @@ def plot(self):
508509
sage: revr = {3: (0, 1),
509510
....: 4: (1, 0)}
510511
sage: g = MatchingGame([suit, revr])
511-
sage: plot(g)
512+
sage: plot(g) # needs sage.plot
512513
Traceback (most recent call last):
513514
...
514515
ValueError: game has not been solved yet
515516
516517
sage: g.solve()
517518
{0: 3, 1: 4}
518-
sage: plot(g)
519+
sage: plot(g) # needs sage.plot
519520
Graphics object consisting of 7 graphics primitives
520521
"""
521522
pl = self.bipartite_graph()

src/sage/game_theory/normal_form_game.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@
157157
`(Ay)_i`, ie element in position `i` of the matrix/vector multiplication
158158
`Ay`) ::
159159
160-
sage: y = var('y')
160+
sage: y = var('y') # needs sage.symbolic
161161
sage: A = matrix([[1, -1], [-1, 1]])
162-
sage: p = plot((A * vector([y, 1 - y]))[0], y, 0, 1, color='blue',
162+
sage: p = plot((A * vector([y, 1 - y]))[0], y, 0, 1, color='blue', # needs sage.symbolic
163163
....: legend_label='$u_1(r_1, (y, 1-y))$', axes_labels=['$y$', ''])
164-
sage: p += plot((A * vector([y, 1 - y]))[1], y, 0, 1, color='red',
164+
sage: p += plot((A * vector([y, 1 - y]))[1], y, 0, 1, color='red', # needs sage.symbolic
165165
....: legend_label='$u_1(r_2, (y, 1-y))$'); p
166166
Graphics object consisting of 2 graphics primitives
167167

src/sage/structure/formal_sum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _latex_(self):
203203
r"""
204204
EXAMPLES::
205205
206-
sage: latex(FormalSum([(1,2), (5, 8/9), (-3, 7)]))
206+
sage: latex(FormalSum([(1,2), (5, 8/9), (-3, 7)])) # needs sage.rings.real_mpfr
207207
2 + 5\cdot \frac{8}{9} - 3\cdot 7
208208
"""
209209
from sage.misc.latex import repr_lincomb
@@ -441,7 +441,7 @@ def _get_action_(self, other, op, self_is_left):
441441
"""
442442
EXAMPLES::
443443
444-
sage: A = FormalSums(RR); A.get_action(RR) # indirect doctest
444+
sage: A = FormalSums(RR); A.get_action(RR) # indirect doctest # needs sage.rings.real_mpfr
445445
Right scalar multiplication by Real Field with 53 bits of precision
446446
on Abelian Group of all Formal Finite Sums over Real Field with 53 bits of precision
447447

src/sage/topology/cell_complex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ def _n_cells_sorted(self, n, subcomplex=None):
227227
sage: K = SimplicialComplex([[1,2,3], [2,3,4]])
228228
sage: Z._n_cells_sorted(2, subcomplex=K)
229229
[(1, 2, 4), (1, 3, 4)]
230+
231+
sage: # needs sage.symbolic
230232
sage: S = SimplicialComplex([[complex(i), complex(1)]])
231233
sage: S._n_cells_sorted(0)
232234
[((1+0j),), (1j,)]

src/sage/topology/moment_angle_complex.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
from itertools import combinations
1919

2020
from sage.categories.fields import Fields
21-
from sage.homology.homology_group import HomologyGroup
2221
from sage.misc.cachefunc import cached_method
2322
from sage.misc.lazy_attribute import lazy_attribute
23+
from sage.misc.lazy_import import lazy_import
2424
from sage.rings.integer_ring import ZZ
2525
from sage.rings.rational_field import QQ
2626
from sage.structure.sage_object import SageObject
@@ -29,6 +29,8 @@
2929
from sage.topology.cubical_complex import CubicalComplex, cubical_complexes
3030
from sage.topology.simplicial_complex import SimplicialComplex, copy
3131

32+
lazy_import('sage.homology.homology_group', 'HomologyGroup')
33+
3234

3335
def _cubical_complex_union(c1, c2):
3436
"""
@@ -130,11 +132,11 @@ class MomentAngleComplex(UniqueRepresentation, SageObject):
130132
We can perform a number of operations, such as find the dimension or
131133
compute the homology::
132134
133-
sage: M.homology()
135+
sage: M.homology() # needs sage.modules
134136
{0: 0, 1: 0, 2: 0, 3: Z}
135137
sage: Z.dimension()
136138
6
137-
sage: Z.homology()
139+
sage: Z.homology() # needs sage.modules
138140
{0: 0, 1: 0, 2: 0, 3: Z x Z, 4: Z, 5: Z, 6: Z}
139141
140142
If the associated simplicial complex is an `n`-simplex, then the
@@ -403,9 +405,9 @@ def components(self):
403405
404406
sage: S3 = simplicial_complexes.Sphere(3)
405407
sage: product_of_spheres = S3.product(S3)
406-
sage: Z.cohomology()
408+
sage: Z.cohomology() # needs sage.modules
407409
{0: 0, 1: 0, 2: 0, 3: Z x Z, 4: 0, 5: 0, 6: Z}
408-
sage: Z.cohomology() == product_of_spheres.cohomology() # long time
410+
sage: Z.cohomology() == product_of_spheres.cohomology() # long time # needs sage.modules
409411
True
410412
"""
411413
return self._components
@@ -453,6 +455,7 @@ def _homology_group(self, i, base_ring, cohomology, algorithm, verbose, reduced)
453455
454456
TESTS::
455457
458+
sage: # needs sage.modules
456459
sage: Z = MomentAngleComplex([[0,1,2], [1,2,3]]); Z
457460
Moment-angle complex of Simplicial complex with vertex set
458461
(0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)}
@@ -550,6 +553,7 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False,
550553
551554
EXAMPLES::
552555
556+
sage: # needs sage.modules
553557
sage: Z = MomentAngleComplex([[0,1,2], [1,2,3], [3,0]]); Z
554558
Moment-angle complex of Simplicial complex with vertex set
555559
(0, 1, 2, 3) and facets {(0, 3), (0, 1, 2), (1, 2, 3)}
@@ -580,13 +584,14 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False,
580584
(0, 1, 2) and facets {(0, 1), (0, 2), (1, 2)}
581585
sage: Z.cubical_complex()
582586
Cubical complex with 64 vertices and 729 cubes
583-
sage: Z.cubical_complex().homology() == Z.homology()
587+
sage: Z.cubical_complex().homology() == Z.homology() # needs sage.modules
584588
True
585589
586590
Meanwhile, the homology computation used here is quite efficient
587591
and works well even with significantly larger underlying simplicial
588592
complexes::
589593
594+
sage: # needs sage.modules
590595
sage: Z = MomentAngleComplex([[0,1,2,3,4,5], [0,1,2,3,4,6],
591596
....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]])
592597
sage: Z.homology() # long time
@@ -656,6 +661,7 @@ def cohomology(self, dim=None, base_ring=ZZ, algorithm='pari',
656661
to a product of two 3-spheres (which can be seen by looking at the
657662
output of ``components()``)::
658663
664+
sage: # needs sage.modules
659665
sage: S3 = simplicial_complexes.Sphere(3)
660666
sage: product_of_spheres = S3.product(S3)
661667
sage: Z.cohomology()
@@ -684,6 +690,7 @@ def betti(self, dim=None):
684690
685691
EXAMPLES::
686692
693+
sage: # needs sage.modules
687694
sage: Z = MomentAngleComplex([[0,1], [1,2], [2,0], [1,2,3]])
688695
sage: Z.betti()
689696
{0: 1, 1: 0, 2: 0, 3: 1, 4: 0, 5: 1, 6: 1, 7: 0}
@@ -714,6 +721,7 @@ def euler_characteristic(self):
714721
715722
EXAMPLES::
716723
724+
sage: # needs sage.modules
717725
sage: X = SimplicialComplex([[0,1,2,3,4,5], [0,1,2,3,4,6],
718726
....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]])
719727
sage: M = MomentAngleComplex(X)

0 commit comments

Comments
 (0)