Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/sage/categories/chain_complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def homology(self, n=None):
::

sage: # needs sage.combinat sage.modules
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3))
sage: C = A.cdg_algebra({z: x*y})
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.libs.singular
sage: C = A.cdg_algebra({z: x*y}) # needs sage.libs.singular
sage: C.homology(0)
Free module generated by {[1]} over Rational Field
sage: C.homology(1)
Expand Down Expand Up @@ -109,8 +109,8 @@ def differential(self, *args, **kwargs):

::

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.modules
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.modules
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.libs.singular sage.modules
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.libs.singular sage.modules
sage: C.differential() # needs sage.combinat sage.modules
Differential of Commutative Differential Graded Algebra with
generators ('x', 'y', 'z') in degrees (2, 2, 3) over Rational Field
Expand Down Expand Up @@ -182,8 +182,8 @@ class HomologyFunctor(Functor):

::

sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.modules
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.modules
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # needs sage.combinat sage.libs.singular sage.modules
sage: C = A.cdg_algebra({z: x*y}) # needs sage.combinat sage.libs.singular sage.modules
sage: H = HomologyFunctor(ChainComplexes(QQ), 2)
sage: H(C) # needs sage.combinat sage.modules
Free module generated by {[x], [y]} over Rational Field
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/examples/lie_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __classcall_private__(cls, gens):

EXAMPLES::

sage: # needs sage.combinat
sage: # needs sage.combinat sage.groups
sage: S3 = SymmetricGroupAlgebra(QQ, 3)
sage: L1 = LieAlgebras(QQ).example()
sage: gens = list(S3.algebra_generators())
Expand All @@ -84,8 +84,8 @@ def __init__(self, gens):
"""
EXAMPLES::

sage: L = LieAlgebras(QQ).example() # needs sage.combinat
sage: TestSuite(L).run() # needs sage.combinat
sage: L = LieAlgebras(QQ).example() # needs sage.combinat sage.groups
sage: TestSuite(L).run() # needs sage.combinat sage.groups
"""
if not gens:
raise ValueError("need at least one generator")
Expand Down
34 changes: 20 additions & 14 deletions src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,31 @@ def __contains__(self, x):
in other doctests, we introduced a strong reference to all previously created
uncollected objects in :issue:`19244`. ::

sage: # needs sage.libs.pari
sage: import gc
sage: _ = gc.collect()
sage: permstore = [X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
sage: permstore = [X for X in gc.get_objects()
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
sage: n = len(permstore)
sage: for i in prime_range(100): # needs sage.libs.pari
sage: for i in prime_range(100):
....: R = ZZ.quotient(i)
....: t = R in Fields()

First, we show that there are now more quotient rings in cache than before::

sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) > n
sage: # needs sage.libs.pari
sage: len([X for X in gc.get_objects()
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) > n
True

When we delete the last quotient ring created in the loop and then do a garbage
collection, all newly created rings vanish::

sage: # needs sage.libs.pari
sage: del R
sage: _ = gc.collect()
sage: len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) - n
sage: len([X for X in gc.get_objects()
....: if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]) - n
0

"""
Expand Down Expand Up @@ -623,15 +629,15 @@ def gcd(self,other):
For field of characteristic zero, the gcd of integers is considered
as if they were elements of the integer ring::

sage: gcd(15.0,12.0)
sage: gcd(15.0,12.0) # needs sage.rings.real_mpfr
3.00000000000000

But for other floating point numbers, the gcd is just `0.0` or `1.0`::

sage: gcd(3.2, 2.18)
sage: gcd(3.2, 2.18) # needs sage.rings.real_mpfr
1.00000000000000

sage: gcd(0.0, 0.0)
sage: gcd(0.0, 0.0) # needs sage.rings.real_mpfr
0.000000000000000

AUTHOR:
Expand Down Expand Up @@ -677,15 +683,15 @@ def lcm(self, other):
For field of characteristic zero, the lcm of integers is considered
as if they were elements of the integer ring::

sage: lcm(15.0,12.0)
sage: lcm(15.0, 12.0) # needs sage.rings.real_mpfr
60.0000000000000

But for others floating point numbers, it is just `0.0` or `1.0`::

sage: lcm(3.2, 2.18)
sage: lcm(3.2, 2.18) # needs sage.rings.real_mpfr
1.00000000000000

sage: lcm(0.0, 0.0)
sage: lcm(0.0, 0.0) # needs sage.rings.real_mpfr
0.000000000000000

AUTHOR:
Expand Down Expand Up @@ -747,13 +753,13 @@ def xgcd(self, other):
the result is a floating point version of the standard gcd on
`\ZZ`::

sage: xgcd(12.0, 8.0)
sage: xgcd(12.0, 8.0) # needs sage.rings.real_mpfr
(4.00000000000000, 1.00000000000000, -1.00000000000000)

sage: xgcd(3.1, 2.98714)
sage: xgcd(3.1, 2.98714) # needs sage.rings.real_mpfr
(1.00000000000000, 0.322580645161290, 0.000000000000000)

sage: xgcd(0.0, 1.1)
sage: xgcd(0.0, 1.1) # needs sage.rings.real_mpfr
(1.00000000000000, 0.000000000000000, 0.909090909090909)
"""
P = self.parent()
Expand Down Expand Up @@ -786,7 +792,7 @@ def factor(self):
sage: x = GF(7)(5)
sage: x.factor()
5
sage: RR(0).factor()
sage: RR(0).factor() # needs sage.rings.real_mpfr
Traceback (most recent call last):
...
ArithmeticError: factorization of 0.000000000000000 is not defined
Expand Down
14 changes: 9 additions & 5 deletions src/sage/categories/finite_dimensional_modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def _repr_matrix(self):

EXAMPLES::

sage: # needs sage.modules
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
....: column_keys=['a', 'b', 'c'],
....: row_keys=['v', 'w']); M
Expand Down Expand Up @@ -713,6 +714,7 @@ def _ascii_art_matrix(self):

EXAMPLES::

sage: # needs sage.modules
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
....: column_keys=['a', 'b', 'c'],
....: row_keys=['v', 'w']); M
Expand Down Expand Up @@ -744,6 +746,7 @@ def _unicode_art_matrix(self):

EXAMPLES::

sage: # needs sage.modules
sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
....: column_keys=['a', 'b', 'c'],
....: row_keys=['v', 'w']); M
Expand Down Expand Up @@ -909,6 +912,7 @@ def characteristic_polynomial(self):

EXAMPLES::

sage: # needs sage.modules
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
sage: phi.characteristic_polynomial()
x^2 - 3*x + 2
Expand All @@ -918,7 +922,6 @@ def characteristic_polynomial(self):
x^2 - 3*x + 2
sage: phi.charpoly('T')
T^2 - 3*T + 2

sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
sage: psi = W.module_morphism(matrix=M, codomain=W)
Expand All @@ -938,12 +941,12 @@ def determinant(self):

EXAMPLES::

sage: # needs sage.modules
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
sage: phi.determinant()
2
sage: phi.det()
2

sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
sage: psi = W.module_morphism(matrix=M, codomain=W)
Expand All @@ -965,12 +968,12 @@ def fcp(self):

EXAMPLES::

sage: # needs sage.modules
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
sage: phi.fcp() # needs sage.libs.pari
(x - 2) * (x - 1)
sage: phi.fcp('T') # needs sage.libs.pari
(T - 2) * (T - 1)

sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
sage: psi = W.module_morphism(matrix=M, codomain=W)
Expand All @@ -994,6 +997,7 @@ def minimal_polynomial(self):

Compute the minimal polynomial, and check it. ::

sage: # needs sage.modules
sage: V = GF(7)^3
sage: H = V.Hom(V)([[0,1,2], [-1,0,3], [2,4,1]]); H
Vector space morphism represented by the matrix:
Expand All @@ -1014,7 +1018,7 @@ def minimal_polynomial(self):
Domain: Vector space of dimension 3 over Finite Field of size 7
Codomain: Vector space of dimension 3 over Finite Field of size 7

sage: # needs sage.rings.finite_rings
sage: # needs sage.modules sage.rings.finite_rings
sage: k = GF(9, 'c')
sage: V = CombinatorialFreeModule(k, ['x', 'y', 'z', 'w'])
sage: A = matrix(k, 4, [1,1,0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])
Expand All @@ -1037,10 +1041,10 @@ def trace(self):

EXAMPLES::

sage: # needs sage.modules
sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
sage: phi.trace()
3

sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
sage: M = matrix(ZZ, [[1, 0], [1, 2]])
sage: psi = W.module_morphism(matrix=M, codomain=W)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/categories/finite_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def cardinality(self):
We need to use a finite group which uses this default
implementation of cardinality::

sage: G = groups.misc.SemimonomialTransformation(GF(5), 3); G
sage: G = groups.misc.SemimonomialTransformation(GF(5), 3); G # needs sage.rings.number_field
Semimonomial transformation group over Finite Field of size 5 of degree 3
sage: G.cardinality.__module__
sage: G.cardinality.__module__ # needs sage.rings.number_field
'sage.categories.finite_groups'
sage: G.cardinality()
sage: G.cardinality() # needs sage.rings.number_field
384
"""
if hasattr(self, 'order'):
Expand Down Expand Up @@ -172,7 +172,7 @@ def conjugacy_classes_representatives(self):
EXAMPLES::

sage: G = SymmetricGroup(3)
sage: G.conjugacy_classes_representatives()
sage: G.conjugacy_classes_representatives() # needs sage.combinat
[(), (1,2), (1,2,3)]
"""
return [C.representative() for C in self.conjugacy_classes()]
Expand Down Expand Up @@ -231,7 +231,7 @@ def __init_extra__(self):
sage: A in Algebras.Semisimple
False

sage: G = groups.misc.AdditiveCyclic(4)
sage: G = groups.misc.AdditiveCyclic(4) # needs sage.rings.number_field
sage: Cat = CommutativeAdditiveGroups().Finite()
sage: A = G.algebra(GF(5), category=Cat)
sage: A in Algebras.Semisimple
Expand Down
14 changes: 7 additions & 7 deletions src/sage/categories/group_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init_extra__(self):

EXAMPLES::

sage: # needs sage.groups sage.modules
sage: # needs sage.combinat sage.groups sage.modules
sage: A = GroupAlgebra(SymmetricGroup(4), QQ)
sage: B = GroupAlgebra(SymmetricGroup(3), ZZ)
sage: A.has_coerce_map_from(B)
Expand Down Expand Up @@ -172,7 +172,7 @@ def group(self):

sage: GroupAlgebras(QQ).example(GL(3, GF(11))).group() # needs sage.groups sage.modules
General Linear Group of degree 3 over Finite Field of size 11
sage: SymmetricGroup(10).algebra(QQ).group() # needs sage.groups sage.modules
sage: SymmetricGroup(10).algebra(QQ).group() # needs sage.combinat sage.groups sage.modules
Symmetric group of order 10! as a permutation group
"""
return self.basis().keys()
Expand Down Expand Up @@ -200,7 +200,7 @@ def center_basis(self):

EXAMPLES::

sage: SymmetricGroup(3).algebra(QQ).center_basis() # needs sage.groups sage.modules
sage: SymmetricGroup(3).algebra(QQ).center_basis() # needs sage.combinat sage.groups sage.modules
((), (2,3) + (1,2) + (1,3), (1,2,3) + (1,3,2))

.. SEEALSO::
Expand Down Expand Up @@ -318,12 +318,12 @@ def is_integral_domain(self, proof=True):

sage: # needs sage.groups sage.modules
sage: S2 = SymmetricGroup(2)
sage: GroupAlgebra(S2).is_integral_domain()
sage: GroupAlgebra(S2).is_integral_domain() # needs sage.combinat
False
sage: S1 = SymmetricGroup(1)
sage: GroupAlgebra(S1).is_integral_domain()
sage: GroupAlgebra(S1).is_integral_domain() # needs sage.combinat
True
sage: GroupAlgebra(S1, IntegerModRing(4)).is_integral_domain()
sage: GroupAlgebra(S1, IntegerModRing(4)).is_integral_domain() # needs sage.combinat
False
sage: GroupAlgebra(AbelianGroup(1)).is_integral_domain()
True
Expand Down Expand Up @@ -399,7 +399,7 @@ def central_form(self):

EXAMPLES::

sage: # needs sage.groups sage.modules
sage: # needs sage.combinat sage.groups sage.modules
sage: QS3 = SymmetricGroup(3).algebra(QQ)
sage: A = QS3([2,3,1]) + QS3([3,1,2])
sage: A.central_form()
Expand Down
Loading