Skip to content

Commit 7beacf0

Browse files
author
Release Manager
committed
gh-38170: `sage.categories`: Update `# needs`, modularization fixes (imports) <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> - In part cherry-picked from #35095. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38170 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents 1f0a3ad + bbc1a6f commit 7beacf0

10 files changed

+97
-81
lines changed

src/sage/categories/chain_complexes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def homology(self, n=None):
8181
::
8282
8383
sage: # needs sage.combinat sage.modules
84-
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3))
85-
sage: C = A.cdg_algebra({z: x*y})
84+
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.libs.singular
85+
sage: C = A.cdg_algebra({z: x*y}) # needs sage.libs.singular
8686
sage: C.homology(0)
8787
Free module generated by {[1]} over Rational Field
8888
sage: C.homology(1)
@@ -110,8 +110,8 @@ def differential(self, *args, **kwargs):
110110
111111
::
112112
113-
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.modules
114-
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.modules
113+
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.libs.singular sage.modules
114+
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.libs.singular sage.modules
115115
sage: C.differential() # needs sage.combinat sage.modules
116116
Differential of Commutative Differential Graded Algebra with
117117
generators ('x', 'y', 'z') in degrees (2, 2, 3) over Rational Field
@@ -183,8 +183,8 @@ class HomologyFunctor(Functor):
183183
184184
::
185185
186-
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.modules
187-
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.modules
186+
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.libs.singular sage.modules
187+
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.libs.singular sage.modules
188188
sage: H = HomologyFunctor(ChainComplexes(QQ), 2)
189189
sage: H(C) # needs sage.combinat sage.modules
190190
Free module generated by {[x], [y]} over Rational Field

src/sage/categories/examples/lie_algebras.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __classcall_private__(cls, gens):
7171
7272
EXAMPLES::
7373
74-
sage: # needs sage.combinat
74+
sage: # needs sage.combinat sage.groups
7575
sage: S3 = SymmetricGroupAlgebra(QQ, 3)
7676
sage: L1 = LieAlgebras(QQ).example()
7777
sage: gens = list(S3.algebra_generators())
@@ -85,8 +85,8 @@ def __init__(self, gens):
8585
"""
8686
EXAMPLES::
8787
88-
sage: L = LieAlgebras(QQ).example() # needs sage.combinat
89-
sage: TestSuite(L).run() # needs sage.combinat
88+
sage: L = LieAlgebras(QQ).example() # needs sage.combinat sage.groups
89+
sage: TestSuite(L).run() # needs sage.combinat sage.groups
9090
"""
9191
if not gens:
9292
raise ValueError("need at least one generator")

src/sage/categories/fields.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,31 @@ def __contains__(self, x):
9999
in other doctests, we introduced a strong reference to all previously created
100100
uncollected objects in :issue:`19244`. ::
101101
102+
sage: # needs sage.libs.pari
102103
sage: import gc
103104
sage: _ = gc.collect()
104-
sage: permstore = [X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
105+
sage: permstore = [X for X in gc.get_objects()
106+
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
105107
sage: n = len(permstore)
106-
sage: for i in prime_range(100): # needs sage.libs.pari
108+
sage: for i in prime_range(100):
107109
....: R = ZZ.quotient(i)
108110
....: t = R in Fields()
109111
110112
First, we show that there are now more quotient rings in cache than before::
111113
112-
sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) > n
114+
sage: # needs sage.libs.pari
115+
sage: len([X for X in gc.get_objects()
116+
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) > n
113117
True
114118
115119
When we delete the last quotient ring created in the loop and then do a garbage
116120
collection, all newly created rings vanish::
117121
122+
sage: # needs sage.libs.pari
118123
sage: del R
119124
sage: _ = gc.collect()
120-
sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) - n
125+
sage: len([X for X in gc.get_objects()
126+
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) - n
121127
0
122128
123129
"""
@@ -624,15 +630,15 @@ def gcd(self,other):
624630
For field of characteristic zero, the gcd of integers is considered
625631
as if they were elements of the integer ring::
626632
627-
sage: gcd(15.0,12.0)
633+
sage: gcd(15.0,12.0) # needs sage.rings.real_mpfr
628634
3.00000000000000
629635
630636
But for other floating point numbers, the gcd is just `0.0` or `1.0`::
631637
632-
sage: gcd(3.2, 2.18)
638+
sage: gcd(3.2, 2.18) # needs sage.rings.real_mpfr
633639
1.00000000000000
634640
635-
sage: gcd(0.0, 0.0)
641+
sage: gcd(0.0, 0.0) # needs sage.rings.real_mpfr
636642
0.000000000000000
637643
638644
AUTHOR:
@@ -678,15 +684,15 @@ def lcm(self, other):
678684
For field of characteristic zero, the lcm of integers is considered
679685
as if they were elements of the integer ring::
680686
681-
sage: lcm(15.0,12.0)
687+
sage: lcm(15.0, 12.0) # needs sage.rings.real_mpfr
682688
60.0000000000000
683689
684690
But for others floating point numbers, it is just `0.0` or `1.0`::
685691
686-
sage: lcm(3.2, 2.18)
692+
sage: lcm(3.2, 2.18) # needs sage.rings.real_mpfr
687693
1.00000000000000
688694
689-
sage: lcm(0.0, 0.0)
695+
sage: lcm(0.0, 0.0) # needs sage.rings.real_mpfr
690696
0.000000000000000
691697
692698
AUTHOR:
@@ -748,13 +754,13 @@ def xgcd(self, other):
748754
the result is a floating point version of the standard gcd on
749755
`\ZZ`::
750756
751-
sage: xgcd(12.0, 8.0)
757+
sage: xgcd(12.0, 8.0) # needs sage.rings.real_mpfr
752758
(4.00000000000000, 1.00000000000000, -1.00000000000000)
753759
754-
sage: xgcd(3.1, 2.98714)
760+
sage: xgcd(3.1, 2.98714) # needs sage.rings.real_mpfr
755761
(1.00000000000000, 0.322580645161290, 0.000000000000000)
756762
757-
sage: xgcd(0.0, 1.1)
763+
sage: xgcd(0.0, 1.1) # needs sage.rings.real_mpfr
758764
(1.00000000000000, 0.000000000000000, 0.909090909090909)
759765
"""
760766
P = self.parent()
@@ -787,7 +793,7 @@ def factor(self):
787793
sage: x = GF(7)(5)
788794
sage: x.factor()
789795
5
790-
sage: RR(0).factor()
796+
sage: RR(0).factor() # needs sage.rings.real_mpfr
791797
Traceback (most recent call last):
792798
...
793799
ArithmeticError: factorization of 0.000000000000000 is not defined

src/sage/categories/finite_dimensional_modules_with_basis.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ def _repr_matrix(self):
686686
687687
EXAMPLES::
688688
689+
sage: # needs sage.modules
689690
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
690691
....: column_keys=['a', 'b', 'c'],
691692
....: row_keys=['v', 'w']); M
@@ -714,6 +715,7 @@ def _ascii_art_matrix(self):
714715
715716
EXAMPLES::
716717
718+
sage: # needs sage.modules
717719
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
718720
....: column_keys=['a', 'b', 'c'],
719721
....: row_keys=['v', 'w']); M
@@ -745,6 +747,7 @@ def _unicode_art_matrix(self):
745747
746748
EXAMPLES::
747749
750+
sage: # needs sage.modules
748751
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
749752
....: column_keys=['a', 'b', 'c'],
750753
....: row_keys=['v', 'w']); M
@@ -910,6 +913,7 @@ def characteristic_polynomial(self):
910913
911914
EXAMPLES::
912915
916+
sage: # needs sage.modules
913917
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
914918
sage: phi.characteristic_polynomial()
915919
x^2 - 3*x + 2
@@ -919,7 +923,6 @@ def characteristic_polynomial(self):
919923
x^2 - 3*x + 2
920924
sage: phi.charpoly('T')
921925
T^2 - 3*T + 2
922-
923926
sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
924927
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
925928
sage: psi = W.module_morphism(matrix=M, codomain=W)
@@ -939,12 +942,12 @@ def determinant(self):
939942
940943
EXAMPLES::
941944
945+
sage: # needs sage.modules
942946
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
943947
sage: phi.determinant()
944948
2
945949
sage: phi.det()
946950
2
947-
948951
sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
949952
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
950953
sage: psi = W.module_morphism(matrix=M, codomain=W)
@@ -966,12 +969,12 @@ def fcp(self):
966969
967970
EXAMPLES::
968971
972+
sage: # needs sage.modules
969973
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
970974
sage: phi.fcp() # needs sage.libs.pari
971975
(x - 2) * (x - 1)
972976
sage: phi.fcp('T') # needs sage.libs.pari
973977
(T - 2) * (T - 1)
974-
975978
sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
976979
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
977980
sage: psi = W.module_morphism(matrix=M, codomain=W)
@@ -995,6 +998,7 @@ def minimal_polynomial(self):
995998
996999
Compute the minimal polynomial, and check it. ::
9971000
1001+
sage: # needs sage.modules
9981002
sage: V = GF(7)^3
9991003
sage: H = V.Hom(V)([[0,1,2], [-1,0,3], [2,4,1]]); H
10001004
Vector space morphism represented by the matrix:
@@ -1015,7 +1019,7 @@ def minimal_polynomial(self):
10151019
Domain: Vector space of dimension 3 over Finite Field of size 7
10161020
Codomain: Vector space of dimension 3 over Finite Field of size 7
10171021
1018-
sage: # needs sage.rings.finite_rings
1022+
sage: # needs sage.modules sage.rings.finite_rings
10191023
sage: k = GF(9, 'c')
10201024
sage: V = CombinatorialFreeModule(k, ['x', 'y', 'z', 'w'])
10211025
sage: A = matrix(k, 4, [1,1,0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])
@@ -1038,10 +1042,10 @@ def trace(self):
10381042
10391043
EXAMPLES::
10401044
1045+
sage: # needs sage.modules
10411046
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
10421047
sage: phi.trace()
10431048
3
1044-
10451049
sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
10461050
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
10471051
sage: psi = W.module_morphism(matrix=M, codomain=W)

src/sage/categories/finite_groups.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def cardinality(self):
9595
We need to use a finite group which uses this default
9696
implementation of cardinality::
9797
98-
sage: G = groups.misc.SemimonomialTransformation(GF(5), 3); G
98+
sage: G = groups.misc.SemimonomialTransformation(GF(5), 3); G # needs sage.rings.number_field
9999
Semimonomial transformation group over Finite Field of size 5 of degree 3
100-
sage: G.cardinality.__module__
100+
sage: G.cardinality.__module__ # needs sage.rings.number_field
101101
'sage.categories.finite_groups'
102-
sage: G.cardinality()
102+
sage: G.cardinality() # needs sage.rings.number_field
103103
384
104104
"""
105105
if hasattr(self, 'order'):
@@ -173,7 +173,7 @@ def conjugacy_classes_representatives(self):
173173
EXAMPLES::
174174
175175
sage: G = SymmetricGroup(3)
176-
sage: G.conjugacy_classes_representatives()
176+
sage: G.conjugacy_classes_representatives() # needs sage.combinat
177177
[(), (1,2), (1,2,3)]
178178
"""
179179
return [C.representative() for C in self.conjugacy_classes()]
@@ -232,7 +232,7 @@ def __init_extra__(self):
232232
sage: A in Algebras.Semisimple
233233
False
234234
235-
sage: G = groups.misc.AdditiveCyclic(4)
235+
sage: G = groups.misc.AdditiveCyclic(4) # needs sage.rings.number_field
236236
sage: Cat = CommutativeAdditiveGroups().Finite()
237237
sage: A = G.algebra(GF(5), category=Cat)
238238
sage: A in Algebras.Semisimple

src/sage/categories/group_algebras.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __init_extra__(self):
129129
130130
EXAMPLES::
131131
132-
sage: # needs sage.groups sage.modules
132+
sage: # needs sage.combinat sage.groups sage.modules
133133
sage: A = GroupAlgebra(SymmetricGroup(4), QQ)
134134
sage: B = GroupAlgebra(SymmetricGroup(3), ZZ)
135135
sage: A.has_coerce_map_from(B)
@@ -173,7 +173,7 @@ def group(self):
173173
174174
sage: GroupAlgebras(QQ).example(GL(3, GF(11))).group() # needs sage.groups sage.modules
175175
General Linear Group of degree 3 over Finite Field of size 11
176-
sage: SymmetricGroup(10).algebra(QQ).group() # needs sage.groups sage.modules
176+
sage: SymmetricGroup(10).algebra(QQ).group() # needs sage.combinat sage.groups sage.modules
177177
Symmetric group of order 10! as a permutation group
178178
"""
179179
return self.basis().keys()
@@ -201,7 +201,7 @@ def center_basis(self):
201201
202202
EXAMPLES::
203203
204-
sage: SymmetricGroup(3).algebra(QQ).center_basis() # needs sage.groups sage.modules
204+
sage: SymmetricGroup(3).algebra(QQ).center_basis() # needs sage.combinat sage.groups sage.modules
205205
((), (2,3) + (1,2) + (1,3), (1,2,3) + (1,3,2))
206206
207207
.. SEEALSO::
@@ -319,12 +319,12 @@ def is_integral_domain(self, proof=True):
319319
320320
sage: # needs sage.groups sage.modules
321321
sage: S2 = SymmetricGroup(2)
322-
sage: GroupAlgebra(S2).is_integral_domain()
322+
sage: GroupAlgebra(S2).is_integral_domain() # needs sage.combinat
323323
False
324324
sage: S1 = SymmetricGroup(1)
325-
sage: GroupAlgebra(S1).is_integral_domain()
325+
sage: GroupAlgebra(S1).is_integral_domain() # needs sage.combinat
326326
True
327-
sage: GroupAlgebra(S1, IntegerModRing(4)).is_integral_domain()
327+
sage: GroupAlgebra(S1, IntegerModRing(4)).is_integral_domain() # needs sage.combinat
328328
False
329329
sage: GroupAlgebra(AbelianGroup(1)).is_integral_domain()
330330
True
@@ -400,7 +400,7 @@ def central_form(self):
400400
401401
EXAMPLES::
402402
403-
sage: # needs sage.groups sage.modules
403+
sage: # needs sage.combinat sage.groups sage.modules
404404
sage: QS3 = SymmetricGroup(3).algebra(QQ)
405405
sage: A = QS3([2,3,1]) + QS3([3,1,2])
406406
sage: A.central_form()

0 commit comments

Comments
 (0)