From 0a36b740049258ae60b1d16369c72c6d20930349 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 23 Apr 2026 07:49:48 -0400 Subject: [PATCH] src/sage/topology: remove all "needs sage.foo" tags These are unmaintained, and do nothing in upstream SageMath. --- src/sage/topology/all.py | 1 - src/sage/topology/cell_complex.py | 68 +++---- src/sage/topology/cubical_complex.py | 34 ++-- src/sage/topology/delta_complex.py | 54 +++--- .../topology/filtered_simplicial_complex.py | 35 ++-- src/sage/topology/moment_angle_complex.py | 16 +- src/sage/topology/simplicial_complex.py | 138 +++++++------- .../topology/simplicial_complex_catalog.py | 7 +- .../topology/simplicial_complex_examples.py | 89 +++++---- .../topology/simplicial_complex_homset.py | 1 - .../topology/simplicial_complex_morphism.py | 33 ++-- src/sage/topology/simplicial_set.py | 177 ++++++++---------- src/sage/topology/simplicial_set_catalog.py | 7 +- .../topology/simplicial_set_constructions.py | 126 +++++-------- src/sage/topology/simplicial_set_examples.py | 35 ++-- src/sage/topology/simplicial_set_morphism.py | 85 ++++----- 16 files changed, 402 insertions(+), 504 deletions(-) diff --git a/src/sage/topology/all.py b/src/sage/topology/all.py index 18b553e873d..837c4d77768 100644 --- a/src/sage/topology/all.py +++ b/src/sage/topology/all.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs from sage.topology.simplicial_complex import SimplicialComplex, Simplex from sage.topology.simplicial_complex_morphism import SimplicialComplexMorphism diff --git a/src/sage/topology/cell_complex.py b/src/sage/topology/cell_complex.py index 4ac07065b56..cdaf02be34c 100644 --- a/src/sage/topology/cell_complex.py +++ b/src/sage/topology/cell_complex.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Generic cell complexes @@ -228,7 +227,6 @@ def _n_cells_sorted(self, n, subcomplex=None): sage: Z._n_cells_sorted(2, subcomplex=K) [(1, 2, 4), (1, 3, 4)] - sage: # needs sage.symbolic sage: S = SimplicialComplex([[complex(i), complex(1)]]) sage: S._n_cells_sorted(0) [((1+0j),), (1j,)] @@ -508,7 +506,6 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None, EXAMPLES:: - sage: # needs sage.modules sage: P = delta_complexes.RealProjectivePlane() sage: P.homology() {0: 0, 1: C2, 2: 0} @@ -527,7 +524,7 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None, Sage can compute generators of homology groups:: sage: S2 = simplicial_complexes.Sphere(2) - sage: S2.homology(dim=2, generators=True, base_ring=GF(2)) # needs sage.modules + sage: S2.homology(dim=2, generators=True, base_ring=GF(2)) [(Vector space of dimension 1 over Finite Field of size 2, (0, 1, 2) + (0, 1, 3) + (0, 2, 3) + (1, 2, 3))] @@ -538,7 +535,7 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None, complexes, each generator is a linear combination of cubes:: sage: S2_cub = cubical_complexes.Sphere(2) - sage: S2_cub.homology(dim=2, generators=True) # needs sage.modules + sage: S2_cub.homology(dim=2, generators=True) [(Z, [0,0] x [0,1] x [0,1] - [0,1] x [0,0] x [0,1] + [0,1] x [0,1] x [0,0] - [0,1] x [0,1] x [1,1] + [0,1] x [1,1] x [0,1] - [1,1] x [0,1] x [0,1])] @@ -546,7 +543,7 @@ def homology(self, dim=None, base_ring=ZZ, subcomplex=None, Similarly for simplicial sets:: sage: S = simplicial_sets.Sphere(2) - sage: S.homology(generators=True) # needs sage.modules + sage: S.homology(generators=True) {0: [], 1: 0, 2: [(Z, sigma_2)]} """ from sage.homology.homology_group import HomologyGroup @@ -625,14 +622,13 @@ def cohomology(self, dim=None, base_ring=ZZ, subcomplex=None, EXAMPLES:: sage: circle = SimplicialComplex([[0,1], [1,2], [0, 2]]) - sage: circle.cohomology(0) # needs sage.modules + sage: circle.cohomology(0) 0 - sage: circle.cohomology(1) # needs sage.modules + sage: circle.cohomology(1) Z Projective plane:: - sage: # needs sage.modules sage: P2 = SimplicialComplex([[0,1,2], [0,2,3], [0,1,5], [0,4,5], [0,3,4], ....: [1,2,4], [1,3,4], [1,3,5], [2,3,5], [2,4,5]]) sage: P2.cohomology(2) @@ -642,20 +638,20 @@ def cohomology(self, dim=None, base_ring=ZZ, subcomplex=None, sage: P2.cohomology(2, base_ring=GF(3)) Vector space of dimension 0 over Finite Field of size 3 - sage: cubical_complexes.KleinBottle().cohomology(2) # needs sage.modules + sage: cubical_complexes.KleinBottle().cohomology(2) C2 Relative cohomology:: sage: T = SimplicialComplex([[0,1]]) sage: U = SimplicialComplex([[0], [1]]) - sage: T.cohomology(1, subcomplex=U) # needs sage.modules + sage: T.cohomology(1, subcomplex=U) Z A `\Delta`-complex example:: sage: s5 = delta_complexes.Sphere(5) - sage: s5.cohomology(base_ring=GF(7))[5] # needs sage.modules + sage: s5.cohomology(base_ring=GF(7))[5] Vector space of dimension 1 over Finite Field of size 7 """ return self.homology(dim=dim, cohomology=True, base_ring=base_ring, @@ -689,23 +685,23 @@ def betti(self, dim=None, subcomplex=None): two-point space with itself:: sage: S = SimplicialComplex([[0], [1]]) - sage: (S*S*S).betti() # needs sage.modules + sage: (S*S*S).betti() {0: 1, 1: 0, 2: 1} - sage: (S*S*S).betti([1,2]) # needs sage.modules + sage: (S*S*S).betti([1,2]) {1: 0, 2: 1} - sage: (S*S*S).betti(2) # needs sage.modules + sage: (S*S*S).betti(2) 1 Or build the two-sphere as a `\Delta`-complex:: sage: S2 = delta_complexes.Sphere(2) - sage: S2.betti([1,2]) # needs sage.modules + sage: S2.betti([1,2]) {1: 0, 2: 1} Or as a cubical complex:: sage: S2c = cubical_complexes.Sphere(2) - sage: S2c.betti(2) # needs sage.modules + sage: S2c.betti(2) 1 """ dic = {} @@ -733,9 +729,9 @@ def is_acyclic(self, base_ring=ZZ) -> bool: EXAMPLES:: sage: RP2 = simplicial_complexes.RealProjectivePlane() - sage: RP2.is_acyclic() # needs sage.modules + sage: RP2.is_acyclic() False - sage: RP2.is_acyclic(QQ) # needs sage.modules + sage: RP2.is_acyclic(QQ) True This first computes the Euler characteristic: if it is not 1, @@ -779,12 +775,12 @@ def n_chains(self, n, base_ring=ZZ, cochains=False): EXAMPLES:: sage: S2 = simplicial_complexes.Sphere(2) - sage: S2.n_chains(1, QQ) # needs sage.modules + sage: S2.n_chains(1, QQ) Free module generated by {(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)} over Rational Field - sage: list(S2.n_chains(1, QQ, cochains=False).basis()) # needs sage.modules + sage: list(S2.n_chains(1, QQ, cochains=False).basis()) [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)] - sage: list(S2.n_chains(1, QQ, cochains=True).basis()) # needs sage.modules + sage: list(S2.n_chains(1, QQ, cochains=True).basis()) [\chi_(0, 1), \chi_(0, 2), \chi_(0, 3), \chi_(1, 2), \chi_(1, 3), \chi_(2, 3)] """ from sage.homology.chains import Chains, Cochains @@ -847,7 +843,6 @@ def homology_with_basis(self, base_ring=QQ, cohomology=False): EXAMPLES:: - sage: # needs sage.modules sage: K = simplicial_complexes.KleinBottle() sage: H = K.homology_with_basis(QQ); H Homology module of Minimal triangulation of the Klein bottle @@ -863,12 +858,12 @@ def homology_with_basis(self, base_ring=QQ, cohomology=False): The homology is constructed as a graded object, so for example, you can ask for the basis in a single degree:: - sage: H.basis(1) # needs sage.modules + sage: H.basis(1) Finite family {(1, 0): h_{1,0}, (1, 1): h_{1,1}} sage: S3 = delta_complexes.Sphere(3) - sage: H = S3.homology_with_basis(QQ, cohomology=True) # needs sage.modules - sage: list(H.basis(3)) # needs sage.modules + sage: H = S3.homology_with_basis(QQ, cohomology=True) + sage: list(H.basis(3)) [h^{3,0}] """ from sage.homology.homology_vector_space_with_basis import \ @@ -914,7 +909,6 @@ def cohomology_ring(self, base_ring=QQ): EXAMPLES:: - sage: # needs sage.modules sage: K = simplicial_complexes.KleinBottle() sage: H = K.cohomology_ring(QQ); H Cohomology ring of Minimal triangulation of the Klein bottle @@ -928,23 +922,22 @@ def cohomology_ring(self, base_ring=QQ): [h^{0,0}, h^{1,0}, h^{1,1}, h^{2,0}] sage: X = delta_complexes.SurfaceOfGenus(2) - sage: H = X.cohomology_ring(QQ); H # needs sage.modules + sage: H = X.cohomology_ring(QQ); H Cohomology ring of Delta complex with 3 vertices and 29 simplices over Rational Field - sage: sorted(H.basis(1), key=str) # needs sage.modules + sage: sorted(H.basis(1), key=str) [h^{1,0}, h^{1,1}, h^{1,2}, h^{1,3}] - sage: H = simplicial_complexes.Torus().cohomology_ring(QQ); H # needs sage.modules + sage: H = simplicial_complexes.Torus().cohomology_ring(QQ); H Cohomology ring of Minimal triangulation of the torus over Rational Field - sage: x = H.basis()[1,0]; x # needs sage.modules + sage: x = H.basis()[1,0]; x h^{1,0} - sage: y = H.basis()[1,1]; y # needs sage.modules + sage: y = H.basis()[1,1]; y h^{1,1} You can compute cup products of cohomology classes:: - sage: # needs sage.modules sage: x.cup_product(y) -h^{2,0} sage: x * y # alternate notation @@ -956,13 +949,12 @@ def cohomology_ring(self, base_ring=QQ): Cohomology operations:: - sage: # needs sage.groups sage: RP2 = simplicial_complexes.RealProjectivePlane() sage: K = RP2.suspension() sage: K.set_immutable() - sage: y = K.cohomology_ring(GF(2)).basis()[2,0]; y # needs sage.modules + sage: y = K.cohomology_ring(GF(2)).basis()[2,0]; y h^{2,0} - sage: y.Sq(1) # needs sage.modules + sage: y.Sq(1) h^{3,0} To compute the cohomology ring, the complex must be @@ -976,12 +968,12 @@ def cohomology_ring(self, base_ring=QQ): sage: T = S1.product(S1) sage: T.is_immutable() False - sage: T.cohomology_ring() # needs sage.modules + sage: T.cohomology_ring() Traceback (most recent call last): ... ValueError: this simplicial complex must be immutable; call set_immutable() sage: T.set_immutable() - sage: T.cohomology_ring() # needs sage.modules + sage: T.cohomology_ring() Cohomology ring of Simplicial complex with 9 vertices and 18 facets over Rational Field """ diff --git a/src/sage/topology/cubical_complex.py b/src/sage/topology/cubical_complex.py index ccbfedeb502..49e9f65a5e3 100644 --- a/src/sage/topology/cubical_complex.py +++ b/src/sage/topology/cubical_complex.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Finite cubical complexes @@ -46,11 +45,11 @@ segment in the plane from `(0,2)` to `(0,3)`. We could form a topologically equivalent space by inserting some degenerate simplices:: - sage: S1.homology() # needs sage.modules + sage: S1.homology() {0: 0, 1: Z} sage: X = CubicalComplex([([0,0], [2,3], [2]), ([0,1], [3,3], [2]), ....: ([0,1], [2,2], [2]), ([1,1], [2,3], [2])]) - sage: X.homology() # needs sage.modules + sage: X.homology() {0: 0, 1: Z} Topologically, the cubical complex ``X`` consists of four edges of a @@ -797,7 +796,7 @@ class :class:`Cube`, or lists or tuples suitable for conversion to sage: S1 = CubicalComplex([([0,0], [2,3]), ([0,1], [3,3]), ....: ([0,1], [2,2]), ([1,1], [2,3])]); S1 Cubical complex with 4 vertices and 8 cubes - sage: S1.homology() # needs sage.modules + sage: S1.homology() {0: 0, 1: Z} A set of five points and its product with ``S1``:: @@ -805,18 +804,18 @@ class :class:`Cube`, or lists or tuples suitable for conversion to sage: pts = CubicalComplex([([0],), ([3],), ([6],), ([-12],), ([5],)]) sage: pts Cubical complex with 5 vertices and 5 cubes - sage: pts.homology() # needs sage.modules + sage: pts.homology() {0: Z x Z x Z x Z} sage: X = S1.product(pts); X Cubical complex with 20 vertices and 40 cubes - sage: X.homology() # needs sage.modules + sage: X.homology() {0: Z x Z x Z x Z, 1: Z^5} Converting a simplicial complex to a cubical complex:: sage: S2 = simplicial_complexes.Sphere(2) sage: C2 = CubicalComplex(S2) - sage: all(C2.homology(n) == S2.homology(n) for n in range(3)) # needs sage.modules + sage: all(C2.homology(n) == S2.homology(n) for n in range(3)) True You can get the set of maximal cells or a dictionary of all cells:: @@ -853,14 +852,14 @@ class :class:`Cube`, or lists or tuples suitable for conversion to sage: T = S1.product(S1); T Cubical complex with 16 vertices and 64 cubes - sage: T.chain_complex() # needs sage.modules + sage: T.chain_complex() Chain complex with at most 3 nonzero terms over Integer Ring - sage: T.homology(base_ring=QQ) # needs sage.modules + sage: T.homology(base_ring=QQ) {0: Vector space of dimension 0 over Rational Field, 1: Vector space of dimension 2 over Rational Field, 2: Vector space of dimension 1 over Rational Field} sage: RP2 = cubical_complexes.RealProjectivePlane() - sage: RP2.cohomology(dim=[1, 2], base_ring=GF(2)) # needs sage.modules + sage: RP2.cohomology(dim=[1, 2], base_ring=GF(2)) {1: Vector space of dimension 1 over Finite Field of size 2, 2: Vector space of dimension 1 over Finite Field of size 2} @@ -1191,7 +1190,6 @@ def chain_complex(self, subcomplex=None, augmented=False, EXAMPLES:: - sage: # needs sage.modules sage: S2 = cubical_complexes.Sphere(2) sage: S2.chain_complex() Chain complex with at most 3 nonzero terms over Integer Ring @@ -1210,7 +1208,6 @@ def chain_complex(self, subcomplex=None, augmented=False, Check that :issue:`32203` has been fixed:: - sage: # needs sage.modules sage: Square = CubicalComplex([([0,1],[0,1])]) sage: EdgesLTR = CubicalComplex([([0,0],[0,1]),([0,1],[1,1]),([1,1],[0,1])]) sage: EdgesLBR = CubicalComplex([([0,0],[0,1]),([0,1],[0,0]),([1,1],[0,1])]) @@ -1507,7 +1504,7 @@ def disjoint_union(self, other): sage: S1 = cubical_complexes.Sphere(1) sage: S2 = cubical_complexes.Sphere(2) - sage: S1.disjoint_union(S2).homology() # needs sage.modules + sage: S1.disjoint_union(S2).homology() {0: Z, 1: Z, 2: Z} """ embedded_left = len(tuple(self.maximal_cells()[0])) @@ -1545,7 +1542,7 @@ def wedge(self, other): sage: S1 = cubical_complexes.Sphere(1) sage: S2 = cubical_complexes.Sphere(2) - sage: S1.wedge(S2).homology() # needs sage.modules + sage: S1.wedge(S2).homology() {0: 0, 1: Z, 2: Z} """ embedded_left = len(tuple(self.maximal_cells()[0])) @@ -1582,12 +1579,12 @@ def connected_sum(self, other): sage: T = cubical_complexes.Torus() sage: S2 = cubical_complexes.Sphere(2) - sage: T.connected_sum(S2).cohomology() == T.cohomology() # needs sage.modules + sage: T.connected_sum(S2).cohomology() == T.cohomology() True sage: RP2 = cubical_complexes.RealProjectivePlane() - sage: T.connected_sum(RP2).homology(1) # needs sage.modules + sage: T.connected_sum(RP2).homology(1) Z x Z x C2 - sage: RP2.connected_sum(RP2).connected_sum(RP2).homology(1) # needs sage.modules + sage: RP2.connected_sum(RP2).connected_sum(RP2).homology(1) Z x Z x C2 """ # connected_sum: first check whether the complexes are pure @@ -1703,7 +1700,6 @@ def algebraic_topological_model(self, base_ring=None): EXAMPLES:: - sage: # needs sage.modules sage: RP2 = cubical_complexes.RealProjectivePlane() sage: phi, M = RP2.algebraic_topological_model(GF(2)) sage: M.homology() @@ -1764,7 +1760,7 @@ def _simplicial_(self): sage: Ts = T._simplicial_(); Ts Simplicial complex with 16 vertices and 32 facets - sage: T.homology() == Ts.homology() # needs sage.modules + sage: T.homology() == Ts.homology() True Each `n`-dimensional cube produces `n!` `n`-simplices:: diff --git a/src/sage/topology/delta_complex.py b/src/sage/topology/delta_complex.py index e93b8cf5d2c..044927b3d5e 100644 --- a/src/sage/topology/delta_complex.py +++ b/src/sage/topology/delta_complex.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Finite Delta-complexes @@ -109,7 +108,7 @@ class DeltaComplex(GenericCellComplex): Let's compute its homology, and also compare it to the simplicial version:: - sage: S5.homology() # needs sage.modules + sage: S5.homology() {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: Z} sage: S5.f_vector() # number of simplices in each dimension [1, 6, 15, 20, 15, 6, 2] @@ -130,7 +129,7 @@ class DeltaComplex(GenericCellComplex): ....: Simplex(0): ()} sage: T = DeltaComplex(torus_dict); T Delta complex with 1 vertex and 7 simplices - sage: T.cohomology(base_ring=QQ) # needs sage.modules + sage: T.cohomology(base_ring=QQ) {0: Vector space of dimension 0 over Rational Field, 1: Vector space of dimension 2 over Rational Field, 2: Vector space of dimension 1 over Rational Field} @@ -181,9 +180,9 @@ class DeltaComplex(GenericCellComplex): :: - sage: P.homology(1) # needs sage.modules + sage: P.homology(1) C2 - sage: P.cohomology(2) # needs sage.modules + sage: P.cohomology(2) C2 Closely related to this form for ``data`` is ``X.cells()`` @@ -248,7 +247,7 @@ def __init__(self, data=None, check_validity=True): sage: X = DeltaComplex({Simplex(3):True, Simplex(range(1,5)): Simplex(3), Simplex(range(2,6)): Simplex(3)}); X # indirect doctest Delta complex with 4 vertices and 18 simplices - sage: X.homology() # needs sage.modules + sage: X.homology() {0: 0, 1: 0, 2: 0, 3: Z x Z} sage: X == loads(dumps(X)) True @@ -403,7 +402,7 @@ def subcomplex(self, data): sage: X = delta_complexes.Torus() sage: A = X.subcomplex({2: [0]}) # one of the triangles of X - sage: X.homology(subcomplex=A) # needs sage.modules + sage: X.homology(subcomplex=A) {0: 0, 1: 0, 2: Z} In the following, ``line`` is a line segment and ``ends`` is @@ -416,7 +415,7 @@ def subcomplex(self, data): sage: ends = line.subcomplex({0: (0, 1)}) sage: ends.cells() {-1: ((),), 0: ((), ())} - sage: line.homology(subcomplex=ends) # needs sage.modules + sage: line.homology(subcomplex=ends) {0: 0, 1: Z} """ if isinstance(data, (list, tuple)): @@ -601,7 +600,6 @@ def chain_complex(self, subcomplex=None, augmented=False, EXAMPLES:: - sage: # needs sage.modules sage: circle = delta_complexes.Sphere(1) sage: circle.chain_complex() Chain complex with at most 2 nonzero terms over Integer Ring @@ -740,7 +738,7 @@ def n_skeleton(self, n): Delta complex with 4 vertices and 11 simplices sage: S3.n_skeleton(1).dimension() 1 - sage: S3.n_skeleton(1).homology() # needs sage.modules + sage: S3.n_skeleton(1).homology() {0: 0, 1: Z x Z x Z} """ if n >= self.dimension(): @@ -808,7 +806,7 @@ def join(self, other): sage: S1 = delta_complexes.Sphere(1) sage: X = S1 * S1 # X is a 3-sphere - sage: X.homology() # needs sage.modules + sage: X.homology() {0: 0, 1: 0, 2: 0, 3: Z} """ data = [] @@ -883,7 +881,7 @@ def cone(self): sage: K = delta_complexes.KleinBottle() sage: K.cone() Delta complex with 2 vertices and 14 simplices - sage: K.cone().homology() # needs sage.modules + sage: K.cone().homology() {0: 0, 1: 0, 2: 0, 3: 0} """ return self.join(delta_complexes.Simplex(0)) @@ -905,7 +903,7 @@ def suspension(self, n=1): sage: S = delta_complexes.Sphere(0) sage: S3 = S.suspension(3) # the 3-sphere - sage: S3.homology() # needs sage.modules + sage: S3.homology() {0: 0, 1: 0, 2: 0, 3: Z} """ if n < 0: @@ -936,7 +934,6 @@ def product(self, other): sage: K = delta_complexes.KleinBottle() sage: X = K.product(K) - sage: # needs sage.modules sage: X.homology(1) Z x Z x C2 x C2 sage: X.homology(2) @@ -953,7 +950,7 @@ def product(self, other): 4: Vector space of dimension 1 over Finite Field of size 2} sage: S1 = delta_complexes.Sphere(1) - sage: K.product(S1).homology() == S1.product(K).homology() # needs sage.modules + sage: K.product(S1).homology() == S1.product(K).homology() True sage: S1.product(S1) == delta_complexes.Torus() True @@ -1051,7 +1048,7 @@ def disjoint_union(self, right): sage: S1 = delta_complexes.Sphere(1) sage: S2 = delta_complexes.Sphere(2) - sage: S1.disjoint_union(S2).homology() # needs sage.modules + sage: S1.disjoint_union(S2).homology() {0: Z, 1: Z, 2: Z} """ dim = max(self.dimension(), right.dimension()) @@ -1083,7 +1080,7 @@ def wedge(self, right): sage: S1 = delta_complexes.Sphere(1) sage: S2 = delta_complexes.Sphere(2) - sage: S1.wedge(S2).homology() # needs sage.modules + sage: S1.wedge(S2).homology() {0: 0, 1: Z, 2: Z} """ data = self.disjoint_union(right).cells() @@ -1131,7 +1128,6 @@ def connected_sum(self, other): EXAMPLES:: - sage: # needs sage.modules sage: T = delta_complexes.Torus() sage: S2 = delta_complexes.Sphere(2) sage: T.connected_sum(S2).cohomology() == T.cohomology() @@ -1262,7 +1258,7 @@ def elementary_subdivision(self, idx=-1): Delta complex with 2 vertices and 13 simplices sage: X.elementary_subdivision() Delta complex with 3 vertices and 19 simplices - sage: X.homology() == T.homology() # needs sage.modules + sage: X.homology() == T.homology() True """ pi = self._epi_from_standard_simplex(idx=idx) @@ -1510,12 +1506,12 @@ def n_chains(self, n, base_ring=None, cochains=False): EXAMPLES:: sage: T = delta_complexes.Torus() - sage: T.n_chains(1, QQ) # needs sage.modules + sage: T.n_chains(1, QQ) Free module generated by {(0, (0, 0)), (1, (0, 0)), (2, (0, 0))} over Rational Field - sage: list(T.n_chains(1, QQ, cochains=False).basis()) # needs sage.modules + sage: list(T.n_chains(1, QQ, cochains=False).basis()) [(0, (0, 0)), (1, (0, 0)), (2, (0, 0))] - sage: list(T.n_chains(1, QQ, cochains=True).basis()) # needs sage.modules + sage: list(T.n_chains(1, QQ, cochains=True).basis()) [\chi_(0, (0, 0)), \chi_(1, (0, 0)), \chi_(2, (0, 0))] """ from sage.homology.chains import Chains, Cochains @@ -1572,7 +1568,6 @@ def algebraic_topological_model(self, base_ring=None): EXAMPLES:: - sage: # needs sage.modules sage: RP2 = delta_complexes.RealProjectivePlane() sage: phi, M = RP2.algebraic_topological_model(GF(2)) sage: M.homology() @@ -1625,7 +1620,7 @@ class DeltaComplexExamples: sage: S = delta_complexes.Sphere(6) # the 6-sphere sage: S.dimension() 6 - sage: S.cohomology(6) # needs sage.modules + sage: S.cohomology(6) Z sage: delta_complexes.Torus() == delta_complexes.Sphere(3) False @@ -1644,7 +1639,7 @@ def Sphere(self, n): EXAMPLES:: - sage: delta_complexes.Sphere(4).cohomology(4, base_ring=GF(3)) # needs sage.modules + sage: delta_complexes.Sphere(4).cohomology(4, base_ring=GF(3)) Vector space of dimension 1 over Finite Field of size 3 """ if n == 1: @@ -1661,7 +1656,7 @@ def Torus(self): EXAMPLES:: - sage: delta_complexes.Torus().homology(1) # needs sage.modules sage.rings.finite_rings + sage: delta_complexes.Torus().homology(1) Z x Z """ return DeltaComplex((((),), ((0, 0), (0, 0), (0, 0)), @@ -1676,7 +1671,6 @@ def RealProjectivePlane(self): EXAMPLES:: - sage: # needs sage.modules sage: P = delta_complexes.RealProjectivePlane() sage: P.cohomology(1) 0 @@ -1741,9 +1735,9 @@ def SurfaceOfGenus(self, g, orientable=True): sage: delta_complexes.SurfaceOfGenus(1, orientable=False) Delta complex with 2 vertices and 8 simplices - sage: delta_complexes.SurfaceOfGenus(3, orientable=False).homology(1) # needs sage.modules + sage: delta_complexes.SurfaceOfGenus(3, orientable=False).homology(1) Z x Z x C2 - sage: delta_complexes.SurfaceOfGenus(3, orientable=False).homology(2) # needs sage.modules + sage: delta_complexes.SurfaceOfGenus(3, orientable=False).homology(2) 0 Compare to simplicial complexes:: @@ -1754,7 +1748,7 @@ def SurfaceOfGenus(self, g, orientable=True): sage: simpl_g4 = simplicial_complexes.SurfaceOfGenus(4) sage: simpl_g4.f_vector() [1, 19, 75, 50] - sage: delta_g4.homology() == simpl_g4.homology() # needs sage.modules + sage: delta_g4.homology() == simpl_g4.homology() True """ try: diff --git a/src/sage/topology/filtered_simplicial_complex.py b/src/sage/topology/filtered_simplicial_complex.py index 88148886243..6fc0ed943a2 100644 --- a/src/sage/topology/filtered_simplicial_complex.py +++ b/src/sage/topology/filtered_simplicial_complex.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Finite filtered complexes @@ -22,20 +21,20 @@ Sage can compute persistent homology of simplicial complexes:: sage: X = FilteredSimplicialComplex([([0], 0), ([1], 0), ([0, 1], 1)]) - sage: X.persistence_intervals(0) # needs sage.modules + sage: X.persistence_intervals(0) [(0, 1), (0, +Infinity)] FilteredSimplicialComplex objects are mutable. Filtration values can be set with the ``filtration`` method as follows:: sage: X = FilteredSimplicialComplex() # returns an empty complex - sage: X.persistence_intervals(1) # needs sage.modules + sage: X.persistence_intervals(1) [] sage: X.filtration(Simplex([0, 2]), 0) # recursively adds faces sage: X.filtration(Simplex([0, 1]), 0) sage: X.filtration(Simplex([1, 2]), 0) sage: X.filtration(Simplex([0, 1, 2]), 1) # closes the circle - sage: X.persistence_intervals(1) # needs sage.modules + sage: X.persistence_intervals(1) [(0, 1)] The filtration value of a simplex can be accessed as well with the @@ -396,7 +395,7 @@ def _persistent_homology(self, field=2, strict=True, verbose=False): EXAMPLES:: sage: X = FilteredSimplicialComplex([([0], 0), ([1], 0), ([0,1], 2)]) - sage: X._persistent_homology()[0] # needs sage.modules + sage: X._persistent_homology()[0] [(0, 2), (0, +Infinity)] Some homology elements may have a lifespan or persistence of 0. @@ -404,7 +403,7 @@ def _persistent_homology(self, field=2, strict=True, verbose=False): sage: X = FilteredSimplicialComplex() sage: X.insert([0,1],1) # opens a hole and closes it instantly - sage: X._persistent_homology(strict=False)[0] # needs sage.modules + sage: X._persistent_homology(strict=False)[0] [(1, 1), (1, +Infinity)] REFERENCES: @@ -419,11 +418,11 @@ def _persistent_homology(self, field=2, strict=True, verbose=False): ....: ([1, 2], 1), ([0, 3], 2), ([2, 3], 2), ([0, 2], 3), ....: ([0, 1, 2], 4), ([0, 2, 3], 5)] sage: X = FilteredSimplicialComplex(l) - sage: X.persistence_intervals(0) # needs sage.modules + sage: X.persistence_intervals(0) [(0, 1), (1, 2), (0, +Infinity)] - sage: X.persistence_intervals(1) # needs sage.modules + sage: X.persistence_intervals(1) [(3, 4), (2, 5)] - sage: X.persistence_intervals(0, strict=False) # needs sage.modules + sage: X.persistence_intervals(0, strict=False) [(0, 1), (1, 1), (1, 2), (0, +Infinity)] """ # first, order the simplices in lexico order @@ -508,7 +507,6 @@ def _add_interval(self, s, t, intervals): TESTS:: - sage: # needs sage.modules sage: X = FilteredSimplicialComplex([([0], 0), ([1, 2], 10)]) sage: int_list = X._persistent_homology() sage: int_list[0] @@ -520,7 +518,7 @@ def _add_interval(self, s, t, intervals): Infinite interval:: sage: int_list2 = [[],[]] - sage: X._add_interval(Simplex([1, 2]), None, int_list2) # needs sage.modules + sage: X._add_interval(Simplex([1, 2]), None, int_list2) sage: int_list2[1] [(10, +Infinity)] """ @@ -555,12 +553,12 @@ def _remove_pivot_rows(self, s, simplices): sage: l = [([0], 0), ([1], 0), ([2], 1), ([3], 1), ([0, 1], 1), ([1, 2], 1), ....: ([0, 3], 2), ([2, 3], 2), ([0, 2], 3), ([0, 1, 2], 4)] sage: X = FilteredSimplicialComplex(l) - sage: X._persistent_homology() # needs sage.modules + sage: X._persistent_homology() [[(0, 1), (1, 2), (0, +Infinity)], [(3, 4), (2, +Infinity)], []] - sage: X._remove_pivot_rows(Simplex([0,1,2]), list(X._filtration_dict)) # needs sage.modules + sage: X._remove_pivot_rows(Simplex([0,1,2]), list(X._filtration_dict)) 0 sage: X.insert([0,2,3],5) - sage: X._remove_pivot_rows(Simplex([0,2,3]), list(X._filtration_dict)) # needs sage.modules + sage: X._remove_pivot_rows(Simplex([0,2,3]), list(X._filtration_dict)) B[(2, 3)] """ d = self._chaingroup() @@ -605,7 +603,6 @@ def _max_index(self, d): TESTS:: - sage: # needs sage.modules sage: X = FilteredSimplicialComplex([([0], 0), ([1], 5), ([0, 1], 18), ([0, 2, 3], 32)]) sage: X._persistent_homology() [[(5, 18), (0, +Infinity)], [], []] @@ -640,7 +637,7 @@ def persistence_intervals(self, dimension, field=2, strict=True, verbose=None): EXAMPLES:: sage: X = FilteredSimplicialComplex([([0], 0), ([1], 1), ([0,1], 2)]) - sage: X.persistence_intervals(0) # needs sage.modules + sage: X.persistence_intervals(0) [(1, 2), (0, +Infinity)] """ if verbose is None: @@ -674,16 +671,16 @@ def betti_number(self, k, a, b, field=2, strict=True, verbose=None): EXAMPLES:: sage: X = FilteredSimplicialComplex([([0], 0), ([1], 0), ([0,1], 2)]) - sage: X.betti_number(0, 0.5, 1) # needs sage.modules + sage: X.betti_number(0, 0.5, 1) 2 - sage: X.betti_number(0, 1.5, 1) # needs sage.modules + sage: X.betti_number(0, 1.5, 1) 1 If an element vanishes at time ``a + b`` exactly, it does not count towards the Betti number:: sage: X = FilteredSimplicialComplex([([0], 0), ([1], 0), ([0,1], 2)]) - sage: X.betti_number(0, 1.5, 0.5) # needs sage.modules + sage: X.betti_number(0, 1.5, 0.5) 1 """ if verbose is None: diff --git a/src/sage/topology/moment_angle_complex.py b/src/sage/topology/moment_angle_complex.py index 04c6922a99b..1b3cfaa27e9 100644 --- a/src/sage/topology/moment_angle_complex.py +++ b/src/sage/topology/moment_angle_complex.py @@ -132,11 +132,11 @@ class MomentAngleComplex(UniqueRepresentation, SageObject): We can perform a number of operations, such as find the dimension or compute the homology:: - sage: M.homology() # needs sage.modules + sage: M.homology() {0: 0, 1: 0, 2: 0, 3: Z} sage: Z.dimension() 6 - sage: Z.homology() # needs sage.modules + sage: Z.homology() {0: 0, 1: 0, 2: 0, 3: Z x Z, 4: Z, 5: Z, 6: Z} If the associated simplicial complex is an `n`-simplex, then the @@ -405,9 +405,9 @@ def components(self) -> dict: sage: S3 = simplicial_complexes.Sphere(3) sage: product_of_spheres = S3.product(S3) - sage: Z.cohomology() # needs sage.modules + sage: Z.cohomology() {0: 0, 1: 0, 2: 0, 3: Z x Z, 4: 0, 5: 0, 6: Z} - sage: Z.cohomology() == product_of_spheres.cohomology() # long time # needs sage.modules + sage: Z.cohomology() == product_of_spheres.cohomology() # long time True """ return self._components @@ -455,7 +455,6 @@ def _homology_group(self, i, base_ring, cohomology, algorithm, verbose, reduced) TESTS:: - sage: # needs sage.modules sage: Z = MomentAngleComplex([[0,1,2], [1,2,3]]); Z Moment-angle complex of Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)} @@ -553,7 +552,6 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False, EXAMPLES:: - sage: # needs sage.modules sage: Z = MomentAngleComplex([[0,1,2], [1,2,3], [3,0]]); Z Moment-angle complex of Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 3), (0, 1, 2), (1, 2, 3)} @@ -584,14 +582,13 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False, (0, 1, 2) and facets {(0, 1), (0, 2), (1, 2)} sage: Z.cubical_complex() Cubical complex with 64 vertices and 729 cubes - sage: Z.cubical_complex().homology() == Z.homology() # needs sage.modules + sage: Z.cubical_complex().homology() == Z.homology() True Meanwhile, the homology computation used here is quite efficient and works well even with significantly larger underlying simplicial complexes:: - sage: # needs sage.modules sage: Z = MomentAngleComplex([[0,1,2,3,4,5], [0,1,2,3,4,6], ....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]]) sage: Z.homology() # long time @@ -661,7 +658,6 @@ def cohomology(self, dim=None, base_ring=ZZ, algorithm='pari', to a product of two 3-spheres (which can be seen by looking at the output of ``components()``):: - sage: # needs sage.modules sage: S3 = simplicial_complexes.Sphere(3) sage: product_of_spheres = S3.product(S3) sage: Z.cohomology() @@ -690,7 +686,6 @@ def betti(self, dim=None) -> dict: EXAMPLES:: - sage: # needs sage.modules sage: Z = MomentAngleComplex([[0,1], [1,2], [2,0], [1,2,3]]) sage: Z.betti() {0: 1, 1: 0, 2: 0, 3: 1, 4: 0, 5: 1, 6: 1, 7: 0} @@ -722,7 +717,6 @@ def euler_characteristic(self): EXAMPLES:: - sage: # needs sage.modules sage: X = SimplicialComplex([[0,1,2,3,4,5], [0,1,2,3,4,6], ....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]]) sage: M = MomentAngleComplex(X) diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index 1c4ebf82250..c0adfb2d358 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Finite simplicial complexes @@ -92,7 +91,7 @@ sage: T = S.product(S) # torus sage: T Simplicial complex with 9 vertices and 18 facets - sage: T.homology() # this computes reduced homology # needs sage.modules + sage: T.homology() # this computes reduced homology {0: 0, 1: Z x Z, 2: Z} sage: T.euler_characteristic() 0 @@ -105,8 +104,8 @@ [1, 4, 4] sage: X.face_poset() Finite poset containing 8 elements - sage: x0, x1, x2, x3 = X.stanley_reisner_ring().gens() # needs sage.libs.singular - sage: x0*x2 == x1*x3 == 0 # needs sage.libs.singular + sage: x0, x1, x2, x3 = X.stanley_reisner_ring().gens() + sage: x0*x2 == x1*x3 == 0 True sage: X.is_pure() True @@ -899,7 +898,7 @@ class SimplicialComplex(Parent, GenericCellComplex): Cubical complex with 16 vertices and 64 cubes sage: Ts = SimplicialComplex(Tc); Ts Simplicial complex with 16 vertices and 32 facets - sage: Ts.homology() # needs sage.modules + sage: Ts.homology() {0: 0, 1: Z x Z, 2: Z} In the situation where the first argument is a simplicial complex @@ -919,9 +918,9 @@ class SimplicialComplex(Parent, GenericCellComplex): or e.g. the simplicial complex of all 168 hyperovals of the projective plane of order 4:: - sage: l = designs.ProjectiveGeometryDesign(2, 1, GF(4,name='a')) # needs sage.rings.finite_rings + sage: l = designs.ProjectiveGeometryDesign(2, 1, GF(4,name='a')) sage: f = lambda S: not any(len(set(S).intersection(x))>2 for x in l) - sage: SimplicialComplex(from_characteristic_function=(f, l.ground_set())) # needs sage.rings.finite_rings, long time + sage: SimplicialComplex(from_characteristic_function=(f, l.ground_set())) # long time Simplicial complex with 21 vertices and 168 facets TESTS: @@ -1485,7 +1484,6 @@ def g_vector(self): EXAMPLES:: - sage: # needs sage.combinat sage: S3 = simplicial_complexes.Sphere(3).barycentric_subdivision() sage: S3.f_vector() [1, 30, 150, 240, 120] @@ -1610,14 +1608,14 @@ def F_triangle(self, S): EXAMPLES:: sage: cs = simplicial_complexes.Torus() - sage: cs.F_triangle(cs.facets()[0]) # needs sage.combinat + sage: cs.F_triangle(cs.facets()[0]) F: x^3 + 9*x^2*y + 3*x*y^2 + y^3 + 6*x^2 + 12*x*y + 3*y^2 + 4*x + 3*y + 1 TESTS:: sage: S = SimplicialComplex([]) - sage: S.F_triangle(S.facets()[0]) # needs sage.combinat + sage: S.F_triangle(S.facets()[0]) F: 1 """ x, y = polygens(ZZ, 'x, y') @@ -1805,7 +1803,7 @@ def product(self, right, rename_vertices=True, immutable=False): sage: T = S.product(S) # torus sage: T Simplicial complex with 9 vertices and 18 facets - sage: T.homology() # needs sage.modules + sage: T.homology() {0: 0, 1: Z x Z, 2: Z} These can get large pretty quickly:: @@ -1951,7 +1949,7 @@ def suspension(self, n=1, immutable=False): sage: S0.suspension() == simplicial_complexes.Sphere(1) True sage: S3 = S0.suspension(3) # the 3-sphere - sage: S3.homology() # needs sage.modules + sage: S3.homology() {0: 0, 1: 0, 2: 0, 3: Z} For pseudomanifolds, the complex constructed here will be @@ -2002,7 +2000,7 @@ def disjoint_union(self, right, immutable=False): sage: S1 = simplicial_complexes.Sphere(1) sage: S2 = simplicial_complexes.Sphere(2) - sage: S1.disjoint_union(S2).homology() # needs sage.modules + sage: S1.disjoint_union(S2).homology() {0: Z, 1: Z, 2: Z} """ facets = [tuple(f"L{v}" for v in f) for f in self._facets] @@ -2039,7 +2037,7 @@ def wedge(self, right, rename_vertices=True, immutable=False): sage: S1 = simplicial_complexes.Sphere(1) sage: S2 = simplicial_complexes.Sphere(2) - sage: S1.wedge(S2).homology() # needs sage.modules + sage: S1.wedge(S2).homology() {0: 0, 1: Z, 2: Z} """ left_vertices = list(self.vertices()) @@ -2103,11 +2101,11 @@ def chain_complex(self, subcomplex=None, augmented=False, EXAMPLES:: sage: circle = SimplicialComplex([[0,1], [1,2], [0, 2]]) - sage: circle.chain_complex() # needs sage.modules + sage: circle.chain_complex() Chain complex with at most 2 nonzero terms over Integer Ring - sage: circle.chain_complex()._latex_() # needs sage.modules + sage: circle.chain_complex()._latex_() '\\Bold{Z}^{3} \\xrightarrow{d_{1}} \\Bold{Z}^{3}' - sage: circle.chain_complex(base_ring=QQ, augmented=True) # needs sage.modules + sage: circle.chain_complex(base_ring=QQ, augmented=True) Chain complex with at most 3 nonzero terms over Rational Field """ # initialize subcomplex @@ -2282,7 +2280,6 @@ def _homology_(self, dim=None, base_ring=ZZ, subcomplex=None, EXAMPLES:: - sage: # needs sage.modules sage: circle = SimplicialComplex([[0,1], [1,2], [0, 2]]) sage: circle._homology_() {0: 0, 1: Z} @@ -2302,7 +2299,6 @@ def _homology_(self, dim=None, base_ring=ZZ, subcomplex=None, We need an immutable complex to compute homology generators:: - sage: # needs sage.modules sage: sphere.set_immutable() sage: sphere._homology_(generators=True) {0: [], 1: [], 2: [(Z, (0, 1, 2) - (0, 1, 3) + (0, 2, 3) - (1, 2, 3))]} @@ -2311,24 +2307,24 @@ def _homology_(self, dim=None, base_ring=ZZ, subcomplex=None, three-fold join with itself:: sage: S = SimplicialComplex([[0], [1]]) - sage: (S*S*S)._homology_(dim=2, cohomology=True) # needs sage.modules + sage: (S*S*S)._homology_(dim=2, cohomology=True) Z The same computation, done without finding a contractible subcomplex:: - sage: (S*S*S)._homology_(dim=2, cohomology=True, enlarge=False) # needs sage.modules + sage: (S*S*S)._homology_(dim=2, cohomology=True, enlarge=False) Z Relative homology:: sage: T = SimplicialComplex([[0,1,2]]) sage: U = SimplicialComplex([[0,1], [1,2], [0,2]]) - sage: T._homology_(subcomplex=U) # needs sage.modules + sage: T._homology_(subcomplex=U) {0: 0, 1: 0, 2: Z} Generators:: - sage: simplicial_complexes.Torus().homology(generators=True) # needs sage.modules + sage: simplicial_complexes.Torus().homology(generators=True) {0: [], 1: [(Z, (2, 4) - (2, 6) + (4, 6)), (Z, (1, 4) - (1, 6) + (4, 6))], 2: [(Z, (0, 1, 2) - (0, 1, 5) + (0, 2, 6) - (0, 3, 4) + (0, 3, 5) @@ -2463,7 +2459,6 @@ def algebraic_topological_model(self, base_ring=None): EXAMPLES:: - sage: # needs sage.modules sage: RP2 = simplicial_complexes.RealProjectivePlane() sage: phi, M = RP2.algebraic_topological_model(GF(2)) sage: M.homology() @@ -2547,10 +2542,10 @@ def add_face(self, face): Check that the bug reported at :issue:`14354` has been fixed:: sage: T = SimplicialComplex([range(1,5)]).n_skeleton(1) - sage: T.homology() # needs sage.modules + sage: T.homology() {0: 0, 1: Z x Z x Z} sage: T.add_face([1,2,3]) - sage: T.homology() # needs sage.modules + sage: T.homology() {0: 0, 1: Z x Z, 2: 0} Check that the ``_faces`` cache is treated correctly @@ -2558,7 +2553,7 @@ def add_face(self, face): sage: T = SimplicialComplex([range(1,5)]).n_skeleton(1) sage: _ = T.faces() # populate the _faces attribute - sage: _ = T.homology() # add more to _faces # needs sage.modules + sage: _ = T.homology() # add more to _faces sage: T.add_face((1,2,3)) sage: all(Simplex((1,2,3)) in T._faces[L][2] for L in T._faces) True @@ -2567,10 +2562,10 @@ def add_face(self, face): (:issue:`20758`):: sage: T = SimplicialComplex([range(1,5)]).n_skeleton(1) - sage: T.homology() # to populate the __enlarged attribute # needs sage.modules + sage: T.homology() # to populate the __enlarged attribute {0: 0, 1: Z x Z x Z} sage: T.add_face([1,2,3]) - sage: len(T._SimplicialComplex__enlarged) > 0 # needs sage.modules + sage: len(T._SimplicialComplex__enlarged) > 0 True Check we've fixed the bug reported at :issue:`14578`:: @@ -2579,7 +2574,7 @@ def add_face(self, face): sage: t0.add_face(('a', 'b')) sage: t0.add_face(('c', 'd', 'e')) sage: t0.add_face(('e', 'f', 'c')) - sage: t0.homology() # needs sage.modules + sage: t0.homology() {0: Z, 1: 0, 2: 0} Check that we've fixed the bug reported at :issue:`22880`:: @@ -2696,10 +2691,10 @@ def remove_face(self, face, check=False): sage: T = SimplicialComplex([range(1,5)]).n_skeleton(1) sage: _ = T.faces() # populate the _faces attribute - sage: _ = T.homology() # add more to _faces # needs sage.modules + sage: _ = T.homology() # add more to _faces sage: T.add_face((1,2,3)) sage: T.remove_face((1,2,3)) - sage: len(T._faces) # needs sage.modules + sage: len(T._faces) 2 sage: T.remove_face((1,2)) sage: len(T._faces) @@ -2892,7 +2887,7 @@ def connected_sum(self, other, immutable=False): EXAMPLES:: sage: S1 = simplicial_complexes.Sphere(1) - sage: S1.connected_sum(S1.connected_sum(S1)).homology() # needs sage.modules + sage: S1.connected_sum(S1.connected_sum(S1)).homology() {0: 0, 1: Z} sage: P = simplicial_complexes.RealProjectivePlane(); P Minimal triangulation of the real projective plane @@ -2903,7 +2898,7 @@ def connected_sum(self, other, immutable=False): sage: P + P # the Klein bottle Simplicial complex with 9 vertices and 18 facets - sage: (P + P).homology()[1] # needs sage.modules + sage: (P + P).homology()[1] Z x C2 """ if not (self.is_pure() and other.is_pure() and @@ -3024,23 +3019,23 @@ def is_cohen_macaulay(self, base_ring=QQ, ncpus=0) -> bool: Spheres are Cohen-Macaulay:: sage: S = SimplicialComplex([[1,2],[2,3],[3,1]]) - sage: S.is_cohen_macaulay(ncpus=3) # needs sage.modules + sage: S.is_cohen_macaulay(ncpus=3) True The following example is taken from Bruns, Herzog - Cohen-Macaulay rings, Figure 5.3:: sage: S = SimplicialComplex([[1,2,3],[1,4,5]]) - sage: S.is_cohen_macaulay(ncpus=3) # needs sage.modules + sage: S.is_cohen_macaulay(ncpus=3) False The choice of base ring can matter. The real projective plane `\RR P^2` has `H_1(\RR P^2) = \ZZ/2`, hence is CM over `\QQ` but not over `\ZZ`. :: sage: X = simplicial_complexes.RealProjectivePlane() - sage: X.is_cohen_macaulay() # needs sage.modules + sage: X.is_cohen_macaulay() True - sage: X.is_cohen_macaulay(ZZ) # needs sage.modules + sage: X.is_cohen_macaulay(ZZ) False """ from sage.parallel.decorate import parallel @@ -3613,7 +3608,7 @@ def barycentric_subdivision(self): sage: triangle = SimplicialComplex([[0,1], [1,2], [0, 2]]) sage: hexagon = triangle.barycentric_subdivision(); hexagon Simplicial complex with 6 vertices and 6 facets - sage: hexagon.homology(1) == triangle.homology(1) # needs sage.modules + sage: hexagon.homology(1) == triangle.homology(1) True Barycentric subdivisions can get quite large, since each @@ -3778,7 +3773,7 @@ def delta_complex(self, sort_simplices=False): sage: Td = T.delta_complex() sage: Td Delta complex with 7 vertices and 43 simplices - sage: T.homology() == Td.homology() # needs sage.modules + sage: T.homology() == Td.homology() True """ from .delta_complex import DeltaComplex @@ -3889,7 +3884,7 @@ def _contractible_subcomplex(self, verbose=False): sage: L = sphere._contractible_subcomplex(); L Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (0, 1, 3), (0, 2, 3)} - sage: L.homology() # needs sage.modules + sage: L.homology() {0: 0, 1: 0, 2: 0} """ facets = [sorted(self._facets, key=str)[0]] @@ -3927,14 +3922,14 @@ def _enlarge_subcomplex(self, subcomplex, verbose=False): Inside the torus, define a subcomplex consisting of a loop:: sage: S = SimplicialComplex([[0,1], [1,2], [0,2]], immutable=True) - sage: S.homology() # needs sage.modules + sage: S.homology() {0: 0, 1: Z} sage: L = T._enlarge_subcomplex(S) sage: L Simplicial complex with vertex set (0, 1, 2, 3, 4, 5, 6) and 8 facets sage: sorted(L.facets()) [(0, 1), (0, 1, 5), (0, 2), (0, 2, 6), (0, 3, 4), (0, 3, 5), (0, 4, 6), (1, 2)] - sage: L.homology()[1] # needs sage.modules + sage: L.homology()[1] Z """ # Make the subcomplex immutable if not @@ -4047,12 +4042,12 @@ def _cubical_(self): EXAMPLES:: sage: T = simplicial_complexes.Torus() - sage: T.homology() # needs sage.modules + sage: T.homology() {0: 0, 1: Z x Z, 2: Z} sage: Tc = T._cubical_() sage: Tc Cubical complex with 42 vertices and 168 cubes - sage: Tc.homology() # needs sage.modules + sage: Tc.homology() {0: 0, 1: Z x Z, 2: Z} """ from .cubical_complex import CubicalComplex @@ -4151,7 +4146,7 @@ def fundamental_group(self, base_point=None, simplify=True): EXAMPLES:: sage: S1 = simplicial_complexes.Sphere(1) - sage: S1.fundamental_group() # needs sage.groups + sage: S1.fundamental_group() Finitely presented group < e | > If we pass the argument ``simplify=False``, we get generators and @@ -4159,22 +4154,21 @@ def fundamental_group(self, base_point=None, simplify=True): cyclic group of order 2, for instance:: sage: RP2 = simplicial_complexes.RealProjectiveSpace(2) - sage: C2 = RP2.fundamental_group(simplify=False); C2 # needs sage.groups + sage: C2 = RP2.fundamental_group(simplify=False); C2 Finitely presented group < e0, e1, e2, e3, e4, e5, e6, e7, e8, e9 | e0, e3, e4, e7, e9, e5*e2^-1*e0, e7*e2^-1*e1, e8*e3^-1*e1, e8*e6^-1*e4, e9*e6^-1*e5 > - sage: C2.simplified() # needs sage.groups + sage: C2.simplified() Finitely presented group < e1 | e1^2 > This is the same answer given if the argument ``simplify`` is True (the default):: - sage: RP2.fundamental_group() # needs sage.groups + sage: RP2.fundamental_group() Finitely presented group < e1 | e1^2 > You must specify a base point to compute the fundamental group of a non-connected complex:: - sage: # needs sage.groups sage: K = S1.disjoint_union(RP2) sage: K.fundamental_group() Traceback (most recent call last): @@ -4187,12 +4181,11 @@ def fundamental_group(self, base_point=None, simplify=True): Some other examples:: - sage: S1.wedge(S1).fundamental_group() # needs sage.groups + sage: S1.wedge(S1).fundamental_group() Finitely presented group < e0, e1 | > - sage: simplicial_complexes.Torus().fundamental_group() # needs sage.groups + sage: simplicial_complexes.Torus().fundamental_group() Finitely presented group < e1, e4 | e4^-1*e1^-1*e4*e1 > - sage: # needs sage.groups sage: G = simplicial_complexes.MooreSpace(5).fundamental_group() sage: G.ngens() 1 @@ -4319,24 +4312,24 @@ def automorphism_group(self): EXAMPLES:: sage: S = simplicial_complexes.Simplex(3) - sage: S.automorphism_group().is_isomorphic(SymmetricGroup(4)) # needs sage.groups + sage: S.automorphism_group().is_isomorphic(SymmetricGroup(4)) True sage: P = simplicial_complexes.RealProjectivePlane() - sage: P.automorphism_group().is_isomorphic(AlternatingGroup(5)) # needs sage.groups + sage: P.automorphism_group().is_isomorphic(AlternatingGroup(5)) True sage: Z = SimplicialComplex([['1','2'],['2','3','a']]) - sage: Z.automorphism_group().is_isomorphic(CyclicPermutationGroup(2)) # needs sage.groups + sage: Z.automorphism_group().is_isomorphic(CyclicPermutationGroup(2)) True - sage: group = Z.automorphism_group() # needs sage.groups - sage: sorted(group.domain()) # needs sage.groups + sage: group = Z.automorphism_group() + sage: sorted(group.domain()) ['1', '2', '3', 'a'] Check that :issue:`17032` is fixed:: sage: s = SimplicialComplex([[(0,1),(2,3)]]) - sage: s.automorphism_group().cardinality() # needs sage.groups + sage: s.automorphism_group().cardinality() 2 """ from sage.groups.perm_gps.permgroup import PermutationGroup @@ -4377,25 +4370,25 @@ def fixed_complex(self, G): sage: S4 = simplicial_complexes.Sphere(4) sage: S3 = simplicial_complexes.Sphere(3) - sage: fix = S4.fixed_complex([S4.automorphism_group()([(0,1)])]); fix # needs sage.groups + sage: fix = S4.fixed_complex([S4.automorphism_group()([(0,1)])]); fix Simplicial complex with vertex set (0, 2, 3, 4, 5) and 5 facets - sage: fix.is_isomorphic(S3) # needs sage.groups + sage: fix.is_isomorphic(S3) True Another simple example:: sage: T = SimplicialComplex([[1,2,3],[2,3,4]]) - sage: G = T.automorphism_group() # needs sage.groups - sage: T.fixed_complex([G([(1,4)])]) # needs sage.groups + sage: G = T.automorphism_group() + sage: T.fixed_complex([G([(1,4)])]) Simplicial complex with vertex set (2, 3) and facets {(2, 3)} A more sophisticated example:: sage: RP2 = simplicial_complexes.ProjectivePlane() sage: CP2 = simplicial_complexes.ComplexProjectivePlane() - sage: G = CP2.automorphism_group() # needs sage.groups - sage: H = G.subgroup([G([(2,3),(5,6),(8,9)])]) # needs sage.groups - sage: CP2.fixed_complex(H).is_isomorphic(RP2) # needs sage.groups + sage: G = CP2.automorphism_group() + sage: H = G.subgroup([G([(2,3),(5,6),(8,9)])]) + sage: CP2.fixed_complex(H).is_isomorphic(RP2) True """ from sage.categories.groups import Groups @@ -4760,14 +4753,14 @@ def is_partitionable(self, certificate=False, Simplices are trivially partitionable:: sage: X = SimplicialComplex([[1,2,3,4]]) - sage: X.is_partitionable() # needs sage.numerical.mip + sage: X.is_partitionable() True - sage: X.is_partitionable(certificate=True) # needs sage.numerical.mip + sage: X.is_partitionable(certificate=True) [((), (1, 2, 3, 4), 4)] Shellable complexes are partitionable:: - sage: # needs sage.numerical.mip, long time + sage: # long time sage: X = SimplicialComplex([[1,3,5], [1,3,6], [1,4,5], [1,4,6], ....: [2,3,5], [2,3,6], [2,4,5]]) sage: X.is_partitionable() @@ -4783,13 +4776,13 @@ def is_partitionable(self, certificate=False, A non-shellable, non-Cohen-Macaulay, partitionable example, constructed by Björner:: sage: X = SimplicialComplex([[1,2,3], [1,2,4], [1,3,4], [2,3,4], [1,5,6]]) - sage: X.is_partitionable() # needs sage.numerical.mip + sage: X.is_partitionable() True The bowtie complex is not partitionable:: sage: X = SimplicialComplex([[1,2,3], [1,4,5]]) - sage: X.is_partitionable() # needs sage.numerical.mip + sage: X.is_partitionable() False """ from sage.numerical.mip import MixedIntegerLinearProgram @@ -4960,7 +4953,6 @@ def bigraded_betti_number(self, a, b, base_ring=ZZ, verbose=False): EXAMPLES:: - sage: # needs sage.modules sage: X = SimplicialComplex([[0,1],[1,2],[2,0],[1,3]]) sage: X.bigraded_betti_number(-1, 4, base_ring=QQ) 2 @@ -5033,7 +5025,6 @@ def is_golod(self) -> bool: EXAMPLES:: - sage: # needs sage.modules sage: X = SimplicialComplex([[0,1],[1,2],[2,3],[3,0]]) sage: Y = SimplicialComplex([[0,1,2],[0,2],[0,4]]) sage: X.is_golod() @@ -5061,7 +5052,6 @@ def is_minimally_non_golod(self) -> bool: EXAMPLES:: - sage: # needs sage.modules sage: X = SimplicialComplex([[0,1],[1,2],[2,3],[3,0]]) sage: Y = SimplicialComplex([[1,2,3],[1,2,4],[3,5],[4,5]]) sage: X.is_golod() diff --git a/src/sage/topology/simplicial_complex_catalog.py b/src/sage/topology/simplicial_complex_catalog.py index 185b37b09ec..7f47c7e561e 100644 --- a/src/sage/topology/simplicial_complex_catalog.py +++ b/src/sage/topology/simplicial_complex_catalog.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs """ Catalog of simplicial complexes @@ -56,14 +55,14 @@ EXAMPLES:: sage: S = simplicial_complexes.Sphere(2) # the 2-sphere - sage: S.homology() # needs sage.modules + sage: S.homology() {0: 0, 1: 0, 2: Z} sage: simplicial_complexes.SurfaceOfGenus(3) Triangulation of an orientable surface of genus 3 sage: M4 = simplicial_complexes.MooreSpace(4) - sage: M4.homology() # needs sage.modules + sage: M4.homology() {0: 0, 1: C4, 2: 0} - sage: simplicial_complexes.MatchingComplex(6).homology() # needs sage.modules + sage: simplicial_complexes.MatchingComplex(6).homology() {0: 0, 1: Z^16, 2: 0} """ diff --git a/src/sage/topology/simplicial_complex_examples.py b/src/sage/topology/simplicial_complex_examples.py index 0f7b92a9c5f..8ab2024476e 100644 --- a/src/sage/topology/simplicial_complex_examples.py +++ b/src/sage/topology/simplicial_complex_examples.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs """ Examples of simplicial complexes @@ -54,14 +53,14 @@ EXAMPLES:: sage: S = simplicial_complexes.Sphere(2) # the 2-sphere - sage: S.homology() # needs sage.modules + sage: S.homology() {0: 0, 1: 0, 2: Z} sage: simplicial_complexes.SurfaceOfGenus(3) Triangulation of an orientable surface of genus 3 sage: M4 = simplicial_complexes.MooreSpace(4) - sage: M4.homology() # needs sage.modules + sage: M4.homology() {0: 0, 1: C4, 2: 0} - sage: simplicial_complexes.MatchingComplex(6).homology() # needs sage.modules + sage: simplicial_complexes.MatchingComplex(6).homology() {0: 0, 1: Z^16, 2: 0} """ @@ -295,7 +294,7 @@ def Sphere(n): sage: simplicial_complexes.Sphere(2) Minimal triangulation of the 2-sphere - sage: simplicial_complexes.Sphere(5).homology() # needs sage.modules + sage: simplicial_complexes.Sphere(5).homology() {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: Z} sage: [simplicial_complexes.Sphere(n).euler_characteristic() for n in range(6)] [2, 0, 2, 0, 2, 0] @@ -349,7 +348,7 @@ def Torus(): EXAMPLES:: sage: T = simplicial_complexes.Torus() - sage: T.homology(1) # needs sage.modules + sage: T.homology(1) Z x Z sage: T.f_vector() [1, 7, 21, 14] @@ -381,7 +380,6 @@ def RealProjectivePlane(): sage: P == Q True - sage: # needs sage.modules sage: P.cohomology(1) 0 sage: P.cohomology(2) @@ -492,9 +490,9 @@ def MooreSpace(q): sage: simplicial_complexes.MooreSpace(2) Minimal triangulation of the real projective plane - sage: simplicial_complexes.MooreSpace(3).homology()[1] # needs sage.modules + sage: simplicial_complexes.MooreSpace(3).homology()[1] C3 - sage: simplicial_complexes.MooreSpace(4).suspension().homology()[2] # needs sage.modules + sage: simplicial_complexes.MooreSpace(4).suspension().homology()[2] C4 sage: simplicial_complexes.MooreSpace(8) Triangulation of the mod 8 Moore space @@ -533,9 +531,9 @@ def ComplexProjectivePlane(): sage: C = simplicial_complexes.ComplexProjectivePlane() sage: C.f_vector() [1, 9, 36, 84, 90, 36] - sage: C.homology(2) # needs sage.modules + sage: C.homology(2) Z - sage: C.homology(4) # needs sage.modules + sage: C.homology(4) Z """ return UniqueSimplicialComplex( @@ -573,14 +571,14 @@ def QuaternionicProjectivePlane(): EXAMPLES:: - sage: HP2 = simplicial_complexes.QuaternionicProjectivePlane(); HP2 # needs sage.groups + sage: HP2 = simplicial_complexes.QuaternionicProjectivePlane(); HP2 Simplicial complex with 15 vertices and 490 facets - sage: HP2.f_vector() # needs sage.groups + sage: HP2.f_vector() [1, 15, 105, 455, 1365, 3003, 4515, 4230, 2205, 490] Checking its automorphism group:: - sage: HP2.automorphism_group().is_isomorphic(AlternatingGroup(5)) # needs sage.groups + sage: HP2.automorphism_group().is_isomorphic(AlternatingGroup(5)) True """ from sage.groups.perm_gps.permgroup import PermutationGroup @@ -621,9 +619,9 @@ def PoincareHomologyThreeSphere(): sage: S3 = simplicial_complexes.Sphere(3) sage: Sigma3 = simplicial_complexes.PoincareHomologyThreeSphere() - sage: S3.homology() == Sigma3.homology() # needs sage.modules + sage: S3.homology() == Sigma3.homology() True - sage: Sigma3.fundamental_group().cardinality() # long time # needs sage.groups + sage: Sigma3.fundamental_group().cardinality() # long time 120 """ return UniqueSimplicialComplex( @@ -723,7 +721,7 @@ def RealProjectiveSpace(n): sage: P3 = simplicial_complexes.RealProjectiveSpace(3) sage: P3.f_vector() [1, 11, 51, 80, 40] - sage: P3.homology() # needs sage.modules + sage: P3.homology() {0: 0, 1: C2, 2: 0, 3: Z} sage: P4 = simplicial_complexes.RealProjectiveSpace(4) sage: P4.f_vector() @@ -1067,7 +1065,7 @@ def NotIConnectedGraphs(n, i): sage: NICG52 = simplicial_complexes.NotIConnectedGraphs(5, 2) sage: NICG52.f_vector() [1, 10, 45, 120, 210, 240, 140, 20] - sage: NICG52.homology(5).ngens() # needs sage.modules + sage: NICG52.homology(5).ngens() 6 """ G_list = range(1, n+1) @@ -1120,9 +1118,9 @@ def MatchingComplex(n): EXAMPLES:: sage: M = simplicial_complexes.MatchingComplex(7) - sage: H = M.homology(); H # needs sage.modules + sage: H = M.homology(); H {0: 0, 1: C3, 2: Z^20} - sage: H[2].ngens() # needs sage.modules + sage: H[2].ngens() 20 sage: M8 = simplicial_complexes.MatchingComplex(8) sage: M8.homology(2) # long time (6s on sage.math, 2012), needs sage.modules @@ -1197,7 +1195,7 @@ def ChessboardComplex(n, i): sage: C = simplicial_complexes.ChessboardComplex(5, 5) sage: C.f_vector() [1, 25, 200, 600, 600, 120] - sage: simplicial_complexes.ChessboardComplex(3, 3).homology() # needs sage.modules + sage: simplicial_complexes.ChessboardComplex(3, 3).homology() {0: 0, 1: Z x Z x Z x Z, 2: 0} """ A = range(n) @@ -1299,58 +1297,58 @@ def SumComplex(n, A): sage: S = simplicial_complexes.SumComplex(10, [0, 1, 2, 3, 6]); S Sum complex on vertices Z/10Z associated to {0, 1, 2, 3, 6} - sage: S.homology() # needs sage.modules + sage: S.homology() {0: 0, 1: 0, 2: 0, 3: C2728, 4: 0} sage: factor(2728) 2^3 * 11 * 31 sage: S = simplicial_complexes.SumComplex(11, [0, 1, 3]); S Sum complex on vertices Z/11Z associated to {0, 1, 3} - sage: S.homology(1) # needs sage.modules + sage: S.homology(1) C23 sage: S = simplicial_complexes.SumComplex(11, [0, 1, 2, 3, 4, 7]); S Sum complex on vertices Z/11Z associated to {0, 1, 2, 3, 4, 7} - sage: S.homology() # long time # needs sage.modules + sage: S.homology() # long time {0: 0, 1: 0, 2: 0, 3: 0, 4: C645679, 5: 0} sage: factor(645679) 23 * 67 * 419 sage: S = simplicial_complexes.SumComplex(13, [0, 1, 3]); S Sum complex on vertices Z/13Z associated to {0, 1, 3} - sage: S.homology(1) # needs sage.modules + sage: S.homology(1) C159 sage: factor(159) 3 * 53 sage: S = simplicial_complexes.SumComplex(13, [0, 1, 2, 5]); S Sum complex on vertices Z/13Z associated to {0, 1, 2, 5} - sage: S.homology() # long time # needs sage.modules + sage: S.homology() # long time {0: 0, 1: 0, 2: C146989209, 3: 0} sage: factor(1648910295) 3^2 * 5 * 53 * 521 * 1327 sage: S = simplicial_complexes.SumComplex(13, [0, 1, 2, 3, 5]); S Sum complex on vertices Z/13Z associated to {0, 1, 2, 3, 5} - sage: S.homology() # long time # needs sage.modules + sage: S.homology() # long time {0: 0, 1: 0, 2: 0, 3: C3 x C237 x C706565607945, 4: 0} - sage: factor(706565607945) # needs sage.libs.pari + sage: factor(706565607945) 3 * 5 * 53 * 79 * 131 * 157 * 547 sage: S = simplicial_complexes.SumComplex(17, [0, 1, 4]); S Sum complex on vertices Z/17Z associated to {0, 1, 4} - sage: S.homology(1) # needs sage.modules + sage: S.homology(1) C140183 sage: factor(140183) 103 * 1361 sage: S = simplicial_complexes.SumComplex(19, [0, 1, 4]); S Sum complex on vertices Z/19Z associated to {0, 1, 4} - sage: S.homology(1) # needs sage.modules + sage: S.homology(1) C5670599 sage: factor(5670599) 11 * 191 * 2699 sage: S = simplicial_complexes.SumComplex(31, [0, 1, 4]); S Sum complex on vertices Z/31Z associated to {0, 1, 4} - sage: S.homology(1) # long time # needs sage.modules + sage: S.homology(1) # long time C5 x C5 x C5 x C5 x C26951480558170926865 - sage: factor(26951480558170926865) # needs sage.libs.pari + sage: factor(26951480558170926865) 5 * 311 * 683 * 1117 * 11657 * 1948909 """ from sage.rings.finite_rings.integer_mod_ring import Integers @@ -1408,7 +1406,7 @@ def RandomTwoSphere(n): sage: G = simplicial_complexes.RandomTwoSphere(6); G Simplicial complex with vertex set (0, 1, 2, 3, 4, 5) and 8 facets - sage: G.homology() # needs sage.modules + sage: G.homology() {0: 0, 1: 0, 2: Z} sage: G.is_pure() True @@ -1454,7 +1452,6 @@ def ShiftedComplex(generators): EXAMPLES:: - sage: # needs sage.combinat sage: X = simplicial_complexes.ShiftedComplex([Simplex([1, 6]), (2, 4), [8]]) sage: sorted(X.facets()) [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), (7,), (8,)] @@ -1490,9 +1487,9 @@ def RudinBall(): Rudin ball sage: R.f_vector() [1, 14, 66, 94, 41] - sage: R.homology() # needs sage.modules + sage: R.homology() {0: 0, 1: 0, 2: 0, 3: 0} - sage: R.is_cohen_macaulay() # needs sage.modules + sage: R.is_cohen_macaulay() True """ return UniqueSimplicialComplex( @@ -1523,9 +1520,9 @@ def ZieglerBall(): Ziegler ball sage: Z.f_vector() [1, 10, 38, 50, 21] - sage: Z.homology() # needs sage.modules + sage: Z.homology() {0: 0, 1: 0, 2: 0, 3: 0} - sage: Z.is_cohen_macaulay() # needs sage.modules + sage: Z.is_cohen_macaulay() True """ @@ -1551,9 +1548,9 @@ def DunceHat(): Minimal triangulation of the dunce hat sage: D.f_vector() [1, 8, 24, 17] - sage: D.homology() # needs sage.modules + sage: D.homology() {0: 0, 1: 0, 2: 0} - sage: D.is_cohen_macaulay() # needs sage.modules + sage: D.is_cohen_macaulay() True """ return UniqueSimplicialComplex( @@ -1585,14 +1582,14 @@ def FareyMap(p): EXAMPLES:: - sage: S5 = simplicial_complexes.FareyMap(5); S5 # needs sage.groups + sage: S5 = simplicial_complexes.FareyMap(5); S5 Simplicial complex with 12 vertices and 20 facets - sage: S5.automorphism_group().cardinality() # needs sage.groups + sage: S5.automorphism_group().cardinality() 120 - sage: S7 = simplicial_complexes.FareyMap(7); S7 # needs sage.groups + sage: S7 = simplicial_complexes.FareyMap(7); S7 Simplicial complex with 24 vertices and 56 facets - sage: S7.f_vector() # needs sage.groups + sage: S7.f_vector() [1, 24, 84, 56] REFERENCES: @@ -1650,9 +1647,9 @@ def GenusSix(): EXAMPLES:: sage: S = simplicial_complexes.GenusSix() - sage: S.automorphism_group().cardinality() # needs sage.groups + sage: S.automorphism_group().cardinality() 12 - sage: S.betti() # needs sage.modules + sage: S.betti() {0: 1, 1: 12, 2: 1} sage: S.f_vector() [1, 12, 66, 44] diff --git a/src/sage/topology/simplicial_complex_homset.py b/src/sage/topology/simplicial_complex_homset.py index 12180b91ab0..72c3a491fc8 100644 --- a/src/sage/topology/simplicial_complex_homset.py +++ b/src/sage/topology/simplicial_complex_homset.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Homsets between simplicial complexes diff --git a/src/sage/topology/simplicial_complex_morphism.py b/src/sage/topology/simplicial_complex_morphism.py index c0cc2bbd589..e73861e7b07 100644 --- a/src/sage/topology/simplicial_complex_morphism.py +++ b/src/sage/topology/simplicial_complex_morphism.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Morphisms of simplicial complexes @@ -221,7 +220,7 @@ def __call__(self, x, orientation=False): sage: g = Hom(X,X)({0:1, 1:0}) sage: g(Simplex([0,1])) (0, 1) - sage: g(Simplex([0,1]), orientation=True) # needs sage.modules + sage: g(Simplex([0,1]), orientation=True) ((0, 1), -1) TESTS: @@ -315,7 +314,6 @@ def associated_chain_complex_morphism(self, base_ring=ZZ, EXAMPLES:: - sage: # needs sage.modules sage: S = simplicial_complexes.Sphere(1) sage: T = simplicial_complexes.Sphere(2) sage: H = Hom(S, T) @@ -362,7 +360,6 @@ def associated_chain_complex_morphism(self, base_ring=ZZ, Some simplicial maps which reverse the orientation of a few simplices:: - sage: # needs sage.modules sage: g = {0:1, 1:2, 2:0} sage: H(g).associated_chain_complex_morphism()._matrix_dictionary {0: [0 0 1] @@ -628,13 +625,13 @@ def mapping_torus(self): sage: C = simplicial_complexes.Sphere(1) # Circle sage: T = Hom(C,C).identity().mapping_torus() ; T # Torus Simplicial complex with 9 vertices and 18 facets - sage: T.homology() == simplicial_complexes.Torus().homology() # needs sage.modules + sage: T.homology() == simplicial_complexes.Torus().homology() True sage: f = Hom(C,C)({0:0, 1:2, 2:1}) sage: K = f.mapping_torus(); K # Klein Bottle Simplicial complex with 9 vertices and 18 facets - sage: K.homology() == simplicial_complexes.KleinBottle().homology() # needs sage.modules + sage: K.homology() == simplicial_complexes.KleinBottle().homology() True TESTS:: @@ -675,7 +672,7 @@ def induced_homology_morphism(self, base_ring=None, cohomology=False): sage: T = S.product(S, immutable=True) sage: H = Hom(S,T) sage: diag = H.diagonal_morphism() - sage: h = diag.induced_homology_morphism(QQ); h # needs sage.modules + sage: h = diag.induced_homology_morphism(QQ); h Graded vector space morphism: From: Homology module of Minimal triangulation of the 1-sphere over Rational Field @@ -691,12 +688,12 @@ def induced_homology_morphism(self, base_ring=None, cohomology=False): We can view the matrix form for the homomorphism:: - sage: h.to_matrix(0) # in degree 0 # needs sage.modules + sage: h.to_matrix(0) # in degree 0 [1] - sage: h.to_matrix(1) # in degree 1 # needs sage.modules + sage: h.to_matrix(1) # in degree 1 [1] [1] - sage: h.to_matrix() # the entire homomorphism # needs sage.modules + sage: h.to_matrix() # the entire homomorphism [1|0] [-+-] [0|1] @@ -706,18 +703,18 @@ def induced_homology_morphism(self, base_ring=None, cohomology=False): The map on cohomology should be dual to the map on homology:: - sage: coh = diag.induced_homology_morphism(QQ, cohomology=True) # needs sage.modules - sage: coh.to_matrix(1) # needs sage.modules + sage: coh = diag.induced_homology_morphism(QQ, cohomology=True) + sage: coh.to_matrix(1) [1 1] - sage: h.to_matrix() == coh.to_matrix().transpose() # needs sage.modules + sage: h.to_matrix() == coh.to_matrix().transpose() True We can evaluate the map on (co)homology classes:: - sage: x,y = list(T.cohomology_ring(QQ).basis(1)) # needs sage.modules - sage: coh(x) # needs sage.modules + sage: x,y = list(T.cohomology_ring(QQ).basis(1)) + sage: coh(x) h^{1,0} - sage: coh(2*x + 3*y) # needs sage.modules + sage: coh(2*x + 3*y) 5*h^{1,0} Note that the complexes must be immutable for this to @@ -731,13 +728,13 @@ def induced_homology_morphism(self, base_ring=None, cohomology=False): sage: S2 = S.suspension() sage: S2.is_immutable() False - sage: h = Hom(S, S2)({0: 0, 1: 1, 2: 2}).induced_homology_morphism() # needs sage.modules + sage: h = Hom(S, S2)({0: 0, 1: 1, 2: 2}).induced_homology_morphism() Traceback (most recent call last): ... ValueError: the domain and codomain complexes must be immutable sage: S2.set_immutable(); S2.is_immutable() True - sage: h = Hom(S, S2)({0: 0, 1: 1, 2: 2}).induced_homology_morphism() # needs sage.modules + sage: h = Hom(S, S2)({0: 0, 1: 1, 2: 2}).induced_homology_morphism() """ from sage.homology.homology_morphism import InducedHomologyMorphism return InducedHomologyMorphism(self, base_ring, cohomology) diff --git a/src/sage/topology/simplicial_set.py b/src/sage/topology/simplicial_set.py index c4efc80ad60..36a31aac0ed 100644 --- a/src/sage/topology/simplicial_set.py +++ b/src/sage/topology/simplicial_set.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Simplicial sets @@ -41,7 +40,7 @@ sage: simplicial_sets.Torus() Torus - sage: simplicial_sets.RealProjectiveSpace(7) # needs sage.groups + sage: simplicial_sets.RealProjectiveSpace(7) RP^7 sage: S5 = simplicial_sets.Sphere(5); S5 S^5 @@ -51,14 +50,14 @@ One class of infinite simplicial sets is available: classifying spaces of groups, or more generally, nerves of finite monoids:: - sage: Sigma4 = groups.permutation.Symmetric(4) # needs sage.groups - sage: Sigma4.nerve() # needs sage.groups + sage: Sigma4 = groups.permutation.Symmetric(4) + sage: Sigma4.nerve() Nerve of Symmetric group of order 4! as a permutation group The same simplicial set (albeit with a different name) can also be constructed as :: - sage: simplicial_sets.ClassifyingSpace(Sigma4) # needs sage.groups + sage: simplicial_sets.ClassifyingSpace(Sigma4) Classifying space of Symmetric group of order 4! as a permutation group Type ``simplicial_sets.`` and hit the :kbd:`Tab` key to get a full list @@ -166,10 +165,9 @@ sage: S1 = simplicial_sets.Sphere(1) sage: eight = S1.wedge(S1) - sage: eight.fundamental_group() # needs sage.groups + sage: eight.fundamental_group() Finitely presented group < e0, e1 | > - sage: # needs sage.groups sage: Sigma3 = groups.permutation.Symmetric(3) sage: BSigma3 = Sigma3.nerve() sage: pi = BSigma3.fundamental_group(); pi @@ -179,8 +177,8 @@ sage: pi.is_abelian() False - sage: RP6 = simplicial_sets.RealProjectiveSpace(6) # needs sage.groups - sage: RP6.homology(reduced=False, base_ring=GF(2)) # needs sage.groups sage.modules + sage: RP6 = simplicial_sets.RealProjectiveSpace(6) + sage: RP6.homology(reduced=False, base_ring=GF(2)) {0: Vector space of dimension 1 over Finite Field of size 2, 1: Vector space of dimension 1 over Finite Field of size 2, 2: Vector space of dimension 1 over Finite Field of size 2, @@ -188,7 +186,7 @@ 4: Vector space of dimension 1 over Finite Field of size 2, 5: Vector space of dimension 1 over Finite Field of size 2, 6: Vector space of dimension 1 over Finite Field of size 2} - sage: RP6.homology(reduced=False, base_ring=QQ) # needs sage.groups sage.modules + sage: RP6.homology(reduced=False, base_ring=QQ) {0: Vector space of dimension 1 over Rational Field, 1: Vector space of dimension 0 over Rational Field, 2: Vector space of dimension 0 over Rational Field, @@ -201,20 +199,19 @@ by taking an `n`-skeleton for an appropriate `n`, either implicitly or explicitly:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([3]) sage: B3 = simplicial_sets.ClassifyingSpace(G) sage: B3.disjoint_union(B3).n_skeleton(3) Disjoint union: (Simplicial set with 15 non-degenerate simplices u Simplicial set with 15 non-degenerate simplices) sage: S1 = simplicial_sets.Sphere(1) - sage: B3.product(S1).homology(range(4)) # needs sage.modules + sage: B3.product(S1).homology(range(4)) {0: 0, 1: Z x C3, 2: C3, 3: C3} Without the ``range`` argument, this would raise an error, since ``B3`` is infinite:: - sage: B3.product(S1).homology() # needs sage.groups sage.modules + sage: B3.product(S1).homology() Traceback (most recent call last): ... NotImplementedError: this simplicial set may be infinite, @@ -236,7 +233,7 @@ ending at `w`. Therefore the first homology group of `X` should be a copy of the integers:: - sage: X.homology(1) # needs sage.modules + sage: X.homology(1) Z """ # **************************************************************************** @@ -821,7 +818,6 @@ def __deepcopy__(self, memo): The purpose for this method is to be able to make distinct copies of simplicial sets:: - sage: # needs sage.groups sage: from sage.topology.simplicial_set import SimplicialSet sage: RP3 = simplicial_sets.RealProjectiveSpace(3) sage: dict(copy.copy(RP3._data)) == dict(RP3._data) @@ -1156,7 +1152,6 @@ def faces(self, simplex): sage: S2.faces(sigma.apply_degeneracies(0)) [sigma_2, sigma_2, s_1 s_0 v_0, s_1 s_0 v_0] - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: BC3 = simplicial_sets.ClassifyingSpace(C3) sage: f2 = BC3.n_cells(1)[1]; f2 @@ -1361,7 +1356,6 @@ def nondegenerate_simplices(self, max_dim=None): Test an infinite example:: - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: BC3 = simplicial_sets.ClassifyingSpace(C3) sage: BC3.nondegenerate_simplices(2) @@ -1426,7 +1420,6 @@ def cells(self, subcomplex=None, max_dim=None): Test an infinite example:: - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: BC3 = simplicial_sets.ClassifyingSpace(C3) sage: BC3.cells(max_dim=2) @@ -1477,9 +1470,9 @@ def n_cells(self, n, subcomplex=None): [sigma_3] sage: simplicial_sets.Sphere(3).n_cells(2) [] - sage: C2 = groups.misc.MultiplicativeAbelian([2]) # needs sage.groups - sage: BC2 = C2.nerve() # needs sage.groups - sage: BC2.n_cells(3) # needs sage.groups + sage: C2 = groups.misc.MultiplicativeAbelian([2]) + sage: BC2 = C2.nerve() + sage: BC2.n_cells(3) [f * f * f] """ cells = self.cells(subcomplex=subcomplex, max_dim=n) @@ -1537,9 +1530,9 @@ def all_n_simplices(self, n): An example involving an infinite simplicial set:: - sage: C3 = groups.misc.MultiplicativeAbelian([3]) # needs sage.groups - sage: BC3 = simplicial_sets.ClassifyingSpace(C3) # needs sage.groups - sage: BC3.all_n_simplices(2) # needs sage.groups + sage: C3 = groups.misc.MultiplicativeAbelian([3]) + sage: BC3 = simplicial_sets.ClassifyingSpace(C3) + sage: BC3.all_n_simplices(2) [f * f, f * f^2, f^2 * f, @@ -1583,7 +1576,6 @@ def identity(self): Simplicial set endomorphism of S^3 Defn: Identity map - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: BC3 = simplicial_sets.ClassifyingSpace(C3) sage: one = BC3.identity() @@ -1625,8 +1617,8 @@ def constant_map(self, codomain=None, point=None): To: S^0 Defn: Constant map at v_0 - sage: Sigma3 = groups.permutation.Symmetric(3) # needs sage.groups - sage: Sigma3.nerve().constant_map() # needs sage.groups + sage: Sigma3 = groups.permutation.Symmetric(3) + sage: Sigma3.nerve().constant_map() Simplicial set morphism: From: Nerve of Symmetric group of order 3! as a permutation group To: Point @@ -1688,8 +1680,8 @@ def graph(self): sage: len(G.edges(sort=False)) 0 - sage: Sigma3 = groups.permutation.Symmetric(3) # needs sage.groups - sage: Sigma3.nerve().is_connected() # needs sage.groups + sage: Sigma3 = groups.permutation.Symmetric(3) + sage: Sigma3.nerve().is_connected() True """ from sage.graphs.graph import Graph @@ -1766,7 +1758,6 @@ def subsimplicial_set(self, simplices): A subsimplicial set knows about its ambient space and the inclusion map into it:: - sage: # needs sage.groups sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: M = RP4.n_skeleton(2); M Simplicial set with 3 non-degenerate simplices @@ -1780,7 +1771,6 @@ def subsimplicial_set(self, simplices): An infinite ambient simplicial set:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: BxB = B.product(B) @@ -1821,7 +1811,7 @@ def subsimplicial_set(self, simplices): sage: K = CP2.quotient(sub) sage: K.f_vector() [1, 0, 16, 30, 16] - sage: K.homology() # needs sage.modules + sage: K.homology() {0: 0, 1: 0, 2: Z, 3: 0, 4: Z} Try to construct a subcomplex from a simplicial complex which @@ -1921,17 +1911,17 @@ def chain_complex(self, dimensions=None, base_ring=ZZ, augmented=False, EXAMPLES:: - sage: simplicial_sets.Sphere(5).chain_complex() # needs sage.modules + sage: simplicial_sets.Sphere(5).chain_complex() Chain complex with at most 3 nonzero terms over Integer Ring - sage: C3 = groups.misc.MultiplicativeAbelian([3]) # needs sage.groups - sage: BC3 = simplicial_sets.ClassifyingSpace(C3) # needs sage.groups - sage: BC3.chain_complex(range(4), base_ring=GF(3)) # needs sage.groups sage.modules + sage: C3 = groups.misc.MultiplicativeAbelian([3]) + sage: BC3 = simplicial_sets.ClassifyingSpace(C3) + sage: BC3.chain_complex(range(4), base_ring=GF(3)) Chain complex with at most 4 nonzero terms over Finite Field of size 3 TESTS:: - sage: BC3.chain_complex() # needs sage.groups + sage: BC3.chain_complex() Traceback (most recent call last): ... NotImplementedError: this simplicial set may be infinite, so specify dimensions when computing its chain complex @@ -1977,35 +1967,34 @@ def homology(self, dim=None, **kwds): EXAMPLES:: - sage: simplicial_sets.Sphere(5).homology() # needs sage.modules + sage: simplicial_sets.Sphere(5).homology() {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: Z} - sage: C3 = groups.misc.MultiplicativeAbelian([3]) # needs sage.groups - sage: BC3 = simplicial_sets.ClassifyingSpace(C3) # needs sage.groups - sage: BC3.homology(range(4), base_ring=GF(3)) # needs sage.groups sage.modules + sage: C3 = groups.misc.MultiplicativeAbelian([3]) + sage: BC3 = simplicial_sets.ClassifyingSpace(C3) + sage: BC3.homology(range(4), base_ring=GF(3)) {0: Vector space of dimension 0 over Finite Field of size 3, 1: Vector space of dimension 1 over Finite Field of size 3, 2: Vector space of dimension 1 over Finite Field of size 3, 3: Vector space of dimension 1 over Finite Field of size 3} - sage: # needs sage.groups sage: C2 = groups.misc.MultiplicativeAbelian([2]) sage: BC2 = simplicial_sets.ClassifyingSpace(C2) sage: BK = BC2.product(BC2) - sage: BK.homology(range(4)) # needs sage.modules + sage: BK.homology(range(4)) {0: 0, 1: C2 x C2, 2: C2, 3: C2 x C2 x C2} TESTS:: sage: S3 = simplicial_sets.Sphere(3) - sage: S3.homology(0) # needs sage.modules + sage: S3.homology(0) 0 - sage: S3.homology((0,)) # needs sage.modules + sage: S3.homology((0,)) {0: 0} - sage: S3.homology(0, reduced=False) # needs sage.modules + sage: S3.homology(0, reduced=False) Z - sage: BC3.homology() # needs sage.groups sage.modules + sage: BC3.homology() Traceback (most recent call last): ... NotImplementedError: this simplicial set may be infinite, so specify dimensions when computing homology @@ -2060,18 +2049,18 @@ def cohomology(self, dim=None, **kwds): EXAMPLES:: - sage: simplicial_sets.KleinBottle().homology(1) # needs sage.modules + sage: simplicial_sets.KleinBottle().homology(1) Z x C2 - sage: simplicial_sets.KleinBottle().cohomology(1) # needs sage.modules + sage: simplicial_sets.KleinBottle().cohomology(1) Z - sage: simplicial_sets.KleinBottle().cohomology(2) # needs sage.modules + sage: simplicial_sets.KleinBottle().cohomology(2) C2 TESTS:: - sage: C3 = groups.misc.MultiplicativeAbelian([3]) # needs sage.groups - sage: BC3 = simplicial_sets.ClassifyingSpace(C3) # needs sage.groups - sage: BC3.cohomology() # needs sage.groups + sage: C3 = groups.misc.MultiplicativeAbelian([3]) + sage: BC3 = simplicial_sets.ClassifyingSpace(C3) + sage: BC3.cohomology() Traceback (most recent call last): ... NotImplementedError: this simplicial set may be infinite, @@ -2108,12 +2097,12 @@ def betti(self, dim=None, subcomplex=None): Build the two-sphere as a three-fold join of a two-point space with itself:: - sage: simplicial_sets.Sphere(5).betti() # needs sage.modules + sage: simplicial_sets.Sphere(5).betti() {0: 1, 1: 0, 2: 0, 3: 0, 4: 0, 5: 1} - sage: C3 = groups.misc.MultiplicativeAbelian([3]) # needs sage.groups - sage: BC3 = simplicial_sets.ClassifyingSpace(C3) # needs sage.groups - sage: BC3.betti(range(4)) # needs sage.groups sage.modules + sage: C3 = groups.misc.MultiplicativeAbelian([3]) + sage: BC3 = simplicial_sets.ClassifyingSpace(C3) + sage: BC3.betti(range(4)) {0: 1, 1: 0, 2: 0, 3: 0} """ dic = {} @@ -2151,16 +2140,15 @@ def n_chains(self, n, base_ring=ZZ, cochains=False): EXAMPLES:: sage: S3 = simplicial_sets.Sphere(3) - sage: C = S3.n_chains(3, cochains=True) # needs sage.modules - sage: list(C.basis()) # needs sage.modules + sage: C = S3.n_chains(3, cochains=True) + sage: list(C.basis()) [\chi_sigma_3] - sage: # needs sage.groups sage: Sigma3 = groups.permutation.Symmetric(3) sage: BSigma3 = simplicial_sets.ClassifyingSpace(Sigma3) - sage: list(BSigma3.n_chains(1).basis()) # needs sage.modules + sage: list(BSigma3.n_chains(1).basis()) [(1,2), (1,2,3), (1,3), (1,3,2), (2,3)] - sage: list(BSigma3.n_chains(1, cochains=True).basis()) # needs sage.modules + sage: list(BSigma3.n_chains(1, cochains=True).basis()) [\chi_(1,2), \chi_(1,2,3), \chi_(1,3), \chi_(1,3,2), \chi_(2,3)] """ if self.is_finite(): @@ -2210,14 +2198,14 @@ def quotient(self, subcomplex, vertex_name='*'): sage: Y = X.quotient([f]) sage: Y.nondegenerate_simplices() [*, e] - sage: Y.homology(1) # needs sage.modules + sage: Y.homology(1) Z sage: E = SimplicialSet({e: (v, w)}) sage: Z = E.quotient([v, w]) sage: Z.nondegenerate_simplices() [*, e] - sage: Z.homology(1) # needs sage.modules + sage: Z.homology(1) Z sage: F = E.quotient([v]) @@ -2226,11 +2214,10 @@ def quotient(self, subcomplex, vertex_name='*'): sage: F.base_point() * - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: RP2 = RP5.n_skeleton(2) sage: RP5_2 = RP5.quotient(RP2) - sage: RP5_2.homology(base_ring=GF(2)) # needs sage.modules + sage: RP5_2.homology(base_ring=GF(2)) {0: Vector space of dimension 0 over Finite Field of size 2, 1: Vector space of dimension 0 over Finite Field of size 2, 2: Vector space of dimension 0 over Finite Field of size 2, @@ -2270,9 +2257,9 @@ def quotient(self, subcomplex, vertex_name='*'): TESTS:: - sage: pt = RP5.quotient(RP5.n_skeleton(5)); pt # needs sage.groups + sage: pt = RP5.quotient(RP5.n_skeleton(5)); pt Quotient: (RP^5/RP^5) - sage: len(pt.nondegenerate_simplices()) # needs sage.groups + sage: len(pt.nondegenerate_simplices()) 1 """ from .simplicial_set_constructions import SubSimplicialSet @@ -2459,7 +2446,7 @@ def product(self, *others): sage: S1 = simplicial_sets.Sphere(1) sage: T = S1.product(S1) - sage: T.homology(reduced=False) # needs sage.modules + sage: T.homology(reduced=False) {0: Z, 1: Z x Z, 2: Z} Since ``S1`` is pointed, so is ``T``:: @@ -2476,7 +2463,7 @@ def product(self, *others): sage: S2 = simplicial_sets.Sphere(2) sage: S3 = simplicial_sets.Sphere(3) sage: S2xS3 = S2.product(S3) - sage: S2xS3.homology(reduced=False) # needs sage.modules + sage: S2xS3.homology(reduced=False) {0: Z, 1: 0, 2: Z, 3: Z, 4: 0, 5: Z} sage: S2xS3.factors() == (S2, S3) @@ -2484,7 +2471,6 @@ def product(self, *others): sage: S2xS3.factors() == (S3, S2) False - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: B.rename('RP^oo') @@ -2502,7 +2488,7 @@ def product(self, *others): From: S^2 x S^3 To: S^2 Defn: ... - sage: S2xS3.wedge_as_subset().homology() # needs sage.modules + sage: S2xS3.wedge_as_subset().homology() {0: 0, 1: 0, 2: Z, 3: Z} In the case of pointed simplicial sets, there is an inclusion @@ -2583,7 +2569,7 @@ def pushout(self, *maps): (0, 1, 2, 3), (0, 1, 2, 4), (0, 1, 3, 4), (0, 2, 3, 4), (1, 2, 3, 4)] sage: len(S4.nondegenerate_simplices()) 2 - sage: S4.homology(4) # needs sage.modules + sage: S4.homology(4) Z The associated maps:: @@ -2676,7 +2662,7 @@ def pullback(self, *maps): sage: S2 = simplicial_sets.Sphere(2) sage: pt = simplicial_sets.Point() sage: P = pt.pullback(S2.constant_map(), S2.constant_map()) - sage: P.homology(2) # needs sage.modules + sage: P.homology(2) Z x Z If the pullback is defined via maps `f_i: X_i \to Y`, then @@ -2687,7 +2673,7 @@ def pullback(self, *maps): sage: S2 = simplicial_sets.Sphere(2) sage: one = S2.Hom(S2).identity() sage: P = S2.pullback(one, one) - sage: P.homology() # needs sage.modules + sage: P.homology() {0: 0, 1: 0, 2: Z} sage: P.defining_map(0) == one @@ -2772,10 +2758,10 @@ def wedge(self, *others): sage: W = X.wedge(Y) sage: W.nondegenerate_simplices() [*, e, f] - sage: W.homology() # needs sage.modules + sage: W.homology() {0: 0, 1: Z x Z} sage: S2 = simplicial_sets.Sphere(2) - sage: X.wedge(S2).homology(reduced=False) # needs sage.modules + sage: X.wedge(S2).homology(reduced=False) {0: Z, 1: Z, 2: Z} sage: X.wedge(X).nondegenerate_simplices() [*, e, e] @@ -2896,7 +2882,6 @@ def suspension(self, n=1): EXAMPLES:: - sage: # needs sage.groups sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: S1 = simplicial_sets.Sphere(1) sage: SigmaRP4 = RP4.suspension() @@ -2908,14 +2893,14 @@ def suspension(self, n=1): typically less efficient than the reduced suspension produced here:: - sage: SigmaRP4.f_vector() # needs sage.groups + sage: SigmaRP4.f_vector() [1, 0, 1, 1, 1, 1] - sage: S1_smash_RP4.f_vector() # needs sage.groups + sage: S1_smash_RP4.f_vector() [1, 1, 4, 6, 8, 5] TESTS:: - sage: RP4.suspension(-3) # needs sage.groups + sage: RP4.suspension(-3) Traceback (most recent call last): ... ValueError: n must be nonnegative @@ -3246,7 +3231,7 @@ def __init__(self, data, base_point=None, name=None, check=True, sage: skip = ["_test_pickling", "_test_elements"] sage: TestSuite(S1).run(skip=skip) sage: TestSuite(simplicial_sets.Sphere(5)).run(skip=skip) - sage: TestSuite(simplicial_sets.RealProjectiveSpace(6)).run(skip=skip) # needs sage.groups + sage: TestSuite(simplicial_sets.RealProjectiveSpace(6)).run(skip=skip) """ def face(sigma, i): """ @@ -3459,7 +3444,7 @@ def __copy__(self): False sage: T.n_cells(0)[0] == copy(T).n_cells(0)[0] False - sage: T.homology() == copy(T).homology() # needs sage.modules + sage: T.homology() == copy(T).homology() True """ return SimplicialSet(dict(copy.deepcopy(self._data))) @@ -3579,7 +3564,7 @@ def euler_characteristic(self): EXAMPLES:: - sage: simplicial_sets.RealProjectiveSpace(4).euler_characteristic() # needs sage.groups + sage: simplicial_sets.RealProjectiveSpace(4).euler_characteristic() 1 sage: simplicial_sets.Sphere(6).euler_characteristic() 2 @@ -3627,7 +3612,6 @@ def chain_complex(self, dimensions=None, base_ring=ZZ, augmented=False, EXAMPLES:: - sage: # needs sage.modules sage: from sage.topology.simplicial_set import AbstractSimplex, SimplicialSet sage: v = AbstractSimplex(0) sage: degen = v.apply_degeneracies(1, 0) # s_1 s_0 applied to v @@ -3640,9 +3624,9 @@ def chain_complex(self, dimensions=None, base_ring=ZZ, augmented=False, sage: S3.chain_complex(dimensions=range(3), base_ring=QQ).homology() {0: Vector space of dimension 1 over Rational Field} - sage: RP5 = simplicial_sets.RealProjectiveSpace(5) # needs sage.groups - sage: RP2 = RP5.n_skeleton(2) # needs sage.groups - sage: RP5.chain_complex(subcomplex=RP2).homology() # needs sage.groups sage.modules + sage: RP5 = simplicial_sets.RealProjectiveSpace(5) + sage: RP2 = RP5.n_skeleton(2) + sage: RP5.chain_complex(subcomplex=RP2).homology() {0: Z, 3: C2, 4: 0, 5: Z} TESTS: @@ -3650,7 +3634,6 @@ def chain_complex(self, dimensions=None, base_ring=ZZ, augmented=False, Convert some simplicial complexes and `\Delta`-complexes to simplicial sets, and compare homology calculations:: - sage: # needs sage.modules sage: T = simplicial_complexes.Torus() sage: T.homology() == SimplicialSet(T).homology() True @@ -3796,16 +3779,16 @@ def algebraic_topological_model(self, base_ring=None): EXAMPLES:: - sage: RP2 = simplicial_sets.RealProjectiveSpace(2) # needs sage.groups - sage: phi, M = RP2.algebraic_topological_model(GF(2)) # needs sage.groups - sage: M.homology() # needs sage.groups sage.modules + sage: RP2 = simplicial_sets.RealProjectiveSpace(2) + sage: phi, M = RP2.algebraic_topological_model(GF(2)) + sage: M.homology() {0: Vector space of dimension 1 over Finite Field of size 2, 1: Vector space of dimension 1 over Finite Field of size 2, 2: Vector space of dimension 1 over Finite Field of size 2} sage: T = simplicial_sets.Torus() - sage: phi, M = T.algebraic_topological_model(QQ) # needs sage.modules - sage: M.homology() # needs sage.modules + sage: phi, M = T.algebraic_topological_model(QQ) + sage: M.homology() {0: Vector space of dimension 1 over Rational Field, 1: Vector space of dimension 2 over Rational Field, 2: Vector space of dimension 1 over Rational Field} @@ -4066,18 +4049,18 @@ def shrink_simplicial_complex(K): 13 non-degenerate simplices) sage: S2.f_vector() [1, 0, 1] - sage: S2.homology() # needs sage.modules + sage: S2.homology() {0: 0, 1: 0, 2: Z} sage: Z = simplicial_complexes.SurfaceOfGenus(3) sage: Z.f_vector() [1, 15, 57, 38] - sage: Z.homology() # needs sage.modules + sage: Z.homology() {0: 0, 1: Z^6, 2: Z} sage: M = shrink_simplicial_complex(Z) sage: M.f_vector() # random [1, 32, 27] - sage: M.homology() # needs sage.modules + sage: M.homology() {0: 0, 1: Z^6, 2: Z} """ L = K._contractible_subcomplex() diff --git a/src/sage/topology/simplicial_set_catalog.py b/src/sage/topology/simplicial_set_catalog.py index 0269c8f6628..d20df19e4a1 100644 --- a/src/sage/topology/simplicial_set_catalog.py +++ b/src/sage/topology/simplicial_set_catalog.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Catalog of simplicial sets @@ -35,14 +34,14 @@ EXAMPLES:: - sage: RP10 = simplicial_sets.RealProjectiveSpace(8) # needs sage.groups - sage: RP10.homology() # needs sage.groups sage.modules + sage: RP10 = simplicial_sets.RealProjectiveSpace(8) + sage: RP10.homology() {0: 0, 1: C2, 2: 0, 3: C2, 4: 0, 5: C2, 6: 0, 7: C2, 8: 0} sage: eta = simplicial_sets.HopfMap() sage: S3 = eta.domain() sage: S2 = eta.codomain() - sage: S3.wedge(S2).homology() # needs sage.modules + sage: S3.wedge(S2).homology() {0: 0, 1: 0, 2: Z, 3: Z} """ diff --git a/src/sage/topology/simplicial_set_constructions.py b/src/sage/topology/simplicial_set_constructions.py index 1053628023e..7463c22db9d 100644 --- a/src/sage/topology/simplicial_set_constructions.py +++ b/src/sage/topology/simplicial_set_constructions.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Methods of constructing simplicial sets @@ -191,9 +190,9 @@ def inclusion_map(self): EXAMPLES:: - sage: RP6 = simplicial_sets.RealProjectiveSpace(6) # needs sage.groups - sage: K = RP6.n_skeleton(2) # needs sage.groups - sage: K.inclusion_map() # needs sage.groups + sage: RP6 = simplicial_sets.RealProjectiveSpace(6) + sage: K = RP6.n_skeleton(2) + sage: K.inclusion_map() Simplicial set morphism: From: Simplicial set with 3 non-degenerate simplices To: RP^6 @@ -202,7 +201,7 @@ def inclusion_map(self): `RP^6` itself is constructed as a subsimplicial set of `RP^\infty`:: - sage: latex(RP6.inclusion_map()) # needs sage.groups + sage: latex(RP6.inclusion_map()) RP^{6} \to RP^{\infty} """ return self._inclusion @@ -217,7 +216,7 @@ def ambient_space(self): sage: eight = T.wedge_as_subset() sage: eight Simplicial set with 3 non-degenerate simplices - sage: eight.fundamental_group() # needs sage.groups + sage: eight.fundamental_group() Finitely presented group < e0, e1 | > sage: eight.ambient_space() Torus @@ -267,11 +266,10 @@ def __init__(self, maps=None): base point map gives a simplicial set isomorphic to the original subcomplex:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: K = RP5.quotient(RP5.n_skeleton(2)) sage: X = K.pullback(K.quotient_map(), K.base_point_map()) - sage: X.homology() == RP5.n_skeleton(2).homology() # needs sage.modules + sage: X.homology() == RP5.n_skeleton(2).homology() True Pullbacks of identity maps:: @@ -279,7 +277,7 @@ def __init__(self, maps=None): sage: S2 = simplicial_sets.Sphere(2) sage: one = S2.Hom(S2).identity() sage: P = S2.pullback(one, one) - sage: P.homology() # needs sage.modules + sage: P.homology() {0: 0, 1: 0, 2: Z} The pullback is constructed in terms of the product -- of @@ -320,7 +318,6 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: one = Hom(B,B).identity() @@ -332,7 +329,7 @@ def n_skeleton(self, n): Defn: Identity map Simplicial set endomorphism of Simplicial set with 3 non-degenerate simplices Defn: Constant map at 1 - sage: P.n_skeleton(3).homology() # needs sage.modules + sage: P.n_skeleton(3).homology() {0: 0, 1: C2, 2: 0, 3: Z} """ if self.is_finite(): @@ -365,7 +362,6 @@ def defining_map(self, i): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: K = RP5.quotient(RP5.n_skeleton(2)) sage: Y = K.pullback(K.quotient_map(), K.base_point_map()) @@ -448,7 +444,6 @@ def __init__(self, maps=None): sage: S2.pullback(eta, c).is_finite() True - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: one = Hom(B,B).identity() @@ -620,7 +615,6 @@ def structure_map(self, i): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: K = RP5.quotient(RP5.n_skeleton(2)) sage: Y = K.pullback(K.quotient_map(), K.base_point_map()) @@ -643,7 +637,7 @@ def structure_map(self, i): These maps are also accessible via :meth:`projection_map`:: - sage: Y.projection_map(1).codomain() # needs sage.groups + sage: Y.projection_map(1).codomain() Point """ if len(self._maps) == 1: @@ -751,7 +745,6 @@ def factor(self, i): sage: K.factor(0) S^2 - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: X = B.wedge(S3, B) @@ -828,7 +821,7 @@ def __init__(self, factors=None): sage: S1 = simplicial_sets.Sphere(1) sage: T = S1.product(S1) - sage: T.homology(reduced=False) # needs sage.modules + sage: T.homology(reduced=False) {0: Z, 1: Z x Z, 2: Z} Since ``S1`` is pointed, so is ``T``:: @@ -845,12 +838,11 @@ def __init__(self, factors=None): sage: S2 = simplicial_sets.Sphere(2) sage: S3 = simplicial_sets.Sphere(3) sage: Z = S2.product(S3) - sage: Z.homology() # needs sage.modules + sage: Z.homology() {0: 0, 1: 0, 2: Z, 3: Z, 4: 0, 5: Z} Products involving infinite simplicial sets:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: B.rename('RP^oo') @@ -858,12 +850,12 @@ def __init__(self, factors=None): RP^oo x RP^oo sage: X.n_cells(1) [(f, f), (f, s_0 1), (s_0 1, f)] - sage: X.homology(range(3), base_ring=GF(2)) # needs sage.modules + sage: X.homology(range(3), base_ring=GF(2)) {0: Vector space of dimension 0 over Finite Field of size 2, 1: Vector space of dimension 2 over Finite Field of size 2, 2: Vector space of dimension 3 over Finite Field of size 2} sage: Y = B.product(S2) - sage: Y.homology(range(5), base_ring=GF(2)) # needs sage.modules + sage: Y.homology(range(5), base_ring=GF(2)) {0: Vector space of dimension 0 over Finite Field of size 2, 1: Vector space of dimension 1 over Finite Field of size 2, 2: Vector space of dimension 2 over Finite Field of size 2, @@ -896,7 +888,6 @@ def n_skeleton(self, n): sage: S2.product(S3).n_skeleton(2) Simplicial set with 2 non-degenerate simplices - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: X = B.product(B) @@ -946,7 +937,7 @@ def factor(self, i, as_subset=False): sage: K.factor(0, as_subset=True) Simplicial set with 2 non-degenerate simplices - sage: K.factor(0, as_subset=True).homology() # needs sage.modules + sage: K.factor(0, as_subset=True).homology() {0: 0, 1: 0, 2: Z} sage: K.factor(0) is S2 @@ -978,11 +969,11 @@ def _repr_(self): sage: S2 = simplicial_sets.Sphere(2) sage: K = simplicial_sets.KleinBottle() - sage: G = groups.misc.MultiplicativeAbelian([2]) # needs sage.groups - sage: B = simplicial_sets.ClassifyingSpace(G) # needs sage.groups + sage: G = groups.misc.MultiplicativeAbelian([2]) + sage: B = simplicial_sets.ClassifyingSpace(G) sage: S2.product(S2) S^2 x S^2 - sage: S2.product(K, B) # needs sage.groups + sage: S2.product(K, B) S^2 x Klein bottle x Classifying space of Multiplicative Abelian group isomorphic to C2 """ return ' x '.join(str(X) for X in self._factors) @@ -996,8 +987,8 @@ def _latex_(self): sage: S2 = simplicial_sets.Sphere(2) sage: latex(S2.product(S2)) S^{2} \times S^{2} - sage: RPoo = simplicial_sets.RealProjectiveSpace(Infinity) # needs sage.groups - sage: latex(S2.product(RPoo, S2)) # needs sage.groups + sage: RPoo = simplicial_sets.RealProjectiveSpace(Infinity) + sage: latex(S2.product(RPoo, S2)) S^{2} \times RP^{\infty} \times S^{2} """ return ' \\times '.join(latex(X) for X in self._factors) @@ -1026,7 +1017,7 @@ def __init__(self, factors=None): sage: e = AbstractSimplex(1) sage: X = SimplicialSet({e: (v, v)}) sage: W = X.product(X, X) - sage: W.homology() # needs sage.groups + sage: W.homology() {0: 0, 1: Z x Z x Z, 2: Z x Z x Z, 3: Z} sage: W.is_pointed() False @@ -1059,7 +1050,6 @@ def projection_map(self, i): sage: f_0 = T.projection_map(0) sage: f_1 = T.projection_map(1) - sage: # needs sage.modules sage: m_0 = f_0.induced_homology_morphism().to_matrix(1) # matrix in dim 1 sage: m_1 = f_1.induced_homology_morphism().to_matrix(1) sage: m_0.rank() @@ -1089,7 +1079,7 @@ def wedge_as_subset(self): sage: W = P.wedge_as_subset() sage: W.nondegenerate_simplices() [(v, w), (e, s_0 w), (s_0 v, f)] - sage: W.homology() # needs sage.modules + sage: W.homology() {0: 0, 1: Z x Z} """ basept_factors = [sset.base_point() for sset in self.factors()] @@ -1121,7 +1111,7 @@ def fat_wedge_as_subset(self): sage: S1 = simplicial_sets.Sphere(1) sage: X = S1.product(S1, S1) sage: W = X.fat_wedge_as_subset() - sage: W.homology() # needs sage.modules + sage: W.homology() {0: 0, 1: Z x Z x Z, 2: Z x Z x Z} """ basept_factors = [sset.base_point() for sset in self.factors()] @@ -1243,7 +1233,7 @@ def __init__(self, maps=None, vertex_name=None): sage: CT = T.cone() sage: inc = CT.base_as_subset().inclusion_map() sage: P = T.pushout(inc, inc) - sage: P.homology() # needs sage.modules + sage: P.homology() {0: 0, 1: 0, 2: Z x Z, 3: Z} sage: len(P.nondegenerate_simplices()) 20 @@ -1266,7 +1256,7 @@ def __init__(self, maps=None, vertex_name=None): sage: bouquet = pt.pushout(S1.base_point_map(), ....: S1.base_point_map(), ....: S1.base_point_map()) - sage: bouquet.homology(1) # needs sage.modules + sage: bouquet.homology(1) Z x Z x Z """ # Import this here to prevent circular imports. @@ -1300,12 +1290,11 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: K = B.n_skeleton(3) sage: Q = K.pushout(K.inclusion_map(), K.constant_map()) - sage: Q.n_skeleton(5).homology() # needs sage.modules + sage: Q.n_skeleton(5).homology() {0: 0, 1: 0, 2: 0, 3: 0, 4: Z, 5: Z} Of course, computing the `n`-skeleton and then taking homology @@ -1313,7 +1302,7 @@ def n_skeleton(self, n): dimension `n`, since the latter computation will use the `(n+1)`-skeleton:: - sage: Q.homology(range(6)) # needs sage.groups sage.modules + sage: Q.homology(range(6)) {0: 0, 1: 0, 2: 0, 3: 0, 4: Z, 5: C2} """ if self.is_finite(): @@ -1709,7 +1698,6 @@ def __init__(self, inclusion, vertex_name='*'): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: RP2 = RP5.n_skeleton(2) sage: RP5_2 = RP5.quotient(RP2); RP5_2 @@ -1739,14 +1727,12 @@ def ambient(self): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: RP2 = RP5.n_skeleton(2) sage: RP5_2 = RP5.quotient(RP2) sage: RP5_2.ambient() RP^5 - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: K = B.n_skeleton(3) @@ -1764,14 +1750,12 @@ def subcomplex(self): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: RP2 = RP5.n_skeleton(2) sage: RP5_2 = RP5.quotient(RP2) sage: RP5_2.subcomplex() Simplicial set with 3 non-degenerate simplices - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: K = B.n_skeleton(3) @@ -1797,7 +1781,6 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: K = B.n_skeleton(3) @@ -1806,7 +1789,7 @@ def n_skeleton(self, n): Quotient: (Simplicial set with 7 non-degenerate simplices/Simplicial set with 4 non-degenerate simplices) - sage: Q.n_skeleton(6).homology() # needs sage.modules + sage: Q.n_skeleton(6).homology() {0: 0, 1: 0, 2: 0, 3: 0, 4: Z, 5: C2, 6: 0} """ if self.is_finite(): @@ -1845,7 +1828,6 @@ def _latex_(self): EXAMPLES:: - sage: # needs sage.groups sage: RPoo = simplicial_sets.RealProjectiveSpace(Infinity) sage: RP3 = RPoo.n_skeleton(3) sage: RP3.rename_latex('RP^{3}') @@ -1871,7 +1853,6 @@ def __init__(self, inclusion, vertex_name='*'): EXAMPLES:: - sage: # needs sage.groups sage: RP5 = simplicial_sets.RealProjectiveSpace(5) sage: RP2 = RP5.n_skeleton(2) sage: RP5_2 = RP5.quotient(RP2); RP5_2 @@ -1952,7 +1933,7 @@ def __init__(self, factors=None): sage: T = simplicial_sets.Torus() sage: S2 = simplicial_sets.Sphere(2) - sage: T.smash_product(S2).homology() == T.suspension(2).homology() # needs sage.modules + sage: T.smash_product(S2).homology() == T.suspension(2).homology() True """ if any(not space.is_pointed() for space in factors): @@ -1968,9 +1949,9 @@ def _repr_(self): EXAMPLES:: - sage: RP4 = simplicial_sets.RealProjectiveSpace(4) # needs sage.groups + sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: S1 = simplicial_sets.Sphere(1) - sage: S1.smash_product(RP4, S1) # needs sage.groups + sage: S1.smash_product(RP4, S1) Smash product: (S^1 ^ RP^4 ^ S^1) """ s = 'Smash product: (' @@ -1984,9 +1965,9 @@ def _latex_(self): EXAMPLES:: - sage: RP4 = simplicial_sets.RealProjectiveSpace(4) # needs sage.groups + sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: S1 = simplicial_sets.Sphere(1) - sage: latex(S1.smash_product(RP4, S1)) # needs sage.groups + sage: latex(S1.smash_product(RP4, S1)) S^{1} \wedge RP^{4} \wedge S^{1} """ return ' \\wedge '.join(latex(X) for X in self._factors) @@ -2031,7 +2012,7 @@ def __init__(self, factors=None): sage: CP2 = simplicial_sets.ComplexProjectiveSpace(2) sage: K = simplicial_sets.KleinBottle() sage: W = CP2.wedge(K) - sage: W.homology() # needs sage.modules + sage: W.homology() {0: 0, 1: Z x C2, 2: Z, 3: 0, 4: Z} sage: W.inclusion_map(1) @@ -2045,7 +2026,7 @@ def __init__(self, factors=None): Wedge: (CP^2 v Klein bottle) sage: W.projection_map(0).codomain() # copy of CP^2 Quotient: (Wedge: (CP^2 v Klein bottle)/Simplicial set with 6 non-degenerate simplices) - sage: W.projection_map(0).codomain().homology() # needs sage.modules + sage: W.projection_map(0).codomain().homology() {0: 0, 1: 0, 2: Z, 3: 0, 4: Z} An error occurs if any of the factors is not pointed:: @@ -2090,9 +2071,9 @@ def _latex_(self): EXAMPLES:: - sage: RP4 = simplicial_sets.RealProjectiveSpace(4) # needs sage.groups + sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: S1 = simplicial_sets.Sphere(1) - sage: latex(S1.wedge(RP4, S1)) # needs sage.groups + sage: latex(S1.wedge(RP4, S1)) S^{1} \vee RP^{4} \vee S^{1} """ return ' \\vee '.join(latex(X) for X in self._factors) @@ -2170,9 +2151,9 @@ def projection_map(self, i): To: Quotient: (Wedge: (S^1 v S^2 v S^1)/Simplicial set with 3 non-degenerate simplices) Defn: [*, sigma_1, sigma_1, sigma_2] --> [*, s_0 *, s_0 *, sigma_2] - sage: W.projection_map(1).image().homology(1) # needs sage.modules + sage: W.projection_map(1).image().homology(1) 0 - sage: W.projection_map(1).image().homology(2) # needs sage.modules + sage: W.projection_map(1).image().homology(2) Z """ m = len(self._factors) @@ -2222,7 +2203,7 @@ def __init__(self, factors=None): sage: CP2 = simplicial_sets.ComplexProjectiveSpace(2) sage: K = simplicial_sets.KleinBottle() sage: W = CP2.disjoint_union(K) - sage: W.homology() # needs sage.modules + sage: W.homology() {0: Z, 1: Z x C2, 2: Z, 3: 0, 4: Z} sage: W.inclusion_map(1) @@ -2254,12 +2235,11 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: T = simplicial_sets.Torus() sage: X = B.disjoint_union(T) - sage: X.n_skeleton(3).homology() # needs sage.modules + sage: X.n_skeleton(3).homology() {0: Z, 1: Z x Z x C2, 2: Z, 3: Z} """ if self.is_finite(): @@ -2285,8 +2265,8 @@ def _repr_(self): EXAMPLES:: sage: T = simplicial_sets.Torus() - sage: RP3 = simplicial_sets.RealProjectiveSpace(3) # needs sage.groups - sage: T.disjoint_union(T, RP3) # needs sage.groups + sage: RP3 = simplicial_sets.RealProjectiveSpace(3) + sage: T.disjoint_union(T, RP3) Disjoint union: (Torus u Torus u RP^3) """ s = 'Disjoint union: (' @@ -2300,9 +2280,9 @@ def _latex_(self): EXAMPLES:: - sage: RP4 = simplicial_sets.RealProjectiveSpace(4) # needs sage.groups + sage: RP4 = simplicial_sets.RealProjectiveSpace(4) sage: S1 = simplicial_sets.Sphere(1) - sage: latex(S1.disjoint_union(RP4, S1)) # needs sage.groups + sage: latex(S1.disjoint_union(RP4, S1)) S^{1} \amalg RP^{4} \amalg S^{1} """ return ' \\amalg '.join(latex(X) for X in self._factors) @@ -2417,12 +2397,11 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: X = B.disjoint_union(B) sage: CX = B.cone() - sage: CX.n_skeleton(3).homology() # needs sage.modules + sage: CX.n_skeleton(3).homology() {0: 0, 1: 0, 2: 0, 3: Z} """ if self.is_finite(): @@ -2525,7 +2504,6 @@ def base_as_subset(self): EXAMPLES:: - sage: # needs sage.groups sage: X = simplicial_sets.RealProjectiveSpace(4).unset_base_point() sage: Y = X.cone() sage: Y.base_as_subset() @@ -2611,9 +2589,9 @@ def n_skeleton(self, n): EXAMPLES:: - sage: G = groups.misc.MultiplicativeAbelian([2]) # needs sage.groups - sage: B = simplicial_sets.ClassifyingSpace(G) # needs sage.groups - sage: B.cone().n_skeleton(3).homology() # needs sage.groups sage.modules + sage: G = groups.misc.MultiplicativeAbelian([2]) + sage: B = simplicial_sets.ClassifyingSpace(G) + sage: B.cone().n_skeleton(3).homology() {0: 0, 1: 0, 2: 0, 3: Z} """ if self.is_finite(): @@ -2741,12 +2719,11 @@ def __init__(self, base): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: B.suspension() Sigma(Classifying space of Multiplicative Abelian group isomorphic to C2) - sage: B.suspension().n_skeleton(3).homology() # needs sage.modules + sage: B.suspension().n_skeleton(3).homology() {0: 0, 1: 0, 2: C2, 3: 0} If ``X`` is finite, the suspension comes with a quotient map @@ -2766,7 +2743,7 @@ def __init__(self, base): True sage: S3.suspension() == simplicial_sets.Sphere(3).suspension() False - sage: B.suspension() == B.suspension() # needs sage.groups + sage: B.suspension() == B.suspension() True """ Cat = SimplicialSets() @@ -2799,11 +2776,10 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: SigmaB = B.suspension() - sage: SigmaB.n_skeleton(4).homology(base_ring=GF(2)) # needs sage.modules + sage: SigmaB.n_skeleton(4).homology(base_ring=GF(2)) {0: Vector space of dimension 0 over Finite Field of size 2, 1: Vector space of dimension 0 over Finite Field of size 2, 2: Vector space of dimension 1 over Finite Field of size 2, diff --git a/src/sage/topology/simplicial_set_examples.py b/src/sage/topology/simplicial_set_examples.py index c0534917ead..3d2c91fee77 100644 --- a/src/sage/topology/simplicial_set_examples.py +++ b/src/sage/topology/simplicial_set_examples.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Examples of simplicial sets. @@ -109,7 +108,6 @@ def __eq__(self, other) -> bool: EXAMPLES:: - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: C3.nerve() == C3.nerve() False @@ -127,7 +125,6 @@ def __ne__(self, other) -> bool: EXAMPLES:: - sage: # needs sage.groups sage: C3 = groups.misc.MultiplicativeAbelian([3]) sage: G3 = groups.permutation.Cyclic(3) sage: C3.nerve() != G3.nerve() @@ -144,13 +141,12 @@ def __hash__(self): EXAMPLES:: - sage: G3 = groups.permutation.Cyclic(3) # needs sage.groups - sage: hash(G3.nerve()) # random # needs sage.groups + sage: G3 = groups.permutation.Cyclic(3) + sage: hash(G3.nerve()) # random 17 Different instances yield different base points, hence different hashes:: - sage: # needs sage.groups sage: X = G3.nerve() sage: Y = G3.nerve() sage: X.base_point() != Y.base_point() @@ -173,7 +169,6 @@ def n_skeleton(self, n): EXAMPLES:: - sage: # needs sage.groups sage: K4 = groups.misc.MultiplicativeAbelian([2,2]) sage: BK4 = simplicial_sets.ClassifyingSpace(K4) sage: BK4.n_skeleton(3) @@ -319,17 +314,16 @@ def ClassifyingSpace(group): EXAMPLES:: - sage: # needs sage.groups sage: C2 = groups.misc.MultiplicativeAbelian([2]) sage: BC2 = simplicial_sets.ClassifyingSpace(C2) - sage: H = BC2.homology(range(9), base_ring=GF(2)) # needs sage.modules - sage: [H[i].dimension() for i in range(9)] # needs sage.modules + sage: H = BC2.homology(range(9), base_ring=GF(2)) + sage: [H[i].dimension() for i in range(9)] [0, 1, 1, 1, 1, 1, 1, 1, 1] - sage: Klein4 = groups.misc.MultiplicativeAbelian([2, 2]) # needs sage.groups - sage: BK = simplicial_sets.ClassifyingSpace(Klein4); BK # needs sage.groups + sage: Klein4 = groups.misc.MultiplicativeAbelian([2, 2]) + sage: BK = simplicial_sets.ClassifyingSpace(Klein4); BK Classifying space of Multiplicative Abelian group isomorphic to C2 x C2 - sage: BK.homology(range(5), base_ring=GF(2)) # long time (1 second) # needs sage.groups sage.modules + sage: BK.homology(range(5), base_ring=GF(2)) # long time (1 second) {0: Vector space of dimension 0 over Finite Field of size 2, 1: Vector space of dimension 2 over Finite Field of size 2, 2: Vector space of dimension 3 over Finite Field of size 2, @@ -351,7 +345,6 @@ def RealProjectiveSpace(n): EXAMPLES:: - sage: # needs sage.groups sage: simplicial_sets.RealProjectiveSpace(7) RP^7 sage: RP5 = simplicial_sets.RealProjectiveSpace(5) @@ -362,8 +355,8 @@ def RealProjectiveSpace(n): sage: latex(RP5) RP^{5} - sage: BC2 = simplicial_sets.RealProjectiveSpace(Infinity) # needs sage.groups - sage: latex(BC2) # needs sage.groups + sage: BC2 = simplicial_sets.RealProjectiveSpace(Infinity) + sage: latex(BC2) RP^{\infty} """ if n == Infinity: @@ -391,7 +384,7 @@ def KleinBottle(): sage: K = simplicial_sets.KleinBottle() sage: K.f_vector() [1, 3, 2] - sage: K.homology(reduced=False) # needs sage.modules + sage: K.homology(reduced=False) {0: Z, 1: Z x C2, 2: 0} sage: K Klein bottle @@ -416,7 +409,7 @@ def Torus(): sage: T = simplicial_sets.Torus() sage: T.f_vector() [1, 3, 2] - sage: T.homology(reduced=False) # needs sage.modules + sage: T.homology(reduced=False) {0: Z, 1: Z x Z, 2: Z} """ S1 = Sphere(1) @@ -540,7 +533,7 @@ def ComplexProjectiveSpace(n): EXAMPLES:: - sage: simplicial_sets.ComplexProjectiveSpace(2).homology(reduced=False) # needs sage.modules + sage: simplicial_sets.ComplexProjectiveSpace(2).homology(reduced=False) {0: Z, 1: 0, 2: Z, 3: 0, 4: Z} sage: CP3 = simplicial_sets.ComplexProjectiveSpace(3); CP3 # needs pyparsing CP^3 @@ -742,7 +735,7 @@ def HopfMap(): sage: X = g.mapping_cone() sage: CP2 = simplicial_sets.ComplexProjectiveSpace(2) - sage: X.homology() == CP2.homology() # needs sage.modules + sage: X.homology() == CP2.homology() True sage: X.f_vector() @@ -819,7 +812,6 @@ def PresentationComplex(G): EXAMPLES:: - sage: # needs sage.groups sage: G = SymmetricGroup(2).as_finitely_presented_group(); G Finitely presented group < a | a^2 > sage: S = simplicial_sets.PresentationComplex(G); S @@ -835,7 +827,6 @@ def PresentationComplex(G): TESTS:: - sage: # needs sage.groups sage: S = simplicial_sets.PresentationComplex(FreeGroup(0) / []) sage: S Simplicial set with 1 non-degenerate simplex diff --git a/src/sage/topology/simplicial_set_morphism.py b/src/sage/topology/simplicial_set_morphism.py index 5befe2b469c..2f87bbd7ba7 100644 --- a/src/sage/topology/simplicial_set_morphism.py +++ b/src/sage/topology/simplicial_set_morphism.py @@ -1,4 +1,3 @@ -# sage.doctest: needs sage.graphs r""" Morphisms and homsets for simplicial sets @@ -105,8 +104,8 @@ def diagonal_morphism(self): EXAMPLES:: - sage: RP2 = simplicial_sets.RealProjectiveSpace(2) # needs sage.groups - sage: Hom(RP2, RP2.product(RP2)).diagonal_morphism() # needs sage.groups + sage: RP2 = simplicial_sets.RealProjectiveSpace(2) + sage: Hom(RP2, RP2.product(RP2)).diagonal_morphism() Simplicial set morphism: From: RP^2 To: RP^2 x RP^2 @@ -271,7 +270,7 @@ def __iter__(self): From: S^1 To: Torus Defn: Constant map at (v_0, v_0)] - sage: [f.induced_homology_morphism().to_matrix() for f in H] # needs sage.modules + sage: [f.induced_homology_morphism().to_matrix() for f in H] [ [ 1| 0] [1|0] [1|0] [1|0] [--+--] [-+-] [-+-] [-+-] @@ -622,9 +621,9 @@ def __call__(self, x): sage: one(e) == e True - sage: B = AbelianGroup([2]).nerve() # needs sage.groups - sage: c = B.constant_map() # needs sage.groups - sage: c(B.n_cells(2)[0]) # needs sage.groups + sage: B = AbelianGroup([2]).nerve() + sage: c = B.constant_map() + sage: c(B.n_cells(2)[0]) s_1 s_0 * """ if x not in self.domain(): @@ -669,7 +668,7 @@ def _composition_(self, right, homset): Defn: [v_0, sigma_1] --> [(v_0, v_0), (sigma_1, s_0 v_0)] sage: (g*f).image() Simplicial set with 2 non-degenerate simplices - sage: f.image().homology() # needs sage.modules + sage: f.image().homology() {0: 0, 1: Z} """ if self.is_identity(): @@ -699,10 +698,9 @@ def image(self): Defn: [v_0, sigma_1] --> [(v_0, v_0), (sigma_1, s_0 v_0)] sage: f.image() Simplicial set with 2 non-degenerate simplices - sage: f.image().homology() # needs sage.modules + sage: f.image().homology() {0: 0, 1: Z} - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: B.constant_map().image() @@ -747,16 +745,15 @@ def is_identity(self): True sage: (f*g).is_identity() False - sage: (f*g).induced_homology_morphism().to_matrix(1) # needs sage.modules + sage: (f*g).induced_homology_morphism().to_matrix(1) [0] - sage: RP5 = simplicial_sets.RealProjectiveSpace(5) # needs sage.groups - sage: RP5.n_skeleton(2).inclusion_map().is_identity() # needs sage.groups + sage: RP5 = simplicial_sets.RealProjectiveSpace(5) + sage: RP5.n_skeleton(2).inclusion_map().is_identity() False - sage: RP5.n_skeleton(5).inclusion_map().is_identity() # needs sage.groups + sage: RP5.n_skeleton(5).inclusion_map().is_identity() True - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: Hom(B,B).identity().is_identity() @@ -777,18 +774,18 @@ def is_surjective(self): EXAMPLES:: - sage: RP5 = simplicial_sets.RealProjectiveSpace(5) # needs sage.groups - sage: RP2 = RP5.n_skeleton(2) # needs sage.groups - sage: RP2.inclusion_map().is_surjective() # needs sage.groups + sage: RP5 = simplicial_sets.RealProjectiveSpace(5) + sage: RP2 = RP5.n_skeleton(2) + sage: RP2.inclusion_map().is_surjective() False - sage: RP5_2 = RP5.quotient(RP2) # needs sage.groups - sage: RP5_2.quotient_map().is_surjective() # needs sage.groups + sage: RP5_2 = RP5.quotient(RP2) + sage: RP5_2.quotient_map().is_surjective() True - sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) # needs sage.groups - sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) # needs sage.groups - sage: f.is_surjective() # needs sage.groups + sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) + sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) + sage: f.is_surjective() True """ return self._is_identity or self.image() == self.codomain() @@ -799,18 +796,18 @@ def is_injective(self): EXAMPLES:: - sage: RP5 = simplicial_sets.RealProjectiveSpace(5) # needs sage.groups - sage: RP2 = RP5.n_skeleton(2) # needs sage.groups - sage: RP2.inclusion_map().is_injective() # needs sage.groups + sage: RP5 = simplicial_sets.RealProjectiveSpace(5) + sage: RP2 = RP5.n_skeleton(2) + sage: RP2.inclusion_map().is_injective() True - sage: RP5_2 = RP5.quotient(RP2) # needs sage.groups - sage: RP5_2.quotient_map().is_injective() # needs sage.groups + sage: RP5_2 = RP5.quotient(RP2) + sage: RP5_2.quotient_map().is_injective() False - sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) # needs sage.groups - sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) # needs sage.groups - sage: f.is_injective() # needs sage.groups + sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) + sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) + sage: f.is_injective() True """ if self._is_identity: @@ -830,18 +827,18 @@ def is_bijective(self): EXAMPLES:: - sage: RP5 = simplicial_sets.RealProjectiveSpace(5) # needs sage.groups - sage: RP2 = RP5.n_skeleton(2) # needs sage.groups - sage: RP2.inclusion_map().is_bijective() # needs sage.groups + sage: RP5 = simplicial_sets.RealProjectiveSpace(5) + sage: RP2 = RP5.n_skeleton(2) + sage: RP2.inclusion_map().is_bijective() False - sage: RP5_2 = RP5.quotient(RP2) # needs sage.groups - sage: RP5_2.quotient_map().is_bijective() # needs sage.groups + sage: RP5_2 = RP5.quotient(RP2) + sage: RP5_2.quotient_map().is_bijective() False - sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) # needs sage.groups - sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) # needs sage.groups - sage: f.is_bijective() # needs sage.groups + sage: K = RP5_2.pullback(RP5_2.quotient_map(), RP5_2.base_point_map()) + sage: f = K.universal_property(RP2.inclusion_map(), RP2.constant_map()) + sage: f.is_bijective() True """ return self.is_injective() and self.is_surjective() @@ -1109,12 +1106,12 @@ def mapping_cone(self): To: S^1 Defn: [(0,), (1,), (2,), (0, 1), (0, 2), (1, 2)] --> [v_0, v_0, v_0, sigma_1, s_0 v_0, sigma_1] - sage: h.induced_homology_morphism().to_matrix() # needs sage.modules + sage: h.induced_homology_morphism().to_matrix() [1|0] [-+-] [0|2] sage: X = h.mapping_cone() - sage: X.homology() == simplicial_sets.RealProjectiveSpace(2).homology() # needs sage.groups sage.modules + sage: X.homology() == simplicial_sets.RealProjectiveSpace(2).homology() True """ dom = self.domain() @@ -1186,7 +1183,7 @@ def suspension(self, n=1): sage: eta = simplicial_sets.HopfMap() sage: mc_susp_eta = eta.suspension().mapping_cone() sage: susp_mc_eta = eta.mapping_cone().suspension() - sage: mc_susp_eta.homology() == susp_mc_eta.homology() # needs sage.modules + sage: mc_susp_eta.homology() == susp_mc_eta.homology() True This uses reduced suspensions if the original morphism is @@ -1256,7 +1253,6 @@ def n_skeleton(self, n, domain=None, codomain=None): EXAMPLES:: - sage: # needs sage.groups sage: G = groups.misc.MultiplicativeAbelian([2]) sage: B = simplicial_sets.ClassifyingSpace(G) sage: one = Hom(B,B).identity() @@ -1315,7 +1311,7 @@ def associated_chain_complex_morphism(self, base_ring=ZZ, sage: e = S1.n_cells(1)[0] sage: f = {v0: v0, e: v0.apply_degeneracies(0)} # constant map sage: g = Hom(S1, S1)(f) - sage: g.associated_chain_complex_morphism().to_matrix() # needs sage.modules + sage: g.associated_chain_complex_morphism().to_matrix() [1|0] [-+-] [0|0] @@ -1383,7 +1379,6 @@ def induced_homology_morphism(self, base_ring=None, cohomology=False): EXAMPLES:: - sage: # needs sage.modules sage: from sage.topology.simplicial_set import AbstractSimplex, SimplicialSet sage: v = AbstractSimplex(0, name='v') sage: w = AbstractSimplex(0, name='w')