Skip to content

Commit afb74af

Browse files
author
Release Manager
committed
gh-36051: `sage.{topology,homology}`: Update # needs, modularization fixes <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> - Part of: #29705 - Cherry-picked from: #35095 <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] 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 - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36051 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
2 parents ba7d118 + 5d9bdcb commit afb74af

28 files changed

+1344
-1200
lines changed

src/sage/homology/algebraic_topological_model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.graphs
1+
# sage.doctest: needs sage.graphs
22
r"""
33
Algebraic topological model for a cell complex
44
@@ -101,8 +101,8 @@ def algebraic_topological_model(K, base_ring=None):
101101
102102
sage: from sage.homology.algebraic_topological_model import algebraic_topological_model
103103
sage: RP2 = simplicial_complexes.RealProjectivePlane()
104-
sage: phi, M = algebraic_topological_model(RP2, GF(2)) # optional - sage.rings.finite_rings
105-
sage: M.homology() # optional - sage.rings.finite_rings
104+
sage: phi, M = algebraic_topological_model(RP2, GF(2))
105+
sage: M.homology()
106106
{0: Vector space of dimension 1 over Finite Field of size 2,
107107
1: Vector space of dimension 1 over Finite Field of size 2,
108108
2: Vector space of dimension 1 over Finite Field of size 2}
@@ -372,8 +372,8 @@ def algebraic_topological_model_delta_complex(K, base_ring=None):
372372
373373
sage: from sage.homology.algebraic_topological_model import algebraic_topological_model_delta_complex as AT_model
374374
sage: RP2 = simplicial_complexes.RealProjectivePlane()
375-
sage: phi, M = AT_model(RP2, GF(2)) # optional - sage.rings.finite_rings
376-
sage: M.homology() # optional - sage.rings.finite_rings
375+
sage: phi, M = AT_model(RP2, GF(2))
376+
sage: M.homology()
377377
{0: Vector space of dimension 1 over Finite Field of size 2,
378378
1: Vector space of dimension 1 over Finite Field of size 2,
379379
2: Vector space of dimension 1 over Finite Field of size 2}

src/sage/homology/chain_complex.py

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _latex_module(R, m):
8585
'\\Bold{Z}^{3}'
8686
sage: _latex_module(ZZ, 0)
8787
'0'
88-
sage: _latex_module(GF(3), 1) # optional - sage.rings.finite_rings
88+
sage: _latex_module(GF(3), 1)
8989
'\\Bold{F}_{3}^{1}'
9090
"""
9191
if m == 0:
@@ -188,11 +188,11 @@ def ChainComplex(data=None, base_ring=None, grading_group=None,
188188
Chain complex with at most 2 nonzero terms over Integer Ring
189189
190190
sage: m = matrix(ZZ, 2, 2, [0, 1, 0, 0])
191-
sage: D = ChainComplex([m, m], base_ring=GF(2)); D # optional - sage.rings.finite_rings
191+
sage: D = ChainComplex([m, m], base_ring=GF(2)); D
192192
Chain complex with at most 3 nonzero terms over Finite Field of size 2
193-
sage: D == loads(dumps(D)) # optional - sage.rings.finite_rings
193+
sage: D == loads(dumps(D))
194194
True
195-
sage: D.differential(0)==m, m.is_immutable(), D.differential(0).is_immutable() # optional - sage.rings.finite_rings
195+
sage: D.differential(0)==m, m.is_immutable(), D.differential(0).is_immutable()
196196
(True, False, True)
197197
198198
Note that when a chain complex is defined in Sage, new
@@ -214,12 +214,12 @@ def ChainComplex(data=None, base_ring=None, grading_group=None,
214214
215215
sage: ChainComplex([matrix(QQ, 3, 1), matrix(ZZ, 4, 3)])
216216
Chain complex with at most 3 nonzero terms over Rational Field
217-
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(ZZ, 4, 3)]) # optional - sage.rings.finite_rings
217+
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(ZZ, 4, 3)]) # needs sage.rings.finite_rings
218218
Chain complex with at most 3 nonzero terms over Finite Field in a of size 5^3
219219
220220
If the matrices are defined over incompatible rings, an error results::
221221
222-
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(QQ, 4, 3)]) # optional - sage.rings.finite_rings
222+
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1), matrix(QQ, 4, 3)]) # needs sage.rings.finite_rings
223223
Traceback (most recent call last):
224224
...
225225
TypeError: no common canonical parent for objects with parents:
@@ -228,7 +228,7 @@ def ChainComplex(data=None, base_ring=None, grading_group=None,
228228
If the base ring is given explicitly but is not compatible with
229229
the matrices, an error results::
230230
231-
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1)], base_ring=QQ) # optional - sage.rings.finite_rings
231+
sage: ChainComplex([matrix(GF(125, 'a'), 3, 1)], base_ring=QQ) # needs sage.rings.finite_rings
232232
Traceback (most recent call last):
233233
...
234234
TypeError: unable to convert 0 to a rational
@@ -336,9 +336,9 @@ def __init__(self, parent, vectors, check=True):
336336
337337
EXAMPLES::
338338
339-
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}, # optional - sage.rings.finite_rings
339+
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])},
340340
....: base_ring=GF(7))
341-
sage: C.category() # optional - sage.rings.finite_rings
341+
sage: C.category()
342342
Category of chain complexes over Finite Field of size 7
343343
344344
TESTS::
@@ -771,7 +771,7 @@ def rank(self, degree, ring=None):
771771
[2]
772772
sage: C.rank(0)
773773
1
774-
sage: C.rank(0, ring=GF(2)) # optional - sage.rings.finite_rings
774+
sage: C.rank(0, ring=GF(2))
775775
0
776776
"""
777777
degree = self.grading_group()(degree)
@@ -1079,12 +1079,12 @@ def __eq__(self, other):
10791079
10801080
EXAMPLES::
10811081
1082-
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}, # optional - sage.rings.finite_rings
1082+
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])},
10831083
....: base_ring=GF(2))
1084-
sage: D = ChainComplex({0: matrix(GF(2), 2, 3, [1, 0, 0, 0, 0, 0]), # optional - sage.rings.finite_rings
1084+
sage: D = ChainComplex({0: matrix(GF(2), 2, 3, [1, 0, 0, 0, 0, 0]),
10851085
....: 1: matrix(ZZ, 0, 2),
10861086
....: 3: matrix(ZZ, 0, 0)}) # base_ring determined from the matrices
1087-
sage: C == D # optional - sage.rings.finite_rings
1087+
sage: C == D
10881088
True
10891089
"""
10901090
if not isinstance(other, ChainComplex_class) or self.base_ring() != other.base_ring():
@@ -1108,16 +1108,16 @@ def __ne__(self, other):
11081108
11091109
EXAMPLES::
11101110
1111-
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}, # optional - sage.rings.finite_rings
1111+
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])},
11121112
....: base_ring=GF(2))
1113-
sage: D = ChainComplex({0: matrix(GF(2), 2, 3, [1, 0, 0, 0, 0, 0]), # optional - sage.rings.finite_rings
1113+
sage: D = ChainComplex({0: matrix(GF(2), 2, 3, [1, 0, 0, 0, 0, 0]),
11141114
....: 1: matrix(ZZ, 0, 2),
11151115
....: 3: matrix(ZZ, 0, 0)}) # base_ring determined from the matrices
1116-
sage: C != D # optional - sage.rings.finite_rings
1116+
sage: C != D
11171117
False
11181118
sage: E = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])},
11191119
....: base_ring=ZZ)
1120-
sage: C != E # optional - sage.rings.finite_rings
1120+
sage: C != E
11211121
True
11221122
"""
11231123
return not self == other
@@ -1143,15 +1143,15 @@ def _homology_chomp(self, deg, base_ring, verbose, generators):
11431143
11441144
EXAMPLES::
11451145
1146-
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}, base_ring=GF(2)) # optional - sage.rings.finite_rings
1147-
sage: C._homology_chomp(None, GF(2), False, False) # optional - CHomP # optional - sage.rings.finite_rings
1146+
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}, base_ring=GF(2))
1147+
sage: C._homology_chomp(None, GF(2), False, False) # optional - chomp, needs sage.rings.finite_rings
11481148
doctest:...: DeprecationWarning: the CHomP interface is deprecated; hence so is this function
11491149
See https://github.com/sagemath/sage/issues/33777 for details.
11501150
{0: Vector space of dimension 2 over Finite Field of size 2, 1: Vector space of dimension 1 over Finite Field of size 2}
11511151
11521152
sage: D = ChainComplex({0: matrix(ZZ,1,0,[]), 1: matrix(ZZ,1,1,[0]),
11531153
....: 2: matrix(ZZ,0,1,[])})
1154-
sage: D._homology_chomp(None, GF(2), False, False) # optional - CHomP # optional - sage.rings.finite_rings
1154+
sage: D._homology_chomp(None, GF(2), False, False) # optional - chomp, needs sage.rings.finite_rings
11551155
{1: Vector space of dimension 1 over Finite Field of size 2,
11561156
2: Vector space of dimension 1 over Finite Field of size 2}
11571157
"""
@@ -1253,7 +1253,7 @@ def homology(self, deg=None, base_ring=None, generators=False,
12531253
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
12541254
sage: C.homology()
12551255
{0: Z x Z, 1: Z x C3}
1256-
sage: C.homology(deg=1, base_ring=GF(3)) # optional - sage.rings.finite_rings
1256+
sage: C.homology(deg=1, base_ring=GF(3))
12571257
Vector space of dimension 2 over Finite Field of size 3
12581258
sage: D = ChainComplex({0: identity_matrix(ZZ, 4), 4: identity_matrix(ZZ, 30)})
12591259
sage: D.homology()
@@ -1280,9 +1280,9 @@ def homology(self, deg=None, base_ring=None, generators=False,
12801280
12811281
From a torus using a field::
12821282
1283-
sage: T = simplicial_complexes.Torus() # optional - sage.graphs
1284-
sage: C_t = T.chain_complex() # optional - sage.graphs
1285-
sage: C_t.homology(base_ring=QQ, generators=True) # optional - sage.graphs
1283+
sage: T = simplicial_complexes.Torus() # needs sage.graphs
1284+
sage: C_t = T.chain_complex() # needs sage.graphs
1285+
sage: C_t.homology(base_ring=QQ, generators=True) # needs sage.graphs
12861286
{0: [(Vector space of dimension 1 over Rational Field,
12871287
Chain(0:(0, 0, 0, 0, 0, 0, 1)))],
12881288
1: [(Vector space of dimension 1 over Rational Field,
@@ -1461,8 +1461,8 @@ def betti(self, deg=None, base_ring=None):
14611461
sage: C.betti()
14621462
{0: 2, 1: 1}
14631463
1464-
sage: D = ChainComplex({0: matrix(GF(5), [[3, 1],[1, 2]])}) # optional - sage.rings.finite_rings
1465-
sage: D.betti() # optional - sage.rings.finite_rings
1464+
sage: D = ChainComplex({0: matrix(GF(5), [[3, 1],[1, 2]])})
1465+
sage: D.betti()
14661466
{0: 1, 1: 1}
14671467
"""
14681468
if base_ring is None:
@@ -1513,14 +1513,14 @@ def torsion_list(self, max_prime, min_prime=2):
15131513
sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
15141514
sage: C.homology()
15151515
{0: Z x Z, 1: Z x C3}
1516-
sage: C.torsion_list(11) # optional - sage.rings.finite_rings
1516+
sage: C.torsion_list(11) # needs sage.rings.finite_rings
15171517
[(3, [1])]
15181518
sage: C = ChainComplex([matrix(ZZ, 1, 1, [2]), matrix(ZZ, 1, 1), matrix(1, 1, [3])])
15191519
sage: C.homology(1)
15201520
C2
15211521
sage: C.homology(3)
15221522
C3
1523-
sage: C.torsion_list(5) # optional - sage.rings.finite_rings
1523+
sage: C.torsion_list(5) # needs sage.rings.finite_rings
15241524
[(2, [1]), (3, [3])]
15251525
"""
15261526
if self.base_ring() != ZZ:
@@ -1563,11 +1563,12 @@ def _Hom_(self, other, category=None):
15631563
15641564
EXAMPLES::
15651565
1566-
sage: S = simplicial_complexes.Sphere(2) # optional - sage.graphs
1567-
sage: T = simplicial_complexes.Torus() # optional - sage.graphs
1568-
sage: C = S.chain_complex(augmented=True, cochain=True) # optional - sage.graphs
1569-
sage: D = T.chain_complex(augmented=True, cochain=True) # optional - sage.graphs
1570-
sage: Hom(C, D) # indirect doctest # optional - sage.graphs
1566+
sage: # needs sage.graphs
1567+
sage: S = simplicial_complexes.Sphere(2)
1568+
sage: T = simplicial_complexes.Torus()
1569+
sage: C = S.chain_complex(augmented=True, cochain=True)
1570+
sage: D = T.chain_complex(augmented=True, cochain=True)
1571+
sage: Hom(C, D) # indirect doctest
15711572
Set of Morphisms from Chain complex with at most 4 nonzero terms over
15721573
Integer Ring to Chain complex with at most 4 nonzero terms over Integer
15731574
Ring in Category of chain complexes over Integer Ring
@@ -1629,33 +1630,35 @@ def shift(self, n=1):
16291630
16301631
EXAMPLES::
16311632
1632-
sage: S1 = simplicial_complexes.Sphere(1).chain_complex() # optional - sage.graphs
1633-
sage: S1.shift(1).differential(2) == -S1.differential(1) # optional - sage.graphs
1633+
sage: # needs sage.graphs
1634+
sage: S1 = simplicial_complexes.Sphere(1).chain_complex()
1635+
sage: S1.shift(1).differential(2) == -S1.differential(1)
16341636
True
1635-
sage: S1.shift(2).differential(3) == S1.differential(1) # optional - sage.graphs
1637+
sage: S1.shift(2).differential(3) == S1.differential(1)
16361638
True
1637-
sage: S1.shift(3).homology(4) # optional - sage.graphs
1639+
sage: S1.shift(3).homology(4)
16381640
Z
16391641
16401642
For cochain complexes, shifting goes in the other
16411643
direction. Topologically, this makes sense if we grade the
16421644
cochain complex for a space negatively::
16431645
1644-
sage: T = simplicial_complexes.Torus() # optional - sage.graphs
1645-
sage: co_T = T.chain_complex()._flip_() # optional - sage.graphs
1646-
sage: co_T.homology() # optional - sage.graphs
1646+
sage: # needs sage.graphs
1647+
sage: T = simplicial_complexes.Torus()
1648+
sage: co_T = T.chain_complex()._flip_()
1649+
sage: co_T.homology()
16471650
{-2: Z, -1: Z x Z, 0: Z}
1648-
sage: co_T.degree_of_differential() # optional - sage.graphs
1651+
sage: co_T.degree_of_differential()
16491652
1
1650-
sage: co_T.shift(2).homology() # optional - sage.graphs
1653+
sage: co_T.shift(2).homology()
16511654
{-4: Z, -3: Z x Z, -2: Z}
16521655
16531656
You can achieve the same result by tensoring (on the left, to
16541657
get the signs right) with a rank one free module in degree
16551658
``-n * deg``, if ``deg`` is the degree of the differential::
16561659
16571660
sage: C = ChainComplex({-2: matrix(ZZ, 0, 1)})
1658-
sage: C.tensor(co_T).homology() # optional - sage.graphs
1661+
sage: C.tensor(co_T).homology() # needs sage.graphs
16591662
{-4: Z, -3: Z x Z, -2: Z}
16601663
"""
16611664
deg = self.degree_of_differential()

src/sage/homology/chain_complex_homspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sage.doctest: optional - sage.graphs (because all doctests use SimplicialComplex)
1+
# sage.doctest: needs sage.graphs (because all doctests use SimplicialComplex)
22
r"""
33
Homspaces between chain complexes
44

0 commit comments

Comments
 (0)