From a4418cfda5e32fe88a2e83c1c8b0dd2f71648df6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 11 Mar 2023 14:22:05 -0800 Subject: [PATCH 01/64] sage.groups.additive_abelian: More # optional --- .../additive_abelian_group.py | 2 +- .../additive_abelian_wrapper.py | 59 ++++++++++--------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_group.py b/src/sage/groups/additive_abelian/additive_abelian_group.py index de8c4a41656..9245d0ce36c 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_group.py +++ b/src/sage/groups/additive_abelian/additive_abelian_group.py @@ -450,7 +450,7 @@ def permutation_group(self): EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 3]) - sage: G.permutation_group() + sage: G.permutation_group() # optional - sage.groups Permutation Group with generators [(3,4,5), (1,2)] TESTS: diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 5d211f6383b..08c8011ced6 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -85,12 +85,12 @@ def __init__(self, domain): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: F = QQbar.coerce_map_from(G); F + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field + sage: F = QQbar.coerce_map_from(G); F # optional - sage.rings.number_field Generic morphism: From: Additive abelian group isomorphic to Z + Z embedded in Algebraic Field To: Algebraic Field - sage: type(F) + sage: type(F) # optional - sage.rings.number_field """ Morphism.__init__(self, domain.Hom(domain.universe())) @@ -127,8 +127,8 @@ def __init__(self, parent, vector, element=None, check=False): EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: G.0 # indirect doctest + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field + sage: G.0 # indirect doctest # optional - sage.rings.number_field 1.414213562373095? """ addgp.AdditiveAbelianGroupElement.__init__(self, parent, vector, check) @@ -185,13 +185,15 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): :: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) + sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # optional - sage.rings.number_field sage.symbolic Additive abelian group isomorphic to Z + Z embedded in Algebraic Field :: - sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest - Additive abelian group isomorphic to Z/420 + Z/420 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 + sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.libs.pari + Additive abelian group isomorphic to Z/420 + Z/420 embedded in + Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 """ Element = AdditiveAbelianGroupWrapperElement @@ -200,7 +202,7 @@ def __init__(self, universe, gens, invariants): r""" EXAMPLES:: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # indirect doctest + sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # indirect doctest # optional - sage.rings.number_field Additive abelian group isomorphic to Z + Z embedded in Algebraic Field """ self._universe = universe @@ -217,7 +219,7 @@ def universe(self): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field sage: G.universe() Algebraic Field """ @@ -246,8 +248,8 @@ def _repr_(self): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: repr(G) # indirect doctest + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field + sage: repr(G) # indirect doctest # optional - sage.rings.number_field 'Additive abelian group isomorphic to Z + Z embedded in Algebraic Field' """ return addgp.AdditiveAbelianGroup_fixed_gens._repr_(self) + " embedded in " + self.universe()._repr_() @@ -283,10 +285,10 @@ def discrete_exp(self, v): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), -1], [0, 0]) - sage: v = G.discrete_exp([3, 5]); v + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), -1], [0, 0]) # optional - sage.rings.number_field + sage: v = G.discrete_exp([3, 5]); v # optional - sage.rings.number_field -0.7573593128807148? - sage: v.parent() is QQbar + sage: v.parent() is QQbar # optional - sage.rings.number_field True This method is an inverse of :meth:`discrete_log`:: @@ -357,8 +359,8 @@ def discrete_log(self, x, gens=None): :: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) - sage: G.discrete_log(QQbar(2*sqrt(2))) + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # optional - sage.rings.number_field + sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: No black-box discrete log for infinite abelian groups @@ -426,17 +428,20 @@ def torsion_subgroup(self, n=None): sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), ords) sage: T = A.torsion_subgroup(5) sage: T - Additive abelian group isomorphic to Z/5 + Z/5 + Z/5 embedded in Additive abelian group isomorphic to Z/2 + Z/6 + Z/30 + Z + Z/210 + Z/2310 + Additive abelian group isomorphic to Z/5 + Z/5 + Z/5 embedded in + Additive abelian group isomorphic to Z/2 + Z/6 + Z/30 + Z + Z/210 + Z/2310 sage: T.gens() ((0, 0, 6, 0, 0, 0), (0, 0, 0, 0, 42, 0), (0, 0, 0, 0, 0, 462)) :: - sage: E = EllipticCurve(GF(487^2), [311,205]) - sage: T = E.abelian_group().torsion_subgroup(42) - sage: T - Additive abelian group isomorphic to Z/42 + Z/6 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 - sage: [P.order() for P in T.gens()] + sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.libs.pari + sage: T = E.abelian_group().torsion_subgroup(42) # optional - sage.libs.pari + sage: T # optional - sage.libs.pari + Additive abelian group isomorphic to Z/42 + Z/6 embedded in + Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 + sage: [P.order() for P in T.gens()] # optional - sage.libs.pari [42, 6] :: @@ -552,11 +557,11 @@ def _discrete_log_pgroup(p, vals, aa, b): Check for :trac:`34716`:: - sage: E = EllipticCurve(GF(487^2), [311,205]) - sage: G = E.abelian_group().torsion_subgroup(42) - sage: G.invariants() + sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.libs.pari + sage: G = E.abelian_group().torsion_subgroup(42) # optional - sage.libs.pari + sage: G.invariants() # optional - sage.libs.pari (6, 42) - sage: P, Q = G.torsion_subgroup(6).gens() + sage: P, Q = G.torsion_subgroup(6).gens() # optional - sage.libs.pari sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest (2, 3) """ From e8ffe05d573e6765067f80b5adf4d0735068370e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 Mar 2023 00:15:26 -0800 Subject: [PATCH 02/64] src/sage/groups/old.pyx: Add # optional --- src/sage/groups/old.pyx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 92b69af07db..3201a1c17ec 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -47,10 +47,10 @@ cdef class Group(sage.structure.parent.Parent): Check for :trac:`8119`:: - sage: G = SymmetricGroup(2) - sage: h = hash(G) - sage: G.rename('S2') - sage: h == hash(G) + sage: G = SymmetricGroup(2) # optional - sage.groups + sage: h = hash(G) # optional - sage.groups + sage: G.rename('S2') # optional - sage.groups + sage: h == hash(G) # optional - sage.groups True """ from sage.categories.basic import Groups @@ -120,7 +120,7 @@ cdef class Group(sage.structure.parent.Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() + sage: SL(2, 7).is_commutative() # optional - sage.modules False """ return self.is_abelian() From 250fe18852df3ad58f7d691b758a424ab7feeb1b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 Mar 2023 00:24:13 -0800 Subject: [PATCH 03/64] src/sage/groups/additive_abelian/additive_abelian_wrapper.py: More # optional --- src/sage/groups/additive_abelian/additive_abelian_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 08c8011ced6..f2b2cb3c7e8 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -220,7 +220,7 @@ def universe(self): EXAMPLES:: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field - sage: G.universe() + sage: G.universe() # optional - sage.rings.number_field Algebraic Field """ return self._universe From e0833e31771c6cdea4575d12c06ed248ab0053d6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 Mar 2023 18:36:54 -0700 Subject: [PATCH 04/64] sage.groups: More # optional --- src/sage/groups/additive_abelian/additive_abelian_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index f2b2cb3c7e8..d0171db2fe8 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -562,7 +562,7 @@ def _discrete_log_pgroup(p, vals, aa, b): sage: G.invariants() # optional - sage.libs.pari (6, 42) sage: P, Q = G.torsion_subgroup(6).gens() # optional - sage.libs.pari - sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest + sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # optional - sage.groups (2, 3) """ from itertools import product as iproduct From 44267e8f25945fe2779decce6a69feae9a55f44c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 17 Mar 2023 21:50:48 -0700 Subject: [PATCH 05/64] sage.groups: More # optional --- src/sage/groups/group.pyx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index 872d5c509d7..98a5f187638 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -35,11 +35,11 @@ def is_Group(x): EXAMPLES:: - sage: F. = FreeGroup() + sage: F. = FreeGroup() # optional - sage.groups sage: from sage.groups.group import is_Group - sage: is_Group(F) + sage: is_Group(F) # optional - sage.groups True - sage: is_Group("a string") + sage: is_Group("a string") # optional - sage.groups False """ from sage.groups.old import Group as OldGroup @@ -87,7 +87,7 @@ cdef class Group(Parent): sage: G = Group(category=Groups()) # todo: do the same test with some subcategory of Groups when there will exist one sage: G.category() Category of groups - sage: G = Group(category = CommutativeAdditiveGroups()) + sage: G = Group(category=CommutativeAdditiveGroups()) Traceback (most recent call last): ... ValueError: (Category of commutative additive groups,) is not a subcategory of Category of groups @@ -96,10 +96,10 @@ cdef class Group(Parent): Check for :trac:`8119`:: - sage: G = SymmetricGroup(2) - sage: h = hash(G) - sage: G.rename('S2') - sage: h == hash(G) + sage: G = SymmetricGroup(2) # optional - sage.groups + sage: h = hash(G) # optional - sage.groups + sage: G.rename('S2') # optional - sage.groups + sage: h == hash(G) # optional - sage.groups True """ from sage.categories.groups import Groups From c5d0dc6b6295ae49d52abd443e233d20cc43f4fb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 23 Apr 2023 19:17:08 -0700 Subject: [PATCH 06/64] sage.groups: More # optional --- src/sage/groups/generic.py | 495 +++++++++++++++++++------------------ src/sage/groups/group.pyx | 6 +- 2 files changed, 252 insertions(+), 249 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 33e92d43ca5..5ac9daf4350 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -5,15 +5,15 @@ groups, including additive and multiplicative groups. In all cases the group operation is specified by a parameter -'operation', which is a string either one of the set of -multiplication_names or addition_names specified below, or 'other'. -In the latter case, the caller must provide an identity, inverse() and -op() functions. +``operation``, which is a string either one of the set of +``multiplication_names`` or ``addition_names`` specified below, or other. +In the latter case, the caller must provide an identity, ``inverse()`` and +``op()`` functions. :: - multiplication_names = ( 'multiplication', 'times', 'product', '*') - addition_names = ( 'addition', 'plus', 'sum', '+') + multiplication_names = ('multiplication', 'times', 'product', '*') + addition_names = ('addition', 'plus', 'sum', '+') Also included are a generic function for computing multiples (or @@ -25,76 +25,76 @@ - Discrete logs:: - sage: K = GF(3^6,'b') - sage: b = K.gen() - sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings + sage: b = K.gen() # optional - sage.rings.finite_rings + sage: a = b^210 # optional - sage.rings.finite_rings + sage: discrete_log(a, b, K.order()-1) # optional - sage.rings.finite_rings 210 - Linear relation finder:: - sage: F. = GF(3^6,'a') - sage: a.multiplicative_order().factor() + sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings + sage: a.multiplicative_order().factor() # optional - sage.rings.finite_rings 2^3 * 7 * 13 - sage: b = a^7 - sage: c = a^13 - sage: linear_relation(b,c,'*') + sage: b = a^7 # optional - sage.rings.finite_rings + sage: c = a^13 # optional - sage.rings.finite_rings + sage: linear_relation(b,c,'*') # optional - sage.rings.finite_rings (13, 7) - sage: b^13 == c^7 + sage: b^13 == c^7 # optional - sage.rings.finite_rings True - Orders of elements:: sage: from sage.groups.generic import order_from_multiple, order_from_bounds - sage: k. = GF(5^5) - sage: b = a^4 - sage: order_from_multiple(b,5^5-1,operation='*') + sage: k. = GF(5^5) # optional - sage.rings.finite_rings + sage: b = a^4 # optional - sage.rings.finite_rings + sage: order_from_multiple(b, 5^5 - 1, operation='*') # optional - sage.rings.finite_rings 781 - sage: order_from_bounds(b,(5^4,5^5),operation='*') + sage: order_from_bounds(b, (5^4, 5^5), operation='*') # optional - sage.rings.finite_rings 781 Some examples in the group of points of an elliptic curve over a finite field: - Discrete logs:: - sage: F = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) - sage: F. = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) - sage: P = E(25*a + 16 , 15*a + 7 ) - sage: P.order() + sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F,[1,1]) # optional - sage.rings.finite_rings + sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F,[1,1]) # optional - sage.rings.finite_rings + sage: P = E(25*a + 16 , 15*a + 7 ) # optional - sage.rings.finite_rings + sage: P.order() # optional - sage.rings.finite_rings 672 - sage: Q = 39*P; Q + sage: Q = 39*P; Q # optional - sage.rings.finite_rings (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+') + sage: discrete_log(Q, P, P.order(), operation='+') # optional - sage.rings.finite_rings 39 - Linear relation finder:: - sage: F. = GF(3^6,'a') - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) - sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) - sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) - sage: linear_relation(P,Q,'+') + sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings + sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) # optional - sage.rings.finite_rings + sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) # optional - sage.rings.finite_rings + sage: linear_relation(P,Q,'+') # optional - sage.rings.finite_rings (1, 2) - sage: P == 2*Q + sage: P == 2*Q # optional - sage.rings.finite_rings True - Orders of elements:: sage: from sage.groups.generic import order_from_multiple, order_from_bounds - sage: k. = GF(5^5) - sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) - sage: M = E.cardinality(); M + sage: k. = GF(5^5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(k,[2,4]) # optional - sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a , 2*a + 1 ) # optional - sage.rings.finite_rings + sage: M = E.cardinality(); M # optional - sage.rings.finite_rings 3227 - sage: plist = M.prime_factors() - sage: order_from_multiple(P, M, plist, operation='+') + sage: plist = M.prime_factors() # optional - sage.rings.finite_rings + sage: order_from_multiple(P, M, plist, operation='+') # optional - sage.rings.finite_rings 3227 - sage: Q = E(0,2) - sage: order_from_multiple(Q, M, plist, operation='+') + sage: Q = E(0,2) # optional - sage.rings.finite_rings + sage: order_from_multiple(Q, M, plist, operation='+') # optional - sage.rings.finite_rings 7 - sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') + sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') # optional - sage.rings.finite_rings 7 """ @@ -134,24 +134,24 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): EXAMPLES:: - sage: multiple(2,5) + sage: multiple(2, 5) 32 - sage: multiple(RealField()('2.5'),4) + sage: multiple(RealField()('2.5'), 4) # optional - sage.libs.mpfr 39.0625000000000 - sage: multiple(2,-3) + sage: multiple(2, -3) 1/8 - sage: multiple(2,100,'+') == 100*2 + sage: multiple(2, 100, '+') == 100*2 True - sage: multiple(2,100) == 2**100 + sage: multiple(2, 100) == 2**100 True - sage: multiple(2,-100,) == 2**-100 + sage: multiple(2, -100,) == 2**-100 True - sage: R.=ZZ[] - sage: multiple(x,100) + sage: R. = ZZ[] + sage: multiple(x, 100) x^100 - sage: multiple(x,100,'+') + sage: multiple(x, 100, '+') 100*x - sage: multiple(x,-10) + sage: multiple(x, -10) 1/x^10 Idempotence is detected, making the following fast:: @@ -161,9 +161,9 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): sage: E = EllipticCurve('389a1') sage: P = E(-1,1) - sage: multiple(P,10,'+') + sage: multiple(P, 10, '+') (645656132358737542773209599489/22817025904944891235367494656 : 525532176124281192881231818644174845702936831/3446581505217248068297884384990762467229696 : 1) - sage: multiple(P,-10,'+') + sage: multiple(P, -10, '+') (645656132358737542773209599489/22817025904944891235367494656 : -528978757629498440949529703029165608170166527/3446581505217248068297884384990762467229696 : 1) """ from operator import inv, mul, neg, add @@ -247,14 +247,14 @@ class multiples: EXAMPLES:: - sage: list(multiples(1,10)) + sage: list(multiples(1, 10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - sage: list(multiples(1,10,100)) + sage: list(multiples(1, 10, 100)) [100, 101, 102, 103, 104, 105, 106, 107, 108, 109] sage: E = EllipticCurve('389a1') sage: P = E(-1,1) - sage: for Q in multiples(P,5): print((Q, Q.height()/P.height())) + sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) ((0 : 1 : 0), 0.000000000000000) ((-1 : 1 : 1), 1.00000000000000) ((10/9 : -35/27 : 1), 4.00000000000000) @@ -262,22 +262,22 @@ class multiples: ((47503/16641 : 9862190/2146689 : 1), 16.0000000000000) sage: R. = ZZ[] - sage: list(multiples(x,5)) + sage: list(multiples(x, 5)) [0, x, 2*x, 3*x, 4*x] - sage: list(multiples(x,5,operation='*')) + sage: list(multiples(x, 5, operation='*')) [1, x, x^2, x^3, x^4] - sage: list(multiples(x,5,indexed=True)) + sage: list(multiples(x, 5, indexed=True)) [(0, 0), (1, x), (2, 2*x), (3, 3*x), (4, 4*x)] - sage: list(multiples(x,5,indexed=True,operation='*')) + sage: list(multiples(x, 5, indexed=True, operation='*')) [(0, 1), (1, x), (2, x^2), (3, x^3), (4, x^4)] - sage: for i,y in multiples(x,5,indexed=True): print("%s times %s = %s"%(i,x,y)) + sage: for i,y in multiples(x, 5, indexed=True): print("%s times %s = %s"%(i,x,y)) 0 times x = 0 1 times x = x 2 times x = 2*x 3 times x = 3*x 4 times x = 4*x - sage: for i,n in multiples(3,5,indexed=True,operation='*'): print("3 to the power %s = %s" % (i,n)) + sage: for i,n in multiples(3, 5, indexed=True, operation='*'): print("3 to the power %s = %s" % (i,n)) 3 to the power 0 = 1 3 to the power 1 = 3 3 to the power 2 = 9 @@ -286,26 +286,25 @@ class multiples: """ def __init__(self, P, n, P0=None, indexed=False, operation='+', op=None): """ - Create a multiples iterator + Create a multiples iterator. INPUT: - - ``P`` - step value: any Sage object on which a binary - operation is defined - - ``n`` - number of multiples: non-negative integer + - ``P`` -- step value: any Sage object on which a binary operation is defined + - ``n`` -- number of multiples: non-negative integer - ``P0`` - offset (default 0): Sage object which can be 'added' to P - - ``indexed`` - boolean (default False) + - ``indexed`` -- boolean (default ``False``) - If ``indexed==False`` then the iterator delivers ``P0+i*P`` + If ``indexed==False``, then the iterator delivers ``P0+i*P`` (if ``operation=='+'``) or ``P0*P**i`` (if ``operation=='*'``), for ``i`` in ``range(n)``. If ``indexed==True`` then the iterator delivers tuples - ``(i,P0+i*P)`` or ``(i,P0*P**i)``. + ``(i, P0+i*P)`` or ``(i, P0*P**i)``. - - ``operation`` - string: '+' (default ) or '*' or `other`. + - ``operation`` -- string: ``'+'`` (the default) or ``'*'`` or other. - If `other`, a function ``op()`` must be supplied (a function + If other, a function ``op()`` must be supplied (a function of 2 arguments) defining the group binary operation; also ``P0`` must be supplied. """ @@ -377,18 +376,18 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): INPUT: - - ``a`` - group element - - ``b`` - group element - - ``bounds`` - a 2-tuple of integers ``(lower,upper)`` with ``0<=lower<=upper`` - - ``operation`` - string: '*', '+', 'other' - - ``identity`` - the identity element of the group - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` + - ``a`` -- group element + - ``b`` -- group element + - ``bounds`` -- a 2-tuple of integers ``(lower,upper)`` with ``0<=lower<=upper`` + - ``operation`` -- string: ``'*'``, ``'+'``, other + - ``identity`` -- the identity element of the group + - ``inverse()`` -- function of 1 argument ``x``, returning inverse of ``x`` - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group OUTPUT: An integer `n` such that `a^n = b` (or `na = b`). If no - such `n` exists, this function raises a ValueError exception. + such `n` exists, this function raises a :class:`ValueError` exception. NOTE: This is a generalization of discrete logarithm. One situation where this version is useful is to find the order of @@ -513,9 +512,9 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No to compute it - ``operation`` -- a string (default: ``'*'``) denoting whether we are in an additive group or a multiplicative one - - ``identity`` - the group's identity - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` - - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group + - ``identity`` -- the group's identity + - ``inverse()`` -- function of 1 argument ``x``, returning inverse of ``x`` + - ``op()`` - function of 2 arguments ``x``, ``y``, returning ``x*y`` in the group - ``hash_function`` -- having an efficient hash function is critical for this algorithm (see examples) @@ -527,21 +526,23 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No EXAMPLES:: - sage: F. = GF(2^13) - sage: g = F.gen() - sage: discrete_log_rho(g^1234, g) + sage: F. = GF(2^13) # optional - sage.rings.finite_rings + sage: g = F.gen() # optional - sage.rings.finite_rings + sage: discrete_log_rho(g^1234, g) # optional - sage.rings.finite_rings 1234 - sage: F. = GF(37^5) - sage: E = EllipticCurve(F, [1,1]) - sage: G = (3*31*2^4)*E.lift_x(a) - sage: discrete_log_rho(12345*G, G, ord=46591, operation='+') + sage: F. = GF(37^5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: G = (3*31*2^4)*E.lift_x(a) # optional - sage.rings.finite_rings + sage: discrete_log_rho(12345*G, G, ord=46591, operation='+') # optional - sage.rings.finite_rings 12345 It also works with matrices:: - sage: A = matrix(GF(50021),[[10577,23999,28893],[14601,41019,30188],[3081,736,27092]]) - sage: discrete_log_rho(A^1234567, A) + sage: A = matrix(GF(50021), [[10577, 23999, 28893], # optional - sage.rings.finite_rings + ....: [14601, 41019, 30188], + ....: [3081, 736, 27092]]) + sage: discrete_log_rho(A^1234567, A) # optional - sage.rings.finite_rings 1234567 Beware, the order must be prime:: @@ -552,21 +553,21 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No ... ValueError: for Pollard rho algorithm the order of the group must be prime - If it fails to find a suitable logarithm, it raises a ``ValueError``:: + If it fails to find a suitable logarithm, it raises a :class:`ValueError`:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(31002),I(15501)) + sage: discrete_log_rho(I(31002), I(15501)) Traceback (most recent call last): ... ValueError: Pollard rho algorithm failed to find a logarithm The main limitation on the hash function is that we don't want to have - `hash(x*y) = hash(x) + hash(y)`:: + ``hash(x*y) == hash(x) + hash(y)``:: sage: I = IntegerModRing(next_prime(2^23)) sage: def test(): ....: try: - ....: discrete_log_rho(I(123456),I(1),operation='+') + ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: ....: print("FAILURE") sage: test() # random failure @@ -574,7 +575,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No If this happens, we can provide a better hash function:: - sage: discrete_log_rho(I(123456),I(1),operation='+', hash_function=lambda x: hash(x*x)) + sage: discrete_log_rho(I(123456), I(1), operation='+', hash_function=lambda x: hash(x*x)) 123456 AUTHOR: @@ -673,21 +674,21 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i INPUT: - - ``a`` - group element - - ``base`` - group element (the base) - - ``ord`` - integer (multiple of order of base, or ``None``) - - ``bounds`` - a priori bounds on the log - - ``operation`` - string: '*', '+', 'other' - - ``identity`` - the group's identity - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` - - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group - - ``algorithm`` - string denoting what algorithm to use for prime-order logarithms: 'bsgs', 'rho', 'lambda' + - ``a`` -- group element + - ``base`` -- group element (the base) + - ``ord`` -- integer (multiple of order of base, or ``None``) + - ``bounds`` -- a priori bounds on the log + - ``operation`` -- string: ``'*'``, ``'+'``, other + - ``identity`` -- the group's identity + - ``inverse()`` - function of 1 argument ``x``, returning inverse of ``x`` + - ``op()`` - function of 2 arguments ``x``, ``y``, returning ``x*y`` in the group + - ``algorithm`` -- string denoting what algorithm to use for prime-order logarithms: ``'bsgs'``, ``'rho'``, ``'lambda'`` ``a`` and ``base`` must be elements of some group with identity - given by identity, inverse of ``x`` by ``inverse(x)``, and group + given by ``identity``, inverse of ``x`` by ``inverse(x)``, and group operation on ``x``, ``y`` by ``op(x,y)``. - If operation is '*' or '+' then the other + If operation is ``'*'`` or ``'+'``, then the other arguments are provided automatically; otherwise they must be provided by the caller. @@ -697,13 +698,13 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i assuming that ``ord`` is a multiple of the order of the base `b`. If ``ord`` is not specified, an attempt is made to compute it. - If no such `n` exists, this function raises a ``ValueError`` exception. + If no such `n` exists, this function raises a :class:`ValueError` exception. .. warning:: - If ``x`` has a log method, it is likely to be vastly faster + If ``x`` has a ``log`` method, it is likely to be vastly faster than using this function. E.g., if ``x`` is an integer modulo - `n`, use its log method instead! + `n`, use its ``log`` method instead! ALGORITHM: Pohlig-Hellman, Baby step giant step, Pollard's lambda/kangaroo, and Pollard's rho. @@ -735,63 +736,63 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i See :trac:`2356`:: - sage: F. = GF(121) - sage: v = w^120 - sage: v.log(w) + sage: F. = GF(121) # optional - sage.rings.finite_rings + sage: v = w^120 # optional - sage.rings.finite_rings + sage: v.log(w) # optional - sage.rings.finite_rings 0 - sage: K. = CyclotomicField(230) - sage: w = z^50 - sage: discrete_log(w,z) + sage: K. = CyclotomicField(230) # optional - sage.rings.number_field + sage: w = z^50 # optional - sage.rings.number_field + sage: discrete_log(w, z) # optional - sage.rings.number_field 50 An example where the order is infinite: note that we must give an upper bound here:: - sage: K. = QuadraticField(23) - sage: eps = 5*a-24 # a fundamental unit - sage: eps.multiplicative_order() + sage: K. = QuadraticField(23) # optional - sage.rings.number_field + sage: eps = 5*a - 24 # a fundamental unit # optional - sage.rings.number_field + sage: eps.multiplicative_order() # optional - sage.rings.number_field +Infinity - sage: eta = eps^100 - sage: discrete_log(eta,eps,bounds=(0,1000)) + sage: eta = eps^100 # optional - sage.rings.number_field + sage: discrete_log(eta, eps, bounds=(0,1000)) # optional - sage.rings.number_field 100 In this case we cannot detect negative powers:: - sage: eta = eps^(-3) - sage: discrete_log(eta,eps,bounds=(0,100)) + sage: eta = eps^(-3) # optional - sage.rings.number_field + sage: discrete_log(eta,eps,bounds=(0,100)) # optional - sage.rings.number_field Traceback (most recent call last): ... ValueError: no discrete log of -11515*a - 55224 found to base 5*a - 24 But we can invert the base (and negate the result) instead:: - sage: - discrete_log(eta^-1,eps,bounds=(0,100)) + sage: -discrete_log(eta^-1, eps, bounds=(0,100)) # optional - sage.rings.number_field -3 An additive example: elliptic curve DLOG:: - sage: F = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) - sage: F. = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) - sage: P = E(25*a + 16 , 15*a + 7 ) - sage: P.order() + sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: P = E(25*a + 16, 15*a + 7) # optional - sage.rings.finite_rings + sage: P.order() # optional - sage.rings.finite_rings 672 - sage: Q = 39*P; Q + sage: Q = 39*P; Q # optional - sage.rings.finite_rings (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+') + sage: discrete_log(Q, P, P.order(), operation='+') # optional - sage.rings.finite_rings 39 An example of big smooth group:: - sage: F. = GF(2^63) - sage: g = F.gen() - sage: u = g**123456789 - sage: discrete_log(u,g) + sage: F. = GF(2^63) # optional - sage.rings.finite_rings + sage: g = F.gen() # optional - sage.rings.finite_rings + sage: u = g**123456789 # optional - sage.rings.finite_rings + sage: discrete_log(u,g) # optional - sage.rings.finite_rings 123456789 - The above examples also work when the 'rho' and 'lambda' algorithms are used:: + The above examples also work when the ``'rho'`` and ``'lambda'`` algorithms are used:: sage: b = Mod(2,37); a = b^20 sage: discrete_log(a, b, algorithm='rho') @@ -800,10 +801,10 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, algorithm='lambda', bounds=(10, 100)) 20 - sage: K = GF(3^6,'b') - sage: b = K.gen() - sage: a = b^210 - sage: discrete_log(a, b, K.order()-1, algorithm='rho') + sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings + sage: b = K.gen() # optional - sage.rings.finite_rings + sage: a = b^210 # optional - sage.rings.finite_rings + sage: discrete_log(a, b, K.order()-1, algorithm='rho') # optional - sage.rings.finite_rings 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -817,22 +818,22 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i ... ValueError: no discrete log of 2 found to base 1 - sage: F=GF(37^2,'a') - sage: E=EllipticCurve(F,[1,1]) - sage: F.=GF(37^2,'a') - sage: E=EllipticCurve(F,[1,1]) - sage: P=E(25*a + 16 , 15*a + 7 ) - sage: P.order() + sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: P = E(25*a + 16, 15*a + 7) # optional - sage.rings.finite_rings + sage: P.order() # optional - sage.rings.finite_rings 672 - sage: Q=39*P; Q + sage: Q = 39*P; Q # optional - sage.rings.finite_rings (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+',algorithm='lambda') + sage: discrete_log(Q, P, P.order(), operation='+', algorithm='lambda') # optional - sage.rings.finite_rings 39 - sage: F. = GF(2^63) - sage: g = F.gen() - sage: u = g**123456789 - sage: discrete_log(u,g,algorithm='rho') + sage: F. = GF(2^63) # optional - sage.rings.finite_rings + sage: g = F.gen() # optional - sage.rings.finite_rings + sage: u = g**123456789 # optional - sage.rings.finite_rings + sage: discrete_log(u, g, algorithm='rho') # optional - sage.rings.finite_rings 123456789 TESTS: @@ -849,8 +850,8 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: kwargs = {'operation': '+'} sage: kwargs['algorithm'] = choice(['bsgs', 'rho', 'lambda']) sage: if randrange(2): - ....: lo = randrange(-order, sol+1) - ....: hi = randrange(sol+1, 2*order) + ....: lo = randrange(-order, sol + 1) + ....: hi = randrange(sol + 1, 2*order) ....: assert lo <= sol <= hi ....: kwargs['bounds'] = (lo, hi) sage: try: @@ -973,23 +974,25 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N EXAMPLES:: - sage: F. = GF(2^63) - sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) + sage: F. = GF(2^63) # optional - sage.rings.finite_rings + sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) # optional - sage.rings.finite_rings 1234567 - sage: F. = GF(37^5) - sage: E = EllipticCurve(F, [1,1]) - sage: P = E.lift_x(a); P + sage: F. = GF(37^5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: P = E.lift_x(a); P # optional - sage.rings.finite_rings (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: - sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), operation='+') + sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # optional - sage.rings.finite_rings + ....: operation='+') 69327408 - sage: K. = GF(89**5) - sage: hs = lambda x: hash(x) + 15 - sage: discrete_log_lambda(a**(89**3 - 3), a, (89**2, 89**4), operation = '*', hash_function = hs) # long time (10s on sage.math, 2011) + sage: K. = GF(89**5) # optional - sage.rings.finite_rings + sage: hs = lambda x: hash(x) + 15 # optional - sage.rings.finite_rings + sage: discrete_log_lambda(a**(89**3 - 3), # long time (10s on sage.math, 2011) # optional - sage.rings.finite_rings + ....: a, (89**2, 89**4), operation='*', hash_function=hs) 704966 AUTHOR: @@ -1082,25 +1085,25 @@ def linear_relation(P, Q, operation='+', identity=None, inverse=None, op=None): An additive example (in an elliptic curve group):: - sage: F. = GF(3^6,'a') - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a,a^4 + a^3 + 2*a + 1]) - sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) - sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) - sage: linear_relation(P,Q,'+') + sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings + sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2, 0) # optional - sage.rings.finite_rings + sage: Q = E(2*a^3 + 2*a^2 + 2*a, a^3 + 2*a^2 + 1) # optional - sage.rings.finite_rings + sage: linear_relation(P, Q, '+') # optional - sage.rings.finite_rings (1, 2) - sage: P == 2*Q + sage: P == 2*Q # optional - sage.rings.finite_rings True A multiplicative example (in a finite field's multiplicative group):: - sage: F. = GF(3^6,'a') - sage: a.multiplicative_order().factor() + sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings + sage: a.multiplicative_order().factor() # optional - sage.rings.finite_rings 2^3 * 7 * 13 - sage: b = a^7 - sage: c = a^13 - sage: linear_relation(b,c,'*') + sage: b = a^7 # optional - sage.rings.finite_rings + sage: c = a^13 # optional - sage.rings.finite_rings + sage: linear_relation(b, c, '*') # optional - sage.rings.finite_rings (13, 7) - sage: b^13==c^7 + sage: b^13 == c^7 # optional - sage.rings.finite_rings True """ Z = integer_ring.ZZ @@ -1164,16 +1167,16 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, INPUT: - - ``P`` - a Sage object which is a group element; - - ``m`` - a Sage integer which is a multiple of the order of ``P``, + - ``P`` -- a Sage object which is a group element; + - ``m`` -- a Sage integer which is a multiple of the order of ``P``, i.e. we require that ``m*P=0`` (or ``P**m=1``); - - ``check`` - a Boolean (default:True), indicating whether we check if ``m`` + - ``check`` -- a Boolean (default: ``True``), indicating whether we check if ``m`` really is a multiple of the order; - - ``factorization`` - the factorization of ``m``, or ``None`` in which + - ``factorization`` -- the factorization of ``m``, or ``None`` in which case this function will need to factor ``m``; - - ``plist`` - a list of the prime factors of ``m``, or ``None`` - kept for compatibility only, + - ``plist`` -- a list of the prime factors of ``m``, or ``None`` - kept for compatibility only, prefer the use of ``factorization``; - - ``operation`` - string: '+' (default) or '*'. + - ``operation`` -- string: ``'+'`` (default) or ``'*'``. .. note:: @@ -1183,12 +1186,12 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, EXAMPLES:: sage: from sage.groups.generic import order_from_multiple - sage: k. = GF(5^5) - sage: b = a^4 - sage: order_from_multiple(b,5^5-1,operation='*') + sage: k. = GF(5^5) # optional - sage.rings.finite_rings + sage: b = a^4 # optional - sage.rings.finite_rings + sage: order_from_multiple(b, 5^5 - 1, operation='*') # optional - sage.rings.finite_rings 781 - sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: M = E.cardinality(); M 3227 sage: F = M.factor() @@ -1198,18 +1201,19 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: order_from_multiple(Q, M, factorization=F, operation='+') 7 - sage: K. = CyclotomicField(230) - sage: w = z^50 - sage: order_from_multiple(w,230,operation='*') + sage: K. = CyclotomicField(230) # optional - sage.rings.number_field + sage: w = z^50 # optional - sage.rings.number_field + sage: order_from_multiple(w, 230, operation='*') # optional - sage.rings.number_field 23 - sage: F = GF(2^1279,'a') - sage: n = F.cardinality()-1 # Mersenne prime - sage: order_from_multiple(F.random_element(),n,factorization=[(n,1)],operation='*') == n + sage: F = GF(2^1279,'a') # optional - sage.rings.finite_rings + sage: n = F.cardinality() - 1 # Mersenne prime # optional - sage.rings.finite_rings + sage: order_from_multiple(F.random_element(), n, # optional - sage.rings.finite_rings + ....: factorization=[(n,1)], operation='*') == n True - sage: K. = GF(3^60) - sage: order_from_multiple(a, 3^60-1, operation='*', check=False) + sage: K. = GF(3^60) # optional - sage.rings.finite_rings + sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) # optional - sage.rings.finite_rings 42391158275216203514294433200 """ Z = integer_ring.ZZ @@ -1294,21 +1298,21 @@ def order_from_bounds(P, bounds, d=None, operation='+', INPUT: - - ``P`` - a Sage object which is a group element + - ``P`` -- a Sage object which is a group element - - ``bounds`` - a 2-tuple ``(lb,ub)`` such that ``m*P=0`` (or + - ``bounds`` -- a 2-tuple ``(lb,ub)`` such that ``m*P=0`` (or ``P**m=1``) for some ``m`` with ``lb<=m<=ub``. - - ``d`` - (optional) a positive integer; only ``m`` which are + - ``d`` -- (optional) a positive integer; only ``m`` which are multiples of this will be considered. - - ``operation`` - string: '+' (default ) or '*' or other. + - ``operation`` -- string: ``'+'`` (default ) or ``'*'`` or other. If other, the following must be supplied: - - ``identity``: the identity element for the group; - - ``inverse()``: a function of one argument giving the inverse + - ``identity`` -- the identity element for the group; + - ``inverse()`` -- a function of one argument giving the inverse of a group element; - - ``op()``: a function of 2 arguments defining the group binary + - ``op()`` -- a function of 2 arguments defining the group binary operation. @@ -1321,12 +1325,12 @@ def order_from_bounds(P, bounds, d=None, operation='+', EXAMPLES:: sage: from sage.groups.generic import order_from_bounds - sage: k. = GF(5^5) - sage: b = a^4 - sage: order_from_bounds(b,(5^4,5^5),operation='*') + sage: k. = GF(5^5) # optional - sage.rings.finite_rings + sage: b = a^4 # optional - sage.rings.finite_rings + sage: order_from_bounds(b, (5^4, 5^5), operation='*') # optional - sage.rings.finite_rings 781 - sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: bounds = Hasse_bounds(5^5) sage: Q = E(0,2) sage: order_from_bounds(Q, bounds, operation='+') @@ -1334,9 +1338,9 @@ def order_from_bounds(P, bounds, d=None, operation='+', sage: order_from_bounds(P, bounds, 7, operation='+') 3227 - sage: K.=CyclotomicField(230) - sage: w = z^50 - sage: order_from_bounds(w,(200,250),operation='*') + sage: K. = CyclotomicField(230) # optional - sage.rings.number_field + sage: w = z^50 # optional - sage.rings.number_field + sage: order_from_bounds(w, (200, 250), operation='*') # optional - sage.rings.number_field 23 """ from operator import mul, add @@ -1378,15 +1382,14 @@ def merge_points(P1, P2, operation='+', - ``P1`` -- a pair `(g_1,n_1)` where `g_1` is a group element of order `n_1` - ``P2`` -- a pair `(g_2,n_2)` where `g_2` is a group element of order `n_2` - - ``operation`` -- string: '+' (default ) or '*' or other. If + - ``operation`` -- string: ``'+'`` (default) or ``'*'`` or other. If other, the following must be supplied: - - ``identity``: the identity element for the group; - - ``inverse()``: a function of one argument giving the inverse - of a group element; - - ``op()``: a function of 2 arguments defining the group - binary operation. - + - ``identity`` -- the identity element for the group; + - ``inverse()`` -- a function of one argument giving the inverse + of a group element; + - ``op()`` -- a function of 2 arguments defining the group + binary operation. OUTPUT: @@ -1395,27 +1398,27 @@ def merge_points(P1, P2, operation='+', EXAMPLES:: sage: from sage.groups.generic import merge_points - sage: F.=GF(3^6,'a') - sage: b = a^7 - sage: c = a^13 - sage: ob = (3^6-1)//7 - sage: oc = (3^6-1)//13 - sage: merge_points((b,ob),(c,oc),operation='*') + sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings + sage: b = a^7 # optional - sage.rings.finite_rings + sage: c = a^13 # optional - sage.rings.finite_rings + sage: ob = (3^6-1)//7 # optional - sage.rings.finite_rings + sage: oc = (3^6-1)//13 # optional - sage.rings.finite_rings + sage: merge_points((b,ob), (c,oc), operation='*') # optional - sage.rings.finite_rings (a^4 + 2*a^3 + 2*a^2, 728) - sage: d,od = merge_points((b,ob),(c,oc),operation='*') - sage: od == d.multiplicative_order() + sage: d, od = merge_points((b,ob), (c,oc), operation='*') # optional - sage.rings.finite_rings + sage: od == d.multiplicative_order() # optional - sage.rings.finite_rings True - sage: od == lcm(ob,oc) + sage: od == lcm(ob, oc) # optional - sage.rings.finite_rings True - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a,a^4 + a^3 + 2*a + 1]) - sage: P = E(2*a^5 + 2*a^4 + a^3 + 2 , a^4 + a^3 + a^2 + 2*a + 2) + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) sage: P.order() 7 - sage: Q = E(2*a^5 + 2*a^4 + 1 , a^5 + 2*a^3 + 2*a + 2 ) + sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) sage: Q.order() 4 - sage: R,m = merge_points((P,7),(Q,4), operation='+') + sage: R, m = merge_points((P,7), (Q,4), operation='+') sage: R.order() == m True sage: m == lcm(7,4) @@ -1466,12 +1469,12 @@ def structure_description(G, latex=False): INPUT: - - ``latex`` -- a boolean (default: ``False``). If ``True`` return a + - ``latex`` -- a boolean (default: ``False``). If ``True``, return a LaTeX formatted string. OUTPUT: - - string + string .. WARNING:: @@ -1483,38 +1486,38 @@ def structure_description(G, latex=False): EXAMPLES:: - sage: G = CyclicPermutationGroup(6) - sage: G.structure_description() + sage: G = CyclicPermutationGroup(6) # optional - sage.groups + sage: G.structure_description() # optional - sage.groups 'C6' - sage: G.structure_description(latex=True) + sage: G.structure_description(latex=True) # optional - sage.groups 'C_{6}' - sage: G2 = G.direct_product(G, maps=False) - sage: LatexExpr(G2.structure_description(latex=True)) + sage: G2 = G.direct_product(G, maps=False) # optional - sage.groups + sage: LatexExpr(G2.structure_description(latex=True)) # optional - sage.groups C_{6} \times C_{6} This method is mainly intended for small groups or groups with few normal subgroups. Even then there are some surprises:: - sage: D3 = DihedralGroup(3) - sage: D3.structure_description() + sage: D3 = DihedralGroup(3) # optional - sage.groups + sage: D3.structure_description() # optional - sage.groups 'S3' We use the Sage notation for the degree of dihedral groups:: - sage: D4 = DihedralGroup(4) - sage: D4.structure_description() + sage: D4 = DihedralGroup(4) # optional - sage.groups + sage: D4.structure_description() # optional - sage.groups 'D4' Works for finitely presented groups (:trac:`17573`):: - sage: F. = FreeGroup() - sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] - sage: G.structure_description() + sage: F. = FreeGroup() # optional - sage.groups + sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] # optional - sage.groups + sage: G.structure_description() # optional - sage.groups 'C7' And matrix groups (:trac:`17573`):: - sage: groups.matrix.GL(4,2).structure_description() + sage: groups.matrix.GL(4,2).structure_description() # optional - sage.libs.gap sage.modules 'A8' """ import re diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index 98a5f187638..b1c97ce6409 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -139,7 +139,7 @@ cdef class Group(Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # optional - sage.rings.finite_rings + sage: SL(2, 7).is_commutative() # optional - sage.modules sage.rings.finite_rings False """ return self.is_abelian() @@ -161,8 +161,8 @@ cdef class Group(Parent): TESTS:: - sage: H = SL(2, QQ) - sage: H.order() + sage: H = SL(2, QQ) # optional - sage.modules + sage: H.order() # optional - sage.modules +Infinity """ try: From 9a0b7d5ce153b93ea109cd2179518d05095b0c0e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 Apr 2023 20:11:28 -0700 Subject: [PATCH 07/64] sage.groups: More # optional --- src/sage/groups/generic.py | 77 +++++++++++++++++++------------------- src/sage/groups/old.pyx | 2 +- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 5ac9daf4350..9d64d7eeaa4 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -402,35 +402,35 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): sage: from sage.groups.generic import bsgs sage: b = Mod(2,37); a = b^20 - sage: bsgs(b, a, (0,36)) + sage: bsgs(b, a, (0, 36)) 20 - sage: p = next_prime(10^20) - sage: a = Mod(2,p); b = a^(10^25) - sage: bsgs(a, b, (10^25-10^6,10^25+10^6)) == 10^25 + sage: p = next_prime(10^20) # optional - sage.libs.pari + sage: a = Mod(2,p); b = a^(10^25) # optional - sage.libs.pari + sage: bsgs(a, b, (10^25 - 10^6, 10^25 + 10^6)) == 10^25 # optional - sage.libs.pari True - sage: K = GF(3^6,'b') - sage: a = K.gen() - sage: b = a^210 - sage: bsgs(a, b, (0,K.order()-1)) + sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings + sage: a = K.gen() # optional - sage.rings.finite_rings + sage: b = a^210 # optional - sage.rings.finite_rings + sage: bsgs(a, b, (0, K.order() - 1)) # optional - sage.rings.finite_rings 210 - sage: K. = CyclotomicField(230) - sage: w = z^500 - sage: bsgs(z,w,(0,229)) + sage: K. = CyclotomicField(230) # optional - sage.rings.number_field + sage: w = z^500 # optional - sage.rings.number_field + sage: bsgs(z, w, (0, 229)) # optional - sage.rings.number_field 40 An additive example in an elliptic curve group:: - sage: F. = GF(37^5) - sage: E = EllipticCurve(F, [1,1]) - sage: P = E.lift_x(a); P + sage: F. = GF(37^5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings + sage: P = E.lift_x(a); P # optional - sage.rings.finite_rings (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: - sage: bsgs(P,P.parent()(0),Hasse_bounds(F.order()),operation='+') + sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # optional - sage.rings.finite_rings 69327408 AUTHOR: @@ -548,7 +548,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No Beware, the order must be prime:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(2), I(3)) + sage: discrete_log_rho(I(2), I(3)) # optional - sage.libs.pari Traceback (most recent call last): ... ValueError: for Pollard rho algorithm the order of the group must be prime @@ -556,7 +556,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No If it fails to find a suitable logarithm, it raises a :class:`ValueError`:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(31002), I(15501)) + sage: discrete_log_rho(I(31002), I(15501)) # optional - sage.libs.pari Traceback (most recent call last): ... ValueError: Pollard rho algorithm failed to find a logarithm @@ -564,18 +564,19 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No The main limitation on the hash function is that we don't want to have ``hash(x*y) == hash(x) + hash(y)``:: - sage: I = IntegerModRing(next_prime(2^23)) - sage: def test(): + sage: I = IntegerModRing(next_prime(2^23)) # optional - sage.libs.pari + sage: def test(): # optional - sage.libs.pari ....: try: ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: ....: print("FAILURE") - sage: test() # random failure + sage: test() # random failure # optional - sage.libs.pari FAILURE If this happens, we can provide a better hash function:: - sage: discrete_log_rho(I(123456), I(1), operation='+', hash_function=lambda x: hash(x*x)) + sage: discrete_log_rho(I(123456), I(1), operation='+', # optional - sage.libs.pari + ....: hash_function=lambda x: hash(x*x)) 123456 AUTHOR: @@ -717,10 +718,10 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, bounds=(10, 100)) 20 - sage: K = GF(3^6,'b') - sage: b = K.gen() - sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: K = GF(3^6, 'b') # optional - sage.rings.finite_rings + sage: b = K.gen() # optional - sage.rings.finite_rings + sage: a = b^210 # optional - sage.rings.finite_rings + sage: discrete_log(a, b, K.order()-1) # optional - sage.rings.finite_rings 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -1190,15 +1191,15 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: b = a^4 # optional - sage.rings.finite_rings sage: order_from_multiple(b, 5^5 - 1, operation='*') # optional - sage.rings.finite_rings 781 - sage: E = EllipticCurve(k, [2,4]) - sage: P = E(3*a^4 + 3*a, 2*a + 1) - sage: M = E.cardinality(); M + sage: E = EllipticCurve(k, [2,4]) # optional - sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings + sage: M = E.cardinality(); M # optional - sage.rings.finite_rings 3227 - sage: F = M.factor() - sage: order_from_multiple(P, M, factorization=F, operation='+') + sage: F = M.factor() # optional - sage.rings.finite_rings + sage: order_from_multiple(P, M, factorization=F, operation='+') # optional - sage.rings.finite_rings 3227 - sage: Q = E(0,2) - sage: order_from_multiple(Q, M, factorization=F, operation='+') + sage: Q = E(0,2) # optional - sage.rings.finite_rings + sage: order_from_multiple(Q, M, factorization=F, operation='+') # optional - sage.rings.finite_rings 7 sage: K. = CyclotomicField(230) # optional - sage.rings.number_field @@ -1329,13 +1330,13 @@ def order_from_bounds(P, bounds, d=None, operation='+', sage: b = a^4 # optional - sage.rings.finite_rings sage: order_from_bounds(b, (5^4, 5^5), operation='*') # optional - sage.rings.finite_rings 781 - sage: E = EllipticCurve(k, [2,4]) - sage: P = E(3*a^4 + 3*a, 2*a + 1) - sage: bounds = Hasse_bounds(5^5) - sage: Q = E(0,2) - sage: order_from_bounds(Q, bounds, operation='+') + sage: E = EllipticCurve(k, [2,4]) # optional - sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings + sage: bounds = Hasse_bounds(5^5) # optional - sage.rings.finite_rings + sage: Q = E(0,2) # optional - sage.rings.finite_rings + sage: order_from_bounds(Q, bounds, operation='+') # optional - sage.rings.finite_rings 7 - sage: order_from_bounds(P, bounds, 7, operation='+') + sage: order_from_bounds(P, bounds, 7, operation='+') # optional - sage.rings.finite_rings 3227 sage: K. = CyclotomicField(230) # optional - sage.rings.number_field diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 3201a1c17ec..8c9127b957f 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -120,7 +120,7 @@ cdef class Group(sage.structure.parent.Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # optional - sage.modules + sage: SL(2, 7).is_commutative() # optional - sage.modules sage.rings.finite_rings False """ return self.is_abelian() From d930b86a5b0e9d101961d0aeeede080d358534be Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 12 May 2023 20:01:15 -0700 Subject: [PATCH 08/64] sage.groups: Fix # optional --- src/sage/groups/generic.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 9d64d7eeaa4..f4b2462f899 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1412,17 +1412,17 @@ def merge_points(P1, P2, operation='+', sage: od == lcm(ob, oc) # optional - sage.rings.finite_rings True - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) - sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) - sage: P.order() + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings + sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) # optional - sage.rings.finite_rings + sage: P.order() # optional - sage.rings.finite_rings 7 - sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) - sage: Q.order() + sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) # optional - sage.rings.finite_rings + sage: Q.order() # optional - sage.rings.finite_rings 4 - sage: R, m = merge_points((P,7), (Q,4), operation='+') - sage: R.order() == m + sage: R, m = merge_points((P,7), (Q,4), operation='+') # optional - sage.rings.finite_rings + sage: R.order() == m # optional - sage.rings.finite_rings True - sage: m == lcm(7,4) + sage: m == lcm(7,4) # optional - sage.rings.finite_rings True """ from operator import mul, add From 1db61db5c3eb728d30e48b13a5cf769e04134c1e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 13 May 2023 11:57:10 -0700 Subject: [PATCH 09/64] sage.groups: Fix # optional --- .../additive_abelian_wrapper.py | 90 +++++++++++-------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index d0171db2fe8..71c15f2fa51 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -85,12 +85,13 @@ def __init__(self, domain): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field - sage: F = QQbar.coerce_map_from(G); F # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: F = QQbar.coerce_map_from(G); F # optional - sage.rings.number_field Generic morphism: From: Additive abelian group isomorphic to Z + Z embedded in Algebraic Field To: Algebraic Field - sage: type(F) # optional - sage.rings.number_field + sage: type(F) # optional - sage.rings.number_field """ Morphism.__init__(self, domain.Hom(domain.universe())) @@ -105,7 +106,7 @@ def _call_(self, x): True sage: P1 = E([1,-1,1]) sage: P2 = E([0,1,0]) - sage: P1 in G # indirect doctest + sage: P1 in G # indirect doctest False sage: P2 in G True @@ -127,8 +128,9 @@ def __init__(self, parent, vector, element=None, check=False): EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field - sage: G.0 # indirect doctest # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: G.0 # indirect doctest # optional - sage.rings.number_field 1.414213562373095? """ addgp.AdditiveAbelianGroupElement.__init__(self, parent, vector, check) @@ -161,7 +163,7 @@ def _repr_(self): EXAMPLES:: sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) - sage: repr(T) # indirect doctest + sage: repr(T) # indirect doctest '(0 : 0 : 1)' """ return repr(self.element()) @@ -179,18 +181,19 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): sage: G6 = AdditiveAbelianGroupWrapper(Zmod(42), [6], [7]); G6 Additive abelian group isomorphic to Z/7 embedded in Ring of integers modulo 42 sage: G = AdditiveAbelianGroupWrapper(Zmod(42), [21,14,6], [2,3,7]); G - Additive abelian group isomorphic to Z/2 + Z/3 + Z/7 embedded in Ring of integers modulo 42 + Additive abelian group isomorphic to Z/2 + Z/3 + Z/7 embedded in + Ring of integers modulo 42 sage: G.invariants() (42,) :: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # optional - sage.rings.number_field sage.symbolic + sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # optional - sage.rings.number_field sage.symbolic Additive abelian group isomorphic to Z + Z embedded in Algebraic Field :: - sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.libs.pari + sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.rings.finite_rings Additive abelian group isomorphic to Z/420 + Z/420 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 @@ -202,7 +205,8 @@ def __init__(self, universe, gens, invariants): r""" EXAMPLES:: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # indirect doctest # optional - sage.rings.number_field + sage: AdditiveAbelianGroupWrapper(QQbar, # indirect doctest # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) Additive abelian group isomorphic to Z + Z embedded in Algebraic Field """ self._universe = universe @@ -219,8 +223,10 @@ def universe(self): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field - sage: G.universe() # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], + ....: [0, 0]) + sage: G.universe() # optional - sage.rings.number_field Algebraic Field """ return self._universe @@ -248,8 +254,9 @@ def _repr_(self): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # optional - sage.rings.number_field - sage: repr(G) # indirect doctest # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: repr(G) # indirect doctest # optional - sage.rings.number_field 'Additive abelian group isomorphic to Z + Z embedded in Algebraic Field' """ return addgp.AdditiveAbelianGroup_fixed_gens._repr_(self) + " embedded in " + self.universe()._repr_() @@ -285,10 +292,11 @@ def discrete_exp(self, v): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), -1], [0, 0]) # optional - sage.rings.number_field - sage: v = G.discrete_exp([3, 5]); v # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + ....: [sqrt(QQbar(2)), -1], [0, 0]) + sage: v = G.discrete_exp([3, 5]); v # optional - sage.rings.number_field -0.7573593128807148? - sage: v.parent() is QQbar # optional - sage.rings.number_field + sage: v.parent() is QQbar # optional - sage.rings.number_field True This method is an inverse of :meth:`discrete_log`:: @@ -334,7 +342,8 @@ def discrete_log(self, x, gens=None): EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 2*3, 2*3*5, 2*3*5*7, 2*3*5*7*11]) - sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), [g.order() for g in G.gens()]) + sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), + ....: [g.order() for g in G.gens()]) sage: A.discrete_log(A.discrete_exp([1,5,23,127,539])) (1, 5, 23, 127, 539) @@ -359,8 +368,8 @@ def discrete_log(self, x, gens=None): :: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # optional - sage.rings.number_field - sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # optional - sage.rings.number_field sage.symbolic + sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: No black-box discrete log for infinite abelian groups @@ -435,13 +444,13 @@ def torsion_subgroup(self, n=None): :: - sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.libs.pari - sage: T = E.abelian_group().torsion_subgroup(42) # optional - sage.libs.pari - sage: T # optional - sage.libs.pari + sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.rings.finite_rings + sage: T = E.abelian_group().torsion_subgroup(42) # optional - sage.rings.finite_rings + sage: T # optional - sage.rings.finite_rings Additive abelian group isomorphic to Z/42 + Z/6 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 - sage: [P.order() for P in T.gens()] # optional - sage.libs.pari + sage: [P.order() for P in T.gens()] # optional - sage.rings.finite_rings [42, 6] :: @@ -449,15 +458,21 @@ def torsion_subgroup(self, n=None): sage: E = EllipticCurve('574i1') sage: pts = [E(103,172), E(61,18)] sage: assert pts[0].order() == 7 and pts[1].order() == infinity - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]) - sage: M - Additive abelian group isomorphic to Z/7 + Z embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M + Additive abelian group isomorphic to Z/7 + Z embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup() - Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Additive abelian group isomorphic to Z/7 embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup(7) - Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Additive abelian group isomorphic to Z/7 embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup(5) - Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Trivial group embedded in Abelian group of points on Elliptic Curve + defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field AUTHORS: @@ -498,7 +513,8 @@ def from_generators(gens, universe=None): sage: G = AdditiveAbelianGroup([15, 30, 45]) sage: gs = [G((1,2,3)), G((4,5,6)), G((7,7,7)), G((3,2,1))] sage: H = AdditiveAbelianGroupWrapper.from_generators(gs); H - Additive abelian group isomorphic to Z/90 + Z/15 embedded in Additive abelian group isomorphic to Z/15 + Z/30 + Z/45 + Additive abelian group isomorphic to Z/90 + Z/15 embedded in + Additive abelian group isomorphic to Z/15 + Z/30 + Z/45 sage: H.gens() ((12, 13, 14), (1, 26, 21)) @@ -557,12 +573,12 @@ def _discrete_log_pgroup(p, vals, aa, b): Check for :trac:`34716`:: - sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.libs.pari - sage: G = E.abelian_group().torsion_subgroup(42) # optional - sage.libs.pari - sage: G.invariants() # optional - sage.libs.pari + sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.rings.finite_rings + sage: G = E.abelian_group().torsion_subgroup(42) # optional - sage.rings.finite_rings + sage: G.invariants() # optional - sage.rings.finite_rings (6, 42) - sage: P, Q = G.torsion_subgroup(6).gens() # optional - sage.libs.pari - sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # optional - sage.groups + sage: P, Q = G.torsion_subgroup(6).gens() # optional - sage.rings.finite_rings + sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # optional - sage.groups sage.rings.finite_rings (2, 3) """ from itertools import product as iproduct From 4eb10cffa4ae6e46e7ba00746dad65f51f625426 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 15 May 2023 14:09:25 -0700 Subject: [PATCH 10/64] sage.groups: Add # optional --- src/sage/groups/braid.py | 34 +++++++++---------- src/sage/groups/cubic_braid.py | 15 ++++---- src/sage/groups/libgap_morphism.py | 6 ++-- .../groups/perm_gps/permgroup_element.pyx | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index f4ad632b332..8999738d15e 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -606,11 +606,11 @@ def plot3d(self, color='rainbow'): sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot3d() + sage: b.plot3d() # optional - sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color="red") + sage: b.plot3d(color="red") # optional - sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color=["red", "blue", "red", "blue"]) + sage: b.plot3d(color=["red", "blue", "red", "blue"]) # optional - sage.plot sage.symbolic Graphics3d Object """ from sage.plot.plot3d.shapes2 import bezier3d @@ -812,8 +812,8 @@ def links_gould_matrix(self, symbolics=False): Univariate Quotient Polynomial Ring in Yrbar over Multivariate Laurent Polynomial Ring in s0r, s1r over Integer Ring with modulus Yr^2 + s0r^2*s1r^2 - s0r^2 - s1r^2 + 1 - sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) - sage: HopfLGs.base_ring() + sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) # optional - sage.symbolic + sage: HopfLGs.base_ring() # optional - sage.symbolic Symbolic Ring """ rep = self.parent()._links_gould_representation(symbolics=symbolics) @@ -1016,15 +1016,15 @@ def _jones_polynomial(self): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # optional - sage.symbolic 1 sage: B = BraidGroup(2) sage: b = B([]) - sage: b._jones_polynomial + sage: b._jones_polynomial # optional - sage.symbolic -A^-2 - A^2 sage: b = B([-1, -1, -1]) - sage: b._jones_polynomial + sage: b._jones_polynomial # optional - sage.symbolic -A^-16 + A^-12 + A^-4 """ trace = self.markov_trace(normalized=False) @@ -1072,41 +1072,41 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # optional - sage.symbolic 1 Two unlinked unknots:: sage: B = BraidGroup(2) sage: b = B([]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # optional - sage.symbolic -sqrt(t) - 1/sqrt(t) The Hopf link:: sage: B = BraidGroup(2) sage: b = B([-1,-1]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # optional - sage.symbolic -1/sqrt(t) - 1/t^(5/2) Different representations of the trefoil and one of its mirror:: sage: B = BraidGroup(2) sage: b = B([-1, -1, -1]) - sage: b.jones_polynomial(skein_normalization=True) + sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic -A^-16 + A^-12 + A^-4 - sage: b.jones_polynomial() + sage: b.jones_polynomial() # optional - sage.symbolic 1/t + 1/t^3 - 1/t^4 sage: B = BraidGroup(3) sage: b = B([-1, -2, -1, -2]) - sage: b.jones_polynomial(skein_normalization=True) + sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic -A^-16 + A^-12 + A^-4 sage: R. = LaurentPolynomialRing(GF(2)) - sage: b.jones_polynomial(skein_normalization=True, variab=x) + sage: b.jones_polynomial(skein_normalization=True, variab=x) # optional - sage.symbolic x^-16 + x^-12 + x^-4 sage: B = BraidGroup(3) sage: b = B([1, 2, 1, 2]) - sage: b.jones_polynomial(skein_normalization=True) + sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic A^4 + A^12 - A^16 K11n42 (the mirror of the "Kinoshita-Terasaka" knot) and K11n34 (the @@ -1115,7 +1115,7 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(4) sage: b11n42 = B([1, -2, 3, -2, 3, -2, -2, -1, 2, -3, -3, 2, 2]) sage: b11n34 = B([1, 1, 2, -3, 2, -3, 1, -2, -2, -3, -3]) - sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) + sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) # optional - sage.symbolic True """ if skein_normalization: diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index f49293e9924..f3e54cacc3b 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -400,11 +400,11 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Number Field in t with defining polynomial t^2 - t + 1 - sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa + sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # optional - sage.rings.number_field sage.symbolic [ 1/2*sqrt3*I + 1/2 1 -1/2*sqrt3*I - 1/2] [ 1/2*sqrt3*I + 1/2 -1/2*sqrt3*I + 1/2 0] [ 1 0 0] - sage: BuMa.base_ring() + sage: BuMa.base_ring() # optional - sage.rings.number_field sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field sage: BuMa = ele.burau_matrix(characteristic=7); BuMa [3 1 4] @@ -431,17 +431,18 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 5^2 - sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa + sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa # optional - sage.rings.number_field [ 0 zeta12^3] [zeta12^3 0] - sage: BuMa * H * BuMaAd == H + sage: BuMa * H * BuMaAd == H # optional - sage.rings.number_field True - sage: BuMa.base_ring() + sage: BuMa.base_ring() # optional - sage.rings.number_field Cyclotomic Field of order 12 and degree 4 - sage: BuMa, BuMaAd, H = ele.burau_matrix(domain = QQ[I, sqrt(3)], reduced='unitary'); BuMa + sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # optional - sage.rings.number_field sage.symbolic + ....: reduced='unitary'); BuMa [0 I] [I 0] - sage: BuMa.base_ring() + sage: BuMa.base_ring() # optional - sage.rings.number_field sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field """ braid = self.braid() diff --git a/src/sage/groups/libgap_morphism.py b/src/sage/groups/libgap_morphism.py index 93f33bf68a4..cadd25961d6 100644 --- a/src/sage/groups/libgap_morphism.py +++ b/src/sage/groups/libgap_morphism.py @@ -212,9 +212,9 @@ class GroupMorphism_libgap(Morphism): sage: phi(G.one()).parent() General Linear Group of degree 3 over Finite Field of size 3 - sage: MS = MatrixSpace(SR, 2, 2) - sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) - sage: G.Hom(G) + sage: MS = MatrixSpace(SR, 2, 2) # optional - sage.symbolic + sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # optional - sage.symbolic + sage: G.Hom(G) # optional - sage.symbolic Set of Morphisms from Matrix group over Symbolic Ring with 2 generators ( [1 0] [1 2] [0 1], [3 4] diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index efc5e502cc0..908efdd5a9a 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -1046,7 +1046,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): :: - sage: g(x) + sage: g(x) # optional - sage.symbolic Traceback (most recent call last): ... ValueError: must be in the domain or a list, tuple or string From 7dfdb06920a6679bf3ac41d3681b5a41fcc384da Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 May 2023 13:20:30 -0700 Subject: [PATCH 11/64] Massive modularization fixes --- src/sage/groups/braid.py | 6 ++-- src/sage/groups/cactus_group.py | 2 +- src/sage/groups/cubic_braid.py | 40 ++++++++++++++------- src/sage/groups/groups_catalog.py | 5 ++- src/sage/groups/matrix_gps/coxeter_group.py | 20 ++++++----- src/sage/groups/perm_gps/cubegroup.py | 28 +++++++-------- 6 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index 8999738d15e..bf0fd07063b 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -505,14 +505,14 @@ def plot(self, color='rainbow', orientation='bottom-top', gap=0.05, aspect_ratio False sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot() + sage: b.plot() # optional - sage.plot Graphics object consisting of 30 graphics primitives - sage: b.plot(color=["red", "blue", "red", "blue"]) + sage: b.plot(color=["red", "blue", "red", "blue"]) # optional - sage.plot Graphics object consisting of 30 graphics primitives sage: B. = BraidGroup(3) sage: b = t^-1*s^2 - sage: b.plot(orientation="left-right", color="red") + sage: b.plot(orientation="left-right", color="red") # optional - sage.plot Graphics object consisting of 12 graphics primitives """ from sage.plot.bezier_path import bezier_path diff --git a/src/sage/groups/cactus_group.py b/src/sage/groups/cactus_group.py index 9a481cc783c..959f80c9c48 100644 --- a/src/sage/groups/cactus_group.py +++ b/src/sage/groups/cactus_group.py @@ -970,7 +970,7 @@ def gens(self): sage: gen == b True """ - from sage.functions.other import factorial + from sage.arith.misc import factorial J = self.ambient() G = J.gens() one = J.one() diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index f3e54cacc3b..cd631603560 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -80,19 +80,22 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +from enum import Enum + +import sage.rings.abc + from sage.categories.groups import Groups from sage.categories.shephard_groups import ShephardGroups -from sage.misc.cachefunc import cached_method -from sage.libs.gap.element import GapElement from sage.groups.free_group import FreeGroup from sage.groups.finitely_presented import FinitelyPresentedGroup, FinitelyPresentedGroupElement from sage.groups.braid import BraidGroup +from sage.misc.cachefunc import cached_method from sage.rings.integer import Integer -from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField -from sage.rings.number_field.number_field import CyclotomicField -from sage.rings.finite_rings.finite_field_constructor import GF -from enum import Enum +try: + from sage.libs.gap.element import GapElement +except ImportError: + GapElement = () ############################################################################## @@ -461,7 +464,7 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, burau_ori, burau_ori_adj, herm_form_ori = burau_ori if domain is not None: - if isinstance(domain, UniversalCyclotomicField): + if isinstance(domain, sage.rings.abc.UniversalCyclotomicField): if root_bur is None: if unitary: root_bur = domain.gen(12) @@ -505,11 +508,13 @@ def find_root(domain): if not characteristic.is_zero() and not characteristic.is_prime(): raise ValueError('characteristic must be a prime') if characteristic.is_zero(): + from sage.rings.number_field.number_field import CyclotomicField if unitary: domain = CyclotomicField(12) else: domain = CyclotomicField(3) else: + from sage.rings.finite_rings.finite_field_constructor import GF domain = GF(characteristic) root_bur = find_root(domain) domain = root_bur.parent() @@ -964,12 +969,19 @@ def _test_matrix_group(self, **options): sage: CBG2._test_matrix_group() """ tester = self._tester(**options) + + MatDEF = self.as_matrix_group() + self._internal_test_attached_group(MatDEF, tester) + + try: + from sage.rings.finite_rings.finite_field_constructor import GF + except ImportError: + return + F3 = GF(3) r63 = F3(2) F4 = GF(4) r64 = F4.gen() - MatDEF = self.as_matrix_group() - self._internal_test_attached_group(MatDEF, tester) if self._cbg_type != CubicBraidGroup.type.AssionU or self.strands() < 5: # not well defined else-wise matrix_grpF3 = self.as_matrix_group(root_bur=r63) @@ -1318,6 +1330,8 @@ def transvec2mat(v, bas=bas, bform=bform, fact=a): # now 1 + 2*cos(\pi/6)*i\theta = 1 + sqrt(3)*(-sqrt(3)/2 + I/2) = 1- 3/2 + sqrt(3)I/2 = z12^4 = - ~z12^2 # finally: Coxeter's Realization is the unitary Burau representation of Squier for s = ~z12 # ----------------------------------------------------------------------------------------------- + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField + UCF = UniversalCyclotomicField() z12 = UCF.gen(12) classical_group = self.as_matrix_group(root_bur=~z12, domain=UCF, reduced='unitary') @@ -1644,8 +1658,9 @@ def as_classical_group(self, embedded=False): sage: U3 = AssionGroupU(3) sage: U3Cl = U3.as_classical_group(); U3Cl - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] - of (The projective general unitary group of degree 3 over Finite Field of size 2) + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) sage: U3Clemb = U3.as_classical_group(embedded=True); U3Clemb Subgroup with 2 generators ( [0 0 a] [a + 1 a a] @@ -1679,7 +1694,8 @@ def as_classical_group(self, embedded=False): [ 1 0 0] [ 0 1 -E(12)^7] [ 0 0 E(3)^2] - ) of General Unitary Group of degree 3 over Universal Cyclotomic Field with respect to positive definite hermitian form + ) of General Unitary Group of degree 3 over Universal Cyclotomic Field + with respect to positive definite hermitian form [-E(12)^7 + E(12)^11 -1 0] [ -1 -E(12)^7 + E(12)^11 -1] [ 0 -1 -E(12)^7 + E(12)^11] diff --git a/src/sage/groups/groups_catalog.py b/src/sage/groups/groups_catalog.py index 47e6e230508..0e9fd03bba8 100644 --- a/src/sage/groups/groups_catalog.py +++ b/src/sage/groups/groups_catalog.py @@ -105,5 +105,8 @@ from sage.groups.perm_gps import permutation_groups_catalog as permutation from sage.groups.misc_gps import misc_groups_catalog as misc from sage.groups.affine_gps import catalog as affine -from sage.groups.lie_gps import catalog as lie from sage.groups import finitely_presented_catalog as presentation + +from sage.misc.lazy_import import lazy_import +lazy_import('sage.groups.lie_gps', 'catalog', as_='lie') +del lazy_import diff --git a/src/sage/groups/matrix_gps/coxeter_group.py b/src/sage/groups/matrix_gps/coxeter_group.py index 66a877c61ac..537cf1e9cea 100644 --- a/src/sage/groups/matrix_gps/coxeter_group.py +++ b/src/sage/groups/matrix_gps/coxeter_group.py @@ -19,23 +19,20 @@ # http://www.gnu.org/licenses/ ############################################################################## -from sage.structure.unique_representation import UniqueRepresentation +import sage.rings.abc + from sage.categories.coxeter_groups import CoxeterGroups from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix from sage.groups.matrix_gps.finitely_generated import FinitelyGeneratedMatrixGroup_generic from sage.groups.matrix_gps.group_element import MatrixGroupElement_generic from sage.matrix.args import SparseEntry from sage.matrix.matrix_space import MatrixSpace - -import sage.rings.abc +from sage.misc.cachefunc import cached_method from sage.rings.integer_ring import ZZ from sage.rings.infinity import infinity -from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField from sage.rings.number_field.number_field import QuadraticField - -from sage.misc.cachefunc import cached_method - from sage.sets.family import Family +from sage.structure.unique_representation import UniqueRepresentation class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_generic): @@ -227,8 +224,10 @@ def __classcall_private__(cls, data, base_ring=None, index_set=None): elif letter == 'H': base_ring = QuadraticField(5) else: + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField base_ring = UniversalCyclotomicField() else: + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField base_ring = UniversalCyclotomicField() return super().__classcall__(cls, data, base_ring, data.index_set()) @@ -274,8 +273,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): MS = MatrixSpace(base_ring, n, sparse=True) one = MS.one() # FIXME: Hack because there is no ZZ \cup \{ \infty \}: -1 represents \infty - E = UniversalCyclotomicField().gen - if base_ring is UniversalCyclotomicField(): + if isinstance(base_ring, sage.rings.abc.UniversalCyclotomicField): + E = base_ring.gen def val(x): if x == -1: @@ -283,6 +282,9 @@ def val(x): else: return E(2 * x) + ~E(2 * x) elif isinstance(base_ring, sage.rings.abc.NumberField_quadratic): + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField + + E = UniversalCyclotomicField().gen def val(x): if x == -1: diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index e23d072de58..4f87bc77753 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -288,7 +288,7 @@ def create_poly(face, color): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import create_poly, red - sage: create_poly('ur', red) + sage: create_poly('ur', red) # optional - sage.plot Graphics object consisting of 1 graphics primitive """ return polygon(face_polys[face], rgbcolor=color) @@ -491,7 +491,7 @@ def plot3d_cubie(cnt, clrs): sage: from sage.groups.perm_gps.cubegroup import plot3d_cubie, blue, red, green sage: clrF = blue; clrU = red; clrR = green - sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) + sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) # optional - sage.plot """ half = QQ((1, 2)) x = cnt[0] - half @@ -954,11 +954,11 @@ def plot_cube(self, mv, title=True, colors=[lpurple, yellow, red, green, orange, EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title = False) + sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title=False) # optional - sage.plot sage: # (R^2U^2)^3 permutes 2 pairs of edges (uf,ub)(fr,br) - sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") + sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # optional - sage.plot sage: # the superflip (in 20f* moves) - sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") + sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # optional - sage.plot sage: # "superflip+4 spot" (in 26q* moves) """ g = self.parse(mv) @@ -991,8 +991,8 @@ def plot3d_cube(self, mv, title=True): EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") - sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") + sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # optional - sage.plot + sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # optional - sage.plot """ g = self.parse(mv) state = self.facets(g) @@ -1194,7 +1194,7 @@ class RubiksCube(SageObject): EXAMPLES:: sage: C = RubiksCube().move("R U R'") - sage: C.show3d() + sage: C.show3d() # optional - sage.plot :: @@ -1212,7 +1212,7 @@ class RubiksCube(SageObject): | 37 bottom 21 | | 35 47 24 | +--------------+ - sage: C.show() + sage: C.show() # optional - sage.plot sage: C.solve(algorithm='gap') # long time 'L*R' sage: C == RubiksCube("L*R") @@ -1315,7 +1315,7 @@ def plot(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot() + sage: C.plot() # optional - sage.plot Graphics object consisting of 55 graphics primitives """ return self._group.plot_cube(self._state) @@ -1327,7 +1327,7 @@ def show(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show() + sage: C.show() # optional - sage.plot """ self.plot().show() @@ -1346,7 +1346,7 @@ def cubie(self, size, gap, x, y, z, colors, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) + sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) # optional - sage.plot Graphics3d Object """ sides = cubie_face_list[x,y,z] @@ -1366,7 +1366,7 @@ def plot3d(self, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot3d() + sage: C.plot3d() # optional - sage.plot Graphics3d Object """ while len(self.colors) < 7: @@ -1389,7 +1389,7 @@ def show3d(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show3d() + sage: C.show3d() # optional - sage.plot """ return self.plot3d().show() From 9ea490dd744b92e61fde829d6b89bee03adbe686 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 20 May 2023 15:36:12 -0700 Subject: [PATCH 12/64] src/sage/groups/braid.py: Modularization fix --- src/sage/groups/braid.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index bf0fd07063b..9fbe0038985 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -85,6 +85,7 @@ from sage.sets.set import Set from sage.groups.finitely_presented import FinitelyPresentedGroup from sage.groups.artin import FiniteTypeArtinGroup, FiniteTypeArtinGroupElement +from sage.structure.element import Expression from sage.structure.richcmp import richcmp, rich_to_bool from sage.features import PythonModule @@ -1124,12 +1125,14 @@ def jones_polynomial(self, variab=None, skein_normalization=False): else: return self._jones_polynomial(variab) else: - from sage.symbolic.ring import SR from sage.rings.integer_ring import ZZ if variab is None: variab = 't' + if not isinstance(variab, Expression): + from sage.symbolic.ring import SR + variab = SR(variab) # We force the result to be in the symbolic ring because of the expand - return self._jones_polynomial(SR(variab)**(ZZ(1)/ZZ(4))).expand() + return self._jones_polynomial(variab**(ZZ(1)/ZZ(4))).expand() @cached_method def _enhanced_states(self): From ff7160ae1dcb99d0a524261134ef699ac7fbcb93 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 20 May 2023 15:38:10 -0700 Subject: [PATCH 13/64] More # optional --- src/sage/groups/additive_abelian/additive_abelian_wrapper.py | 2 +- src/sage/groups/perm_gps/cubegroup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 71c15f2fa51..d62d25f9b5d 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -369,7 +369,7 @@ def discrete_log(self, x, gens=None): :: sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # optional - sage.rings.number_field sage.symbolic - sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field + sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field sage.symbolic Traceback (most recent call last): ... NotImplementedError: No black-box discrete log for infinite abelian groups diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index 4f87bc77753..7ccce2e5f36 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -191,7 +191,8 @@ def polygon_plot3d(points, tilt=30, turn=30, **kwargs): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import polygon_plot3d,green - sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]],rgbcolor=green) + sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]], # optional - sage.plot + ....: rgbcolor=green) """ rot = rotation_list(tilt, turn) points2 = [(xproj(x, y, z, rot), yproj(x, y, z, rot)) From 91b864ef2d8c0fea5a46f20f100b9c761e508bb9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 23 May 2023 10:04:57 -0700 Subject: [PATCH 14/64] sage.groups.perm_gps: Docstring cosmetics --- src/sage/groups/perm_gps/constructor.py | 4 +- src/sage/groups/perm_gps/permgroup.py | 373 +++++++++++------- .../groups/perm_gps/permgroup_element.pyx | 69 ++-- .../groups/perm_gps/permgroup_morphism.py | 35 +- src/sage/groups/perm_gps/permgroup_named.py | 235 +++++------ 5 files changed, 398 insertions(+), 318 deletions(-) diff --git a/src/sage/groups/perm_gps/constructor.py b/src/sage/groups/perm_gps/constructor.py index 73dc5f94c41..72b3f44df6d 100644 --- a/src/sage/groups/perm_gps/constructor.py +++ b/src/sage/groups/perm_gps/constructor.py @@ -156,8 +156,8 @@ def standardize_generator(g, convert_dict=None, as_cycles=False): INPUT: - - ``g`` -- a list, tuple, string, GapElement, - PermutationGroupElement, Permutation + - ``g`` -- a :class:`list`, :class:`tuple`, :class:`string`, :class:`GapElement`, + :class:`PermutationGroupElement`, or :class:`Permutation` - ``convert_dict`` -- (optional) a dictionary used to convert the points to a number compatible with GAP diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 6e59f4f4b84..82c9d3f529d 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -295,7 +295,7 @@ def PermutationGroup(gens=None, *args, **kwds): sage: H.gens() ((1,2,3,4), (1,3)) - We can also create permutation groups whose generators are Gap + We can also create permutation groups whose generators are GAP permutation objects:: sage: p = gap('(1,2)(3,7)(4,6)(5,8)'); p @@ -362,7 +362,9 @@ def PermutationGroup(gens=None, *args, **kwds): i.e., in bijection with integer partitions:: sage: a = lambda g, x: g*x*g^-1 - sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, domain=SymmetricGroup(n)).orbits()) for n in range(1, 8)] + sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, + ....: domain=SymmetricGroup(n)).orbits()) + ....: for n in range(1, 8)] [1, 2, 3, 5, 7, 11, 15] TESTS:: @@ -427,7 +429,8 @@ class PermutationGroup_generic(FiniteGroup): sage: G Permutation Group with generators [(3,4), (1,2,3)(4,5)] sage: G.center() - Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) + Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) sage: G.group_id() [120, 34] sage: n = G.order(); n @@ -614,14 +617,14 @@ def _has_natural_domain(self): def _gap_init_(self): r""" - Return a string showing how to declare / initialize ``self`` in Gap. + Return a string showing how to declare / initialize ``self`` in GAP. Stored in the ``self._gap_string`` attribute. EXAMPLES: The ``_gap_init_`` method shows how you would define the Sage ``PermutationGroup_generic`` - object in Gap:: + object in GAP:: sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 Permutation Group with generators [(2,3,4), (1,2,3)] @@ -633,7 +636,7 @@ def _gap_init_(self): @cached_method def gap(self): r""" - this method from :class:`sage.groups.libgap_wrapper.ParentLibGAP` is added in order to achieve + This method from :class:`sage.groups.libgap_wrapper.ParentLibGAP` is added in order to achieve compatibility and have :class:`sage.groups.libgap_morphism.GroupHomset_libgap` work for permutation groups, as well @@ -643,7 +646,7 @@ def gap(self): EXAMPLES:: - sage: P8=PSp(8,3) + sage: P8 = PSp(8,3) sage: P8.gap() sage: gap(P8) == P8.gap() @@ -740,7 +743,7 @@ def __richcmp__(self, right, op): The comparison extends the subgroup relation. Hence, it is first checked whether one of the groups is subgroup of the other. If this is not the - case then the ordering is whatever it is in Gap. + case then the ordering is whatever it is in GAP. .. NOTE:: @@ -762,9 +765,9 @@ def __richcmp__(self, right, op): sage: H1 = PermutationGroup([[(1,2)],[(5,6)]]) sage: H2 = PermutationGroup([[(3,4)]]) sage: H3 = PermutationGroup([[(1,2)]]) - sage: H1 < H2 # according to Gap's ordering + sage: H1 < H2 # according to GAP's ordering True - sage: H2 < H3 # according to Gap's ordering + sage: H2 < H3 # according to GAP's ordering True sage: H3 < H1 # since H3 is a subgroup of H1 True @@ -850,7 +853,8 @@ def _element_constructor_(self, x, check=True): sage: G([(1,2)]) Traceback (most recent call last): ... - ValueError: permutation [(1, 2)] not in Permutation Group with generators [(1,2,3,4)] + ValueError: permutation [(1, 2)] not in + Permutation Group with generators [(1,2,3,4)] TESTS: @@ -1166,11 +1170,11 @@ def iteration(self, algorithm="SGS"): - ``algorithm`` -- (default: ``"SGS"``) either - * ``"SGS"`` - using strong generating system - * ``"BFS"`` - a breadth first search on the Cayley graph with - respect to ``self.gens()`` - * ``"DFS"`` - a depth first search on the Cayley graph with - respect to ``self.gens()`` + * ``"SGS"`` -- using strong generating system + * ``"BFS"`` -- a breadth first search on the Cayley graph with + respect to ``self.gens()`` + * ``"DFS"`` -- a depth first search on the Cayley graph with + respect to ``self.gens()`` .. NOTE:: @@ -1312,7 +1316,7 @@ def gens_small(self): def gen(self, i=None): r""" - Return the i-th generator of ``self``; that is, the i-th element of + Return the `i`-th generator of ``self``; that is, the `i`-th element of the list ``self.gens()``. The argument `i` may be omitted if there is only one generator (but @@ -1367,8 +1371,7 @@ def one(self): EXAMPLES:: sage: G = PermutationGroup([[(1,2,3),(4,5)]]) - sage: e = G.identity() # indirect doctest - sage: e + sage: e = G.identity(); e # indirect doctest () sage: g = G.gen(0) sage: g*e @@ -1531,13 +1534,13 @@ def representative_action(self,x,y): INPUT: - - ``x,y`` -- two elements of the domain. + - ``x``, ``y`` -- two elements of the domain. EXAMPLES:: sage: G = groups.permutation.Cyclic(14) - sage: g = G.representative_action(1,10) - sage: all(g(x) == 1+((x+9-1)%14) for x in G.domain()) + sage: g = G.representative_action(1, 10) + sage: all(g(x) == 1 + ((x+9-1)%14) for x in G.domain()) True TESTS:: @@ -1657,7 +1660,7 @@ def orbit(self, point, action="OnPoints"): Action of `S_4` (on a nonstandard domain) on tuples of sets:: sage: S4 = PermutationGroup([ [('c','d')], [('a','c')], [('a','b')] ]) - sage: orb = S4.orbit((('a','c'),('b','d')),"OnTuplesSets") + sage: orb = S4.orbit((('a','c'),('b','d')), "OnTuplesSets") sage: expect = (({'a', 'c'}, {'b', 'd'}), ({'a', 'd'}, {'c', 'b'}), ....: ({'c', 'b'}, {'a', 'd'}), ({'b', 'd'}, {'a', 'c'}), ....: ({'c', 'd'}, {'a', 'b'}), ({'a', 'b'}, {'c', 'd'})) @@ -1668,7 +1671,8 @@ def orbit(self, point, action="OnPoints"): sage: S4 = PermutationGroup([ [((11,(12,13)),'d')], ....: [((12,(12,11)),(11,(12,13)))], [((12,(12,11)),'b')] ]) - sage: orb = S4.orbit((( (11,(12,13)), (12,(12,11))),('b','d')),"OnTuplesSets") + sage: orb = S4.orbit((( (11,(12,13)), (12,(12,11))),('b','d')), + ....: "OnTuplesSets") sage: expect = (({(11, (12, 13)), (12, (12, 11))}, {'b', 'd'}), ....: ({'d', (12, (12, 11))}, {(11, (12, 13)), 'b'}), ....: ({(11, (12, 13)), 'b'}, {'d', (12, (12, 11))}), @@ -1755,9 +1759,9 @@ def stabilizer(self, point, action="OnPoints"): - ``point`` -- a point of the :meth:`domain`, or a set of points depending on the value of ``action``. - - ``action`` (string; default ``"OnPoints"``) -- should the group be + - ``action`` -- (string; default ``"OnPoints"``) should the group be considered to act on points (``action="OnPoints"``) or on sets of - points (``action="OnSets"``) ? In the latter case, the first argument + points (``action="OnSets"``)? In the latter case, the first argument must be a subset of :meth:`domain`. EXAMPLES:: @@ -1848,8 +1852,8 @@ def base(self, seed=None): INPUT: - ``seed`` (optional, default: ``None``), if given must be a - subset of the domain of `base`. When used, an attempt to - create a base containing all or part of `seed` will be + subset of the domain of a base. When used, an attempt to + create a base containing all or part of ``seed`` will be made. EXAMPLES:: @@ -1915,10 +1919,10 @@ def strong_generating_system(self, base_of_group=None, implementation="sage"): - ``implementation`` -- (default: ``"sage"``) either - * ``"sage"`` - use the direct implementation in Sage + * ``"sage"`` -- use the direct implementation in Sage - * ``"gap"`` - if used, the ``base_of_group`` must be ``None`` - and the computation is directly performed in GAP + * ``"gap"`` -- if used, the ``base_of_group`` must be ``None`` + and the computation is directly performed in GAP OUTPUT: @@ -2140,7 +2144,7 @@ def _order(self): # This special case only works with more than 1 generator. if not gens or len(gens) < 2: return None - # Special case: certain subgroups of the symmetric group for which Gap reports + # Special case: certain subgroups of the symmetric group for which GAP reports # generators of the form ((1, 2), (1, 3), ...) # This means that this group is isomorphic to a smaller symmetric group # S_n, where n is the number of generators supported. @@ -2188,7 +2192,8 @@ def _order(self): def order(self): """ Return the number of elements of this group. - See also: G.degree() + + See also: :meth:`degree`. EXAMPLES:: @@ -2202,7 +2207,7 @@ def order(self): sage: G.order() 1 - ``cardinality`` is just an alias:: + :meth:`cardinality` is just an alias:: sage: PermutationGroup([(1,2,3)]).cardinality() 3 @@ -2255,8 +2260,9 @@ def group_id(self): def id(self): """ - (Same as ``self.group_id()``.) Return the ID code of this group, which - is a list of two integers. + Return the ID code of this group, which is a list of two integers. + + Same as :meth:`group_id`. EXAMPLES:: @@ -2273,7 +2279,7 @@ def group_primitive_id(self): OUTPUT: A positive integer, following GAP's conventions. A - ``ValueError`` is raised if the group is not primitive. + :class:`ValueError` is raised if the group is not primitive. EXAMPLES:: @@ -2307,10 +2313,12 @@ def center(self): sage: G = PermutationGroup([[(1,2,3,4)]]) sage: G.center() - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2,3,4)]) sage: G = PermutationGroup([[(1,2,3,4)], [(1,2)]]) sage: G.center() - Subgroup generated by [()] of (Permutation Group with generators [(1,2), (1,2,3,4)]) + Subgroup generated by [()] of + (Permutation Group with generators [(1,2), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Center()) @@ -2325,9 +2333,12 @@ def socle(self): sage: G = SymmetricGroup(4) sage: G.socle() - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Symmetric group of order 4! as a permutation group) sage: G.socle().socle() - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Symmetric group of order 4! as a permutation group)) + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] + of (Symmetric group of order 4! as a permutation group)) """ return self.subgroup(gap_group=self._gap_().Socle()) @@ -2342,10 +2353,12 @@ def frattini_subgroup(self): sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]]) sage: G.frattini_subgroup() - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(2,4), (1,2,3,4)]) + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(2,4), (1,2,3,4)]) sage: G = SymmetricGroup(4) sage: G.frattini_subgroup() - Subgroup generated by [()] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [()] of + (Symmetric group of order 4! as a permutation group) """ return self.subgroup(gap_group=self._libgap_().FrattiniSubgroup()) @@ -2361,10 +2374,12 @@ def fitting_subgroup(self): sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]]) sage: G.fitting_subgroup() - Subgroup generated by [(2,4), (1,2,3,4), (1,3)] of (Permutation Group with generators [(2,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)] of + (Permutation Group with generators [(2,4), (1,2,3,4)]) sage: G = PermutationGroup([[(1,2,3,4)],[(1,2)]]) sage: G.fitting_subgroup() - Subgroup generated by [(1,2)(3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2), (1,2,3,4)]) + Subgroup generated by [(1,2)(3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().FittingSubgroup()) @@ -2380,10 +2395,12 @@ def solvable_radical(self): sage: G = SymmetricGroup(4) sage: G.solvable_radical() - Subgroup generated by [(1,2), (1,2,3,4)] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [(1,2), (1,2,3,4)] of + (Symmetric group of order 4! as a permutation group) sage: G = SymmetricGroup(5) sage: G.solvable_radical() - Subgroup generated by [()] of (Symmetric group of order 5! as a permutation group) + Subgroup generated by [()] of + (Symmetric group of order 5! as a permutation group) """ return self.subgroup(gap_group=self._libgap_().RadicalGroup()) @@ -2489,7 +2506,7 @@ def conjugate(self, g): INPUT: - - ``g`` - a permutation group element, or an object that converts + - ``g`` -- a permutation group element, or an object that converts to a permutation group element, such as a list of integers or a string of cycles. @@ -2583,28 +2600,27 @@ def direct_product(self, other, maps=True): INPUT: - - ``self, other`` - permutation groups + - ``self``, ``other`` -- permutation groups OUTPUT: - - ``D`` - a direct product of the inputs, returned as + - ``D`` -- a direct product of the inputs, returned as a permutation group as well - - ``iota1`` - an embedding of ``self`` into ``D`` + - ``iota1`` -- an embedding of ``self`` into ``D`` - - ``iota2`` - an embedding of ``other`` into ``D`` + - ``iota2`` -- an embedding of ``other`` into ``D`` - - ``pr1`` - the projection of ``D`` onto ``self`` (giving a - splitting 1 - other - D - self - 1) + - ``pr1`` -- the projection of ``D`` onto ``self`` (giving a + splitting ``1 - other - D - self - 1``) - - ``pr2`` - the projection of ``D`` onto ``other`` (giving a - splitting 1 - self - D - other - 1) + - ``pr2`` -- the projection of ``D`` onto ``other`` (giving a + splitting ``1 - self - D - other - 1``) EXAMPLES:: sage: G = CyclicPermutationGroup(4) - sage: D = G.direct_product(G,False) - sage: D + sage: D = G.direct_product(G, False); D Permutation Group with generators [(5,6,7,8), (1,2,3,4)] sage: D,iota1,iota2,pr1,pr2 = G.direct_product(G) sage: D; iota1; iota2; pr1; pr2 @@ -2657,22 +2673,22 @@ def semidirect_product(self, N, mapping, check=True): naturally embeds as a normal subgroup of the returned semidirect product. - - ``mapping`` - A pair of lists that together define a - homomorphism, `\phi :` self `\rightarrow` Aut(N), by giving, + - ``mapping`` -- A pair of lists that together define a + homomorphism, `\phi :` ``self`` `\rightarrow` Aut(``N``), by giving, in the second list, the images of the generators of ``self`` in the order given in the first list. - - ``check`` - A boolean that, if set to False, will skip the + - ``check`` -- A boolean that, if set to ``False``, will skip the initial tests which are made on ``mapping``. This may be beneficial for large ``N``, since in such cases the injectivity test can be - expensive. Set to True by default. + expensive. Set to ``True`` by default. OUTPUT: The semidirect product of ``self`` and ``N`` defined by the action of ``self`` on ``N`` given in ``mapping`` (note that a - homomorphism from A to the automorphism group of B is - equivalent to an action of A on the B's underlying set). The + homomorphism from `A` to the automorphism group of `B` is + equivalent to an action of `A` on `B`'s underlying set). The semidirect product of two groups, `H` and `N`, is a construct similar to the direct product in so far as the elements are the Cartesian product of the elements of `H` and the elements @@ -2739,7 +2755,8 @@ def semidirect_product(self, N, mapping, check=True): sage: S1.is_isomorphic(DiCyclicGroup(6)) False sage: S1.center() - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(5,6,7), (1,2,3,4)(6,7), (1,3)]) + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(5,6,7), (1,2,3,4)(6,7), (1,3)]) sage: len(S1.conjugacy_classes_representatives()) 9 @@ -2855,7 +2872,8 @@ def holomorph(self): sage: A.is_abelian() False sage: A.center() - Subgroup generated by [()] of (Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)]) + Subgroup generated by [()] of + (Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)]) sage: A Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)] @@ -2903,14 +2921,15 @@ def subgroup(self, gens=None, gap_group=None, domain=None, category=None, canoni sage: G = PermutationGroup([(1,2,3),(3,4,5)]) sage: g = G((1,2,3)) sage: G.subgroup([g]) - Subgroup generated by [(1,2,3)] of (Permutation Group with generators [(3,4,5), (1,2,3)]) + Subgroup generated by [(1,2,3)] of + (Permutation Group with generators [(3,4,5), (1,2,3)]) """ return self.Subgroup(self, gens=gens, gap_group=gap_group, domain=None, category=category, canonicalize=canonicalize, check=check) def _subgroup_constructor(self, libgap_group): """ - this method is added for compatibility reason with the + This method is added for compatibility reason with the :meth:`sage.groups.libgap_wrapper.ParentLibGAP_subgroup_constructor` and for usage in :class:`sage.groups.libgap_morphism.GroupMorphism_libgap` @@ -2921,7 +2940,7 @@ def _subgroup_constructor(self, libgap_group): OUTPUT: - the corresponding subgroup of self as an instance of this class + The corresponding subgroup of ``self`` as an instance of this class EXAMPLES:: @@ -2933,7 +2952,8 @@ def _subgroup_constructor(self, libgap_group): sage: type(Hgap) sage: H = G._subgroup_constructor(Hgap); H - Subgroup generated by [(1,6,21,12,20,17)(2,10,15,9,11,5)(3,14,8)(4,18)(7,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) + Subgroup generated by [(1,6,21,12,20,17)(2,10,15,9,11,5)(3,14,8)(4,18)(7,16)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) """ gens = [gen.sage() for gen in libgap_group.GeneratorsOfGroup()] return self.subgroup(gens=gens, gap_group=libgap_group) @@ -2947,15 +2967,15 @@ def as_finitely_presented_group(self, reduced=False): INPUT: - - ``reduced`` -- Default ``False``, if ``True`` :meth:`FinitelyPresentedGroup.simplified + - ``reduced`` -- (default ``False``) if ``True``, :meth:`FinitelyPresentedGroup.simplified ` is called, attempting to simplify the presentation of the finitely presented group to be returned. OUTPUT: - Finite presentation of self, obtained by taking the image - of the isomorphism returned by the GAP function, ``IsomorphismFpGroupByGenerators``. + Finite presentation of ``self``, obtained by taking the image + of the isomorphism returned by the GAP function ``IsomorphismFpGroupByGenerators``. ALGORITHM: @@ -2982,9 +3002,10 @@ def as_finitely_presented_group(self, reduced=False): We can attempt to reduce the output presentation:: - sage: PermutationGroup(['(1,2,3,4,5)','(1,3,5,2,4)']).as_finitely_presented_group() + sage: H = PermutationGroup(['(1,2,3,4,5)', '(1,3,5,2,4)']) + sage: H.as_finitely_presented_group() Finitely presented group < a, b | b^-2*a^-1, b*a^-2 > - sage: PermutationGroup(['(1,2,3,4,5)','(1,3,5,2,4)']).as_finitely_presented_group(reduced=True) + sage: H.as_finitely_presented_group(reduced=True) Finitely presented group < a | a^5 > TESTS:: @@ -3080,11 +3101,11 @@ def commutator(self, other=None): INPUT: - - ``other`` - default: ``None`` - a permutation group. + - ``other`` -- (default: ``None``) a permutation group. OUTPUT: - Let `G` denote ``self``. If ``other`` is ``None`` then this method + Let `G` denote ``self``. If ``other`` is ``None``, then this method returns the subgroup of `G` generated by the set of commutators, .. MATH:: @@ -3277,8 +3298,7 @@ def homology(self, n, p=0): `H_7(S_5, \ZZ / 2 \ZZ)`, `H_7(S_5, \ZZ / 3 \ZZ)`, and `H_7(S_5, \ZZ / 5 \ZZ)`, respectively. To compute the - `2`-part of `H_7(S_5, \ZZ)`, use the ``homology_part`` - function. + `2`-part of `H_7(S_5, \ZZ)`, use the method :meth:`homology_part`. EXAMPLES:: @@ -3395,7 +3415,10 @@ def character_table(self): [ 4 2 0 1 -1 0 -1] [ 1 1 1 1 1 1 1] sage: list(AlternatingGroup(6).character_table()) - [(1, 1, 1, 1, 1, 1, 1), (5, 1, 2, -1, -1, 0, 0), (5, 1, -1, 2, -1, 0, 0), (8, 0, -1, -1, 0, zeta5^3 + zeta5^2 + 1, -zeta5^3 - zeta5^2), (8, 0, -1, -1, 0, -zeta5^3 - zeta5^2, zeta5^3 + zeta5^2 + 1), (9, 1, 0, 0, 1, -1, -1), (10, -2, 1, 1, 0, 0, 0)] + [(1, 1, 1, 1, 1, 1, 1), (5, 1, 2, -1, -1, 0, 0), (5, 1, -1, 2, -1, 0, 0), + (8, 0, -1, -1, 0, zeta5^3 + zeta5^2 + 1, -zeta5^3 - zeta5^2), + (8, 0, -1, -1, 0, -zeta5^3 - zeta5^2, zeta5^3 + zeta5^2 + 1), + (9, 1, 0, 0, 1, -1, -1), (10, -2, 1, 1, 0, 0, 0)] Suppose that you have a class function `f(g)` on `G` and you know the values `v_1, \ldots, v_n` on @@ -3515,25 +3538,36 @@ def conjugacy_classes_subgroups(self): EXAMPLES:: sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) - sage: cl = G.conjugacy_classes_subgroups() - sage: cl - [Subgroup generated by [()] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2)(3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4), (1,2)(3,4), (1,4)(2,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)])] + sage: cl = G.conjugacy_classes_subgroups(); cl + [Subgroup generated by [()] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2)(3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4), (1,2)(3,4), (1,4)(2,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)])] :: sage: G = SymmetricGroup(3) sage: G.conjugacy_classes_subgroups() - [Subgroup generated by [()] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3), (1,2,3)] of (Symmetric group of order 3! as a permutation group)] + [Subgroup generated by [()] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3), (1,2,3)] of + (Symmetric group of order 3! as a permutation group)] AUTHORS: @@ -3575,19 +3609,30 @@ def subgroups(self): sage: G = SymmetricGroup(3) sage: G.subgroups() - [Subgroup generated by [()] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3), (1,2,3)] of (Symmetric group of order 3! as a permutation group)] + [Subgroup generated by [()] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3), (1,2,3)] of + (Symmetric group of order 3! as a permutation group)] sage: G = CyclicPermutationGroup(14) sage: G.subgroups() - [Subgroup generated by [()] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,8)(2,9)(3,10)(4,11)(5,12)(6,13)(7,14)] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12,13,14), (1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of (Cyclic group of order 14 as a permutation group)] + [Subgroup generated by [()] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,8)(2,9)(3,10)(4,11)(5,12)(6,13)(7,14)] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12,13,14), + (1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of + (Cyclic group of order 14 as a permutation group)] AUTHOR: @@ -3636,9 +3681,9 @@ def has_regular_subgroup(self, return_group=False): INPUT: - - ``return_group`` (boolean) -- If ``return_group = True``, a regular + - ``return_group`` -- (boolean) If ``True``, a regular subgroup is returned if there is one, and ``None`` if there isn't. - When ``return_group = False`` (default), only a boolean indicating + When ``return_group=False`` (default), only a boolean indicating whether such a group exists is returned instead. EXAMPLES: @@ -3648,8 +3693,9 @@ def has_regular_subgroup(self, return_group=False): sage: S4 = groups.permutation.Symmetric(4) sage: S4.has_regular_subgroup() True - sage: S4.has_regular_subgroup(return_group = True) # random - Subgroup of (Symmetric group of order 4! as a permutation group) generated by [(1,3)(2,4), (1,4)(2,3)] + sage: S4.has_regular_subgroup(return_group=True) # random + Subgroup of (Symmetric group of order 4! as a permutation group) + generated by [(1,3)(2,4), (1,4)(2,3)] But the automorphism group of Petersen's graph does not:: @@ -3682,7 +3728,7 @@ def blocks_all(self, representatives=True): INPUT: - - ``representative`` (boolean) -- whether to return all possible block + - ``representative`` -- (boolean) whether to return all possible block systems of imprimitivity or only one of their representatives (the block can be obtained from its representative set `S` by computing the orbit of `S` under ``self``). @@ -3698,13 +3744,13 @@ def blocks_all(self, representatives=True): * A list of length (#number of different block systems) of - * block systems, each of them being defined as + * block systems, each of them being defined as - * If ``representatives = True`` : a list of representatives of - each set of the block system + * If ``representatives=True``: a list of representatives of + each set of the block system - * If ``representatives = False`` : a partition of the elements - defining an imprimitivity block. + * If ``representatives=False``: a partition of the elements + defining an imprimitivity block. .. SEEALSO:: @@ -3729,7 +3775,8 @@ def blocks_all(self, representatives=True): Now the full block:: sage: sorted(ag.blocks_all(representatives = False)[0]) - [[0, 15], [1, 16], [2, 12], [3, 13], [4, 9], [5, 10], [6, 11], [7, 18], [8, 17], [14, 19]] + [[0, 15], [1, 16], [2, 12], [3, 13], [4, 9], + [5, 10], [6, 11], [7, 18], [8, 17], [14, 19]] TESTS:: @@ -3754,13 +3801,13 @@ def cosets(self, S, side='right'): INPUT: - - ``S`` - a subgroup of ``self``. An error is raised + - ``S`` -- a subgroup of ``self``. An error is raised if ``S`` is not a subgroup. - - ``side`` - default: 'right' - determines if right cosets or + - ``side`` -- (default: ``'right'``) Determines if right cosets or left cosets are returned. ``side`` refers to where the representative is placed in the products forming the cosets - and thus allowable values are only 'right' and 'left'. + and thus allowable values are only ``'right'`` and ``'left'``. OUTPUT: @@ -3947,13 +3994,16 @@ def normalizer(self, g): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: g = G([(1,3)]) sage: G.normalizer(g) - Subgroup generated by [(2,4), (1,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: g = G([(1,2,3,4)]) sage: G.normalizer(g) - Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: H = G.subgroup([G([(1,2,3,4)])]) sage: G.normalizer(H) - Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Normalizer(g)) @@ -3966,13 +4016,16 @@ def centralizer(self, g): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: g = G([(1,3)]) sage: G.centralizer(g) - Subgroup generated by [(2,4), (1,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: g = G([(1,2,3,4)]) sage: G.centralizer(g) - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: H = G.subgroup([G([(1,2,3,4)])]) sage: G.centralizer(H) - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Centralizer(g)) @@ -4080,9 +4133,9 @@ def isomorphism_to(self, right): INPUT: - - ``self`` - this group + - ``self`` -- this group - - ``right`` - a permutation group + - ``right`` -- a permutation group OUTPUT: @@ -4133,9 +4186,9 @@ def is_isomorphic(self, right): INPUT: - - ``self`` - this group + - ``self`` -- this group - - ``right`` - a permutation group + - ``right`` -- a permutation group OUTPUT: @@ -4243,7 +4296,7 @@ def is_polycyclic(self): Return ``True`` if this group is polycyclic. A group is polycyclic if it has a subnormal series with cyclic factors. (For finite groups, this is the same as if the group is solvable - see - ``is_solvable``.) + :meth:`is_solvable`.) EXAMPLES:: @@ -4574,13 +4627,17 @@ def composition_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.composition_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] sage: G = PermutationGroup([[(1,2,3),(4,5)], [(1,2)]]) sage: CS = G.composition_series() sage: CS[3] - Subgroup generated by [()] of (Permutation Group with generators [(1,2), (1,2,3)(4,5)]) + Subgroup generated by [()] of + (Permutation Group with generators [(1,2), (1,2,3)(4,5)]) """ libgap.set_seed() CS = self._libgap_().CompositionSeries() @@ -4601,8 +4658,10 @@ def derived_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.derived_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() DS = self._libgap_().DerivedSeries() @@ -4623,8 +4682,10 @@ def lower_central_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.lower_central_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() LCS = self._libgap_().LowerCentralSeriesOfGroup() @@ -4701,11 +4762,11 @@ def molien_series(self): R(str(dd).replace("_1", ""))) def normal_subgroups(self): - """ + r""" Return the normal subgroups of this group as a (sorted in increasing order) list of permutation groups. - The normal subgroups of `H = PSL(2,7) \\times PSL(2,7)` are + The normal subgroups of `H = PSL(2,7) \times PSL(2,7)` are `1`, two copies of `PSL(2,7)` and `H` itself, as the following example shows. @@ -4740,10 +4801,10 @@ def poincare_series(self, p=2, n=10): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.poincare_series(2,10) # optional - gap_package_hap + sage: G.poincare_series(2, 10) # optional - gap_package_hap (x^2 + 1)/(x^4 - x^3 - x + 1) sage: G = SymmetricGroup(3) - sage: G.poincare_series(2,10) # optional - gap_package_hap + sage: G.poincare_series(2, 10) # optional - gap_package_hap -1/(x - 1) AUTHORS: @@ -4777,9 +4838,11 @@ def sylow_subgroup(self, p): sage: G = PermutationGroup(['(1,2,3)', '(2,3)']) sage: G.sylow_subgroup(2) - Subgroup generated by [(2,3)] of (Permutation Group with generators [(2,3), (1,2,3)]) + Subgroup generated by [(2,3)] of + (Permutation Group with generators [(2,3), (1,2,3)]) sage: G.sylow_subgroup(5) - Subgroup generated by [()] of (Permutation Group with generators [(2,3), (1,2,3)]) + Subgroup generated by [()] of + (Permutation Group with generators [(2,3), (1,2,3)]) TESTS: @@ -4804,7 +4867,8 @@ def upper_central_series(self): sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.upper_central_series() - [Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() UCS = self._libgap_().UpperCentralSeriesOfGroup() @@ -4846,7 +4910,8 @@ class PermutationGroup_subgroup(PermutationGroup_generic): sage: gens = G.gens() sage: H = DihedralGroup(4) sage: H.subgroup(gens) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: K = H.subgroup(gens) sage: K.list() [(), (1,2,3,4), (1,3)(2,4), (1,4,3,2)] @@ -4863,18 +4928,18 @@ def __init__(self, ambient, gens=None, gap_group=None, domain=None, INPUT: - - ``ambient`` - the ambient group from which to construct this + - ``ambient`` -- the ambient group from which to construct this subgroup - - ``gens`` - the generators of the subgroup + - ``gens`` -- the generators of the subgroup - - ``gap_group`` - a GAP permutation group contained in the ambient group; - constructed from ``gens`` if not given. + - ``gap_group`` -- a GAP permutation group contained in the ambient group; + constructed from ``gens`` if not given. - - ``check`` - ``True``: checks if ``gens`` are indeed elements of the + - ``check`` -- ``True``: checks if ``gens`` are indeed elements of the ambient group - - ``canonicalize`` - boolean (default: ``True``); if ``True``, sort + - ``canonicalize`` -- boolean (default: ``True``); if ``True``, sort generators and remove duplicates EXAMPLES: @@ -5078,7 +5143,8 @@ def is_normal(self, other=None): sage: S = SymmetricGroup(['a','b','c']) sage: H = S.subgroup([('a', 'b', 'c')]); H - Subgroup generated by [('a','b','c')] of (Symmetric group of order 3! as a permutation group) + Subgroup generated by [('a','b','c')] of + (Symmetric group of order 3! as a permutation group) sage: H.is_normal() True @@ -5117,7 +5183,8 @@ class PermutationGroup_action(PermutationGroup_generic): The trivial action of the symmetric group:: - sage: PermutationGroup(SymmetricGroup(3).gens(), action=lambda g, x: x, domain=[1]) + sage: PermutationGroup(SymmetricGroup(3).gens(), + ....: action=lambda g, x: x, domain=[1]) Permutation Group with generators [()] """ def __init__(self, gens, action, domain, gap_group=None, category=None, canonicalize=None): diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 908efdd5a9a..06b51117b84 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -152,7 +152,7 @@ cdef int etuple_index_cmp(const void * a, const void * b) nogil: def make_permgroup_element(G, x): """ - Returns a PermutationGroupElement given the permutation group + Return a :class:`PermutationGroupElement` given the permutation group ``G`` and the permutation ``x`` in list notation. This is function is used when unpickling old (pre-domain) versions @@ -172,7 +172,7 @@ def make_permgroup_element(G, x): def make_permgroup_element_v2(G, x, domain): """ - Returns a PermutationGroupElement given the permutation group + Return a :class:`PermutationGroupElement` given the permutation group ``G``, the permutation ``x`` in list notation, and the domain ``domain`` of the permutation group. @@ -199,7 +199,7 @@ def make_permgroup_element_v2(G, x, domain): def is_PermutationGroupElement(x): """ - Returns True if ``x`` is a PermutationGroupElement. + Return ``True`` if ``x`` is a :class:`PermutationGroupElement`. EXAMPLES:: @@ -216,8 +216,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): EXAMPLES:: - sage: G = PermutationGroup(['(1,2,3)(4,5)']) - sage: G + sage: G = PermutationGroup(['(1,2,3)(4,5)']); G Permutation Group with generators [(1,2,3)(4,5)] sage: g = G.random_element() sage: g in G @@ -278,9 +277,9 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): - ``g`` -- defines element - ``parent`` -- defines parent group (``g`` must be in - parent if specified, or a ``TypeError`` is raised) + parent if specified, or a :class:`TypeError` is raised) - - ``check`` - bool (default: ``True``); if ``False`` assumes ``g`` + - ``check`` -- bool (default: ``True``); if ``False`` assumes ``g`` is a gap element in parent (if specified) @@ -310,8 +309,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): :: - sage: g = G([(1,2),(3,5,6)]) - sage: g + sage: g = G([(1,2),(3,5,6)]); g (1,2)(3,5,6) sage: g.parent() Permutation Group with generators [(1,2)(3,4), (3,4,5,6)] @@ -328,15 +326,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): True We can also make a permutation group element directly using the - ``PermutationGroupElement`` command. Note that the + :class:`PermutationGroupElement` command. Note that the parent is then the full symmetric group `S_n`, where `n` is the largest integer that is moved by the permutation. :: - sage: k = PermutationGroupElement('(1,2)(3,5,6)') - sage: k + sage: k = PermutationGroupElement('(1,2)(3,5,6)'); k (1,2)(3,5,6) sage: k.parent() Symmetric group of order 6! as a permutation group @@ -1496,7 +1493,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def tuple(self): """ - Return tuple of images of the domain under self. + Return tuple of images of the domain under ``self``. EXAMPLES:: @@ -1518,7 +1515,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def dict(self): """ - Returns a dictionary associating each element of the domain with its + Return a dictionary associating each element of the domain with its image. EXAMPLES:: @@ -1551,7 +1548,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: s.multiplicative_order() 6 - ``order`` is just an alias for ``multiplicative_order``:: + :meth:`order` is just an alias for :meth:`multiplicative_order`:: sage: s.order() 6 @@ -1593,7 +1590,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def inverse(self): r""" - Returns the inverse permutation. + Return the inverse permutation. OUTPUT: @@ -1625,7 +1622,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def sign(self): r""" - Returns the sign of self, which is `(-1)^{s}`, where + Return the sign of ``self``, which is `(-1)^{s}`, where `s` is the number of swaps. EXAMPLES:: @@ -1662,7 +1659,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def orbit(self, n, bint sorted=True): """ - Returns the orbit of the integer `n` under this group + Return the orbit of the integer `n` under this group element, as a sorted list. EXAMPLES:: @@ -1706,7 +1703,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def cycles(self): """ - Return self as a list of disjoint cycles. + Return ``self`` as a list of disjoint cycles. EXAMPLES:: @@ -1741,12 +1738,12 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def cycle_tuples(self, singletons=False): """ - Return self as a list of disjoint cycles, represented as tuples + Return ``self`` as a list of disjoint cycles, represented as tuples rather than permutation group elements. INPUT: - - ``singletons`` - boolean (default: False) whether or not consider the + - ``singletons`` -- boolean (default: ``False``) whether or not consider the cycle that correspond to fixed point EXAMPLES:: @@ -1802,7 +1799,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): """ Return string representation of this permutation. - EXAMPLES:: + EXAMPLES:: sage: g = PermutationGroupElement([(1,2,3),(4,5)]) sage: g.cycle_string() @@ -1820,26 +1817,26 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def cycle_type(self, singletons=True, as_list=False): r""" - Return the partition that gives the cycle type of ``g`` as an element of - ``self``. + Return the partition that gives the cycle type of ``self`` as an element of + its parent. INPUT: - ``g`` -- an element of the permutation group ``self.parent()`` - - ``singletons`` -- ``True`` or ``False`` depending on whether on or not + - ``singletons`` -- ``True`` or ``False`` depending on whether or not trivial cycles should be counted (default: ``True``) - ``as_list`` -- ``True`` or ``False`` depending on whether the cycle - type should be returned as a ``list`` or as a :class:`Partition` + type should be returned as a :class:`list` or as a :class:`Partition` (default: ``False``) OUTPUT: - A :class:`Partition`, or list if ``is_list`` is ``True``, - giving the cycle type of ``g`` + A :class:`Partition`, or :class:`list` if ``is_list`` is ``True``, + giving the cycle type of ``self`` - If speed is a concern then ``as_list=True`` should be used. + If speed is a concern, then ``as_list=True`` should be used. EXAMPLES:: @@ -1870,11 +1867,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): INPUT: - ``i`` -- an element of the index set - - ``side`` -- "left" or "right" (default: "right") - - ``positive`` -- a boolean (default: False) + - ``side`` -- ``"left"`` or ``"right"`` (default: ``"right"``) + - ``positive`` -- a boolean (default: ``False``) Returns whether ``self`` has a left (resp. right) descent at - position ``i``. If ``positive`` is True, then test for a non + position ``i``. If ``positive`` is ``True``, then test for a non descent instead. Beware that, since permutations are acting on the right, the @@ -1925,8 +1922,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def matrix(self): """ - Returns deg x deg permutation matrix associated to the permutation - self + Return a deg `\times` deg permutation matrix associated to the permutation + ``self``. EXAMPLES:: @@ -1979,8 +1976,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): This function does not solve the word problem in Sage. Rather it pushes it over to GAP, which has optimized algorithms for the word problem. Essentially, this function is a wrapper for the GAP - functions "EpimorphismFromFreeGroup" and - "PreImagesRepresentative". + functions ``EpimorphismFromFreeGroup`` and + ``PreImagesRepresentative``. EXAMPLES:: diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 917ddd01865..2af6fac46ea 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -15,7 +15,8 @@ sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens())) sage: phi.image(G) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: phi.kernel() Subgroup generated by [()] of (Cyclic group of order 4 as a permutation group) sage: phi.image(g) @@ -71,7 +72,8 @@ def kernel(self): sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, [1]) sage: phi.kernel() - Subgroup generated by [(1,2,3,4)] of (Cyclic group of order 4 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Cyclic group of order 4 as a permutation group) :: @@ -86,8 +88,8 @@ def kernel(self): def image(self, J): """ - J must be a subgroup of G. Computes the subgroup of H which is the - image of J. + `J` must be a subgroup of the domain `G`. Computes the subgroup of the codomain `H` + which is the image of `J`. EXAMPLES:: @@ -96,7 +98,8 @@ def image(self, J): sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens())) sage: phi.image(G) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: phi.image(g) (1,2,3,4) @@ -107,7 +110,8 @@ def image(self, J): sage: H = D[0] sage: pr1 = D[3] sage: pr1.image(G) - Subgroup generated by [(3,7,5)(4,8,6), (1,2,6)(3,4,8)] of (The projective special linear group of degree 2 over Finite Field of size 7) + Subgroup generated by [(3,7,5)(4,8,6), (1,2,6)(3,4,8)] of + (The projective special linear group of degree 2 over Finite Field of size 7) sage: G.is_isomorphic(pr1.image(G)) True @@ -135,7 +139,7 @@ def image(self, J): def __call__(self, g): """ - Some python code for wrapping GAP's Images function but only for + Some python code for wrapping GAP's ``Images`` function but only for permutation groups. This returns an error if g is not in G. EXAMPLES:: @@ -161,14 +165,14 @@ def __init__(self, G, H, gap_hom): This is a Python trick to allow Sage programmers to create a group homomorphism using GAP using very general constructions. An example of its usage is in the direct_product instance method of the - PermutationGroup_generic class in permgroup.py. + :class:`PermutationGroup_generic` class in permgroup.py. Basic syntax: - PermutationGroupMorphism_from_gap(domain_group, - range_group,'phi:=gap_hom_command;','phi') And don't forget the - line: from sage.groups.perm_gps.permgroup_morphism import - PermutationGroupMorphism_from_gap in your program. + ``PermutationGroupMorphism_from_gap(domain_group, + range_group, 'phi:=gap_hom_command;', 'phi')``. And don't forget the + line: ``from sage.groups.perm_gps.permgroup_morphism import + PermutationGroupMorphism_from_gap`` in your program. EXAMPLES:: @@ -177,7 +181,8 @@ def __init__(self, G, H, gap_hom): sage: H = G.subgroup([G([(1,2,3,4)])]) sage: PermutationGroupMorphism_from_gap(H, G, gap.Identity) Permutation group morphism: - From: Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + From: Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) To: Permutation Group with generators [(1,2)(3,4), (1,2,3,4)] Defn: Identity """ @@ -238,7 +243,7 @@ def __call__(self, g): class PermutationGroupMorphism_im_gens(PermutationGroupMorphism): def __init__(self, G, H, gens=None): """ - Some python code for wrapping GAP's GroupHomomorphismByImages + Some python code for wrapping GAP's ``GroupHomomorphismByImages`` function but only for permutation groups. Can be expensive if G is large. This returns "fail" if gens does not generate self or if the map does not extend to a group homomorphism, self - other. @@ -306,7 +311,7 @@ def _gap_(self): def is_PermutationGroupMorphism(f) -> bool: """ - Return True if the argument ``f`` is a PermutationGroupMorphism. + Return ``True`` if the argument ``f`` is a :class:`PermutationGroupMorphism`. EXAMPLES:: diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index 7b3d4947f75..a5066e8ada5 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -3,65 +3,64 @@ You can construct the following permutation groups: --- SymmetricGroup, `S_n` of order `n!` (n can also be a list `X` of distinct - positive integers, in which case it returns `S_X`) +- :class:`SymmetricGroup`, `S_n` of order `n!` (`n` can also be a list `X` of distinct + positive integers, in which case it returns `S_X`) --- AlternatingGroup, `A_n` of order `n!/2` (n can also be a list `X` - of distinct positive integers, in which case it returns - `A_X`) +- :class:`AlternatingGroup`, `A_n` of order `n!/2` (n can also be a list `X` + of distinct positive integers, in which case it returns `A_X`) --- DihedralGroup, `D_n` of order `2n` +- :class:`DihedralGroup`, `D_n` of order `2n` --- GeneralDihedralGroup, `Dih(G)`, where G is an abelian group +- :class:`GeneralDihedralGroup`, `Dih(G)`, where `G` is an abelian group --- CyclicPermutationGroup, `C_n` of order `n` +- :class:`CyclicPermutationGroup`, `C_n` of order `n` --- DiCyclicGroup, nonabelian groups of order `4m` with a unique element of order 2 +- :class:`DiCyclicGroup`, nonabelian groups of order `4m` with a unique element of order 2 --- TransitiveGroup, `n^{th}` transitive group of degree `d` - from the GAP tables of transitive groups +- :class:`TransitiveGroup`, `n`-th` transitive group of degree `d` + from the GAP tables of transitive groups --- TransitiveGroups(d), TransitiveGroups(), set of all of the above +- ``TransitiveGroups(d)``, ``TransitiveGroups()``, set of all of the above --- PrimitiveGroup, `n^{th}` primitive group of degree `d` - from the GAP tables of primitive groups +- :class:`PrimitiveGroup`, `n`-th` primitive group of degree `d` + from the GAP tables of primitive groups --- PrimitiveGroups(d), PrimitiveGroups(), set of all of the above +- ``PrimitiveGroups(d)``, ``PrimitiveGroups()``, set of all of the above --- MathieuGroup(degree), Mathieu group of degree 9, 10, 11, 12, 21, 22, 23, or 24. +- ``MathieuGroup(degree)``, Mathieu group of degree 9, 10, 11, 12, 21, 22, 23, or 24. --- KleinFourGroup, subgroup of `S_4` of order `4` which is not `C_2 \times C_2` +- :class:`KleinFourGroup`, subgroup of `S_4` of order `4` which is not `C_2 \times C_2` --- QuaternionGroup, non-abelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}` +- :class:`QuaternionGroup`, non-abelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}` --- SplitMetacyclicGroup, nonabelian groups of order `p^m` with cyclic -subgroups of index p +- :class:`SplitMetacyclicGroup`, nonabelian groups of order `p^m` with cyclic + subgroups of index p --- SemidihedralGroup, nonabelian 2-groups with cyclic subgroups of index 2 +- :class:`SemidihedralGroup`, nonabelian 2-groups with cyclic subgroups of index 2 --- PGL(n,q), projective general linear group of `n\times n` matrices over - the finite field GF(q) +- ``PGL(n,q)``, projective general linear group of `n\times n` matrices over + the finite field `\GF(q)` --- PSL(n,q), projective special linear group of `n\times n` matrices over - the finite field GF(q) +- ``PSL(n,q)``, projective special linear group of `n\times n` matrices over + the finite field `\GF(q)` --- PSp(2n,q), projective symplectic linear group of `2n\times 2n` matrices - over the finite field GF(q) +- ``PSp(2n,q)``, projective symplectic linear group of `2n\times 2n` matrices + over the finite field `\GF(q)` --- PSU(n,q), projective special unitary group of `n \times n` matrices having - coefficients in the finite field `GF(q^2)` that respect a - fixed nondegenerate sesquilinear form, of determinant 1. +- ``PSU(n,q)``, projective special unitary group of `n \times n` matrices having + coefficients in the finite field `\GF(q^2)` that respect a + fixed nondegenerate sesquilinear form, of determinant 1. --- PGU(n,q), projective general unitary group of `n\times n` matrices having - coefficients in the finite field `GF(q^2)` that respect a - fixed nondegenerate sesquilinear form, modulo the centre. +- ``PGU(n,q)``, projective general unitary group of `n\times n` matrices having + coefficients in the finite field `\GF(q^2)` that respect a + fixed nondegenerate sesquilinear form, modulo the centre. --- SuzukiGroup(q), Suzuki group over GF(q), `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. +- ``SuzukiGroup(q)``, Suzuki group over `\GF(q)`, `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. --- ComplexReflectionGroup, the complex reflection group `G(m, p, n)` or - the exceptional complex reflection group `G_m` +- :class:`ComplexReflectionGroup`, the complex reflection group `G(m, p, n)` or + the exceptional complex reflection group `G_m` --- SmallPermutationGroup, a permutation realization of an group specified by its GAP id. +- :class:`SmallPermutationGroup`, a permutation realization of a group specified by its GAP id. AUTHOR: @@ -148,7 +147,7 @@ def __classcall__(cls, *args, **kwds): class PermutationGroup_symalt(PermutationGroup_unique): """ This is a class used to factor out some of the commonality - in the SymmetricGroup and AlternatingGroup classes. + in the :class:`SymmetricGroup` and :class:`AlternatingGroup` classes. """ @staticmethod @@ -401,7 +400,7 @@ def coxeter_matrix(self): def simple_reflection(self, i): r""" - For `i` in the index set of ``self``, this returns the + For `i` in the index set of ``self``, return the elementary transposition `s_i = (i,i+1)`. EXAMPLES:: @@ -439,11 +438,13 @@ def young_subgroup(self, comp): sage: S = SymmetricGroup(8) sage: c = Composition([2,2,2,2]) sage: S.young_subgroup(c) - Subgroup generated by [(7,8), (5,6), (3,4), (1,2)] of (Symmetric group of order 8! as a permutation group) + Subgroup generated by [(7,8), (5,6), (3,4), (1,2)] of + (Symmetric group of order 8! as a permutation group) sage: S = SymmetricGroup(['a','b','c']) sage: S.young_subgroup([2,1]) - Subgroup generated by [('a','b')] of (Symmetric group of order 3! as a permutation group) + Subgroup generated by [('a','b')] of + (Symmetric group of order 3! as a permutation group) sage: Y = S.young_subgroup([2,2,2,2,2]) Traceback (most recent call last): @@ -725,11 +726,11 @@ def _gap_init_(self, gap=None): class CyclicPermutationGroup(PermutationGroup_unique): def __init__(self, n): """ - A cyclic group of order n, as a permutation group. + A cyclic group of order `n`, as a permutation group. INPUT: - n -- a positive integer + - ``n`` -- a positive integer .. note:: @@ -774,7 +775,7 @@ def _repr_(self): def is_commutative(self): """ - Return True if this group is commutative. + Return ``True`` if this group is commutative. EXAMPLES:: @@ -786,7 +787,7 @@ def is_commutative(self): def is_abelian(self): """ - Return True if this group is abelian. + Return ``True`` if this group is abelian. EXAMPLES:: @@ -798,7 +799,7 @@ def is_abelian(self): def as_AbelianGroup(self): """ - Returns the corresponding Abelian Group instance. + Return the corresponding :class:`AbelianGroup` instance. EXAMPLES:: @@ -819,7 +820,7 @@ class DiCyclicGroup(PermutationGroup_unique): INPUT: - - n -- a positive integer, two or greater + - ``n`` -- a positive integer, two or greater OUTPUT: @@ -1127,7 +1128,7 @@ class QuaternionGroup(DiCyclicGroup): OUTPUT: The quaternion group of order 8, as a permutation group. - See the ``DiCyclicGroup`` class for a generalization of this + See the :class:`DiCyclicGroup` class for a generalization of this construction. .. note:: @@ -1198,7 +1199,7 @@ class GeneralDihedralGroup(PermutationGroup_generic): INPUT: - - ``factors`` - a list of the sizes of the cyclic factors of the + - ``factors`` -- a list of the sizes of the cyclic factors of the abelian group being dihedralized (this will be sorted once entered) @@ -1266,7 +1267,7 @@ class GeneralDihedralGroup(PermutationGroup_generic): If two nonidentical input lists generate isomorphic abelian groups, then they will generate identical groups (with each direct factor broken up into its prime factors), but they will still have - distinct descriptions. Note that If `gcd(n,m)=1`, then `C_n \times + distinct descriptions. Note that if `\gcd(n,m)=1`, then `C_n \times C_m \cong C_{nm}`, while the general dihedral groups generated by isomorphic abelian groups should be themselves isomorphic. :: @@ -1433,7 +1434,8 @@ def __init__(self, n): sage: DihedralGroup(5).gens() ((1,2,3,4,5), (1,5)(2,4)) sage: sorted(DihedralGroup(5)) - [(), (2,5)(3,4), (1,2)(3,5), (1,2,3,4,5), (1,3)(4,5), (1,3,5,2,4), (1,4)(2,3), (1,4,2,5,3), (1,5,4,3,2), (1,5)(2,4)] + [(), (2,5)(3,4), (1,2)(3,5), (1,2,3,4,5), (1,3)(4,5), (1,3,5,2,4), + (1,4)(2,3), (1,4,2,5,3), (1,5,4,3,2), (1,5)(2,4)] sage: G = DihedralGroup(6) sage: G.order() @@ -1644,7 +1646,7 @@ def __init__(self, m): INPUT: - - ``m`` - a positive integer; the power of 2 that is the + - ``m`` -- a positive integer; the power of 2 that is the group's order OUTPUT: @@ -1754,11 +1756,11 @@ def __init__(self, n): INPUT: - n -- a positive integer in {9, 10, 11, 12, 21, 22, 23, 24}. + - ``n`` -- a positive integer in {9, 10, 11, 12, 21, 22, 23, 24}. OUTPUT: - the Mathieu group of degree n, as a permutation group + the Mathieu group of degree `n`, as a permutation group .. note:: @@ -1766,8 +1768,7 @@ def __init__(self, n): EXAMPLES:: - sage: G = MathieuGroup(12) - sage: G + sage: G = MathieuGroup(12); G Mathieu group of degree 12 and order 95040 as a permutation group TESTS:: @@ -1807,13 +1808,13 @@ def __init__(self, d, n): INPUT: - - d -- non-negative integer; the degree - - n -- positive integer; the index of the group in the GAP database, + - ``d`` -- non-negative integer; the degree + - ``n`` -- positive integer; the index of the group in the GAP database, starting at 1 OUTPUT: - the n-th transitive group of degree d + the `n`-th transitive group of degree `d` .. note:: @@ -1847,7 +1848,8 @@ def __init__(self, d, n): sage: TransitiveGroup(32,1) Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database TESTS:: @@ -1915,7 +1917,7 @@ def TransitiveGroups(d=None): - ``d`` -- an integer (optional) - Returns the set of all transitive groups of a given degree + Return the set of all transitive groups of a given degree ``d`` up to isomorphisms. If ``d`` is not specified, it returns the set of all transitive groups up to isomorphisms. @@ -1937,7 +1939,8 @@ def TransitiveGroups(d=None): sage: TransitiveGroups(32).cardinality() Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database """ if d is None: @@ -2167,7 +2170,8 @@ def cardinality(self): sage: TransitiveGroups(32).cardinality() Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database TESTS:: @@ -2617,18 +2621,18 @@ def matrix_degree(self): class PGL(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective general linear groups over GF(q). + r""" + The projective general linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PGL(n,q) + PGL(`n`, `q`) .. note:: @@ -2679,18 +2683,18 @@ def __str__(self): class PSL(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective special linear groups over GF(q). + r""" + The projective special linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- either a prime power (the size of the ground field) or a finite field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- either a prime power (the size of the ground field) or a finite field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - the group PSL(n,q) + the group PSL(`n`, `q`) .. note:: @@ -2766,7 +2770,7 @@ def __str__(self): def ramification_module_decomposition_hurwitz_curve(self): r""" Helps compute the decomposition of the ramification module - for the Hurwitz curves X (over CC say) with automorphism group + for the Hurwitz curves X (over `\CC` say) with automorphism group G = PSL(2,q), q a "Hurwitz prime" (ie, p is `\pm 1 \pmod 7`). Using this computation and Borne's formula helps determine the G-module structure of the RR spaces of equivariant @@ -2779,9 +2783,11 @@ def ramification_module_decomposition_hurwitz_curve(self): Here IrrRepns(G) = [pi_1,...,pi_n] (in the order listed in the output of self.character_table()). - REFERENCE: David Joyner, Amy Ksir, Roger Vogeler, - "Group representations on Riemann-Roch spaces of some - Hurwitz curves," preprint, 2006. + REFERENCE: + + David Joyner, Amy Ksir, Roger Vogeler, + "Group representations on Riemann-Roch spaces of some + Hurwitz curves," preprint, 2006. EXAMPLES:: @@ -2813,7 +2819,7 @@ def ramification_module_decomposition_hurwitz_curve(self): return mults.sage() def ramification_module_decomposition_modular_curve(self): - """ + r""" Helps compute the decomposition of the ramification module for the modular curve X(p) (over CC say) with automorphism group G = PSL(2,q), q a prime > 5. Using this computation and Borne's formula helps determine the @@ -2859,18 +2865,18 @@ def ramification_module_decomposition_modular_curve(self): class PSp(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective symplectic linear groups over GF(q). + r""" + The projective symplectic linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PSp(n,q) + PSp(`n`, `q`) .. note:: @@ -2937,8 +2943,8 @@ def field_of_definition(self): class PSU(PermutationGroup_pug): def __init__(self, n, q, name='a'): - """ - The projective special unitary groups over GF(q). + r""" + The projective special unitary groups over `\GF(q)`. INPUT: @@ -2989,18 +2995,18 @@ def _repr_(self): class PGU(PermutationGroup_pug): def __init__(self, n, q, name='a'): - """ - The projective general unitary groups over GF(q). + r""" + The projective general unitary groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PGU(n,q) + PGU(`n`, `q`) .. note:: @@ -3012,7 +3018,8 @@ def __init__(self, n, q, name='a'): The projective general unitary group of degree 2 over Finite Field of size 3 sage: G = PGU(2, 8, name='alpha'); G - The projective general unitary group of degree 2 over Finite Field in alpha of size 2^3 + The projective general unitary group of degree 2 + over Finite Field in alpha of size 2^3 sage: G.base_ring() Finite Field in alpha of size 2^3 @@ -3042,22 +3049,22 @@ def _repr_(self): class SuzukiGroup(PermutationGroup_unique): def __init__(self, q, name='a'): r""" - The Suzuki group over GF(q), + The Suzuki group over `\GF(q)`, `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. - A wrapper for the GAP function SuzukiGroup. + A wrapper for the GAP function ``SuzukiGroup``. INPUT: - - q -- 2^n, an odd power of 2; the size of the ground - field. (Strictly speaking, n should be greater than 1, or - else this group os not simple.) - - name -- (default: 'a') variable name of indeterminate of - finite field GF(q) + - ``q`` -- `2^n`, an odd power of 2; the size of the ground + field. (Strictly speaking, `n` should be greater than 1, or + else this group is not simple.) + - ``name`` -- (default: ``'a'``) variable name of indeterminate of + finite field `\GF(q)` OUTPUT: - - A Suzuki group. + A Suzuki group. .. note:: @@ -3469,8 +3476,8 @@ class SmallPermutationGroup(PermutationGroup_generic): Group of order 12 and GAP Id 4 as a permutation group sage: G.gens() ((1,2)(3,5)(4,10)(6,8)(7,12)(9,11), - (1,3)(2,5)(4,7)(6,9)(8,11)(10,12), - (1,4,8)(2,6,10)(3,7,11)(5,9,12)) + (1,3)(2,5)(4,7)(6,9)(8,11)(10,12), + (1,4,8)(2,6,10)(3,7,11)(5,9,12)) sage: G.character_table() [ 1 1 1 1 1 1] [ 1 -1 -1 1 1 -1] @@ -3479,15 +3486,19 @@ class SmallPermutationGroup(PermutationGroup_generic): [ 2 0 -2 -1 0 1] [ 2 0 2 -1 0 -1] sage: def numgps(n): return ZZ(libgap.NumberSmallGroups(n)) - sage: all(SmallPermutationGroup(n,k).id()==[n,k] for n in [1..64] for k in [1..numgps(n)]) + sage: all(SmallPermutationGroup(n,k).id() == [n,k] + ....: for n in [1..64] for k in [1..numgps(n)]) True sage: H = SmallPermutationGroup(6,1) sage: H.is_abelian() False sage: [H.centralizer(g) for g in H.conjugacy_classes_representatives()] - [Subgroup generated by [(1,2)(3,6)(4,5), (1,3,5)(2,4,6)] of (Group of order 6 and GAP Id 1 as a permutation group), - Subgroup generated by [(1,2)(3,6)(4,5)] of (Group of order 6 and GAP Id 1 as a permutation group), - Subgroup generated by [(1,3,5)(2,4,6), (1,5,3)(2,6,4)] of (Group of order 6 and GAP Id 1 as a permutation group)] + [Subgroup generated by [(1,2)(3,6)(4,5), (1,3,5)(2,4,6)] of + (Group of order 6 and GAP Id 1 as a permutation group), + Subgroup generated by [(1,2)(3,6)(4,5)] of + (Group of order 6 and GAP Id 1 as a permutation group), + Subgroup generated by [(1,3,5)(2,4,6), (1,5,3)(2,6,4)] of + (Group of order 6 and GAP Id 1 as a permutation group)] """ def __init__(self, order, gap_id): @@ -3528,10 +3539,10 @@ def gap_small_group(self): r""" Return the GAP small group object corresponding to ``self``. - GAP realizes some small groups as PermutationGroup, others as PcGroups + GAP realizes some small groups as ``PermutationGroup``, others as ``PcGroups`` (polycyclic groups). The :class:`SmallPermutationGroup` class always - returns a PermutationGroup, but in the process of creating this group - a GAP SmallGroup is generated. This method returns that group. + returns a ``PermutationGroup``, but in the process of creating this group + a GAP ``SmallGroup`` is generated. This method returns that group. EXAMPLES:: From d469ceee1df6bb44fd89e4d34590db1a68f15347 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 26 May 2023 18:05:13 -0700 Subject: [PATCH 15/64] sage.groups: Add # optional --- .../perm_gps/partn_ref/automorphism_group_canonical_label.pyx | 1 + src/sage/groups/perm_gps/partn_ref/double_coset.pyx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index d174874194f..0282ffc6494 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.groups r""" Automorphism groups and canonical labels diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index 56a97f6ece4..e6d397c0cfe 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.groups r""" Double cosets From 9785e7cdac1690c425a76f76f44390d03625d19e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 27 May 2023 20:18:26 -0700 Subject: [PATCH 16/64] Add # optional --- .../perm_gps/partn_ref/data_structures.pyx | 70 +++++++++---------- .../perm_gps/partn_ref/refinement_binary.pyx | 1 + .../perm_gps/partn_ref/refinement_graphs.pyx | 10 +-- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index cd6284fb1b8..c947d2ebdb0 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -1235,48 +1235,48 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm1 = [1,0] + list(range(2, m)) ....: perm2 = [(i+1)%n for i in range( n )] + list(range(n,m)) ....: SC_test_list_perms([perm1, perm2], m, limit, gap, 0, contains) - sage: for i in range(2,9): + sage: for i in range(2,9): # optional - sage.groups ....: test_Sn_on_m_points(i,i,1,0) - sage: for i in range(2,9): + sage: for i in range(2,9): # optional - sage.groups ....: test_Sn_on_m_points(i,i,0,1) - sage: for i in range(2,9): # long time + sage: for i in range(2,9): # long time # optional - sage.groups ....: test_Sn_on_m_points(i,i,1,1) - sage: test_Sn_on_m_points(8,8,1,1) + sage: test_Sn_on_m_points(8,8,1,1) # optional - sage.groups sage: def test_stab_chain_fns_1(n, gap, contains): ....: perm1 = sum([[2*i+1,2*i] for i in range(n)], []) ....: perm2 = [(i+1)%(2*n) for i in range( 2*n)] ....: SC_test_list_perms([perm1, perm2], 2*n, limit, gap, 0, contains) - sage: for n in range(1,11): + sage: for n in range(1,11): # optional - sage.groups ....: test_stab_chain_fns_1(n, 1, 0) - sage: for n in range(1,11): + sage: for n in range(1,11): # optional - sage.groups ....: test_stab_chain_fns_1(n, 0, 1) - sage: for n in range(1,9): # long time + sage: for n in range(1,9): # long time # optional - sage.groups ....: test_stab_chain_fns_1(n, 1, 1) - sage: test_stab_chain_fns_1(11, 1, 1) + sage: test_stab_chain_fns_1(11, 1, 1) # optional - sage.groups sage: def test_stab_chain_fns_2(n, gap, contains): ....: perms = [] ....: for p,e in factor(n): ....: perm1 = [(p*(i//p)) + ((i+1)%p) for i in range(n)] ....: perms.append(perm1) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(2,11): + sage: for n in range(2,11): # optional - sage.groups ....: test_stab_chain_fns_2(n, 1, 0) - sage: for n in range(2,11): + sage: for n in range(2,11): # optional - sage.groups ....: test_stab_chain_fns_2(n, 0, 1) - sage: for n in range(2,11): # long time + sage: for n in range(2,11): # long time # optional - sage.groups ....: test_stab_chain_fns_2(n, 1, 1) - sage: test_stab_chain_fns_2(11, 1, 1) + sage: test_stab_chain_fns_2(11, 1, 1) # optional - sage.groups sage: def test_stab_chain_fns_3(n, gap, contains): ....: perm1 = [(-i)%n for i in range( n )] ....: perm2 = [(i+1)%n for i in range( n )] ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in range(2,20): + sage: for n in range(2,20): # optional - sage.groups ....: test_stab_chain_fns_3(n, 1, 0) - sage: for n in range(2,20): + sage: for n in range(2,20): # optional - sage.groups ....: test_stab_chain_fns_3(n, 0, 1) - sage: for n in range(2,14): # long time + sage: for n in range(2,14): # long time # optional - sage.groups ....: test_stab_chain_fns_3(n, 1, 1) - sage: test_stab_chain_fns_3(20, 1, 1) + sage: test_stab_chain_fns_3(20, 1, 1) # optional - sage.groups sage: def test_stab_chain_fns_4(n, g, gap, contains): ....: perms = [] ....: for _ in range(g): @@ -1284,24 +1284,24 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm) ....: perms.append(perm) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(4,9): # long time + sage: for n in range(4,9): # long time # optional - sage.groups ....: test_stab_chain_fns_4(n, 1, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 3, 1, 0) - sage: for n in range(4,9): # not tested, known bug (see :trac:`32187`) + sage: for n in range(4,9): # not tested, known bug (see :trac:`32187`) # optional - sage.groups ....: test_stab_chain_fns_4(n, 1, 0, 1) ....: for j in range(6): ....: test_stab_chain_fns_4(n, 2, 0, 1) ....: test_stab_chain_fns_4(n, 3, 0, 1) - sage: for n in range(4,8): # long time + sage: for n in range(4,8): # long time # optional - sage.groups ....: test_stab_chain_fns_4(n, 1, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 3, 1, 1) - sage: test_stab_chain_fns_4(8, 2, 1, 1) + sage: test_stab_chain_fns_4(8, 2, 1, 1) # optional - sage.groups sage: def test_stab_chain_fns_5(n, gap, contains): ....: perms = [] ....: m = n//3 @@ -1312,12 +1312,12 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm2) ....: perm2 = list(range(m)) + perm2 ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in [4..9]: # long time + sage: for n in [4..9]: # long time # optional - sage.groups ....: for _ in range(2): ....: test_stab_chain_fns_5(n, 1, 0) - sage: for n in [4..8]: # long time + sage: for n in [4..8]: # long time # optional - sage.groups ....: test_stab_chain_fns_5(n, 0, 1) - sage: for n in [4..9]: # long time + sage: for n in [4..9]: # long time # optional - sage.groups ....: test_stab_chain_fns_5(n, 1, 1) sage: def random_perm(x): ....: shuffle(x) @@ -1328,19 +1328,19 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm = sum([random_perm(list(range(i*(n//m),min(n,(i+1)*(n//m))))) for i in range(m)], []) ....: perms.append(perm) ....: SC_test_list_perms(perms, m*(n//m), limit, gap, 0, contains) - sage: for m in range(2,9): # long time + sage: for m in range(2,9): # long time # optional - sage.groups ....: for n in range(m,3*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 1, 0) - sage: for m in range(2,10): + sage: for m in range(2,10): # optional - sage.groups ....: for n in range(m,4*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 0, 1) - sage: test_stab_chain_fns_6(10,20,2, 1, 1) - sage: test_stab_chain_fns_6(8,16,2, 1, 1) - sage: test_stab_chain_fns_6(6,36,2, 1, 1) - sage: test_stab_chain_fns_6(4,40,3, 1, 1) - sage: test_stab_chain_fns_6(4,40,2, 1, 1) + sage: test_stab_chain_fns_6(10,20,2, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_6(8,16,2, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_6(6,36,2, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_6(4,40,3, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_6(4,40,2, 1, 1) # optional - sage.groups sage: def test_stab_chain_fns_7(n, cop, gap, contains): ....: perms = [] ....: for i in range(0,n//2,2): @@ -1352,17 +1352,17 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: else: ....: perms.append(p) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in [6..14]: + sage: for n in [6..14]: # optional - sage.groups ....: test_stab_chain_fns_7(n, 1, 1, 0) ....: test_stab_chain_fns_7(n, 0, 1, 0) - sage: for n in [6..30]: + sage: for n in [6..30]: # optional - sage.groups ....: test_stab_chain_fns_7(n, 1, 0, 1) ....: test_stab_chain_fns_7(n, 0, 0, 1) - sage: for n in [6..14]: # long time + sage: for n in [6..14]: # long time # optional - sage.groups ....: test_stab_chain_fns_7(n, 1, 1, 1) ....: test_stab_chain_fns_7(n, 0, 1, 1) - sage: test_stab_chain_fns_7(20, 1, 1, 1) - sage: test_stab_chain_fns_7(20, 0, 1, 1) + sage: test_stab_chain_fns_7(20, 1, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_7(20, 0, 1, 1) # optional - sage.groups """ if gap: diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx index 3616decd7e4..56e4a062d02 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.modules sage.rings.finite_rings """ Partition backtrack functions for binary codes diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index 17ddfce42db..d4546856b68 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -905,12 +905,12 @@ def orbit_partition(gamma, list_perm=False): sage: from sage.groups.perm_gps.partn_ref.refinement_graphs import orbit_partition sage: G = graphs.PetersenGraph() - sage: S = SymmetricGroup(10) - sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') - sage: orbit_partition(gamma) + sage: S = SymmetricGroup(10) # optional - sage.groups + sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') # optional - sage.groups + sage: orbit_partition(gamma) # optional - sage.groups [[1, 2, 3, 4, 0], [5, 6, 7], [8, 9]] - sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') - sage: orbit_partition(gamma) + sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') # optional - sage.groups + sage: orbit_partition(gamma) # optional - sage.groups [[1, 6], [2, 7], [3, 8], [4, 9], [5, 0]] """ if list_perm: From f67f93aeb1c2b39f917c2e749cab258565e39e28 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 1 Jun 2023 23:00:59 -0700 Subject: [PATCH 17/64] sage.groups: Add # optional --- src/sage/groups/affine_gps/group_element.py | 4 ++-- src/sage/groups/perm_gps/permgroup_element.pyx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/groups/affine_gps/group_element.py b/src/sage/groups/affine_gps/group_element.py index 48126ba64a8..c117541bbf8 100644 --- a/src/sage/groups/affine_gps/group_element.py +++ b/src/sage/groups/affine_gps/group_element.py @@ -395,8 +395,8 @@ def __call__(self, v): sage: M = matrix(3, [-1, -2, 0, 0, 0, 1, -2, 1, -1]) sage: v = vector(QQ,(1,2,3)) sage: f = F(M, v) - sage: cube = polytopes.cube() - sage: f(cube) + sage: cube = polytopes.cube() # optional - sage.geometry.polyhedron + sage: f(cube) # optional - sage.geometry.polyhedron A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 8 vertices """ diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 06b51117b84..192e34d3749 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -1431,7 +1431,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): cpdef domain(self): """ - Returns the domain of self. + Return the domain of ``self``. EXAMPLES:: From dcb124500601ead3d0b2ed414279228f4e26a706 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 3 Jun 2023 16:36:54 -0700 Subject: [PATCH 18/64] sage.groups: Add # optional --- src/sage/groups/matrix_gps/finitely_generated.py | 4 ++-- src/sage/groups/matrix_gps/linear.py | 4 ++-- src/sage/groups/matrix_gps/matrix_group.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index 874b6b72d7b..ef62b955d30 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -19,8 +19,8 @@ subgroups of matrix groups:: sage: SL2Z = SL(2, ZZ) - sage: S, T = SL2Z.gens() - sage: SL2Z.subgroup([T^2]) + sage: S, T = SL2Z.gens() # optional - sage.libs.gap + sage: SL2Z.subgroup([T^2]) # optional - sage.libs.gap Subgroup with 1 generators ( [1 2] [0 1] diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 8dc29267923..4e173cf9edb 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -221,7 +221,7 @@ def SL(n, R, var='a'): Special Linear Group of degree 2 over Integer Ring sage: G.category() Category of infinite groups - sage: G.gens() + sage: G.gens() # optional - sage.libs.gap ( [ 0 1] [1 1] [-1 0], [0 1] @@ -231,7 +231,7 @@ def SL(n, R, var='a'): sage: G = SL(3, ZZ); G Special Linear Group of degree 3 over Integer Ring - sage: G.gens() + sage: G.gens() # optional - sage.libs.gap ( [0 1 0] [ 0 1 0] [1 1 0] [0 0 1] [-1 0 0] [0 1 0] diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 526c86695b0..36b534449e3 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -16,7 +16,7 @@ We test that :trac:`9437` is fixed:: - sage: len(list(SL(2, Zmod(4)))) + sage: len(list(SL(2, Zmod(4)))) # optional - sage.libs.gap 48 AUTHORS: From bb2839f00760502d7cd60ea138b69d177c538b18 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 4 Jun 2023 15:27:44 -0700 Subject: [PATCH 19/64] More # optional --- .../additive_abelian_wrapper.py | 18 +++++++++--------- src/sage/groups/matrix_gps/orthogonal.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index d62d25f9b5d..665171dd48f 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -770,21 +770,21 @@ def basis_from_generators(gens, ords=None): EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import basis_from_generators - sage: E = EllipticCurve(GF(31337^6,'a'), j=37) - sage: E.order() + sage: E = EllipticCurve(GF(31337^6,'a'), j=37) # optional - sage.groups sage.rings.finite_rings + sage: E.order() # optional - sage.groups sage.rings.finite_rings 946988065073788930380545280 - sage: (R,S), (ordR,ordS) = basis_from_generators(E.gens()) - sage: ordR, ordS + sage: (R,S), (ordR,ordS) = basis_from_generators(E.gens()) # optional - sage.groups sage.rings.finite_rings + sage: ordR, ordS # optional - sage.groups sage.rings.finite_rings (313157428926517503432720, 3024) - sage: R.order() == ordR + sage: R.order() == ordR # optional - sage.groups sage.rings.finite_rings True - sage: S.order() == ordS + sage: S.order() == ordS # optional - sage.groups sage.rings.finite_rings True - sage: ordR * ordS == E.order() + sage: ordR * ordS == E.order() # optional - sage.groups sage.rings.finite_rings True - sage: R.weil_pairing(S, ordR).multiplicative_order() == ordS + sage: R.weil_pairing(S, ordR).multiplicative_order() == ordS # optional - sage.groups sage.rings.finite_rings True - sage: E.abelian_group().invariants() + sage: E.abelian_group().invariants() # optional - sage.groups sage.rings.finite_rings (3024, 313157428926517503432720) """ if not gens: diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 694401d6d31..42b9d6e21b6 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -308,7 +308,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): [1 0 0] [0 0 3] - sage: GO(3,3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) + sage: GO(3,3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # optional - sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -324,7 +324,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): TESTS:: sage: TestSuite(GO3).run() - sage: groups.matrix.GO(2, 3, e=-1) + sage: groups.matrix.GO(2, 3, e=-1) # optional - sage.rings.finite_rings General Orthogonal Group of degree 2 and form parameter -1 over Finite Field of size 3 """ return _OG(n, R, False, e=e, var=var, invariant_form=invariant_form) From 4c049fb862a56f88946b6dfa19f7b0fa72b06996 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 7 Jun 2023 18:06:20 -0700 Subject: [PATCH 20/64] More # optional --- .../additive_abelian_wrapper.py | 61 +++++++++---------- src/sage/groups/generic.py | 8 +-- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 665171dd48f..94f194e9546 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -11,20 +11,19 @@ We create a toy example based on the Mordell-Weil group of an elliptic curve over `\QQ`:: - sage: E = EllipticCurve('30a2') - sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]) - sage: M + sage: E = EllipticCurve('30a2') # optional - sage.schemes + sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] # optional - sage.schemes + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]); M # optional - sage.schemes Additive abelian group isomorphic to Z/3 + Z/2 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - 19*x + 26 over Rational Field - sage: M.gens() + sage: M.gens() # optional - sage.schemes ((4 : -7 : 1), (7/4 : -11/8 : 1), (3 : -2 : 1)) - sage: 3*M.0 + sage: 3*M.0 # optional - sage.schemes (0 : 1 : 0) - sage: 3000000000000001 * M.0 + sage: 3000000000000001 * M.0 # optional - sage.schemes (4 : -7 : 1) - sage: M == loads(dumps(M)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 + sage: M == loads(dumps(M)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 # optional - sage.schemes True TESTS: @@ -33,7 +32,7 @@ sage: from sage.misc.verbose import set_verbose sage: set_verbose(2, 'additive_abelian_wrapper.py') - sage: 300001 * M.0 + sage: 300001 * M.0 # optional - sage.schemes verbose 1 (...: additive_abelian_wrapper.py, discrete_exp) Calling discrete exp on (1, 0, 0) (4 : -7 : 1) sage: set_verbose(0, 'additive_abelian_wrapper.py') @@ -100,19 +99,19 @@ def _call_(self, x): r""" TESTS:: - sage: E = EllipticCurve("65a1") - sage: G = E.torsion_subgroup() - sage: isinstance(G, sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper) + sage: E = EllipticCurve("65a1") # optional - sage.schemes + sage: G = E.torsion_subgroup() # optional - sage.schemes + sage: isinstance(G, sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper) # optional - sage.schemes True - sage: P1 = E([1,-1,1]) - sage: P2 = E([0,1,0]) - sage: P1 in G # indirect doctest + sage: P1 = E([1,-1,1]) # optional - sage.schemes + sage: P2 = E([0,1,0]) # optional - sage.schemes + sage: P1 in G # indirect doctest # optional - sage.schemes False - sage: P2 in G + sage: P2 in G # optional - sage.schemes True - sage: (G(P2) + P1) in G + sage: (G(P2) + P1) in G # optional - sage.schemes False - sage: (G(P2) + P1).parent() + sage: (G(P2) + P1).parent() # optional - sage.schemes Abelian group of points on Elliptic Curve defined by y^2 + x*y = x^3 - x over Rational Field """ return self.codomain()(x.element()) @@ -144,11 +143,11 @@ def element(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) - sage: T; type(T) + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # optional - sage.schemes + sage: T; type(T) # optional - sage.schemes (0 : 0 : 1) - sage: T.element(); type(T.element()) + sage: T.element(); type(T.element()) # optional - sage.schemes (0 : 0 : 1) """ @@ -162,8 +161,8 @@ def _repr_(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) - sage: repr(T) # indirect doctest + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # optional - sage.schemes + sage: repr(T) # indirect doctest # optional - sage.schemes '(0 : 0 : 1)' """ return repr(self.element()) @@ -193,7 +192,7 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): :: - sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.rings.finite_rings sage.schemes Additive abelian group isomorphic to Z/420 + Z/420 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 @@ -455,22 +454,22 @@ def torsion_subgroup(self, n=None): :: - sage: E = EllipticCurve('574i1') - sage: pts = [E(103,172), E(61,18)] - sage: assert pts[0].order() == 7 and pts[1].order() == infinity - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M + sage: E = EllipticCurve('574i1') # optional - sage.schemes + sage: pts = [E(103,172), E(61,18)] # optional - sage.schemes + sage: assert pts[0].order() == 7 and pts[1].order() == infinity # optional - sage.schemes + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M # optional - sage.schemes Additive abelian group isomorphic to Z/7 + Z embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup() + sage: M.torsion_subgroup() # optional - sage.schemes Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup(7) + sage: M.torsion_subgroup(7) # optional - sage.schemes Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup(5) + sage: M.torsion_subgroup(5) # optional - sage.schemes Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index f4b2462f899..fcb4aab304b 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -159,11 +159,11 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): sage: multiple(1,10^1000) 1 - sage: E = EllipticCurve('389a1') - sage: P = E(-1,1) - sage: multiple(P, 10, '+') + sage: E = EllipticCurve('389a1') # optional - sage.schemes + sage: P = E(-1,1) # optional - sage.schemes + sage: multiple(P, 10, '+') # optional - sage.schemes (645656132358737542773209599489/22817025904944891235367494656 : 525532176124281192881231818644174845702936831/3446581505217248068297884384990762467229696 : 1) - sage: multiple(P, -10, '+') + sage: multiple(P, -10, '+') # optional - sage.schemes (645656132358737542773209599489/22817025904944891235367494656 : -528978757629498440949529703029165608170166527/3446581505217248068297884384990762467229696 : 1) """ from operator import inv, mul, neg, add From 0c540ad61bf4e7a958abf237520a24e663aac846 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 9 Jun 2023 00:55:41 -0700 Subject: [PATCH 21/64] More # optional --- src/sage/groups/generic.py | 9 +++++---- src/sage/groups/matrix_gps/linear.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index fcb4aab304b..d9f2336497a 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -252,9 +252,9 @@ class multiples: sage: list(multiples(1, 10, 100)) [100, 101, 102, 103, 104, 105, 106, 107, 108, 109] - sage: E = EllipticCurve('389a1') - sage: P = E(-1,1) - sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) + sage: E = EllipticCurve('389a1') # optional - sage.schemes + sage: P = E(-1,1) # optional - sage.schemes + sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) # optional - sage.schemes ((0 : 1 : 0), 0.000000000000000) ((-1 : 1 : 1), 1.00000000000000) ((10/9 : -35/27 : 1), 4.00000000000000) @@ -277,7 +277,8 @@ class multiples: 3 times x = 3*x 4 times x = 4*x - sage: for i,n in multiples(3, 5, indexed=True, operation='*'): print("3 to the power %s = %s" % (i,n)) + sage: for i,n in multiples(3, 5, indexed=True, operation='*'): + ....: print("3 to the power %s = %s" % (i,n)) 3 to the power 0 = 1 3 to the power 1 = 3 3 to the power 2 = 9 diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 4e173cf9edb..6c7f5d34ec5 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -241,7 +241,7 @@ def SL(n, R, var='a'): TESTS:: - sage: groups.matrix.SL(2, 3) + sage: groups.matrix.SL(2, 3) # optional - sage.rings.finite_rings Special Linear Group of degree 2 over Finite Field of size 3 """ degree, ring = normalize_args_vectorspace(n, R, var='a') From 456eb79052357e4b0aed87bcb3ea1d6202f4db61 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 11 Jun 2023 14:37:23 -0700 Subject: [PATCH 22/64] More # optional --- src/sage/groups/matrix_gps/group_element.pyx | 120 +++++++++---------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 4e57798b384..44e460a4965 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -137,8 +137,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element(); g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element(); g # optional - sage.combinat sage.libs.gap [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -149,9 +149,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: TestSuite(g).run() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: TestSuite(g).run() # optional - sage.combinat sage.libs.gap """ if convert: M = parent.matrix_space()(M) @@ -172,9 +172,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: hash(g) # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: hash(g) # optional - sage.combinat sage.libs.gap 660522311176098153 # 64-bit -606138007 # 32-bit """ @@ -186,9 +186,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: loads(g.dumps()) == g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: loads(g.dumps()) == g # optional - sage.combinat sage.libs.gap True """ return (_unpickle_generic_element, (self.parent(), self._matrix,)) @@ -199,8 +199,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: W.an_element() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: W.an_element() # optional - sage.combinat sage.libs.gap [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -211,9 +211,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: latex(g) # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: latex(g) # optional - sage.combinat sage.libs.gap \left(\begin{array}{rrr} 0 & 0 & -1 \\ 1 & 0 & -1 \\ @@ -226,13 +226,13 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',4], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g * vector([1,1,1,1]) # optional - sage.combinat + sage: W = CoxeterGroup(['A',4], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: g * vector([1,1,1,1]) # optional - sage.combinat sage.libs.gap (0, 1, 1, 1) - sage: v = vector([3,2,1,-1]) # optional - sage.combinat - sage: g = W.gen(1) # optional - sage.combinat - sage: v * g == v * g.matrix() # indirect doctest # optional - sage.combinat + sage: v = vector([3,2,1,-1]) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(1) # optional - sage.combinat sage.libs.gap + sage: v * g == v * g.matrix() # indirect doctest # optional - sage.combinat sage.libs.gap True """ if not is_MatrixGroupElement(x) and x not in self.parent().base_ring(): @@ -248,16 +248,16 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: TestSuite(g).run() # optional - sage.combinat - sage: h = W.gen(0) * W.gen(1) * W.gen(2) # optional - sage.combinat - sage: g == h # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: TestSuite(g).run() # optional - sage.combinat sage.libs.gap + sage: h = W.gen(0) * W.gen(1) * W.gen(2) # optional - sage.combinat sage.libs.gap + sage: g == h # optional - sage.combinat sage.libs.gap True - sage: a = W.gen(0) # optional - sage.combinat - sage: a == g # optional - sage.combinat + sage: a = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: a == g # optional - sage.combinat sage.libs.gap False - sage: a != g # optional - sage.combinat + sage: a != g # optional - sage.combinat sage.libs.gap True """ cdef MatrixGroupElement_generic x = self @@ -270,13 +270,13 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: g # optional - sage.combinat sage.libs.gap [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: g.list() # optional - sage.combinat + sage: g.list() # optional - sage.combinat sage.libs.gap [[-1, 1, 0], [0, 1, 0], [0, 0, 1]] """ return [r.list() for r in self._matrix.rows()] @@ -291,19 +291,19 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g.matrix() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: g.matrix() # optional - sage.combinat sage.libs.gap [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: parent(g.matrix()) # optional - sage.combinat + sage: parent(g.matrix()) # optional - sage.combinat sage.libs.gap Full MatrixSpace of 3 by 3 dense matrices over Integer Ring Matrices have extra functionality that matrix group elements do not have:: - sage: g.matrix().charpoly('t') # optional - sage.combinat + sage: g.matrix().charpoly('t') # optional - sage.combinat sage.libs.gap t^3 - t^2 - t + 1 """ return self._matrix @@ -314,9 +314,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: matrix(RDF, g) # optional - sage.combinat + sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: matrix(RDF, g) # optional - sage.combinat sage.libs.gap [-1.0 1.0 0.0] [ 0.0 1.0 0.0] [ 0.0 0.0 1.0] @@ -330,10 +330,10 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: h = W.an_element() # optional - sage.combinat - sage: g * h # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: h = W.an_element() # optional - sage.combinat sage.libs.gap + sage: g * h # optional - sage.combinat sage.libs.gap [ 1 0 0] [ 1 0 -1] [ 0 1 -1] @@ -351,14 +351,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3]) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g.is_one() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3]) # optional - sage.combinat sage.libs.gap + sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap + sage: g.is_one() # optional - sage.combinat sage.libs.gap False - sage: W.an_element().is_one() # optional - sage.combinat + sage: W.an_element().is_one() # optional - sage.combinat sage.libs.gap False - sage: W.one().is_one() # optional - sage.combinat + sage: W.one().is_one() # optional - sage.combinat sage.libs.gap True """ return self._matrix.is_one() @@ -371,22 +371,22 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: ~g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap + sage: ~g # optional - sage.combinat sage.libs.gap [-1 1 0] [-1 0 1] [-1 0 0] - sage: g * ~g == W.one() # optional - sage.combinat + sage: g * ~g == W.one() # optional - sage.combinat sage.libs.gap True - sage: ~g * g == W.one() # optional - sage.combinat + sage: ~g * g == W.one() # optional - sage.combinat sage.libs.gap True - sage: W = CoxeterGroup(['B',3]) # optional - sage.combinat sage.rings.number_field - sage: W.base_ring() # optional - sage.combinat sage.rings.number_field + sage: W = CoxeterGroup(['B',3]) # optional - sage.combinat sage.libs.gap sage.rings.number_field + sage: W.base_ring() # optional - sage.combinat sage.libs.gap sage.rings.number_field Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? - sage: g = W.an_element() # optional - sage.combinat sage.rings.number_field - sage: ~g # optional - sage.combinat sage.rings.number_field + sage: g = W.an_element() # optional - sage.combinat sage.libs.gap sage.rings.number_field + sage: ~g # optional - sage.combinat sage.libs.gap sage.rings.number_field [-1 1 0] [-1 0 a] [-a 0 1] From 20605481a230c8eb5c73b8ab786b2bc30e1387f4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 12 Jun 2023 20:59:33 -0700 Subject: [PATCH 23/64] src/sage/groups/groups_catalog.py: Use lazy_import --- src/sage/groups/groups_catalog.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/groups/groups_catalog.py b/src/sage/groups/groups_catalog.py index 0e9fd03bba8..a95ffaefb4a 100644 --- a/src/sage/groups/groups_catalog.py +++ b/src/sage/groups/groups_catalog.py @@ -101,12 +101,13 @@ # groups.presentation - free groups with relations # groups.symmetries - permutation groups of regular solids, or similar -from sage.groups.matrix_gps import catalog as matrix -from sage.groups.perm_gps import permutation_groups_catalog as permutation -from sage.groups.misc_gps import misc_groups_catalog as misc -from sage.groups.affine_gps import catalog as affine -from sage.groups import finitely_presented_catalog as presentation - from sage.misc.lazy_import import lazy_import + +lazy_import('sage.groups.matrix_gps', 'catalog', as_='matrix') +lazy_import('sage.groups.perm_gps', 'permutation_groups_catalog', as_='permutation') +lazy_import('sage.groups.misc_gps', 'misc_groups_catalog', as_='misc') +lazy_import('sage.groups.affine_gps', 'catalog', as_='affine') +lazy_import('sage.groups', 'finitely_presented_catalog', as_='presentation') lazy_import('sage.groups.lie_gps', 'catalog', as_='lie') + del lazy_import From ad506ba30aab95b831ff5cf54948bdc57a434c4e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 15 Jun 2023 21:45:14 -0700 Subject: [PATCH 24/64] sage.groups.perm_gps: Modularization fixes for imports --- src/sage/groups/class_function.py | 4 +++- src/sage/groups/perm_gps/all.py | 2 -- src/sage/groups/perm_gps/constructor.py | 7 ++++++- src/sage/groups/perm_gps/permgroup_element.pyx | 15 +++++++++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/sage/groups/class_function.py b/src/sage/groups/class_function.py index 08d69ce57b0..876dc1a5afe 100644 --- a/src/sage/groups/class_function.py +++ b/src/sage/groups/class_function.py @@ -27,10 +27,12 @@ from sage.structure.richcmp import richcmp, richcmp_method from sage.interfaces.gap import gap from sage.rings.integer import Integer -from sage.rings.number_field.number_field import CyclotomicField from sage.libs.gap.element import GapElement from sage.libs.gap.libgap import libgap from sage.libs.gap.element import GapElement as LibGapElement +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.rings.number_field.number_field', 'CyclotomicField') # TODO: # diff --git a/src/sage/groups/perm_gps/all.py b/src/sage/groups/perm_gps/all.py index ae405f298a2..4c445cdaf42 100644 --- a/src/sage/groups/perm_gps/all.py +++ b/src/sage/groups/perm_gps/all.py @@ -10,8 +10,6 @@ from .permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups -from .constructor import PermutationGroupElement - from .permgroup_morphism import (PermutationGroupMorphism as PermutationGroupMap, PermutationGroupMorphism_im_gens, PermutationGroupMorphism_id) diff --git a/src/sage/groups/perm_gps/constructor.py b/src/sage/groups/perm_gps/constructor.py index 72b3f44df6d..5a130eb19be 100644 --- a/src/sage/groups/perm_gps/constructor.py +++ b/src/sage/groups/perm_gps/constructor.py @@ -23,10 +23,15 @@ from sage.misc.sage_eval import sage_eval from sage.misc.lazy_import import lazy_import from sage.interfaces.gap import GapElement -from sage.libs.pari.all import pari_gen from sage.libs.gap.element import GapElement_Permutation + lazy_import('sage.combinat.permutation', ['Permutation', 'from_cycles']) +try: + from sage.libs.pari.all import pari_gen +except ImportError: + pari_gen = () + def PermutationGroupElement(g, parent=None, check=True): r""" diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 192e34d3749..cfc956e6185 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -115,19 +115,21 @@ from libc.stdlib cimport qsort from cysignals.memory cimport sig_malloc, sig_calloc, sig_realloc, sig_free from cpython.list cimport * -from cypari2.gen cimport Gen +try: + from cypari2.gen import Gen +except ImportError: + Gen = () from sage.ext.stdsage cimport HAS_DICTIONARY -from sage.rings.integer_ring import ZZ +from sage.interfaces.abc import GpElement from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ from sage.rings.polynomial.multi_polynomial import MPolynomial from sage.rings.polynomial.polynomial_element import Polynomial -from sage.structure.element import is_Matrix -from sage.matrix.matrix_space import MatrixSpace from sage.sets.finite_enumerated_set import FiniteEnumeratedSet -from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool from sage.structure.coerce cimport coercion_model -from sage.interfaces.abc import GpElement +from sage.structure.element import is_Matrix +from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool import sage.interfaces.abc @@ -1936,6 +1938,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): [0 0 0 0 1] [0 0 0 1 0] """ + from sage.matrix.matrix_space import MatrixSpace M = MatrixSpace(ZZ, self.n, self.n, sparse=True) cdef int i entries = {} From e531f22f8f1853000d1f8a7a5b6b6c627fad3a0a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 15 Jun 2023 23:04:42 -0700 Subject: [PATCH 25/64] src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx: Add # optional --- .../partn_ref/automorphism_group_canonical_label.pyx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 0282ffc6494..590d25e321a 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -236,30 +236,30 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]): [5, 0, 1, 2, 3, 4] sage: gens = [[1,2,3,0]] sage: reps = [] - sage: for p in SymmetricGroup(4): + sage: for p in SymmetricGroup(4): # optional - sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) + sage: len(reps) # optional - sage.groups 6 sage: gens = [[1,0,2,3],[0,1,3,2]] sage: reps = [] - sage: for p in SymmetricGroup(4): + sage: for p in SymmetricGroup(4): # optional - sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) + sage: len(reps) # optional - sage.groups 6 sage: gens = [[1,2,0,3]] sage: reps = [] - sage: for p in SymmetricGroup(4): + sage: for p in SymmetricGroup(4): # optional - sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) + sage: len(reps) # optional - sage.groups 8 """ From f59d175a18dc03e7c9392cee496e6aa94d8d0918 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 15 Jun 2023 23:15:40 -0700 Subject: [PATCH 26/64] Add # optional --- src/sage/groups/class_function.py | 15 ++++++++++----- src/sage/groups/pari_group.py | 1 + src/sage/groups/perm_gps/permgroup.py | 9 ++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sage/groups/class_function.py b/src/sage/groups/class_function.py index 876dc1a5afe..adfaa487a88 100644 --- a/src/sage/groups/class_function.py +++ b/src/sage/groups/class_function.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.rings.number_field r""" Class functions of groups. @@ -714,7 +715,8 @@ def restrict(self, H): Character of Symmetric group of order 5! as a permutation group sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: chi.restrict(H) - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: chi.restrict(H).values() [3, -3, -3, -1, 0, 0] """ @@ -740,7 +742,8 @@ def induct(self, G): sage: G = SymmetricGroup(5) sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: xi = H.trivial_character(); xi - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: xi.induct(G) Character of Symmetric group of order 5! as a permutation group sage: xi.induct(G).values() @@ -1333,7 +1336,7 @@ def values(self): EXAMPLES:: sage: G = GL(2,3) - sage: [x.values() for x in G.irreducible_characters()] #random + sage: [x.values() for x in G.irreducible_characters()] # random [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, -1, -1, -1], [2, -1, 2, -1, 2, 0, 0, 0], @@ -1411,7 +1414,8 @@ def restrict(self, H): Character of Symmetric group of order 5! as a permutation group sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: chi.restrict(H) - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: chi.restrict(H).values() [3, -3, -3, -1, 0, 0] """ @@ -1442,7 +1446,8 @@ def induct(self, G): sage: G = SymmetricGroup(5) sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: xi = H.trivial_character(); xi - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: xi.induct(G) Character of Symmetric group of order 5! as a permutation group sage: xi.induct(G).values() diff --git a/src/sage/groups/pari_group.py b/src/sage/groups/pari_group.py index c54cd4885df..c0a3b835357 100644 --- a/src/sage/groups/pari_group.py +++ b/src/sage/groups/pari_group.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.libs.pari r""" PARI Groups diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 82c9d3f529d..5ce9d33951e 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- r""" Permutation groups @@ -287,12 +286,12 @@ def PermutationGroup(gens=None, *args, **kwds): We can also make permutation groups from PARI groups:: - sage: H = pari('x^4 - 2*x^3 - 2*x + 1').polgalois() - sage: G = PariGroup(H, 4); G + sage: H = pari('x^4 - 2*x^3 - 2*x + 1').polgalois() # optional - sage.libs.pari + sage: G = PariGroup(H, 4); G # optional - sage.libs.pari PARI group [8, -1, 3, "D(4)"] of degree 4 - sage: H = PermutationGroup(G); H + sage: H = PermutationGroup(G); H # optional - sage.libs.pari Transitive group number 3 of degree 4 - sage: H.gens() + sage: H.gens() # optional - sage.libs.pari ((1,2,3,4), (1,3)) We can also create permutation groups whose generators are GAP From 9916a1bfcb558cf318c7aa4b04c80db489d20cf9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 19 Jun 2023 09:15:47 -0700 Subject: [PATCH 27/64] Fix imports --- src/sage/groups/perm_gps/all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/groups/perm_gps/all.py b/src/sage/groups/perm_gps/all.py index 4c445cdaf42..ae405f298a2 100644 --- a/src/sage/groups/perm_gps/all.py +++ b/src/sage/groups/perm_gps/all.py @@ -10,6 +10,8 @@ from .permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups +from .constructor import PermutationGroupElement + from .permgroup_morphism import (PermutationGroupMorphism as PermutationGroupMap, PermutationGroupMorphism_im_gens, PermutationGroupMorphism_id) From bf476b4de5a434cf0d266d6d52ac29a725ad35bc Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 30 Jun 2023 18:38:35 -0700 Subject: [PATCH 28/64] ./sage -fixdoctests --long --distribution 'sagemath-modules' --probe sage.rings.finite_rings,sage.libs.pari --overwrite src/sage/groups/affine_gps/*.py --- src/sage/groups/affine_gps/affine_group.py | 76 +++++++++---------- src/sage/groups/affine_gps/euclidean_group.py | 24 +++--- src/sage/groups/affine_gps/group_element.py | 72 +++++++++--------- 3 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/sage/groups/affine_gps/affine_group.py b/src/sage/groups/affine_gps/affine_group.py index 81074a3e50d..3688d39695c 100644 --- a/src/sage/groups/affine_gps/affine_group.py +++ b/src/sage/groups/affine_gps/affine_group.py @@ -129,11 +129,11 @@ class AffineGroup(UniqueRepresentation, Group): Some additional ways to create affine groups:: - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: G = AffineGroup(A); G # optional - sage.rings.finite_rings + sage: G = AffineGroup(A); G # needs sage.rings.finite_rings Affine Group of degree 2 over Finite Field in a of size 2^2 - sage: G is AffineGroup(2,4) # shorthand # optional - sage.rings.finite_rings + sage: G is AffineGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V @@ -152,10 +152,10 @@ def __classcall__(cls, *args, **kwds): EXAMPLES:: - sage: A = AffineSpace(2, GF(4,'a')) # optional - sage.rings.finite_rings - sage: AffineGroup(A) is AffineGroup(2,4) # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')) # needs sage.rings.finite_rings + sage: AffineGroup(A) is AffineGroup(2,4) # needs sage.rings.finite_rings True - sage: AffineGroup(A) is AffineGroup(2, GF(4,'a')) # optional - sage.rings.finite_rings + sage: AffineGroup(A) is AffineGroup(2, GF(4,'a')) # needs sage.rings.finite_rings True sage: A = AffineGroup(2, QQ) sage: V = QQ^2 @@ -202,10 +202,10 @@ def __init__(self, degree, ring): TESTS:: - sage: G = AffineGroup(2, GF(5)); G # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(5)); G Affine Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings - sage: G.category() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: G.category() Category of finite groups sage: Aff6 = AffineGroup(6, QQ) @@ -264,8 +264,8 @@ def _latex_(self): EXAMPLES:: - sage: G = AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = AffineGroup(6, GF(5)) + sage: latex(G) \mathrm{Aff}_{6}(\Bold{F}_{5}) """ return "\\mathrm{Aff}_{%s}(%s)" % (self.degree(), @@ -277,7 +277,7 @@ def _repr_(self): EXAMPLES:: - sage: AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings + sage: AffineGroup(6, GF(5)) Affine Group of degree 6 over Finite Field of size 5 """ return "Affine Group of degree %s over %s" % (self.degree(), @@ -289,7 +289,7 @@ def cardinality(self): EXAMPLES:: - sage: AffineGroup(6, GF(5)).cardinality() # optional - sage.rings.finite_rings + sage: AffineGroup(6, GF(5)).cardinality() # needs sage.rings.finite_rings 172882428468750000000000000000 sage: AffineGroup(6, ZZ).cardinality() +Infinity @@ -305,11 +305,11 @@ def degree(self): EXAMPLES:: - sage: G = AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: g = G.an_element() # optional - sage.rings.finite_rings - sage: G.degree() # optional - sage.rings.finite_rings + sage: G = AffineGroup(6, GF(5)) + sage: g = G.an_element() # needs sage.rings.finite_rings + sage: G.degree() 6 - sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() # optional - sage.rings.finite_rings + sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() # needs sage.rings.finite_rings True """ return self._degree @@ -327,8 +327,8 @@ def matrix_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.matrix_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.matrix_space() Full MatrixSpace of 3 by 3 dense matrices over Finite Field of size 5 """ d = self.degree() @@ -341,8 +341,8 @@ def vector_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.vector_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.vector_space() Vector space of dimension 3 over Finite Field of size 5 """ return FreeModule(self.base_ring(), self.degree()) @@ -371,8 +371,8 @@ def linear_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.linear_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.linear_space() Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 5 """ dp = self.degree() + 1 @@ -390,8 +390,8 @@ def linear(self, A): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.linear([1,2,3,4,5,6,7,8,0]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.linear([1,2,3,4,5,6,7,8,0]) [1 2 3] [0] x |-> [4 0 1] x + [0] [2 3 0] [0] @@ -411,8 +411,8 @@ def translation(self, b): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.translation([1,4,8]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.translation([1,4,8]) [1 0 0] [1] x |-> [0 1 0] x + [4] [0 0 1] [3] @@ -440,12 +440,12 @@ def reflection(self, v): EXAMPLES:: - sage: G = AffineGroup(3, QQ) # optional - sage.rings.finite_rings - sage: G.reflection([1,0,0]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, QQ) + sage: G.reflection([1,0,0]) [-1 0 0] [0] x |-> [ 0 1 0] x + [0] [ 0 0 1] [0] - sage: G.reflection([3,4,-5]) # optional - sage.rings.finite_rings + sage: G.reflection([3,4,-5]) [ 16/25 -12/25 3/5] [0] x |-> [-12/25 9/25 4/5] x + [0] [ 3/5 4/5 0] [0] @@ -464,13 +464,13 @@ def random_element(self): EXAMPLES:: - sage: G = AffineGroup(4, GF(3)) # optional - sage.rings.finite_rings - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G = AffineGroup(4, GF(3)) + sage: G.random_element() # random # needs sage.rings.finite_rings [2 0 1 2] [1] [2 1 1 2] [2] x |-> [1 0 2 2] x + [2] [1 1 1 1] [2] - sage: G.random_element() in G # optional - sage.rings.finite_rings + sage: G.random_element() in G # needs sage.rings.finite_rings True """ A = self._GL.random_element() @@ -484,8 +484,8 @@ def _an_element_(self): TESTS:: - sage: G = AffineGroup(4,5) # optional - sage.rings.finite_rings - sage: G.an_element() in G # optional - sage.rings.finite_rings + sage: G = AffineGroup(4,5) + sage: G.an_element() in G # needs sage.rings.finite_rings True """ A = self._GL.an_element() @@ -498,8 +498,8 @@ def some_elements(self): EXAMPLES:: - sage: G = AffineGroup(4,5) # optional - sage.rings.finite_rings - sage: G.some_elements() # optional - sage.rings.finite_rings + sage: G = AffineGroup(4,5) + sage: G.some_elements() # needs sage.rings.finite_rings [ [2 0 0 0] [1] [0 1 0 0] [0] x |-> [0 0 1 0] x + [0] @@ -512,7 +512,7 @@ def some_elements(self): [0 1 0 0] [...] x |-> [0 0 1 0] x + [...] [0 0 0 1] [...]] - sage: all(v.parent() is G for v in G.some_elements()) # optional - sage.rings.finite_rings + sage: all(v.parent() is G for v in G.some_elements()) # needs sage.rings.finite_rings True sage: G = AffineGroup(2,QQ) diff --git a/src/sage/groups/affine_gps/euclidean_group.py b/src/sage/groups/affine_gps/euclidean_group.py index b88b4f741ac..1da846aaba4 100644 --- a/src/sage/groups/affine_gps/euclidean_group.py +++ b/src/sage/groups/affine_gps/euclidean_group.py @@ -121,11 +121,11 @@ class EuclideanGroup(AffineGroup): Some additional ways to create Euclidean groups:: - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: G = EuclideanGroup(A); G # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(A); G # needs sage.rings.finite_rings Euclidean Group of degree 2 over Finite Field in a of size 2^2 - sage: G is EuclideanGroup(2,4) # shorthand # optional - sage.rings.finite_rings + sage: G is EuclideanGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V @@ -144,9 +144,9 @@ class EuclideanGroup(AffineGroup): sage: V = QQ^6 sage: E6 is EuclideanGroup(V) True - sage: G = EuclideanGroup(2, GF(5)); G # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(2, GF(5)); G Euclidean Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.rings.finite_rings REFERENCES: @@ -195,8 +195,8 @@ def _latex_(self): r""" EXAMPLES:: - sage: G = EuclideanGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(6, GF(5)) + sage: latex(G) \mathrm{E}_{6}(\Bold{F}_{5}) """ return "\\mathrm{E}_{%s}(%s)"%(self.degree(), self.base_ring()._latex_()) @@ -207,7 +207,7 @@ def _repr_(self): EXAMPLES:: - sage: EuclideanGroup(6, GF(5)) # optional - sage.rings.finite_rings + sage: EuclideanGroup(6, GF(5)) Euclidean Group of degree 6 over Finite Field of size 5 """ return "Euclidean Group of degree %s over %s"%(self.degree(), self.base_ring()) @@ -218,18 +218,18 @@ def random_element(self): EXAMPLES:: - sage: G = EuclideanGroup(4, GF(3)) # optional - sage.rings.finite_rings - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(4, GF(3)) + sage: G.random_element() # random [2 1 2 1] [1] [1 2 2 1] [0] x |-> [2 2 2 2] x + [1] [1 1 2 2] [2] - sage: G.random_element() in G # optional - sage.rings.finite_rings + sage: G.random_element() in G True TESTS:: - sage: G.random_element().A().is_unitary() # optional - sage.rings.finite_rings + sage: G.random_element().A().is_unitary() True """ while True: diff --git a/src/sage/groups/affine_gps/group_element.py b/src/sage/groups/affine_gps/group_element.py index c117541bbf8..b1ad28203df 100644 --- a/src/sage/groups/affine_gps/group_element.py +++ b/src/sage/groups/affine_gps/group_element.py @@ -78,13 +78,13 @@ class AffineGroupElement(MultiplicativeGroupElement): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G.random_element() # optional - sage.rings.finite_rings - sage: type(g) # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G.random_element() # needs sage.rings.finite_rings + sage: type(g) # needs sage.rings.finite_rings - sage: G(g.matrix()) == g # optional - sage.rings.finite_rings + sage: G(g.matrix()) == g # needs sage.rings.finite_rings True - sage: G(2) # optional - sage.rings.finite_rings + sage: G(2) [2 0] [0] x |-> [0 2] x + [0] @@ -108,9 +108,9 @@ def __init__(self, parent, A, b=0, convert=True, check=True): TESTS:: - sage: G = AffineGroup(4, GF(5)) # optional - sage.rings.finite_rings - sage: g = G.random_element() # optional - sage.rings.finite_rings - sage: TestSuite(g).run() # optional - sage.rings.finite_rings + sage: G = AffineGroup(4, GF(5)) + sage: g = G.random_element() # needs sage.rings.finite_rings + sage: TestSuite(g).run() # needs sage.rings.finite_rings """ try: A = A.matrix() @@ -181,29 +181,29 @@ def matrix(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(7)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4,5,6,7,8,0], [10,11,12]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(7)) + sage: g = G([1,2,3,4,5,6,7,8,0], [10,11,12]) + sage: g [1 2 3] [3] x |-> [4 5 6] x + [4] [0 1 0] [5] - sage: g.matrix() # optional - sage.rings.finite_rings + sage: g.matrix() [1 2 3|3] [4 5 6|4] [0 1 0|5] [-----+-] [0 0 0|1] - sage: parent(g.matrix()) # optional - sage.rings.finite_rings + sage: parent(g.matrix()) Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 7 - sage: g.matrix() == matrix(g) # optional - sage.rings.finite_rings + sage: g.matrix() == matrix(g) True Composition of affine group elements equals multiplication of the matrices:: - sage: g1 = G.random_element() # optional - sage.rings.finite_rings - sage: g2 = G.random_element() # optional - sage.rings.finite_rings - sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() # optional - sage.rings.finite_rings + sage: g1 = G.random_element() # needs sage.rings.finite_rings + sage: g2 = G.random_element() # needs sage.rings.finite_rings + sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() # needs sage.rings.finite_rings True """ A = self._A @@ -332,13 +332,13 @@ def _mul_(self, other): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,1, 0,1], [0,1]) # optional - sage.rings.finite_rings - sage: h = G([1,1, 0,1], [1,2]) # optional - sage.rings.finite_rings - sage: g*h # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,1, 0,1], [0,1]) + sage: h = G([1,1, 0,1], [1,2]) + sage: g*h [1 2] [0] x |-> [0 1] x + [0] - sage: g.matrix() * h.matrix() == (g*h).matrix() # optional - sage.rings.finite_rings + sage: g.matrix() * h.matrix() == (g*h).matrix() True """ parent = self.parent() @@ -395,8 +395,8 @@ def __call__(self, v): sage: M = matrix(3, [-1, -2, 0, 0, 0, 1, -2, 1, -1]) sage: v = vector(QQ,(1,2,3)) sage: f = F(M, v) - sage: cube = polytopes.cube() # optional - sage.geometry.polyhedron - sage: f(cube) # optional - sage.geometry.polyhedron + sage: cube = polytopes.cube() # needs sage.geometry.polyhedron + sage: f(cube) # needs sage.geometry.polyhedron A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 8 vertices """ @@ -432,16 +432,16 @@ def _act_on_(self, x, self_on_left): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4], [5,6]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,2,3,4], [5,6]) + sage: g [1 2] [2] x |-> [0 1] x + [0] - sage: v = vector(GF(3), [1,-1]); v # optional - sage.rings.finite_rings + sage: v = vector(GF(3), [1,-1]); v (1, 2) - sage: g*v # optional - sage.rings.finite_rings + sage: g*v (1, 2) - sage: g*v == g.A() * v + g.b() # optional - sage.rings.finite_rings + sage: g*v == g.A() * v + g.b() True """ if self_on_left: @@ -455,18 +455,18 @@ def __invert__(self): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4], [5,6]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,2,3,4], [5,6]) + sage: g [1 2] [2] x |-> [0 1] x + [0] - sage: ~g # optional - sage.rings.finite_rings + sage: ~g [1 1] [1] x |-> [0 1] x + [0] - sage: g * g.inverse() # indirect doctest # optional - sage.rings.finite_rings + sage: g * g.inverse() # indirect doctest [1 0] [0] x |-> [0 1] x + [0] - sage: g * g.inverse() == g.inverse() * g == G(1) # optional - sage.rings.finite_rings + sage: g * g.inverse() == g.inverse() * g == G(1) True """ parent = self.parent() From ba6f9d293e9a9fb60ca18acd6bfbaa294e0c9ba5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 30 Jun 2023 18:41:08 -0700 Subject: [PATCH 29/64] ./sage -fixdoctests --long --distribution 'sagemath-modules' --probe sage.rings.finite_rings,sage.libs.pari --overwrite src/sage/groups/matrix_gps/*.py --- .../groups/matrix_gps/finitely_generated.py | 138 +++++++++--------- src/sage/groups/matrix_gps/linear.py | 78 +++++----- src/sage/groups/matrix_gps/matrix_group.py | 122 ++++++++-------- src/sage/groups/matrix_gps/named_group.py | 34 ++--- src/sage/groups/matrix_gps/orthogonal.py | 112 +++++++------- src/sage/groups/matrix_gps/symplectic.py | 36 ++--- src/sage/groups/matrix_gps/unitary.py | 104 ++++++------- 7 files changed, 312 insertions(+), 312 deletions(-) diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index ef62b955d30..3b79f5ebef1 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -6,10 +6,10 @@ EXAMPLES:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: gens = [matrix(F, 2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: gens = [matrix(F, 2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] + sage: G = MatrixGroup(gens) + sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] @@ -19,8 +19,8 @@ subgroups of matrix groups:: sage: SL2Z = SL(2, ZZ) - sage: S, T = SL2Z.gens() # optional - sage.libs.gap - sage: SL2Z.subgroup([T^2]) # optional - sage.libs.gap + sage: S, T = SL2Z.gens() # needs sage.libs.gap + sage: SL2Z.subgroup([T^2]) # needs sage.libs.gap Subgroup with 1 generators ( [1 2] [0 1] @@ -161,37 +161,37 @@ def QuaternionMatrixGroupGF3(): is the product of `I` and `J`. :: sage: from sage.groups.matrix_gps.finitely_generated import QuaternionMatrixGroupGF3 - sage: Q = QuaternionMatrixGroupGF3() # optional - sage.rings.finite_rings - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q = QuaternionMatrixGroupGF3() + sage: Q.order() # needs sage.rings.finite_rings 8 - sage: aye = Q.gens()[0]; aye # optional - sage.rings.finite_rings + sage: aye = Q.gens()[0]; aye [1 1] [1 2] - sage: jay = Q.gens()[1]; jay # optional - sage.rings.finite_rings + sage: jay = Q.gens()[1]; jay [2 1] [1 1] - sage: kay = aye*jay; kay # optional - sage.rings.finite_rings + sage: kay = aye*jay; kay [0 2] [1 0] TESTS:: - sage: groups.matrix.QuaternionGF3() # optional - sage.rings.finite_rings + sage: groups.matrix.QuaternionGF3() # needs sage.rings.finite_rings Matrix group over Finite Field of size 3 with 2 generators ( [1 1] [2 1] [1 2], [1 1] ) - sage: Q = QuaternionMatrixGroupGF3() # optional - sage.rings.finite_rings - sage: QP = Q.as_permutation_group() # optional - sage.rings.finite_rings - sage: QP.is_isomorphic(QuaternionGroup()) # optional - sage.rings.finite_rings + sage: Q = QuaternionMatrixGroupGF3() + sage: QP = Q.as_permutation_group() # needs sage.rings.finite_rings + sage: QP.is_isomorphic(QuaternionGroup()) # needs sage.rings.finite_rings True - sage: H = DihedralGroup(4) # optional - sage.groups sage.rings.finite_rings - sage: H.order() # optional - sage.groups sage.rings.finite_rings + sage: H = DihedralGroup(4) # needs sage.groups sage.rings.finite_rings + sage: H.order() # needs sage.groups sage.rings.finite_rings 8 - sage: QP.is_abelian(), H.is_abelian() # optional - sage.groups sage.rings.finite_rings + sage: QP.is_abelian(), H.is_abelian() # needs sage.groups sage.rings.finite_rings (False, False) - sage: QP.is_isomorphic(H) # optional - sage.groups sage.rings.finite_rings + sage: QP.is_isomorphic(H) # needs sage.groups sage.rings.finite_rings False """ from sage.rings.finite_rings.finite_field_constructor import FiniteField @@ -216,9 +216,9 @@ def MatrixGroup(*gens, **kwds): EXAMPLES:: - sage: F = GF(5) # optional - sage.rings.finite_rings - sage: gens = [matrix(F, 2, [1,2, -1,1]), matrix(F,2, [1,1, 0,1])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: F = GF(5) + sage: gens = [matrix(F, 2, [1,2, -1,1]), matrix(F,2, [1,1, 0,1])] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 5 with 2 generators ( [1 2] [1 1] [4 1], [0 1] @@ -230,8 +230,8 @@ def MatrixGroup(*gens, **kwds): matrices over the finite field, so creates that matrix group there:: - sage: gens = [matrix(2, [1,2, -1,1]), matrix(GF(7), 2, [1,1, 0,1]), 2] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: gens = [matrix(2, [1,2, -1,1]), matrix(GF(7), 2, [1,1, 0,1]), 2] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 7 with 3 generators ( [1 2] [1 1] [2 0] [6 1], [0 1], [0 2] @@ -244,12 +244,12 @@ def MatrixGroup(*gens, **kwds): ... ValueError: each generator must be an invertible matrix - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: MatrixGroup([MS.0]) # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: MatrixGroup([MS.0]) Traceback (most recent call last): ... ValueError: each generator must be an invertible matrix - sage: MatrixGroup([MS.0], check=False) # works formally but is mathematical nonsense # optional - sage.rings.finite_rings + sage: MatrixGroup([MS.0], check=False) # works formally but is mathematical nonsense Matrix group over Finite Field of size 5 with 1 generators ( [1 0] [0 0] @@ -319,15 +319,15 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): """ TESTS:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: MatrixGroup(m1) == MatrixGroup(m1) # optional - sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic + sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m1) # needs sage.symbolic True - sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) # optional - sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) # needs sage.symbolic False - sage: MatrixGroup(m1) == MatrixGroup(m2) # optional - sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m2) # needs sage.symbolic False - sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) # optional - sage.symbolic + sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) # needs sage.symbolic False sage: m1 = matrix(QQ, [[1,2], [3,4]]) @@ -339,9 +339,9 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) False - sage: G = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: H = G.as_matrix_group() # optional - sage.rings.finite_rings - sage: H == G, G == H # optional - sage.rings.finite_rings + sage: G = GL(2, GF(3)) + sage: H = G.as_matrix_group() # needs sage.rings.finite_rings + sage: H == G, G == H # needs sage.rings.finite_rings (True, True) """ @@ -351,11 +351,11 @@ def __init__(self, degree, base_ring, generator_matrices, category=None): EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: TestSuite(G).run() # optional - sage.symbolic - sage: type(G) # optional - sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic + sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic + sage: G = MatrixGroup(m1, m2) # needs sage.symbolic + sage: TestSuite(G).run() # needs sage.symbolic + sage: type(G) # needs sage.symbolic sage: from sage.groups.matrix_gps.finitely_generated import \ @@ -377,24 +377,24 @@ def gens(self): EXAMPLES:: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: gens[0] in G # optional - sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens) + sage: gens[0] in G True - sage: gens = G.gens() # optional - sage.rings.finite_rings - sage: gens[0] in G # optional - sage.rings.finite_rings + sage: gens = G.gens() + sage: gens[0] in G True - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup([MS(1), MS([1,2, 3,4])]) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: G = MatrixGroup([MS(1), MS([1,2, 3,4])]) + sage: G Matrix group over Finite Field of size 5 with 2 generators ( [1 0] [1 2] [0 1], [3 4] ) - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() ( [1 0] [1 2] [0 1], [3 4] @@ -413,13 +413,13 @@ def gen(self, i): EXAMPLES:: - sage: H = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: G = H.subgroup([h1, h2]) # optional - sage.rings.finite_rings - sage: G.gen(0) # optional - sage.rings.finite_rings + sage: H = GL(2, GF(3)) + sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) + sage: G = H.subgroup([h1, h2]) # needs sage.rings.finite_rings + sage: G.gen(0) # needs sage.rings.finite_rings [1 0] [2 1] - sage: G.gen(0).matrix() == h1.matrix() # optional - sage.rings.finite_rings + sage: G.gen(0).matrix() == h1.matrix() # needs sage.rings.finite_rings True """ return self.gens()[i] @@ -434,10 +434,10 @@ def ngens(self): EXAMPLES:: - sage: H = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: G = H.subgroup([h1, h2]) # optional - sage.rings.finite_rings - sage: G.ngens() # optional - sage.rings.finite_rings + sage: H = GL(2, GF(3)) + sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) + sage: G = H.subgroup([h1, h2]) # needs sage.rings.finite_rings + sage: G.ngens() # needs sage.rings.finite_rings 2 """ return len(self._gens_matrix) @@ -455,10 +455,10 @@ def __reduce__(self): Check that :trac:`22128` is fixed:: - sage: R = MatrixSpace(SR, 2) # optional - sage.symbolic - sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) # optional - sage.symbolic - sage: G.register_embedding(R) # optional - sage.symbolic - sage: loads(dumps(G)) # optional - sage.symbolic + sage: R = MatrixSpace(SR, 2) # needs sage.symbolic + sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) # needs sage.symbolic + sage: G.register_embedding(R) # needs sage.symbolic + sage: loads(dumps(G)) # needs sage.symbolic Matrix group over Symbolic Ring with 1 generators ( [1 1] [0 1] @@ -470,10 +470,10 @@ def _test_matrix_generators(self, **options): """ EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: G._test_matrix_generators() # optional - sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic + sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic + sage: G = MatrixGroup(m1, m2) # needs sage.symbolic + sage: G._test_matrix_generators() # needs sage.symbolic """ tester = self._tester(**options) for g,h in zip(self.gens(), MatrixGroup(self.gens()).gens()): diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 6c7f5d34ec5..c1ff96c7c1f 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -9,22 +9,22 @@ General Linear Group of degree 1 over Integer Ring sage: GL(100, RR) General Linear Group of degree 100 over Real Field with 53 bits of precision - sage: GL(3, GF(49,'a')) # optional - sage.rings.finite_rings + sage: GL(3, GF(49,'a')) # needs sage.rings.finite_rings General Linear Group of degree 3 over Finite Field in a of size 7^2 sage: SL(2, ZZ) Special Linear Group of degree 2 over Integer Ring - sage: G = SL(2, GF(3)); G # optional - sage.rings.finite_rings + sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # optional - sage.rings.finite_rings + sage: G.is_finite() # needs sage.rings.finite_rings True - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) - sage: G = SL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SL(6, GF(5)) + sage: G.gens() # needs sage.rings.finite_rings ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -93,14 +93,14 @@ def GL(n, R, var='a'): EXAMPLES:: - sage: G = GL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: G = GL(6, GF(5)) + sage: G.order() # needs sage.rings.finite_rings 11064475422000000000000000 - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G.base_ring() Finite Field of size 5 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.rings.finite_rings sage: G = GL(6, QQ) sage: G.category() @@ -109,34 +109,34 @@ def GL(n, R, var='a'): Here is the Cayley graph of (relatively small) finite General Linear Group:: - sage: g = GL(2,3) # optional - sage.rings.finite_rings - sage: d = g.cayley_graph(); d # optional - sage.graphs sage.rings.finite_rings + sage: g = GL(2,3) + sage: d = g.cayley_graph(); d # needs sage.graphs sage.rings.finite_rings Digraph on 48 vertices - sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # optional - sage.graphs sage.rings.finite_rings sage.plot + sage: d.plot(color_by_label=True, vertex_size=0.03, # long time, needs sage.graphs sage.plot sage.rings.finite_rings ....: vertex_labels=False) Graphics object consisting of 144 graphics primitives - sage: d.plot3d(color_by_label=True) # long time # optional - sage.graphs sage.rings.finite_rings sage.plot + sage: d.plot3d(color_by_label=True) # long time, needs sage.graphs sage.plot sage.rings.finite_rings Graphics3d Object :: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[2,0], [0,1]]), MS([[2,1], [2,0]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[2,0], [0,1]]), MS([[2,1], [2,0]])] + sage: G = MatrixGroup(gens) + sage: G.order() # needs sage.rings.finite_rings 48 - sage: G.cardinality() # optional - sage.rings.finite_rings + sage: G.cardinality() # needs sage.rings.finite_rings 48 - sage: H = GL(2,F) # optional - sage.rings.finite_rings - sage: H.order() # optional - sage.rings.finite_rings + sage: H = GL(2,F) + sage: H.order() # needs sage.rings.finite_rings 48 - sage: H == G # optional - sage.rings.finite_rings + sage: H == G # needs sage.rings.finite_rings True - sage: H.gens() == G.gens() # optional - sage.rings.finite_rings + sage: H.gens() == G.gens() # needs sage.rings.finite_rings True - sage: H.as_matrix_group() == H # optional - sage.rings.finite_rings + sage: H.as_matrix_group() == H # needs sage.rings.finite_rings True - sage: H.gens() # optional - sage.rings.finite_rings + sage: H.gens() # needs sage.rings.finite_rings ( [2 0] [2 1] [0 1], [2 0] @@ -144,11 +144,11 @@ def GL(n, R, var='a'): TESTS:: - sage: groups.matrix.GL(2, 3) # optional - sage.groups sage.rings.finite_rings + sage: groups.matrix.GL(2, 3) # needs sage.groups sage.rings.finite_rings General Linear Group of degree 2 over Finite Field of size 3 - sage: groups.matrix.GL(1, ZZ).category() # optional - sage.groups + sage: groups.matrix.GL(1, ZZ).category() # needs sage.groups Category of groups - sage: groups.matrix.GL(1, QQ).category() # optional - sage.groups + sage: groups.matrix.GL(1, QQ).category() # needs sage.groups Category of infinite groups """ degree, ring = normalize_args_vectorspace(n, R, var='a') @@ -207,21 +207,21 @@ def SL(n, R, var='a'): EXAMPLES:: - sage: SL(3, GF(2)) # optional - sage.rings.finite_rings + sage: SL(3, GF(2)) Special Linear Group of degree 3 over Finite Field of size 2 - sage: G = SL(15, GF(7)); G # optional - sage.rings.finite_rings + sage: G = SL(15, GF(7)); G Special Linear Group of degree 15 over Finite Field of size 7 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups - sage: G.order() # optional - sage.rings.finite_rings + sage: G.order() # needs sage.rings.finite_rings 1956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000 - sage: len(G.gens()) # optional - sage.rings.finite_rings + sage: len(G.gens()) # needs sage.rings.finite_rings 2 sage: G = SL(2, ZZ); G Special Linear Group of degree 2 over Integer Ring sage: G.category() Category of infinite groups - sage: G.gens() # optional - sage.libs.gap + sage: G.gens() # needs sage.libs.gap ( [ 0 1] [1 1] [-1 0], [0 1] @@ -231,7 +231,7 @@ def SL(n, R, var='a'): sage: G = SL(3, ZZ); G Special Linear Group of degree 3 over Integer Ring - sage: G.gens() # optional - sage.libs.gap + sage: G.gens() # needs sage.libs.gap ( [0 1 0] [ 0 1 0] [1 1 0] [0 0 1] [-1 0 0] [0 1 0] @@ -241,7 +241,7 @@ def SL(n, R, var='a'): TESTS:: - sage: groups.matrix.SL(2, 3) # optional - sage.rings.finite_rings + sage: groups.matrix.SL(2, 3) # needs sage.rings.finite_rings Special Linear Group of degree 2 over Finite Field of size 3 """ degree, ring = normalize_args_vectorspace(n, R, var='a') @@ -285,8 +285,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = SL(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = SL(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special: if x.determinant() != 1: diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 36b534449e3..501237c9843 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -5,18 +5,18 @@ Loading, saving, ... works:: - sage: G = GL(2,5); G # optional - sage.rings.finite_rings + sage: G = GL(2,5); G General Linear Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.rings.finite_rings - sage: g = G.1; g # optional - sage.rings.finite_rings + sage: g = G.1; g # needs sage.rings.finite_rings [4 1] [4 0] - sage: TestSuite(g).run() # optional - sage.rings.finite_rings + sage: TestSuite(g).run() # needs sage.rings.finite_rings We test that :trac:`9437` is fixed:: - sage: len(list(SL(2, Zmod(4)))) # optional - sage.libs.gap + sage: len(list(SL(2, Zmod(4)))) # needs sage.libs.gap 48 AUTHORS: @@ -107,9 +107,9 @@ class MatrixGroup_base(Group): TESTS:: - sage: G = SO(3, GF(11)); G # optional - sage.rings.finite_rings + sage: G = SO(3, GF(11)); G Special Orthogonal Group of degree 3 over Finite Field of size 11 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups """ _ambient = None # internal attribute to register the ambient group in case this instance is a subgroup @@ -137,9 +137,9 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = SU(2, GF(5)); F = G.base_ring() # this is GF(5^2,'a') # optional - sage.rings.finite_rings - sage: G._check_matrix(identity_matrix(F, 2)) # optional - sage.rings.finite_rings - sage: G._check_matrix(matrix(F, [[1,1], [0,1]])) # optional - sage.rings.finite_rings + sage: G = SU(2, GF(5)); F = G.base_ring() # this is GF(5^2,'a') # needs sage.rings.finite_rings + sage: G._check_matrix(identity_matrix(F, 2)) # needs sage.rings.finite_rings + sage: G._check_matrix(matrix(F, [[1,1], [0,1]])) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -158,8 +158,8 @@ def as_matrix_group(self): EXAMPLES:: - sage: G = SU(4, GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = SU(4, GF(5)) # needs sage.rings.finite_rings + sage: G.as_matrix_group() # needs sage.rings.finite_rings Matrix group over Finite Field in a of size 5^2 with 2 generators ( [ a 0 0 0] [ 1 0 4*a + 3 0] [ 0 2*a + 3 0 0] [ 1 0 0 0] @@ -167,8 +167,8 @@ def as_matrix_group(self): [ 0 0 0 3*a], [ 0 3*a + 1 0 0] ) - sage: G = GO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = GO(3,GF(5)) + sage: G.as_matrix_group() # needs sage.rings.finite_rings Matrix group over Finite Field of size 5 with 2 generators ( [2 0 0] [0 1 0] [0 3 0] [1 4 4] @@ -191,22 +191,22 @@ def subgroup(self, generators, check=True): EXAMPLES:: - sage: UCF = UniversalCyclotomicField() # optional - sage.rings.number_field - sage: G = GL(3, UCF) # optional - sage.rings.number_field - sage: e3 = UCF.gen(3); e5 = UCF.gen(5) # optional - sage.rings.number_field - sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: UCF = UniversalCyclotomicField() # needs sage.rings.number_field + sage: G = GL(3, UCF) # needs sage.rings.number_field + sage: e3 = UCF.gen(3); e5 = UCF.gen(5) # needs sage.rings.number_field + sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) # needs sage.rings.number_field + sage: S = G.subgroup([m]); S # needs sage.rings.number_field Subgroup with 1 generators ( [E(3) 1 0] [ 0 E(5) 7] [ 4 3 2] ) of General Linear Group of degree 3 over Universal Cyclotomic Field - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: G = GL(3, CF3) # optional - sage.rings.number_field - sage: e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field + sage: G = GL(3, CF3) # needs sage.rings.number_field + sage: e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) # needs sage.rings.number_field + sage: S = G.subgroup([m]); S # needs sage.rings.number_field Subgroup with 1 generators ( [ zeta3 1 0] [ 0 -zeta3 - 1 7] @@ -215,8 +215,8 @@ def subgroup(self, generators, check=True): TESTS:: - sage: TestSuite(G).run() # optional - sage.rings.number_field - sage: TestSuite(S).run() # optional - sage.rings.number_field + sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(S).run() # needs sage.rings.number_field """ try: test = self.is_finite() @@ -265,10 +265,10 @@ def _repr_(self): EXAMPLES:: - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens) + sage: G Matrix group over Finite Field of size 5 with 2 generators ( [1 2] [1 1] [4 1], [0 1] @@ -276,11 +276,11 @@ def _repr_(self): case of being a subgroup:: - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: G = GL(2, CF3) # optional - sage.rings.number_field - sage: e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field + sage: G = GL(2, CF3) # needs sage.rings.number_field + sage: e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) # needs sage.rings.number_field + sage: S = G.subgroup([m]); S # needs sage.rings.number_field Subgroup with 1 generators ( [ zeta3 1] [ 0 -zeta3 - 1] @@ -313,8 +313,8 @@ def _repr_option(self, key): EXAMPLES:: - sage: SO3 = groups.matrix.SO(3, QQ) # optional - sage.groups - sage: SO3._repr_option('element_ascii_art') # optional - sage.groups + sage: SO3 = groups.matrix.SO(3, QQ) # needs sage.groups + sage: SO3._repr_option('element_ascii_art') # needs sage.groups True """ if key == 'element_ascii_art': @@ -325,9 +325,9 @@ def _latex_(self): r""" EXAMPLES:: - sage: MS = MatrixSpace(GF(5), 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup(MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: MS = MatrixSpace(GF(5), 2, 2) + sage: G = MatrixGroup(MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])) + sage: latex(G) \left\langle \left(\begin{array}{rr} 1 & 2 \\ 4 & 1 @@ -355,19 +355,19 @@ def sign_representation(self, base_ring=None, side="twosided"): EXAMPLES:: sage: G = GL(2, QQ) - sage: V = G.sign_representation() # optional - sage.combinat - sage: e = G.an_element() # optional - sage.combinat - sage: e # optional - sage.combinat + sage: V = G.sign_representation() # needs sage.combinat + sage: e = G.an_element() # needs sage.combinat + sage: e # needs sage.combinat [1 0] [0 1] - sage: V._default_sign(e) # optional - sage.combinat + sage: V._default_sign(e) # needs sage.combinat 1 - sage: m2 = V.an_element() # optional - sage.combinat - sage: m2 # optional - sage.combinat + sage: m2 = V.an_element() # needs sage.combinat + sage: m2 # needs sage.combinat 2*B['v'] - sage: m2*e # optional - sage.combinat + sage: m2*e # needs sage.combinat 2*B['v'] - sage: m2*e*e # optional - sage.combinat + sage: m2*e*e # needs sage.combinat 2*B['v'] """ if base_ring is None: @@ -432,7 +432,7 @@ def degree(self): EXAMPLES:: - sage: SU(5,5).degree() # optional - sage.rings.finite_rings + sage: SU(5,5).degree() # needs sage.rings.finite_rings 5 """ return self._deg @@ -447,11 +447,11 @@ def matrix_space(self): EXAMPLES:: - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # optional - sage.rings.finite_rings - sage: G.matrix_space() # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) + sage: G.matrix_space() Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 5 - sage: G.matrix_space() is MS # optional - sage.rings.finite_rings + sage: G.matrix_space() is MS True """ return MatrixSpace(self.base_ring(), self.degree()) @@ -476,11 +476,11 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.rings.finite_rings - sage: H == G # optional - sage.rings.finite_rings + sage: G = GL(2,3) + sage: H = MatrixGroup(G.gens()) # needs sage.rings.finite_rings + sage: H == G # needs sage.rings.finite_rings True - sage: G == H # optional - sage.rings.finite_rings + sage: G == H # needs sage.rings.finite_rings True sage: MS = MatrixSpace(QQ, 2, 2) @@ -492,11 +492,11 @@ def __richcmp__(self, other, op): TESTS:: - sage: G = groups.matrix.GL(4,2) # optional - sage.groups sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.groups sage.rings.finite_rings - sage: G == H # optional - sage.groups sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) # needs sage.groups sage.rings.finite_rings + sage: H = MatrixGroup(G.gens()) # needs sage.groups sage.rings.finite_rings + sage: G == H # needs sage.groups sage.rings.finite_rings True - sage: G != H # optional - sage.groups sage.rings.finite_rings + sage: G != H # needs sage.groups sage.rings.finite_rings False """ if not is_MatrixGroup(other): diff --git a/src/sage/groups/matrix_gps/named_group.py b/src/sage/groups/matrix_gps/named_group.py index 08717dd7110..c98cdb55f40 100644 --- a/src/sage/groups/matrix_gps/named_group.py +++ b/src/sage/groups/matrix_gps/named_group.py @@ -8,17 +8,17 @@ sage: SL(2, ZZ) Special Linear Group of degree 2 over Integer Ring - sage: G = SL(2, GF(3)); G # optional - sage.rings.finite_rings + sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # optional - sage.rings.finite_rings + sage: G.is_finite() # needs sage.rings.finite_rings True - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) - sage: G = SL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SL(6, GF(5)) + sage: G.gens() # needs sage.rings.finite_rings ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -83,12 +83,12 @@ def normalize_args_vectorspace(*args, **kwds): TESTS:: sage: from sage.groups.matrix_gps.named_group import normalize_args_vectorspace - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: normalize_args_vectorspace(A) # optional - sage.rings.finite_rings + sage: normalize_args_vectorspace(A) # needs sage.rings.finite_rings (2, Finite Field in a of size 2^2) - sage: normalize_args_vectorspace(2,4) # shorthand # optional - sage.rings.finite_rings + sage: normalize_args_vectorspace(2,4) # shorthand # needs sage.rings.finite_rings (2, Finite Field in a of size 2^2) sage: V = ZZ^3; V @@ -150,12 +150,12 @@ def normalize_args_invariant_form(R, d, invariant_form): TESTS:: sage: from sage.groups.matrix_gps.named_group import normalize_args_invariant_form - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: m = normalize_args_invariant_form(CF3, 3, (1,2,3,0,2,0,0,2,1)); m # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field + sage: m = normalize_args_invariant_form(CF3, 3, (1,2,3,0,2,0,0,2,1)); m # needs sage.rings.number_field [1 2 3] [0 2 0] [0 2 1] - sage: m.base_ring() == CF3 # optional - sage.rings.number_field + sage: m.base_ring() == CF3 # needs sage.rings.number_field True sage: normalize_args_invariant_form(ZZ, 3, (1,2,3,0,2,0,0,2)) @@ -288,15 +288,15 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: G == MatrixGroup(G.gens()) # optional - sage.rings.finite_rings + sage: G = GL(2,3) + sage: G == MatrixGroup(G.gens()) # needs sage.rings.finite_rings True - sage: G = groups.matrix.GL(4,2) # optional - sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.rings.finite_rings - sage: G == H # optional - sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) # needs sage.rings.finite_rings + sage: H = MatrixGroup(G.gens()) # needs sage.rings.finite_rings + sage: G == H # needs sage.rings.finite_rings True - sage: G != H # optional - sage.rings.finite_rings + sage: G != H # needs sage.rings.finite_rings False """ return MatrixGroup_generic.__richcmp__(self, other, op) diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 42b9d6e21b6..dfeefbe5566 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -33,13 +33,13 @@ EXAMPLES:: - sage: GO(3,7) # optional - sage.rings.finite_rings + sage: GO(3,7) General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: G = SO(4, GF(7), 1); G # optional - sage.rings.finite_rings + sage: G = SO(4, GF(7), 1); G Special Orthogonal Group of degree 4 and form parameter 1 over Finite Field of size 7 - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G.random_element() # random # needs sage.rings.finite_rings [4 3 5 2] [6 6 4 0] [0 4 6 0] @@ -47,14 +47,14 @@ TESTS:: - sage: G = GO(3, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = GO(3, GF(5)) + sage: latex(G) \text{GO}_{3}(\Bold{F}_{5}) - sage: G = SO(3, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = SO(3, GF(5)) + sage: latex(G) \text{SO}_{3}(\Bold{F}_{5}) - sage: G = SO(4, GF(5), 1) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = SO(4, GF(5), 1) + sage: latex(G) \text{SO}_{4}(\Bold{F}_{5}, +) AUTHORS: @@ -121,13 +121,13 @@ def normalize_args_e(degree, ring, e): TESTS:: sage: from sage.groups.matrix_gps.orthogonal import normalize_args_e - sage: normalize_args_e(2, GF(3), +1) # optional - sage.rings.finite_rings + sage: normalize_args_e(2, GF(3), +1) 1 - sage: normalize_args_e(3, GF(3), 0) # optional - sage.rings.finite_rings + sage: normalize_args_e(3, GF(3), 0) 0 - sage: normalize_args_e(3, GF(3), +1) # optional - sage.rings.finite_rings + sage: normalize_args_e(3, GF(3), +1) 0 - sage: normalize_args_e(2, GF(3), 0) # optional - sage.rings.finite_rings + sage: normalize_args_e(2, GF(3), 0) Traceback (most recent call last): ... ValueError: must have e=-1 or e=1 for even degree @@ -154,14 +154,14 @@ def _OG(n, R, special, e=0, var='a', invariant_form=None): Check that :trac:`26028` is fixed:: - sage: GO(3,25).order() # indirect doctest # optional - sage.rings.finite_rings + sage: GO(3,25).order() # indirect doctest # needs sage.rings.finite_rings 31200 Check that :trac:`28054` is fixed:: - sage: G = SO(2, GF(3), -1) # optional - sage.rings.finite_rings - sage: m = G.invariant_form() # optional - sage.rings.finite_rings - sage: G2 = SO(2, GF(3), 1, invariant_form=m) # optional - sage.rings.finite_rings + sage: G = SO(2, GF(3), -1) + sage: m = G.invariant_form() + sage: G2 = SO(2, GF(3), 1, invariant_form=m) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -268,11 +268,11 @@ def GO(n, R, e=0, var='a', invariant_form=None): EXAMPLES:: - sage: GO(3, GF(7)) # optional - sage.rings.finite_rings + sage: GO(3, GF(7)) General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: GO(3, GF(7)).order() # optional - sage.rings.finite_rings + sage: GO(3, GF(7)).order() # needs sage.rings.finite_rings 672 - sage: GO(3, GF(7)).gens() # optional - sage.rings.finite_rings + sage: GO(3, GF(7)).gens() # needs sage.rings.finite_rings ( [3 0 0] [0 1 0] [0 5 0] [1 6 6] @@ -294,13 +294,13 @@ def GO(n, R, e=0, var='a', invariant_form=None): [0 1 0] [1 0 0] [0 0 3] - sage: pm = Permutation([2,3,1]).to_matrix() # optional - sage.combinat - sage: g = GO3(pm); g in GO3; g # optional - sage.combinat + sage: pm = Permutation([2,3,1]).to_matrix() # needs sage.combinat + sage: g = GO3(pm); g in GO3; g # needs sage.combinat True [0 0 1] [1 0 0] [0 1 0] - sage: GO3m(pm) # optional - sage.combinat + sage: GO3m(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -308,7 +308,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): [1 0 0] [0 0 3] - sage: GO(3,3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # optional - sage.rings.finite_rings + sage: GO(3,3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -324,7 +324,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): TESTS:: sage: TestSuite(GO3).run() - sage: groups.matrix.GO(2, 3, e=-1) # optional - sage.rings.finite_rings + sage: groups.matrix.GO(2, 3, e=-1) # needs sage.rings.finite_rings General Orthogonal Group of degree 2 and form parameter -1 over Finite Field of size 3 """ return _OG(n, R, False, e=e, var=var, invariant_form=invariant_form) @@ -375,19 +375,19 @@ def SO(n, R, e=None, var='a', invariant_form=None): EXAMPLES:: - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)) + sage: G Special Orthogonal Group of degree 3 over Finite Field of size 5 - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)) + sage: G.gens() # needs sage.rings.finite_rings ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] [0 0 1], [0 3 1], [2 0 4] ) - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)) + sage: G.as_matrix_group() # needs sage.rings.finite_rings Matrix group over Finite Field of size 5 with 3 generators ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] @@ -396,27 +396,27 @@ def SO(n, R, e=None, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: SO3 = SO(3, CF3) # optional - sage.rings.number_field - sage: SO3m = SO(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: SO3 == SO3m # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) # needs sage.rings.number_field + sage: SO3 = SO(3, CF3) # needs sage.rings.number_field + sage: SO3m = SO(3, CF3, invariant_form=m) # needs sage.rings.number_field + sage: SO3 == SO3m # needs sage.rings.number_field False - sage: SO3.invariant_form() # optional - sage.rings.number_field + sage: SO3.invariant_form() # needs sage.rings.number_field [1 0 0] [0 1 0] [0 0 1] - sage: SO3m.invariant_form() # optional - sage.rings.number_field + sage: SO3m.invariant_form() # needs sage.rings.number_field [ 1 zeta3 0] [zeta3 2 0] [ 0 0 1] - sage: pm = Permutation([2,3,1]).to_matrix() # optional - sage.combinat - sage: g = SO3(pm); g in SO3; g # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation([2,3,1]).to_matrix() # needs sage.combinat + sage: g = SO3(pm); g in SO3; g # needs sage.combinat sage.rings.number_field True [0 0 1] [1 0 0] [0 1 0] - sage: SO3m(pm) # optional - sage.combinat sage.rings.number_field + sage: SO3m(pm) # needs sage.combinat sage.rings.number_field Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -424,7 +424,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): [zeta3 2 0] [ 0 0 1] - sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # optional - sage.combinat sage.rings.number_field + sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # needs sage.combinat sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -433,8 +433,8 @@ def SO(n, R, e=None, var='a', invariant_form=None): TESTS:: - sage: TestSuite(SO3m).run() # optional - sage.rings.number_field - sage: groups.matrix.SO(2, 3, e=1) # optional - sage.rings.number_field + sage: TestSuite(SO3m).run() # needs sage.rings.number_field + sage: groups.matrix.SO(2, 3, e=1) # needs sage.rings.number_field Special Orthogonal Group of degree 2 and form parameter 1 over Finite Field of size 3 """ return _OG(n, R, True, e=e, var=var, invariant_form=invariant_form) @@ -450,20 +450,20 @@ class OrthogonalMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: G = GO(3, GF(7)); G # optional - sage.rings.finite_rings + sage: G = GO(3, GF(7)); G General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) \text{GO}_{3}(\Bold{F}_{7}) - sage: G = SO(3, GF(5)); G # optional - sage.rings.finite_rings + sage: G = SO(3, GF(5)); G Special Orthogonal Group of degree 3 over Finite Field of size 5 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) \text{SO}_{3}(\Bold{F}_{5}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) # optional - sage.rings.number_field - sage: G = SO(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: latex(G) # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) # needs sage.rings.number_field + sage: G = SO(3, CF3, invariant_form=m) # needs sage.rings.number_field + sage: latex(G) # needs sage.rings.number_field \text{SO}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to non positive definite symmetric form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ \zeta_{3} & 2 & 0 \\ @@ -482,10 +482,10 @@ def invariant_bilinear_form(self): EXAMPLES:: - sage: GO(2,3,+1).invariant_bilinear_form() # optional - sage.rings.finite_rings + sage: GO(2,3,+1).invariant_bilinear_form() # needs sage.rings.finite_rings [0 1] [1 0] - sage: GO(2,3,-1).invariant_bilinear_form() # optional - sage.rings.finite_rings + sage: GO(2,3,-1).invariant_bilinear_form() # needs sage.rings.finite_rings [2 1] [1 1] sage: G = GO(4, QQ) @@ -527,8 +527,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = GO(4, GF(5), +1) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = GO(4, GF(5), +1) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special and x.determinant() != 1: raise TypeError('matrix must have determinant one') diff --git a/src/sage/groups/matrix_gps/symplectic.py b/src/sage/groups/matrix_gps/symplectic.py index aad18def93b..58cd29d9717 100644 --- a/src/sage/groups/matrix_gps/symplectic.py +++ b/src/sage/groups/matrix_gps/symplectic.py @@ -3,17 +3,17 @@ EXAMPLES:: - sage: G = Sp(4, GF(7)); G # optional - sage.rings.finite_rings + sage: G = Sp(4, GF(7)); G Symplectic Group of degree 4 over Finite Field of size 7 - sage: g = prod(G.gens()); g # optional - sage.rings.finite_rings + sage: g = prod(G.gens()); g # needs sage.rings.finite_rings [3 0 3 0] [1 0 0 0] [0 1 0 1] [0 2 0 0] - sage: m = g.matrix() # optional - sage.rings.finite_rings - sage: m * G.invariant_form() * m.transpose() == G.invariant_form() # optional - sage.rings.finite_rings + sage: m = g.matrix() # needs sage.rings.finite_rings + sage: m * G.invariant_form() * m.transpose() == G.invariant_form() # needs sage.rings.finite_rings True - sage: G.order() # optional - sage.rings.finite_rings + sage: G.order() # needs sage.rings.finite_rings 276595200 AUTHORS: @@ -82,13 +82,13 @@ def Sp(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: Sp(4, 5) # optional - sage.rings.finite_rings + sage: Sp(4, 5) Symplectic Group of degree 4 over Finite Field of size 5 sage: Sp(4, IntegerModRing(15)) Symplectic Group of degree 4 over Ring of integers modulo 15 - sage: Sp(3, GF(7)) # optional - sage.rings.finite_rings + sage: Sp(3, GF(7)) Traceback (most recent call last): ... ValueError: the degree must be even @@ -110,14 +110,14 @@ def Sp(n, R, var='a', invariant_form=None): [ 0 0 0 2] [-1 0 0 0] [ 0 -2 0 0] - sage: pm = Permutation([2,1,4,3]).to_matrix() # optional - sage.combinat - sage: g = Sp4(pm); g in Sp4; g # optional - sage.combinat + sage: pm = Permutation([2,1,4,3]).to_matrix() # needs sage.combinat + sage: g = Sp4(pm); g in Sp4; g # needs sage.combinat True [0 1 0 0] [1 0 0 0] [0 0 0 1] [0 0 1 0] - sage: Sp4m(pm) # optional - sage.combinat + sage: Sp4m(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be symplectic with respect to the alternating form @@ -126,7 +126,7 @@ def Sp(n, R, var='a', invariant_form=None): [-1 0 0 0] [ 0 -2 0 0] - sage: Sp(4,3, invariant_form=[[0,0,0,1],[0,0,1,0],[0,2,0,0], [2,0,0,0]]) # optional - sage.rings.finite_rings + sage: Sp(4,3, invariant_form=[[0,0,0,1],[0,0,1,0],[0,2,0,0], [2,0,0,0]]) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -135,11 +135,11 @@ def Sp(n, R, var='a', invariant_form=None): sage: TestSuite(Sp4).run() sage: TestSuite(Sp4m).run() - sage: groups.matrix.Sp(2, 3) # optional - sage.rings.finite_rings + sage: groups.matrix.Sp(2, 3) # needs sage.rings.finite_rings Symplectic Group of degree 2 over Finite Field of size 3 - sage: G = Sp(4,5) # optional - sage.rings.finite_rings - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: G = Sp(4,5) + sage: TestSuite(G).run() # needs sage.rings.finite_rings """ degree, ring = normalize_args_vectorspace(n, R, var=var) if degree % 2: @@ -181,9 +181,9 @@ class SymplecticMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: Sp43 = Sp(4,3); Sp43 # optional - sage.rings.finite_rings + sage: Sp43 = Sp(4,3); Sp43 Symplectic Group of degree 4 over Finite Field of size 3 - sage: latex(Sp43) # optional - sage.rings.finite_rings + sage: latex(Sp43) \text{Sp}_{4}(\Bold{F}_{3}) sage: Sp4m = Sp(4, QQ, invariant_form=(0, 0, 1, 0, 0, 0, 0, 2, @@ -239,8 +239,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = Sp(4, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = Sp(4, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ F = self.invariant_form() if x * F * x.transpose() != F: diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 8d8a4d23491..6a32437003a 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -6,18 +6,18 @@ EXAMPLES:: - sage: G = SU(3,5) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: G = SU(3,5) # needs sage.rings.finite_rings + sage: G.order() # needs sage.rings.finite_rings 378000 - sage: G # optional - sage.rings.finite_rings + sage: G # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() # needs sage.rings.finite_rings ( [ a 0 0] [4*a 4 1] [ 0 2*a + 2 0] [ 4 4 0] [ 0 0 3*a], [ 1 0 0] ) - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in a of size 5^2 AUTHORS: @@ -76,7 +76,7 @@ def finite_field_sqrt(ring): EXAMPLES:: sage: from sage.groups.matrix_gps.unitary import finite_field_sqrt - sage: finite_field_sqrt(GF(4, 'a')) # optional - sage.rings.finite_rings + sage: finite_field_sqrt(GF(4, 'a')) # needs sage.rings.finite_rings 2 """ if not isinstance(ring, FiniteField): @@ -99,7 +99,7 @@ def _UG(n, R, special, var='a', invariant_form=None): TESTS:: - sage: GU(3,25).order() # indirect doctest # optional - sage.rings.finite_rings + sage: GU(3,25).order() # indirect doctest # needs sage.rings.finite_rings 3961191000000 """ prefix = 'General' @@ -192,9 +192,9 @@ def GU(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: G = GU(3, 7); G # optional - sage.rings.finite_rings + sage: G = GU(3, 7); G # needs sage.rings.finite_rings General Unitary Group of degree 3 over Finite Field in a of size 7^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() # needs sage.rings.finite_rings ( [ a 0 0] [6*a 6 1] [ 0 1 0] [ 6 6 0] @@ -203,10 +203,10 @@ def GU(n, R, var='a', invariant_form=None): sage: GU(2, QQ) General Unitary Group of degree 2 over Rational Field - sage: G = GU(3, 5, var='beta') # optional - sage.rings.finite_rings - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G = GU(3, 5, var='beta') # needs sage.rings.finite_rings + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in beta of size 5^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() # needs sage.rings.finite_rings ( [ beta 0 0] [4*beta 4 1] [ 0 1 0] [ 4 4 0] @@ -215,27 +215,27 @@ def GU(n, R, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) # optional - sage.rings.number_field - sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = GU(3, UCF) # optional - sage.rings.number_field - sage: Gm = GU(3, UCF, invariant_form=m) # optional - sage.rings.number_field - sage: G == Gm # optional - sage.rings.number_field + sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) # needs sage.rings.number_field + sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field + sage: G = GU(3, UCF) # needs sage.rings.number_field + sage: Gm = GU(3, UCF, invariant_form=m) # needs sage.rings.number_field + sage: G == Gm # needs sage.rings.number_field False - sage: G.invariant_form() # optional - sage.rings.number_field + sage: G.invariant_form() # needs sage.rings.number_field [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # optional - sage.rings.number_field + sage: Gm.invariant_form() # needs sage.rings.number_field [ 1 E(5) 0] [E(5)^4 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # optional - sage.combinat sage.rings.number_field - sage: g = G(pm); g in G; g # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat sage.rings.number_field + sage: g = G(pm); g in G; g # needs sage.combinat sage.rings.number_field True [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # optional - sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat sage.rings.number_field Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -243,7 +243,7 @@ def GU(n, R, var='a', invariant_form=None): [E(5)^4 2 0] [ 0 0 1] - sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # optional - sage.rings.number_field + sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -255,8 +255,8 @@ def GU(n, R, var='a', invariant_form=None): TESTS:: - sage: TestSuite(G).run() # optional - sage.rings.number_field - sage: groups.matrix.GU(2, 3) # optional - sage.groups sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.rings.number_field + sage: groups.matrix.GU(2, 3) # needs sage.groups sage.rings.finite_rings General Unitary Group of degree 2 over Finite Field in a of size 3^2 """ return _UG(n, R, False, var=var, invariant_form=invariant_form) @@ -305,35 +305,35 @@ def SU(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: SU(3,5) # optional - sage.rings.finite_rings + sage: SU(3,5) # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: SU(3, GF(5)) # optional - sage.rings.finite_rings + sage: SU(3, GF(5)) # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 sage: SU(3, QQ) Special Unitary Group of degree 3 over Rational Field Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = SU(3, CF3) # optional - sage.rings.number_field - sage: Gm = SU(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: G == Gm # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field + sage: G = SU(3, CF3) # needs sage.rings.number_field + sage: Gm = SU(3, CF3, invariant_form=m) # needs sage.rings.number_field + sage: G == Gm # needs sage.rings.number_field False - sage: G.invariant_form() # optional - sage.rings.number_field + sage: G.invariant_form() # needs sage.rings.number_field [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # optional - sage.rings.number_field + sage: Gm.invariant_form() # needs sage.rings.number_field [ 1 zeta3 0] [-zeta3 - 1 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # optional - sage.combinat sage.rings.number_field - sage: G(pm) # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat sage.rings.number_field + sage: G(pm) # needs sage.combinat sage.rings.number_field [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # optional - sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat sage.rings.number_field Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -341,15 +341,15 @@ def SU(n, R, var='a', invariant_form=None): [-zeta3 - 1 2 0] [ 0 0 1] - sage: SU(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # optional - sage.rings.finite_rings + sage: SU(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP TESTS:: - sage: TestSuite(Gm).run() # optional - sage.rings.number_field - sage: groups.matrix.SU(2, 3) # optional - sage.rings.finite_rings + sage: TestSuite(Gm).run() # needs sage.rings.number_field + sage: groups.matrix.SU(2, 3) # needs sage.rings.finite_rings Special Unitary Group of degree 2 over Finite Field in a of size 3^2 """ return _UG(n, R, True, var=var, invariant_form=invariant_form) @@ -365,20 +365,20 @@ class UnitaryMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: G = GU(3, GF(7)); G # optional - sage.rings.finite_rings + sage: G = GU(3, GF(7)); G # needs sage.rings.finite_rings General Unitary Group of degree 3 over Finite Field in a of size 7^2 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) # needs sage.rings.finite_rings \text{GU}_{3}(\Bold{F}_{7^{2}}) - sage: G = SU(3, GF(5)); G # optional - sage.rings.finite_rings + sage: G = SU(3, GF(5)); G # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) # needs sage.rings.finite_rings \text{SU}_{3}(\Bold{F}_{5^{2}}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = SU(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: latex(G) # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field + sage: G = SU(3, CF3, invariant_form=m) # needs sage.rings.number_field + sage: latex(G) # needs sage.rings.number_field \text{SU}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to positive definite hermitian form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ -\zeta_{3} - 1 & 2 & 0 \\ @@ -420,10 +420,10 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = GU(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings - sage: G = SU(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = GU(2, GF(5)) # needs sage.rings.finite_rings + sage: G._check_matrix(G.an_element().matrix()) # needs sage.rings.finite_rings + sage: G = SU(2, GF(5)) # needs sage.rings.finite_rings + sage: G._check_matrix(G.an_element().matrix()) # needs sage.rings.finite_rings """ if self._special and x.determinant() != 1: raise TypeError('matrix must have determinant one') From da35c295a5dbfc2e98c5df6c78c2aa2f91f90fb9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 12 Jul 2023 17:54:03 -0700 Subject: [PATCH 30/64] ./sage -fixdoctests --only-tags --overwrite src/sage/groups --- .../groups/abelian_gps/abelian_group_gap.py | 2 +- .../additive_abelian_group.py | 2 +- .../additive_abelian_wrapper.py | 140 +++--- src/sage/groups/braid.py | 40 +- src/sage/groups/cubic_braid.py | 45 +- src/sage/groups/generic.py | 425 +++++++++--------- src/sage/groups/group.pyx | 25 +- src/sage/groups/libgap_morphism.py | 6 +- .../groups/matrix_gps/finitely_generated.py | 42 +- src/sage/groups/matrix_gps/group_element.pyx | 163 +++---- src/sage/groups/matrix_gps/linear.py | 4 +- src/sage/groups/matrix_gps/matrix_group.py | 42 +- src/sage/groups/matrix_gps/named_group.py | 9 +- src/sage/groups/matrix_gps/orthogonal.py | 9 +- src/sage/groups/matrix_gps/unitary.py | 71 +-- src/sage/groups/old.pyx | 11 +- src/sage/groups/perm_gps/cubegroup.py | 30 +- .../automorphism_group_canonical_label.pyx | 12 +- .../perm_gps/partn_ref/data_structures.pyx | 70 +-- .../perm_gps/partn_ref/refinement_graphs.pyx | 10 +- src/sage/groups/perm_gps/permgroup.py | 9 +- .../groups/perm_gps/permgroup_element.pyx | 2 +- 22 files changed, 614 insertions(+), 555 deletions(-) diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py index 04ebb9d3ed1..55b540cc6f7 100644 --- a/src/sage/groups/abelian_gps/abelian_group_gap.py +++ b/src/sage/groups/abelian_gps/abelian_group_gap.py @@ -781,7 +781,7 @@ def __init__(self, ambient, gens): Check that we are in the correct category:: - sage: # optional - gap_package_polycyclic + sage: # optional - gap_packages sage: G = AbelianGroupGap([2,3,0]) sage: g = G.gens() sage: H1 = G.subgroup([g[0],g[1]]) diff --git a/src/sage/groups/additive_abelian/additive_abelian_group.py b/src/sage/groups/additive_abelian/additive_abelian_group.py index 9245d0ce36c..358302ffd13 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_group.py +++ b/src/sage/groups/additive_abelian/additive_abelian_group.py @@ -450,7 +450,7 @@ def permutation_group(self): EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 3]) - sage: G.permutation_group() # optional - sage.groups + sage: G.permutation_group() # needs sage.groups Permutation Group with generators [(3,4,5), (1,2)] TESTS: diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 94f194e9546..3b8c9ab7d9c 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -11,19 +11,20 @@ We create a toy example based on the Mordell-Weil group of an elliptic curve over `\QQ`:: - sage: E = EllipticCurve('30a2') # optional - sage.schemes - sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] # optional - sage.schemes - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]); M # optional - sage.schemes + sage: # needs sage.schemes + sage: E = EllipticCurve('30a2') + sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]); M Additive abelian group isomorphic to Z/3 + Z/2 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - 19*x + 26 over Rational Field - sage: M.gens() # optional - sage.schemes + sage: M.gens() ((4 : -7 : 1), (7/4 : -11/8 : 1), (3 : -2 : 1)) - sage: 3*M.0 # optional - sage.schemes + sage: 3*M.0 (0 : 1 : 0) - sage: 3000000000000001 * M.0 # optional - sage.schemes + sage: 3000000000000001 * M.0 (4 : -7 : 1) - sage: M == loads(dumps(M)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 # optional - sage.schemes + sage: M == loads(dumps(M)) # known bug True TESTS: @@ -32,7 +33,7 @@ sage: from sage.misc.verbose import set_verbose sage: set_verbose(2, 'additive_abelian_wrapper.py') - sage: 300001 * M.0 # optional - sage.schemes + sage: 300001 * M.0 # needs sage.schemes verbose 1 (...: additive_abelian_wrapper.py, discrete_exp) Calling discrete exp on (1, 0, 0) (4 : -7 : 1) sage: set_verbose(0, 'additive_abelian_wrapper.py') @@ -84,13 +85,13 @@ def __init__(self, domain): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: F = QQbar.coerce_map_from(G); F # optional - sage.rings.number_field + sage: F = QQbar.coerce_map_from(G); F # needs sage.rings.number_field Generic morphism: From: Additive abelian group isomorphic to Z + Z embedded in Algebraic Field To: Algebraic Field - sage: type(F) # optional - sage.rings.number_field + sage: type(F) # needs sage.rings.number_field """ Morphism.__init__(self, domain.Hom(domain.universe())) @@ -99,19 +100,20 @@ def _call_(self, x): r""" TESTS:: - sage: E = EllipticCurve("65a1") # optional - sage.schemes - sage: G = E.torsion_subgroup() # optional - sage.schemes - sage: isinstance(G, sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper) # optional - sage.schemes + sage: # needs sage.schemes + sage: E = EllipticCurve("65a1") + sage: G = E.torsion_subgroup() + sage: isinstance(G, sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper) True - sage: P1 = E([1,-1,1]) # optional - sage.schemes - sage: P2 = E([0,1,0]) # optional - sage.schemes - sage: P1 in G # indirect doctest # optional - sage.schemes + sage: P1 = E([1,-1,1]) + sage: P2 = E([0,1,0]) + sage: P1 in G # indirect doctest False - sage: P2 in G # optional - sage.schemes + sage: P2 in G True - sage: (G(P2) + P1) in G # optional - sage.schemes + sage: (G(P2) + P1) in G False - sage: (G(P2) + P1).parent() # optional - sage.schemes + sage: (G(P2) + P1).parent() Abelian group of points on Elliptic Curve defined by y^2 + x*y = x^3 - x over Rational Field """ return self.codomain()(x.element()) @@ -127,9 +129,9 @@ def __init__(self, parent, vector, element=None, check=False): EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper - sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: G.0 # indirect doctest # optional - sage.rings.number_field + sage: G.0 # indirect doctest # needs sage.rings.number_field 1.414213562373095? """ addgp.AdditiveAbelianGroupElement.__init__(self, parent, vector, check) @@ -143,11 +145,11 @@ def element(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # optional - sage.schemes - sage: T; type(T) # optional - sage.schemes + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # needs sage.schemes + sage: T; type(T) # needs sage.schemes (0 : 0 : 1) - sage: T.element(); type(T.element()) # optional - sage.schemes + sage: T.element(); type(T.element()) # needs sage.schemes (0 : 0 : 1) """ @@ -161,8 +163,8 @@ def _repr_(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # optional - sage.schemes - sage: repr(T) # indirect doctest # optional - sage.schemes + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # needs sage.schemes + sage: repr(T) # indirect doctest # needs sage.schemes '(0 : 0 : 1)' """ return repr(self.element()) @@ -187,12 +189,12 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): :: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # optional - sage.rings.number_field sage.symbolic + sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # needs sage.rings.number_field sage.symbolic Additive abelian group isomorphic to Z + Z embedded in Algebraic Field :: - sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # optional - sage.rings.finite_rings sage.schemes + sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # needs sage.rings.finite_rings sage.schemes Additive abelian group isomorphic to Z/420 + Z/420 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 @@ -204,7 +206,7 @@ def __init__(self, universe, gens, invariants): r""" EXAMPLES:: - sage: AdditiveAbelianGroupWrapper(QQbar, # indirect doctest # optional - sage.rings.number_field + sage: AdditiveAbelianGroupWrapper(QQbar, # indirect doctest # needs sage.rings.number_field ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) Additive abelian group isomorphic to Z + Z embedded in Algebraic Field """ @@ -222,10 +224,10 @@ def universe(self): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], ....: [0, 0]) - sage: G.universe() # optional - sage.rings.number_field + sage: G.universe() # needs sage.rings.number_field Algebraic Field """ return self._universe @@ -253,9 +255,9 @@ def _repr_(self): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: repr(G) # indirect doctest # optional - sage.rings.number_field + sage: repr(G) # indirect doctest # needs sage.rings.number_field 'Additive abelian group isomorphic to Z + Z embedded in Algebraic Field' """ return addgp.AdditiveAbelianGroup_fixed_gens._repr_(self) + " embedded in " + self.universe()._repr_() @@ -291,11 +293,11 @@ def discrete_exp(self, v): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, # optional - sage.rings.number_field + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field ....: [sqrt(QQbar(2)), -1], [0, 0]) - sage: v = G.discrete_exp([3, 5]); v # optional - sage.rings.number_field + sage: v = G.discrete_exp([3, 5]); v # needs sage.rings.number_field -0.7573593128807148? - sage: v.parent() is QQbar # optional - sage.rings.number_field + sage: v.parent() is QQbar # needs sage.rings.number_field True This method is an inverse of :meth:`discrete_log`:: @@ -349,9 +351,9 @@ def discrete_log(self, x, gens=None): :: sage: x = polygen(ZZ, 'x') - sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # optional - sage.rings.finite_rings - sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # optional - sage.rings.finite_rings - sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # optional - sage.rings.finite_rings + sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # needs sage.rings.finite_rings + sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # needs sage.rings.finite_rings + sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # needs sage.rings.finite_rings (123, 777) :: @@ -367,8 +369,8 @@ def discrete_log(self, x, gens=None): :: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # optional - sage.rings.number_field sage.symbolic - sage: G.discrete_log(QQbar(2*sqrt(2))) # optional - sage.rings.number_field sage.symbolic + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # needs sage.rings.number_field sage.symbolic + sage: G.discrete_log(QQbar(2*sqrt(2))) # needs sage.rings.number_field sage.symbolic Traceback (most recent call last): ... NotImplementedError: No black-box discrete log for infinite abelian groups @@ -443,33 +445,35 @@ def torsion_subgroup(self, n=None): :: - sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.rings.finite_rings - sage: T = E.abelian_group().torsion_subgroup(42) # optional - sage.rings.finite_rings - sage: T # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(487^2), [311,205]) + sage: T = E.abelian_group().torsion_subgroup(42) + sage: T Additive abelian group isomorphic to Z/42 + Z/6 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 - sage: [P.order() for P in T.gens()] # optional - sage.rings.finite_rings + sage: [P.order() for P in T.gens()] [42, 6] :: - sage: E = EllipticCurve('574i1') # optional - sage.schemes - sage: pts = [E(103,172), E(61,18)] # optional - sage.schemes - sage: assert pts[0].order() == 7 and pts[1].order() == infinity # optional - sage.schemes - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M # optional - sage.schemes + sage: # needs sage.schemes + sage: E = EllipticCurve('574i1') + sage: pts = [E(103,172), E(61,18)] + sage: assert pts[0].order() == 7 and pts[1].order() == infinity + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M Additive abelian group isomorphic to Z/7 + Z embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup() # optional - sage.schemes + sage: M.torsion_subgroup() Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup(7) # optional - sage.schemes + sage: M.torsion_subgroup(7) Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field - sage: M.torsion_subgroup(5) # optional - sage.schemes + sage: M.torsion_subgroup(5) Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field @@ -572,12 +576,13 @@ def _discrete_log_pgroup(p, vals, aa, b): Check for :trac:`34716`:: - sage: E = EllipticCurve(GF(487^2), [311,205]) # optional - sage.rings.finite_rings - sage: G = E.abelian_group().torsion_subgroup(42) # optional - sage.rings.finite_rings - sage: G.invariants() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(487^2), [311,205]) + sage: G = E.abelian_group().torsion_subgroup(42) + sage: G.invariants() (6, 42) - sage: P, Q = G.torsion_subgroup(6).gens() # optional - sage.rings.finite_rings - sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # optional - sage.groups sage.rings.finite_rings + sage: P, Q = G.torsion_subgroup(6).gens() + sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # needs sage.groups (2, 3) """ from itertools import product as iproduct @@ -768,22 +773,23 @@ def basis_from_generators(gens, ords=None): EXAMPLES:: + sage: # needs sage.groups sage.rings.finite_rings sage: from sage.groups.additive_abelian.additive_abelian_wrapper import basis_from_generators - sage: E = EllipticCurve(GF(31337^6,'a'), j=37) # optional - sage.groups sage.rings.finite_rings - sage: E.order() # optional - sage.groups sage.rings.finite_rings + sage: E = EllipticCurve(GF(31337^6,'a'), j=37) + sage: E.order() 946988065073788930380545280 - sage: (R,S), (ordR,ordS) = basis_from_generators(E.gens()) # optional - sage.groups sage.rings.finite_rings - sage: ordR, ordS # optional - sage.groups sage.rings.finite_rings + sage: (R,S), (ordR,ordS) = basis_from_generators(E.gens()) + sage: ordR, ordS (313157428926517503432720, 3024) - sage: R.order() == ordR # optional - sage.groups sage.rings.finite_rings + sage: R.order() == ordR True - sage: S.order() == ordS # optional - sage.groups sage.rings.finite_rings + sage: S.order() == ordS True - sage: ordR * ordS == E.order() # optional - sage.groups sage.rings.finite_rings + sage: ordR * ordS == E.order() True - sage: R.weil_pairing(S, ordR).multiplicative_order() == ordS # optional - sage.groups sage.rings.finite_rings + sage: R.weil_pairing(S, ordR).multiplicative_order() == ordS True - sage: E.abelian_group().invariants() # optional - sage.groups sage.rings.finite_rings + sage: E.abelian_group().invariants() (3024, 313157428926517503432720) """ if not gens: diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index 9fbe0038985..c2cc1951f9e 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -506,14 +506,14 @@ def plot(self, color='rainbow', orientation='bottom-top', gap=0.05, aspect_ratio False sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot() # optional - sage.plot + sage: b.plot() # needs sage.plot Graphics object consisting of 30 graphics primitives - sage: b.plot(color=["red", "blue", "red", "blue"]) # optional - sage.plot + sage: b.plot(color=["red", "blue", "red", "blue"]) # needs sage.plot Graphics object consisting of 30 graphics primitives sage: B. = BraidGroup(3) sage: b = t^-1*s^2 - sage: b.plot(orientation="left-right", color="red") # optional - sage.plot + sage: b.plot(orientation="left-right", color="red") # needs sage.plot Graphics object consisting of 12 graphics primitives """ from sage.plot.bezier_path import bezier_path @@ -607,11 +607,11 @@ def plot3d(self, color='rainbow'): sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot3d() # optional - sage.plot sage.symbolic + sage: b.plot3d() # needs sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color="red") # optional - sage.plot sage.symbolic + sage: b.plot3d(color="red") # needs sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color=["red", "blue", "red", "blue"]) # optional - sage.plot sage.symbolic + sage: b.plot3d(color=["red", "blue", "red", "blue"]) # needs sage.plot sage.symbolic Graphics3d Object """ from sage.plot.plot3d.shapes2 import bezier3d @@ -813,8 +813,8 @@ def links_gould_matrix(self, symbolics=False): Univariate Quotient Polynomial Ring in Yrbar over Multivariate Laurent Polynomial Ring in s0r, s1r over Integer Ring with modulus Yr^2 + s0r^2*s1r^2 - s0r^2 - s1r^2 + 1 - sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) # optional - sage.symbolic - sage: HopfLGs.base_ring() # optional - sage.symbolic + sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) # needs sage.symbolic + sage: HopfLGs.base_ring() # needs sage.symbolic Symbolic Ring """ rep = self.parent()._links_gould_representation(symbolics=symbolics) @@ -1017,15 +1017,15 @@ def _jones_polynomial(self): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() # optional - sage.symbolic + sage: b.jones_polynomial() # needs sage.symbolic 1 sage: B = BraidGroup(2) sage: b = B([]) - sage: b._jones_polynomial # optional - sage.symbolic + sage: b._jones_polynomial # needs sage.symbolic -A^-2 - A^2 sage: b = B([-1, -1, -1]) - sage: b._jones_polynomial # optional - sage.symbolic + sage: b._jones_polynomial # needs sage.symbolic -A^-16 + A^-12 + A^-4 """ trace = self.markov_trace(normalized=False) @@ -1073,41 +1073,41 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() # optional - sage.symbolic + sage: b.jones_polynomial() # needs sage.symbolic 1 Two unlinked unknots:: sage: B = BraidGroup(2) sage: b = B([]) - sage: b.jones_polynomial() # optional - sage.symbolic + sage: b.jones_polynomial() # needs sage.symbolic -sqrt(t) - 1/sqrt(t) The Hopf link:: sage: B = BraidGroup(2) sage: b = B([-1,-1]) - sage: b.jones_polynomial() # optional - sage.symbolic + sage: b.jones_polynomial() # needs sage.symbolic -1/sqrt(t) - 1/t^(5/2) Different representations of the trefoil and one of its mirror:: sage: B = BraidGroup(2) sage: b = B([-1, -1, -1]) - sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic -A^-16 + A^-12 + A^-4 - sage: b.jones_polynomial() # optional - sage.symbolic + sage: b.jones_polynomial() # needs sage.symbolic 1/t + 1/t^3 - 1/t^4 sage: B = BraidGroup(3) sage: b = B([-1, -2, -1, -2]) - sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic -A^-16 + A^-12 + A^-4 sage: R. = LaurentPolynomialRing(GF(2)) - sage: b.jones_polynomial(skein_normalization=True, variab=x) # optional - sage.symbolic + sage: b.jones_polynomial(skein_normalization=True, variab=x) # needs sage.symbolic x^-16 + x^-12 + x^-4 sage: B = BraidGroup(3) sage: b = B([1, 2, 1, 2]) - sage: b.jones_polynomial(skein_normalization=True) # optional - sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic A^4 + A^12 - A^16 K11n42 (the mirror of the "Kinoshita-Terasaka" knot) and K11n34 (the @@ -1116,7 +1116,7 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(4) sage: b11n42 = B([1, -2, 3, -2, 3, -2, -2, -1, 2, -3, -3, 2, 2]) sage: b11n34 = B([1, 1, 2, -3, 2, -3, 1, -2, -2, -3, -3]) - sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) # optional - sage.symbolic + sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) # needs sage.symbolic True """ if skein_normalization: diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index cd631603560..08818ccaff3 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -403,11 +403,11 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Number Field in t with defining polynomial t^2 - t + 1 - sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # optional - sage.rings.number_field sage.symbolic + sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # needs sage.rings.number_field sage.symbolic [ 1/2*sqrt3*I + 1/2 1 -1/2*sqrt3*I - 1/2] [ 1/2*sqrt3*I + 1/2 -1/2*sqrt3*I + 1/2 0] [ 1 0 0] - sage: BuMa.base_ring() # optional - sage.rings.number_field sage.symbolic + sage: BuMa.base_ring() # needs sage.rings.number_field sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field sage: BuMa = ele.burau_matrix(characteristic=7); BuMa [3 1 4] @@ -434,18 +434,18 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 5^2 - sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa # optional - sage.rings.number_field + sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa # needs sage.rings.number_field [ 0 zeta12^3] [zeta12^3 0] - sage: BuMa * H * BuMaAd == H # optional - sage.rings.number_field + sage: BuMa * H * BuMaAd == H # needs sage.rings.number_field True - sage: BuMa.base_ring() # optional - sage.rings.number_field + sage: BuMa.base_ring() # needs sage.rings.number_field Cyclotomic Field of order 12 and degree 4 - sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # optional - sage.rings.number_field sage.symbolic + sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # needs sage.rings.number_field sage.symbolic ....: reduced='unitary'); BuMa [0 I] [I 0] - sage: BuMa.base_ring() # optional - sage.rings.number_field sage.symbolic + sage: BuMa.base_ring() # needs sage.rings.number_field sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field """ braid = self.braid() @@ -1743,27 +1743,29 @@ def as_reflection_group(self): EXAMPLES:: - sage: C3. = CubicBraidGroup(3) # optional - gap3 - sage: R3 = C3.as_reflection_group(); R3 # optional - gap3 + sage: # optional - gap3 + sage: C3. = CubicBraidGroup(3) + sage: R3 = C3.as_reflection_group(); R3 Irreducible complex reflection group of rank 2 and type ST4 - sage: R3.cartan_matrix() # optional - gap3 + sage: R3.cartan_matrix() [-2*E(3) - E(3)^2 E(3)^2] [ -E(3)^2 -2*E(3) - E(3)^2] - sage: R3.simple_roots() # optional - gap3 + sage: R3.simple_roots() Finite family {1: (0, -2*E(3) - E(3)^2), 2: (2*E(3)^2, E(3)^2)} - sage: R3.simple_coroots() # optional - gap3 + sage: R3.simple_coroots() Finite family {1: (0, 1), 2: (1/3*E(3) - 1/3*E(3)^2, 1/3*E(3) - 1/3*E(3)^2)} Conversion maps:: - sage: r = R3.an_element() # optional - gap3 - sage: cr = C3(r); cr # optional - gap3 + sage: # optional - gap3 + sage: r = R3.an_element() + sage: cr = C3(r); cr c1*c2 - sage: mr = r.matrix(); mr # optional - gap3 + sage: mr = r.matrix(); mr [ 1/3*E(3) - 1/3*E(3)^2 2/3*E(3) + 1/3*E(3)^2] [-2/3*E(3) + 2/3*E(3)^2 2/3*E(3) + 1/3*E(3)^2] - sage: C3Cl = C3.as_classical_group() # optional - gap3 - sage: C3Cl(cr) # optional - gap3 + sage: C3Cl = C3.as_classical_group() + sage: C3Cl(cr) [ E(3)^2 -E(4)] [-E(12)^7 0] @@ -1773,13 +1775,14 @@ def as_reflection_group(self): the classical group due to different hermitian forms for the unitary groups they live in:: - sage: C4 = CubicBraidGroup(4) # optional - gap3 - sage: R4 = C4.as_reflection_group() # optional - gap3 - sage: R4.invariant_form() # optional - gap3 + sage: # optional - gap3 + sage: C4 = CubicBraidGroup(4) + sage: R4 = C4.as_reflection_group() + sage: R4.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: _ == C4.classical_invariant_form() # optional - gap3 + sage: _ == C4.classical_invariant_form() False """ # ------------------------------------------------------------------------------- diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index d9f2336497a..6724567454e 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -25,76 +25,82 @@ - Discrete logs:: - sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings - sage: b = K.gen() # optional - sage.rings.finite_rings - sage: a = b^210 # optional - sage.rings.finite_rings - sage: discrete_log(a, b, K.order()-1) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3^6,'b') + sage: b = K.gen() + sage: a = b^210 + sage: discrete_log(a, b, K.order()-1) 210 - Linear relation finder:: - sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings - sage: a.multiplicative_order().factor() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(3^6,'a') + sage: a.multiplicative_order().factor() 2^3 * 7 * 13 - sage: b = a^7 # optional - sage.rings.finite_rings - sage: c = a^13 # optional - sage.rings.finite_rings - sage: linear_relation(b,c,'*') # optional - sage.rings.finite_rings + sage: b = a^7 + sage: c = a^13 + sage: linear_relation(b,c,'*') (13, 7) - sage: b^13 == c^7 # optional - sage.rings.finite_rings + sage: b^13 == c^7 True - Orders of elements:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_multiple, order_from_bounds - sage: k. = GF(5^5) # optional - sage.rings.finite_rings - sage: b = a^4 # optional - sage.rings.finite_rings - sage: order_from_multiple(b, 5^5 - 1, operation='*') # optional - sage.rings.finite_rings + sage: k. = GF(5^5) + sage: b = a^4 + sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: order_from_bounds(b, (5^4, 5^5), operation='*') # optional - sage.rings.finite_rings + sage: order_from_bounds(b, (5^4, 5^5), operation='*') 781 Some examples in the group of points of an elliptic curve over a finite field: - Discrete logs:: - sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[1,1]) # optional - sage.rings.finite_rings - sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[1,1]) # optional - sage.rings.finite_rings - sage: P = E(25*a + 16 , 15*a + 7 ) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(37^2,'a') + sage: E = EllipticCurve(F,[1,1]) + sage: F. = GF(37^2,'a') + sage: E = EllipticCurve(F,[1,1]) + sage: P = E(25*a + 16 , 15*a + 7 ) + sage: P.order() 672 - sage: Q = 39*P; Q # optional - sage.rings.finite_rings + sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q, P, P.order(), operation='+') # optional - sage.rings.finite_rings + sage: discrete_log(Q, P, P.order(), operation='+') 39 - Linear relation finder:: - sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings - sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) # optional - sage.rings.finite_rings - sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) # optional - sage.rings.finite_rings - sage: linear_relation(P,Q,'+') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(3^6,'a') + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) + sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) + sage: linear_relation(P,Q,'+') (1, 2) - sage: P == 2*Q # optional - sage.rings.finite_rings + sage: P == 2*Q True - Orders of elements:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_multiple, order_from_bounds - sage: k. = GF(5^5) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[2,4]) # optional - sage.rings.finite_rings - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) # optional - sage.rings.finite_rings - sage: M = E.cardinality(); M # optional - sage.rings.finite_rings + sage: k. = GF(5^5) + sage: E = EllipticCurve(k,[2,4]) + sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + sage: M = E.cardinality(); M 3227 - sage: plist = M.prime_factors() # optional - sage.rings.finite_rings - sage: order_from_multiple(P, M, plist, operation='+') # optional - sage.rings.finite_rings + sage: plist = M.prime_factors() + sage: order_from_multiple(P, M, plist, operation='+') 3227 - sage: Q = E(0,2) # optional - sage.rings.finite_rings - sage: order_from_multiple(Q, M, plist, operation='+') # optional - sage.rings.finite_rings + sage: Q = E(0,2) + sage: order_from_multiple(Q, M, plist, operation='+') 7 - sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') # optional - sage.rings.finite_rings + sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') 7 """ @@ -136,7 +142,7 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): sage: multiple(2, 5) 32 - sage: multiple(RealField()('2.5'), 4) # optional - sage.libs.mpfr + sage: multiple(RealField()('2.5'), 4) # needs sage.libs.mpfr 39.0625000000000 sage: multiple(2, -3) 1/8 @@ -159,11 +165,12 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): sage: multiple(1,10^1000) 1 - sage: E = EllipticCurve('389a1') # optional - sage.schemes - sage: P = E(-1,1) # optional - sage.schemes - sage: multiple(P, 10, '+') # optional - sage.schemes + sage: # needs sage.schemes + sage: E = EllipticCurve('389a1') + sage: P = E(-1,1) + sage: multiple(P, 10, '+') (645656132358737542773209599489/22817025904944891235367494656 : 525532176124281192881231818644174845702936831/3446581505217248068297884384990762467229696 : 1) - sage: multiple(P, -10, '+') # optional - sage.schemes + sage: multiple(P, -10, '+') (645656132358737542773209599489/22817025904944891235367494656 : -528978757629498440949529703029165608170166527/3446581505217248068297884384990762467229696 : 1) """ from operator import inv, mul, neg, add @@ -252,9 +259,9 @@ class multiples: sage: list(multiples(1, 10, 100)) [100, 101, 102, 103, 104, 105, 106, 107, 108, 109] - sage: E = EllipticCurve('389a1') # optional - sage.schemes - sage: P = E(-1,1) # optional - sage.schemes - sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) # optional - sage.schemes + sage: E = EllipticCurve('389a1') # needs sage.schemes + sage: P = E(-1,1) # needs sage.schemes + sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) # needs sage.schemes ((0 : 1 : 0), 0.000000000000000) ((-1 : 1 : 1), 1.00000000000000) ((10/9 : -35/27 : 1), 4.00000000000000) @@ -406,32 +413,33 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): sage: bsgs(b, a, (0, 36)) 20 - sage: p = next_prime(10^20) # optional - sage.libs.pari - sage: a = Mod(2,p); b = a^(10^25) # optional - sage.libs.pari - sage: bsgs(a, b, (10^25 - 10^6, 10^25 + 10^6)) == 10^25 # optional - sage.libs.pari + sage: p = next_prime(10^20) # needs sage.libs.pari + sage: a = Mod(2,p); b = a^(10^25) # needs sage.libs.pari + sage: bsgs(a, b, (10^25 - 10^6, 10^25 + 10^6)) == 10^25 # needs sage.libs.pari True - sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings - sage: a = K.gen() # optional - sage.rings.finite_rings - sage: b = a^210 # optional - sage.rings.finite_rings - sage: bsgs(a, b, (0, K.order() - 1)) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3^6,'b') + sage: a = K.gen() + sage: b = a^210 + sage: bsgs(a, b, (0, K.order() - 1)) 210 - sage: K. = CyclotomicField(230) # optional - sage.rings.number_field - sage: w = z^500 # optional - sage.rings.number_field - sage: bsgs(z, w, (0, 229)) # optional - sage.rings.number_field + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^500 # needs sage.rings.number_field + sage: bsgs(z, w, (0, 229)) # needs sage.rings.number_field 40 An additive example in an elliptic curve group:: - sage: F. = GF(37^5) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(a); P # optional - sage.rings.finite_rings + sage: F. = GF(37^5) # needs sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings + sage: P = E.lift_x(a); P # needs sage.rings.finite_rings (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: - sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # optional - sage.rings.finite_rings + sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # needs sage.rings.finite_rings 69327408 AUTHOR: @@ -527,29 +535,30 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No EXAMPLES:: - sage: F. = GF(2^13) # optional - sage.rings.finite_rings - sage: g = F.gen() # optional - sage.rings.finite_rings - sage: discrete_log_rho(g^1234, g) # optional - sage.rings.finite_rings + sage: F. = GF(2^13) # needs sage.rings.finite_rings + sage: g = F.gen() # needs sage.rings.finite_rings + sage: discrete_log_rho(g^1234, g) # needs sage.rings.finite_rings 1234 - sage: F. = GF(37^5) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: G = (3*31*2^4)*E.lift_x(a) # optional - sage.rings.finite_rings - sage: discrete_log_rho(12345*G, G, ord=46591, operation='+') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(37^5) + sage: E = EllipticCurve(F, [1,1]) + sage: G = (3*31*2^4)*E.lift_x(a) + sage: discrete_log_rho(12345*G, G, ord=46591, operation='+') 12345 It also works with matrices:: - sage: A = matrix(GF(50021), [[10577, 23999, 28893], # optional - sage.rings.finite_rings + sage: A = matrix(GF(50021), [[10577, 23999, 28893], # needs sage.rings.finite_rings ....: [14601, 41019, 30188], ....: [3081, 736, 27092]]) - sage: discrete_log_rho(A^1234567, A) # optional - sage.rings.finite_rings + sage: discrete_log_rho(A^1234567, A) # needs sage.rings.finite_rings 1234567 Beware, the order must be prime:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(2), I(3)) # optional - sage.libs.pari + sage: discrete_log_rho(I(2), I(3)) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: for Pollard rho algorithm the order of the group must be prime @@ -557,7 +566,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No If it fails to find a suitable logarithm, it raises a :class:`ValueError`:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(31002), I(15501)) # optional - sage.libs.pari + sage: discrete_log_rho(I(31002), I(15501)) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: Pollard rho algorithm failed to find a logarithm @@ -565,18 +574,18 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No The main limitation on the hash function is that we don't want to have ``hash(x*y) == hash(x) + hash(y)``:: - sage: I = IntegerModRing(next_prime(2^23)) # optional - sage.libs.pari - sage: def test(): # optional - sage.libs.pari + sage: I = IntegerModRing(next_prime(2^23)) # needs sage.libs.pari + sage: def test(): # needs sage.libs.pari ....: try: ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: ....: print("FAILURE") - sage: test() # random failure # optional - sage.libs.pari + sage: test() # random failure # needs sage.libs.pari FAILURE If this happens, we can provide a better hash function:: - sage: discrete_log_rho(I(123456), I(1), operation='+', # optional - sage.libs.pari + sage: discrete_log_rho(I(123456), I(1), operation='+', # needs sage.libs.pari ....: hash_function=lambda x: hash(x*x)) 123456 @@ -719,10 +728,11 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, bounds=(10, 100)) 20 - sage: K = GF(3^6, 'b') # optional - sage.rings.finite_rings - sage: b = K.gen() # optional - sage.rings.finite_rings - sage: a = b^210 # optional - sage.rings.finite_rings - sage: discrete_log(a, b, K.order()-1) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3^6, 'b') + sage: b = K.gen() + sage: a = b^210 + sage: discrete_log(a, b, K.order()-1) 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -738,60 +748,63 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i See :trac:`2356`:: - sage: F. = GF(121) # optional - sage.rings.finite_rings - sage: v = w^120 # optional - sage.rings.finite_rings - sage: v.log(w) # optional - sage.rings.finite_rings + sage: F. = GF(121) # needs sage.rings.finite_rings + sage: v = w^120 # needs sage.rings.finite_rings + sage: v.log(w) # needs sage.rings.finite_rings 0 - sage: K. = CyclotomicField(230) # optional - sage.rings.number_field - sage: w = z^50 # optional - sage.rings.number_field - sage: discrete_log(w, z) # optional - sage.rings.number_field + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^50 # needs sage.rings.number_field + sage: discrete_log(w, z) # needs sage.rings.number_field 50 An example where the order is infinite: note that we must give an upper bound here:: - sage: K. = QuadraticField(23) # optional - sage.rings.number_field - sage: eps = 5*a - 24 # a fundamental unit # optional - sage.rings.number_field - sage: eps.multiplicative_order() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(23) + sage: eps = 5*a - 24 # a fundamental unit + sage: eps.multiplicative_order() +Infinity - sage: eta = eps^100 # optional - sage.rings.number_field - sage: discrete_log(eta, eps, bounds=(0,1000)) # optional - sage.rings.number_field + sage: eta = eps^100 + sage: discrete_log(eta, eps, bounds=(0,1000)) 100 In this case we cannot detect negative powers:: - sage: eta = eps^(-3) # optional - sage.rings.number_field - sage: discrete_log(eta,eps,bounds=(0,100)) # optional - sage.rings.number_field + sage: eta = eps^(-3) # needs sage.rings.number_field + sage: discrete_log(eta,eps,bounds=(0,100)) # needs sage.rings.number_field Traceback (most recent call last): ... ValueError: no discrete log of -11515*a - 55224 found to base 5*a - 24 But we can invert the base (and negate the result) instead:: - sage: -discrete_log(eta^-1, eps, bounds=(0,100)) # optional - sage.rings.number_field + sage: -discrete_log(eta^-1, eps, bounds=(0,100)) # needs sage.rings.number_field -3 An additive example: elliptic curve DLOG:: - sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: P = E(25*a + 16, 15*a + 7) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: F. = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: P = E(25*a + 16, 15*a + 7) + sage: P.order() 672 - sage: Q = 39*P; Q # optional - sage.rings.finite_rings + sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q, P, P.order(), operation='+') # optional - sage.rings.finite_rings + sage: discrete_log(Q, P, P.order(), operation='+') 39 An example of big smooth group:: - sage: F. = GF(2^63) # optional - sage.rings.finite_rings - sage: g = F.gen() # optional - sage.rings.finite_rings - sage: u = g**123456789 # optional - sage.rings.finite_rings - sage: discrete_log(u,g) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(2^63) + sage: g = F.gen() + sage: u = g**123456789 + sage: discrete_log(u,g) 123456789 The above examples also work when the ``'rho'`` and ``'lambda'`` algorithms are used:: @@ -803,10 +816,11 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, algorithm='lambda', bounds=(10, 100)) 20 - sage: K = GF(3^6,'b') # optional - sage.rings.finite_rings - sage: b = K.gen() # optional - sage.rings.finite_rings - sage: a = b^210 # optional - sage.rings.finite_rings - sage: discrete_log(a, b, K.order()-1, algorithm='rho') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(3^6,'b') + sage: b = K.gen() + sage: a = b^210 + sage: discrete_log(a, b, K.order()-1, algorithm='rho') 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -820,22 +834,24 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i ... ValueError: no discrete log of 2 found to base 1 - sage: F = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: F. = GF(37^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: P = E(25*a + 16, 15*a + 7) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: F. = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: P = E(25*a + 16, 15*a + 7) + sage: P.order() 672 - sage: Q = 39*P; Q # optional - sage.rings.finite_rings + sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q, P, P.order(), operation='+', algorithm='lambda') # optional - sage.rings.finite_rings + sage: discrete_log(Q, P, P.order(), operation='+', algorithm='lambda') 39 - sage: F. = GF(2^63) # optional - sage.rings.finite_rings - sage: g = F.gen() # optional - sage.rings.finite_rings - sage: u = g**123456789 # optional - sage.rings.finite_rings - sage: discrete_log(u, g, algorithm='rho') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(2^63) + sage: g = F.gen() + sage: u = g**123456789 + sage: discrete_log(u, g, algorithm='rho') 123456789 TESTS: @@ -976,24 +992,24 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N EXAMPLES:: - sage: F. = GF(2^63) # optional - sage.rings.finite_rings - sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) # optional - sage.rings.finite_rings + sage: F. = GF(2^63) # needs sage.rings.finite_rings + sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) # needs sage.rings.finite_rings 1234567 - sage: F. = GF(37^5) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(a); P # optional - sage.rings.finite_rings + sage: F. = GF(37^5) # needs sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings + sage: P = E.lift_x(a); P # needs sage.rings.finite_rings (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: - sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # optional - sage.rings.finite_rings + sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # needs sage.rings.finite_rings ....: operation='+') 69327408 - sage: K. = GF(89**5) # optional - sage.rings.finite_rings - sage: hs = lambda x: hash(x) + 15 # optional - sage.rings.finite_rings - sage: discrete_log_lambda(a**(89**3 - 3), # long time (10s on sage.math, 2011) # optional - sage.rings.finite_rings + sage: K. = GF(89**5) # needs sage.rings.finite_rings + sage: hs = lambda x: hash(x) + 15 # needs sage.rings.finite_rings + sage: discrete_log_lambda(a**(89**3 - 3), # long time (10s on sage.math, 2011), needs sage.rings.finite_rings ....: a, (89**2, 89**4), operation='*', hash_function=hs) 704966 @@ -1087,25 +1103,27 @@ def linear_relation(P, Q, operation='+', identity=None, inverse=None, op=None): An additive example (in an elliptic curve group):: - sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings - sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2, 0) # optional - sage.rings.finite_rings - sage: Q = E(2*a^3 + 2*a^2 + 2*a, a^3 + 2*a^2 + 1) # optional - sage.rings.finite_rings - sage: linear_relation(P, Q, '+') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(3^6,'a') + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2, 0) + sage: Q = E(2*a^3 + 2*a^2 + 2*a, a^3 + 2*a^2 + 1) + sage: linear_relation(P, Q, '+') (1, 2) - sage: P == 2*Q # optional - sage.rings.finite_rings + sage: P == 2*Q True A multiplicative example (in a finite field's multiplicative group):: - sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings - sage: a.multiplicative_order().factor() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(3^6,'a') + sage: a.multiplicative_order().factor() 2^3 * 7 * 13 - sage: b = a^7 # optional - sage.rings.finite_rings - sage: c = a^13 # optional - sage.rings.finite_rings - sage: linear_relation(b, c, '*') # optional - sage.rings.finite_rings + sage: b = a^7 + sage: c = a^13 + sage: linear_relation(b, c, '*') (13, 7) - sage: b^13 == c^7 # optional - sage.rings.finite_rings + sage: b^13 == c^7 True """ Z = integer_ring.ZZ @@ -1187,35 +1205,36 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_multiple - sage: k. = GF(5^5) # optional - sage.rings.finite_rings - sage: b = a^4 # optional - sage.rings.finite_rings - sage: order_from_multiple(b, 5^5 - 1, operation='*') # optional - sage.rings.finite_rings + sage: k. = GF(5^5) + sage: b = a^4 + sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: E = EllipticCurve(k, [2,4]) # optional - sage.rings.finite_rings - sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings - sage: M = E.cardinality(); M # optional - sage.rings.finite_rings + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: M = E.cardinality(); M 3227 - sage: F = M.factor() # optional - sage.rings.finite_rings - sage: order_from_multiple(P, M, factorization=F, operation='+') # optional - sage.rings.finite_rings + sage: F = M.factor() + sage: order_from_multiple(P, M, factorization=F, operation='+') 3227 - sage: Q = E(0,2) # optional - sage.rings.finite_rings - sage: order_from_multiple(Q, M, factorization=F, operation='+') # optional - sage.rings.finite_rings + sage: Q = E(0,2) + sage: order_from_multiple(Q, M, factorization=F, operation='+') 7 - sage: K. = CyclotomicField(230) # optional - sage.rings.number_field - sage: w = z^50 # optional - sage.rings.number_field - sage: order_from_multiple(w, 230, operation='*') # optional - sage.rings.number_field + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^50 # needs sage.rings.number_field + sage: order_from_multiple(w, 230, operation='*') # needs sage.rings.finite_rings sage.rings.number_field 23 - sage: F = GF(2^1279,'a') # optional - sage.rings.finite_rings - sage: n = F.cardinality() - 1 # Mersenne prime # optional - sage.rings.finite_rings - sage: order_from_multiple(F.random_element(), n, # optional - sage.rings.finite_rings + sage: F = GF(2^1279,'a') # needs sage.rings.finite_rings + sage: n = F.cardinality() - 1 # Mersenne prime # needs sage.rings.finite_rings + sage: order_from_multiple(F.random_element(), n, # needs sage.rings.finite_rings ....: factorization=[(n,1)], operation='*') == n True - sage: K. = GF(3^60) # optional - sage.rings.finite_rings - sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) # optional - sage.rings.finite_rings + sage: K. = GF(3^60) # needs sage.rings.finite_rings + sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) # needs sage.rings.finite_rings 42391158275216203514294433200 """ Z = integer_ring.ZZ @@ -1326,23 +1345,24 @@ def order_from_bounds(P, bounds, d=None, operation='+', EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_bounds - sage: k. = GF(5^5) # optional - sage.rings.finite_rings - sage: b = a^4 # optional - sage.rings.finite_rings - sage: order_from_bounds(b, (5^4, 5^5), operation='*') # optional - sage.rings.finite_rings + sage: k. = GF(5^5) + sage: b = a^4 + sage: order_from_bounds(b, (5^4, 5^5), operation='*') 781 - sage: E = EllipticCurve(k, [2,4]) # optional - sage.rings.finite_rings - sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings - sage: bounds = Hasse_bounds(5^5) # optional - sage.rings.finite_rings - sage: Q = E(0,2) # optional - sage.rings.finite_rings - sage: order_from_bounds(Q, bounds, operation='+') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: bounds = Hasse_bounds(5^5) + sage: Q = E(0,2) + sage: order_from_bounds(Q, bounds, operation='+') 7 - sage: order_from_bounds(P, bounds, 7, operation='+') # optional - sage.rings.finite_rings + sage: order_from_bounds(P, bounds, 7, operation='+') 3227 - sage: K. = CyclotomicField(230) # optional - sage.rings.number_field - sage: w = z^50 # optional - sage.rings.number_field - sage: order_from_bounds(w, (200, 250), operation='*') # optional - sage.rings.number_field + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^50 # needs sage.rings.number_field + sage: order_from_bounds(w, (200, 250), operation='*') # needs sage.rings.finite_rings sage.rings.number_field 23 """ from operator import mul, add @@ -1399,31 +1419,33 @@ def merge_points(P1, P2, operation='+', EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import merge_points - sage: F. = GF(3^6,'a') # optional - sage.rings.finite_rings - sage: b = a^7 # optional - sage.rings.finite_rings - sage: c = a^13 # optional - sage.rings.finite_rings - sage: ob = (3^6-1)//7 # optional - sage.rings.finite_rings - sage: oc = (3^6-1)//13 # optional - sage.rings.finite_rings - sage: merge_points((b,ob), (c,oc), operation='*') # optional - sage.rings.finite_rings + sage: F. = GF(3^6,'a') + sage: b = a^7 + sage: c = a^13 + sage: ob = (3^6-1)//7 + sage: oc = (3^6-1)//13 + sage: merge_points((b,ob), (c,oc), operation='*') (a^4 + 2*a^3 + 2*a^2, 728) - sage: d, od = merge_points((b,ob), (c,oc), operation='*') # optional - sage.rings.finite_rings - sage: od == d.multiplicative_order() # optional - sage.rings.finite_rings + sage: d, od = merge_points((b,ob), (c,oc), operation='*') + sage: od == d.multiplicative_order() True - sage: od == lcm(ob, oc) # optional - sage.rings.finite_rings + sage: od == lcm(ob, oc) True - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) # optional - sage.rings.finite_rings - sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) + sage: P.order() 7 - sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) # optional - sage.rings.finite_rings - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) + sage: Q.order() 4 - sage: R, m = merge_points((P,7), (Q,4), operation='+') # optional - sage.rings.finite_rings - sage: R.order() == m # optional - sage.rings.finite_rings + sage: R, m = merge_points((P,7), (Q,4), operation='+') + sage: R.order() == m True - sage: m == lcm(7,4) # optional - sage.rings.finite_rings + sage: m == lcm(7,4) True """ from operator import mul, add @@ -1488,38 +1510,39 @@ def structure_description(G, latex=False): EXAMPLES:: - sage: G = CyclicPermutationGroup(6) # optional - sage.groups - sage: G.structure_description() # optional - sage.groups + sage: # needs sage.groups + sage: G = CyclicPermutationGroup(6) + sage: G.structure_description() 'C6' - sage: G.structure_description(latex=True) # optional - sage.groups + sage: G.structure_description(latex=True) 'C_{6}' - sage: G2 = G.direct_product(G, maps=False) # optional - sage.groups - sage: LatexExpr(G2.structure_description(latex=True)) # optional - sage.groups + sage: G2 = G.direct_product(G, maps=False) + sage: LatexExpr(G2.structure_description(latex=True)) C_{6} \times C_{6} This method is mainly intended for small groups or groups with few normal subgroups. Even then there are some surprises:: - sage: D3 = DihedralGroup(3) # optional - sage.groups - sage: D3.structure_description() # optional - sage.groups + sage: D3 = DihedralGroup(3) # needs sage.groups + sage: D3.structure_description() # needs sage.groups 'S3' We use the Sage notation for the degree of dihedral groups:: - sage: D4 = DihedralGroup(4) # optional - sage.groups - sage: D4.structure_description() # optional - sage.groups + sage: D4 = DihedralGroup(4) # needs sage.groups + sage: D4.structure_description() # needs sage.groups 'D4' Works for finitely presented groups (:trac:`17573`):: - sage: F. = FreeGroup() # optional - sage.groups - sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] # optional - sage.groups - sage: G.structure_description() # optional - sage.groups + sage: F. = FreeGroup() # needs sage.groups + sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] # needs sage.groups + sage: G.structure_description() # needs sage.groups 'C7' And matrix groups (:trac:`17573`):: - sage: groups.matrix.GL(4,2).structure_description() # optional - sage.libs.gap sage.modules + sage: groups.matrix.GL(4,2).structure_description() # needs sage.libs.gap sage.modules 'A8' """ import re diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index b1c97ce6409..eed158d8628 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -35,11 +35,11 @@ def is_Group(x): EXAMPLES:: - sage: F. = FreeGroup() # optional - sage.groups + sage: F. = FreeGroup() # needs sage.groups sage: from sage.groups.group import is_Group - sage: is_Group(F) # optional - sage.groups + sage: is_Group(F) # needs sage.groups True - sage: is_Group("a string") # optional - sage.groups + sage: is_Group("a string") # needs sage.groups False """ from sage.groups.old import Group as OldGroup @@ -96,10 +96,11 @@ cdef class Group(Parent): Check for :trac:`8119`:: - sage: G = SymmetricGroup(2) # optional - sage.groups - sage: h = hash(G) # optional - sage.groups - sage: G.rename('S2') # optional - sage.groups - sage: h == hash(G) # optional - sage.groups + sage: # needs sage.groups + sage: G = SymmetricGroup(2) + sage: h = hash(G) + sage: G.rename('S2') + sage: h == hash(G) True """ from sage.categories.groups import Groups @@ -139,7 +140,7 @@ cdef class Group(Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # optional - sage.modules sage.rings.finite_rings + sage: SL(2, 7).is_commutative() # needs sage.modules sage.rings.finite_rings False """ return self.is_abelian() @@ -161,8 +162,8 @@ cdef class Group(Parent): TESTS:: - sage: H = SL(2, QQ) # optional - sage.modules - sage: H.order() # optional - sage.modules + sage: H = SL(2, QQ) # needs sage.modules + sage: H.order() # needs sage.modules +Infinity """ try: @@ -211,8 +212,8 @@ cdef class Group(Parent): EXAMPLES:: - sage: G = AbelianGroup([2,3,4,5]) # optional - sage.groups - sage: G.an_element() # optional - sage.groups + sage: G = AbelianGroup([2,3,4,5]) # needs sage.groups + sage: G.an_element() # needs sage.groups f0*f1*f2*f3 """ return self.prod(self.gens()) diff --git a/src/sage/groups/libgap_morphism.py b/src/sage/groups/libgap_morphism.py index cadd25961d6..68af4bf5ae2 100644 --- a/src/sage/groups/libgap_morphism.py +++ b/src/sage/groups/libgap_morphism.py @@ -212,9 +212,9 @@ class GroupMorphism_libgap(Morphism): sage: phi(G.one()).parent() General Linear Group of degree 3 over Finite Field of size 3 - sage: MS = MatrixSpace(SR, 2, 2) # optional - sage.symbolic - sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # optional - sage.symbolic - sage: G.Hom(G) # optional - sage.symbolic + sage: MS = MatrixSpace(SR, 2, 2) # needs sage.symbolic + sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # needs sage.symbolic + sage: G.Hom(G) # needs sage.symbolic Set of Morphisms from Matrix group over Symbolic Ring with 2 generators ( [1 0] [1 2] [0 1], [3 4] diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index 3b79f5ebef1..1fcdccdd2bb 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -319,15 +319,16 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): """ TESTS:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic - sage: MatrixGroup(m1) == MatrixGroup(m1) # needs sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: MatrixGroup(m1) == MatrixGroup(m1) True - sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) # needs sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) False - sage: MatrixGroup(m1) == MatrixGroup(m2) # needs sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m2) False - sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) # needs sage.symbolic + sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) False sage: m1 = matrix(QQ, [[1,2], [3,4]]) @@ -351,11 +352,12 @@ def __init__(self, degree, base_ring, generator_matrices, category=None): EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic - sage: G = MatrixGroup(m1, m2) # needs sage.symbolic - sage: TestSuite(G).run() # needs sage.symbolic - sage: type(G) # needs sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: TestSuite(G).run() + sage: type(G) sage: from sage.groups.matrix_gps.finitely_generated import \ @@ -455,10 +457,11 @@ def __reduce__(self): Check that :trac:`22128` is fixed:: - sage: R = MatrixSpace(SR, 2) # needs sage.symbolic - sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) # needs sage.symbolic - sage: G.register_embedding(R) # needs sage.symbolic - sage: loads(dumps(G)) # needs sage.symbolic + sage: # needs sage.symbolic + sage: R = MatrixSpace(SR, 2) + sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) + sage: G.register_embedding(R) + sage: loads(dumps(G)) Matrix group over Symbolic Ring with 1 generators ( [1 1] [0 1] @@ -470,10 +473,11 @@ def _test_matrix_generators(self, **options): """ EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # needs sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # needs sage.symbolic - sage: G = MatrixGroup(m1, m2) # needs sage.symbolic - sage: G._test_matrix_generators() # needs sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: G._test_matrix_generators() """ tester = self._tester(**options) for g,h in zip(self.gens(), MatrixGroup(self.gens()).gens()): diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 44e460a4965..f19514515e7 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -3,15 +3,16 @@ Matrix Group Elements EXAMPLES:: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 3 with 2 generators ( [1 0] [1 1] [0 1], [0 1] ) - sage: g = G([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: h = G([[1,2], [0,1]]) # optional - sage.rings.finite_rings - sage: g*h # optional - sage.rings.finite_rings + sage: g = G([[1,1], [0,1]]) + sage: h = G([[1,2], [0,1]]) + sage: g*h [1 0] [0 1] @@ -19,7 +20,7 @@ You cannot add two matrices, since this is not a group operation. You can coerce matrices back to the matrix space and add them there:: - sage: g + h # optional - sage.rings.finite_rings + sage: g + h # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: @@ -32,14 +33,14 @@ there:: [0 1], [0 1] )' - sage: g.matrix() + h.matrix() # optional - sage.rings.finite_rings + sage: g.matrix() + h.matrix() # needs sage.rings.finite_rings [2 0] [0 2] Similarly, you cannot multiply group elements by scalars but you can do it with the underlying matrices:: - sage: 2*g # optional - sage.rings.finite_rings + sage: 2*g # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Integer Ring' @@ -105,8 +106,8 @@ cpdef is_MatrixGroupElement(x): sage: is_MatrixGroupElement('helloooo') False - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: is_MatrixGroupElement(G.an_element()) # optional - sage.rings.finite_rings + sage: G = GL(2,3) # needs sage.rings.finite_rings + sage: is_MatrixGroupElement(G.an_element()) # needs sage.rings.finite_rings True """ return isinstance(x, (MatrixGroupElement_generic, MatrixGroupElement_gap)) @@ -137,8 +138,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element(); g # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.an_element(); g # needs sage.combinat sage.libs.gap [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -149,9 +150,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: TestSuite(g).run() # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.an_element() # needs sage.combinat sage.libs.gap + sage: TestSuite(g).run() # needs sage.combinat sage.libs.gap """ if convert: M = parent.matrix_space()(M) @@ -172,9 +173,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: hash(g) # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.an_element() # needs sage.combinat sage.libs.gap + sage: hash(g) # needs sage.combinat sage.libs.gap 660522311176098153 # 64-bit -606138007 # 32-bit """ @@ -186,9 +187,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: loads(g.dumps()) == g # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.an_element() # needs sage.combinat sage.libs.gap + sage: loads(g.dumps()) == g # needs sage.combinat sage.libs.gap True """ return (_unpickle_generic_element, (self.parent(), self._matrix,)) @@ -199,8 +200,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: W.an_element() # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: W.an_element() # needs sage.combinat sage.libs.gap [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -211,9 +212,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: latex(g) # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.an_element() # needs sage.combinat sage.libs.gap + sage: latex(g) # needs sage.combinat sage.libs.gap \left(\begin{array}{rrr} 0 & 0 & -1 \\ 1 & 0 & -1 \\ @@ -226,13 +227,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',4], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: g * vector([1,1,1,1]) # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',4], base_ring=ZZ) + sage: g = W.gen(0) + sage: g * vector([1,1,1,1]) (0, 1, 1, 1) - sage: v = vector([3,2,1,-1]) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(1) # optional - sage.combinat sage.libs.gap - sage: v * g == v * g.matrix() # indirect doctest # optional - sage.combinat sage.libs.gap + sage: v = vector([3,2,1,-1]) + sage: g = W.gen(1) + sage: v * g == v * g.matrix() # indirect doctest True """ if not is_MatrixGroupElement(x) and x not in self.parent().base_ring(): @@ -248,16 +250,17 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: TestSuite(g).run() # optional - sage.combinat sage.libs.gap - sage: h = W.gen(0) * W.gen(1) * W.gen(2) # optional - sage.combinat sage.libs.gap - sage: g == h # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.an_element() + sage: TestSuite(g).run() + sage: h = W.gen(0) * W.gen(1) * W.gen(2) + sage: g == h True - sage: a = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: a == g # optional - sage.combinat sage.libs.gap + sage: a = W.gen(0) + sage: a == g False - sage: a != g # optional - sage.combinat sage.libs.gap + sage: a != g True """ cdef MatrixGroupElement_generic x = self @@ -270,13 +273,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: g # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: g [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: g.list() # optional - sage.combinat sage.libs.gap + sage: g.list() [[-1, 1, 0], [0, 1, 0], [0, 0, 1]] """ return [r.list() for r in self._matrix.rows()] @@ -291,19 +295,20 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: g.matrix() # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: g.matrix() [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: parent(g.matrix()) # optional - sage.combinat sage.libs.gap + sage: parent(g.matrix()) Full MatrixSpace of 3 by 3 dense matrices over Integer Ring Matrices have extra functionality that matrix group elements do not have:: - sage: g.matrix().charpoly('t') # optional - sage.combinat sage.libs.gap + sage: g.matrix().charpoly('t') # needs sage.combinat sage.libs.gap t^3 - t^2 - t + 1 """ return self._matrix @@ -314,9 +319,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: matrix(RDF, g) # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # needs sage.combinat sage.libs.gap + sage: g = W.gen(0) # needs sage.combinat sage.libs.gap + sage: matrix(RDF, g) # needs sage.combinat sage.libs.gap [-1.0 1.0 0.0] [ 0.0 1.0 0.0] [ 0.0 0.0 1.0] @@ -330,10 +335,11 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: h = W.an_element() # optional - sage.combinat sage.libs.gap - sage: g * h # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: h = W.an_element() + sage: g * h [ 1 0 0] [ 1 0 -1] [ 0 1 -1] @@ -351,14 +357,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3]) # optional - sage.combinat sage.libs.gap - sage: g = W.gen(0) # optional - sage.combinat sage.libs.gap - sage: g.is_one() # optional - sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3]) # needs sage.combinat sage.libs.gap + sage: g = W.gen(0) # needs sage.combinat sage.libs.gap + sage: g.is_one() # needs sage.combinat sage.libs.gap False - sage: W.an_element().is_one() # optional - sage.combinat sage.libs.gap + sage: W.an_element().is_one() # needs sage.combinat sage.libs.gap False - sage: W.one().is_one() # optional - sage.combinat sage.libs.gap + sage: W.one().is_one() # needs sage.combinat sage.libs.gap True """ return self._matrix.is_one() @@ -371,22 +377,24 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat sage.libs.gap - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap - sage: ~g # optional - sage.combinat sage.libs.gap + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.an_element() + sage: ~g [-1 1 0] [-1 0 1] [-1 0 0] - sage: g * ~g == W.one() # optional - sage.combinat sage.libs.gap + sage: g * ~g == W.one() True - sage: ~g * g == W.one() # optional - sage.combinat sage.libs.gap + sage: ~g * g == W.one() True - sage: W = CoxeterGroup(['B',3]) # optional - sage.combinat sage.libs.gap sage.rings.number_field - sage: W.base_ring() # optional - sage.combinat sage.libs.gap sage.rings.number_field + sage: # needs sage.combinat sage.libs.gap sage.rings.number_field + sage: W = CoxeterGroup(['B',3]) + sage: W.base_ring() Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? - sage: g = W.an_element() # optional - sage.combinat sage.libs.gap sage.rings.number_field - sage: ~g # optional - sage.combinat sage.libs.gap sage.rings.number_field + sage: g = W.an_element() + sage: ~g [-1 1 0] [-1 0 a] [-a 0 1] @@ -413,12 +421,13 @@ def _unpickle_generic_element(G, mat): EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: m = G.an_element() # optional - sage.symbolic - sage: from sage.groups.matrix_gps.group_element import _unpickle_generic_element # optional - sage.symbolic - sage: _unpickle_generic_element(G, m.matrix()) == m # optional - sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: m = G.an_element() + sage: from sage.groups.matrix_gps.group_element import _unpickle_generic_element + sage: _unpickle_generic_element(G, m.matrix()) == m True """ return G.element_class(G, mat, False, False) diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index c1ff96c7c1f..4cd6f1d73b1 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -112,10 +112,10 @@ def GL(n, R, var='a'): sage: g = GL(2,3) sage: d = g.cayley_graph(); d # needs sage.graphs sage.rings.finite_rings Digraph on 48 vertices - sage: d.plot(color_by_label=True, vertex_size=0.03, # long time, needs sage.graphs sage.plot sage.rings.finite_rings + sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # needs sage.graphs sage.plot sage.rings.finite_rings ....: vertex_labels=False) Graphics object consisting of 144 graphics primitives - sage: d.plot3d(color_by_label=True) # long time, needs sage.graphs sage.plot sage.rings.finite_rings + sage: d.plot3d(color_by_label=True) # long time # needs sage.graphs sage.plot sage.rings.finite_rings Graphics3d Object :: diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 501237c9843..f94c859f315 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -191,22 +191,24 @@ def subgroup(self, generators, check=True): EXAMPLES:: - sage: UCF = UniversalCyclotomicField() # needs sage.rings.number_field - sage: G = GL(3, UCF) # needs sage.rings.number_field - sage: e3 = UCF.gen(3); e5 = UCF.gen(5) # needs sage.rings.number_field - sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) # needs sage.rings.number_field - sage: S = G.subgroup([m]); S # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: UCF = UniversalCyclotomicField() + sage: G = GL(3, UCF) + sage: e3 = UCF.gen(3); e5 = UCF.gen(5) + sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [E(3) 1 0] [ 0 E(5) 7] [ 4 3 2] ) of General Linear Group of degree 3 over Universal Cyclotomic Field - sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field - sage: G = GL(3, CF3) # needs sage.rings.number_field - sage: e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) # needs sage.rings.number_field - sage: S = G.subgroup([m]); S # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3) + sage: G = GL(3, CF3) + sage: e3 = CF3.gen() + sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [ zeta3 1 0] [ 0 -zeta3 - 1 7] @@ -276,11 +278,12 @@ def _repr_(self): case of being a subgroup:: - sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field - sage: G = GL(2, CF3) # needs sage.rings.number_field - sage: e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) # needs sage.rings.number_field - sage: S = G.subgroup([m]); S # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3) + sage: G = GL(2, CF3) + sage: e3 = CF3.gen() + sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [ zeta3 1] [ 0 -zeta3 - 1] @@ -492,11 +495,12 @@ def __richcmp__(self, other, op): TESTS:: - sage: G = groups.matrix.GL(4,2) # needs sage.groups sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # needs sage.groups sage.rings.finite_rings - sage: G == H # needs sage.groups sage.rings.finite_rings + sage: # needs sage.groups sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) + sage: H = MatrixGroup(G.gens()) + sage: G == H True - sage: G != H # needs sage.groups sage.rings.finite_rings + sage: G != H False """ if not is_MatrixGroup(other): diff --git a/src/sage/groups/matrix_gps/named_group.py b/src/sage/groups/matrix_gps/named_group.py index c98cdb55f40..55c64763b03 100644 --- a/src/sage/groups/matrix_gps/named_group.py +++ b/src/sage/groups/matrix_gps/named_group.py @@ -292,11 +292,12 @@ def __richcmp__(self, other, op): sage: G == MatrixGroup(G.gens()) # needs sage.rings.finite_rings True - sage: G = groups.matrix.GL(4,2) # needs sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # needs sage.rings.finite_rings - sage: G == H # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) + sage: H = MatrixGroup(G.gens()) + sage: G == H True - sage: G != H # needs sage.rings.finite_rings + sage: G != H False """ return MatrixGroup_generic.__richcmp__(self, other, op) diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index dfeefbe5566..424518f341a 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -460,10 +460,11 @@ class OrthogonalMatrixGroup_generic(NamedMatrixGroup_generic): sage: latex(G) \text{SO}_{3}(\Bold{F}_{5}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) # needs sage.rings.number_field - sage: G = SO(3, CF3, invariant_form=m) # needs sage.rings.number_field - sage: latex(G) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) + sage: G = SO(3, CF3, invariant_form=m) + sage: latex(G) \text{SO}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to non positive definite symmetric form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ \zeta_{3} & 2 & 0 \\ diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 6a32437003a..49e71eb45c2 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -6,18 +6,19 @@ EXAMPLES:: - sage: G = SU(3,5) # needs sage.rings.finite_rings - sage: G.order() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = SU(3,5) + sage: G.order() 378000 - sage: G # needs sage.rings.finite_rings + sage: G Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: G.gens() # needs sage.rings.finite_rings + sage: G.gens() ( [ a 0 0] [4*a 4 1] [ 0 2*a + 2 0] [ 4 4 0] [ 0 0 3*a], [ 1 0 0] ) - sage: G.base_ring() # needs sage.rings.finite_rings + sage: G.base_ring() Finite Field in a of size 5^2 AUTHORS: @@ -215,27 +216,28 @@ def GU(n, R, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) # needs sage.rings.number_field - sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field - sage: G = GU(3, UCF) # needs sage.rings.number_field - sage: Gm = GU(3, UCF, invariant_form=m) # needs sage.rings.number_field - sage: G == Gm # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) + sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) + sage: G = GU(3, UCF) + sage: Gm = GU(3, UCF, invariant_form=m) + sage: G == Gm False - sage: G.invariant_form() # needs sage.rings.number_field + sage: G.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # needs sage.rings.number_field + sage: Gm.invariant_form() [ 1 E(5) 0] [E(5)^4 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat sage.rings.number_field - sage: g = G(pm); g in G; g # needs sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat + sage: g = G(pm); g in G; g # needs sage.combinat True [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # needs sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -314,26 +316,27 @@ def SU(n, R, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field - sage: G = SU(3, CF3) # needs sage.rings.number_field - sage: Gm = SU(3, CF3, invariant_form=m) # needs sage.rings.number_field - sage: G == Gm # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) + sage: G = SU(3, CF3) + sage: Gm = SU(3, CF3, invariant_form=m) + sage: G == Gm False - sage: G.invariant_form() # needs sage.rings.number_field + sage: G.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # needs sage.rings.number_field + sage: Gm.invariant_form() [ 1 zeta3 0] [-zeta3 - 1 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat sage.rings.number_field - sage: G(pm) # needs sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat + sage: G(pm) # needs sage.combinat [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # needs sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -375,10 +378,11 @@ class UnitaryMatrixGroup_generic(NamedMatrixGroup_generic): sage: latex(G) # needs sage.rings.finite_rings \text{SU}_{3}(\Bold{F}_{5^{2}}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # needs sage.rings.number_field - sage: G = SU(3, CF3, invariant_form=m) # needs sage.rings.number_field - sage: latex(G) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) + sage: G = SU(3, CF3, invariant_form=m) + sage: latex(G) \text{SU}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to positive definite hermitian form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ -\zeta_{3} - 1 & 2 & 0 \\ @@ -420,10 +424,11 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = GU(2, GF(5)) # needs sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # needs sage.rings.finite_rings - sage: G = SU(2, GF(5)) # needs sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = GU(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) + sage: G = SU(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special and x.determinant() != 1: raise TypeError('matrix must have determinant one') diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 8c9127b957f..2b59e483bd2 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -47,10 +47,11 @@ cdef class Group(sage.structure.parent.Parent): Check for :trac:`8119`:: - sage: G = SymmetricGroup(2) # optional - sage.groups - sage: h = hash(G) # optional - sage.groups - sage: G.rename('S2') # optional - sage.groups - sage: h == hash(G) # optional - sage.groups + sage: # needs sage.groups + sage: G = SymmetricGroup(2) + sage: h = hash(G) + sage: G.rename('S2') + sage: h == hash(G) True """ from sage.categories.basic import Groups @@ -120,7 +121,7 @@ cdef class Group(sage.structure.parent.Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # optional - sage.modules sage.rings.finite_rings + sage: SL(2, 7).is_commutative() # needs sage.modules sage.rings.finite_rings False """ return self.is_abelian() diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index 7ccce2e5f36..c2900907919 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -191,7 +191,7 @@ def polygon_plot3d(points, tilt=30, turn=30, **kwargs): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import polygon_plot3d,green - sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]], # optional - sage.plot + sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]], # needs sage.plot ....: rgbcolor=green) """ rot = rotation_list(tilt, turn) @@ -289,7 +289,7 @@ def create_poly(face, color): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import create_poly, red - sage: create_poly('ur', red) # optional - sage.plot + sage: create_poly('ur', red) # needs sage.plot Graphics object consisting of 1 graphics primitive """ return polygon(face_polys[face], rgbcolor=color) @@ -492,7 +492,7 @@ def plot3d_cubie(cnt, clrs): sage: from sage.groups.perm_gps.cubegroup import plot3d_cubie, blue, red, green sage: clrF = blue; clrU = red; clrR = green - sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) # optional - sage.plot + sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) # needs sage.plot """ half = QQ((1, 2)) x = cnt[0] - half @@ -955,11 +955,11 @@ def plot_cube(self, mv, title=True, colors=[lpurple, yellow, red, green, orange, EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title=False) # optional - sage.plot + sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title=False) # needs sage.plot sage: # (R^2U^2)^3 permutes 2 pairs of edges (uf,ub)(fr,br) - sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # optional - sage.plot + sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # needs sage.plot sage: # the superflip (in 20f* moves) - sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # optional - sage.plot + sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # needs sage.plot sage: # "superflip+4 spot" (in 26q* moves) """ g = self.parse(mv) @@ -992,8 +992,8 @@ def plot3d_cube(self, mv, title=True): EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # optional - sage.plot - sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # optional - sage.plot + sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # needs sage.plot + sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # needs sage.plot """ g = self.parse(mv) state = self.facets(g) @@ -1195,7 +1195,7 @@ class RubiksCube(SageObject): EXAMPLES:: sage: C = RubiksCube().move("R U R'") - sage: C.show3d() # optional - sage.plot + sage: C.show3d() # needs sage.plot :: @@ -1213,7 +1213,7 @@ class RubiksCube(SageObject): | 37 bottom 21 | | 35 47 24 | +--------------+ - sage: C.show() # optional - sage.plot + sage: C.show() # needs sage.plot sage: C.solve(algorithm='gap') # long time 'L*R' sage: C == RubiksCube("L*R") @@ -1316,7 +1316,7 @@ def plot(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot() # optional - sage.plot + sage: C.plot() # needs sage.plot Graphics object consisting of 55 graphics primitives """ return self._group.plot_cube(self._state) @@ -1328,7 +1328,7 @@ def show(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show() # optional - sage.plot + sage: C.show() # needs sage.plot """ self.plot().show() @@ -1347,7 +1347,7 @@ def cubie(self, size, gap, x, y, z, colors, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) # optional - sage.plot + sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) # needs sage.plot Graphics3d Object """ sides = cubie_face_list[x,y,z] @@ -1367,7 +1367,7 @@ def plot3d(self, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot3d() # optional - sage.plot + sage: C.plot3d() # needs sage.plot Graphics3d Object """ while len(self.colors) < 7: @@ -1390,7 +1390,7 @@ def show3d(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show3d() # optional - sage.plot + sage: C.show3d() # needs sage.plot """ return self.plot3d().show() diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 590d25e321a..4c10f364a07 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -236,30 +236,30 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]): [5, 0, 1, 2, 3, 4] sage: gens = [[1,2,3,0]] sage: reps = [] - sage: for p in SymmetricGroup(4): # optional - sage.groups + sage: for p in SymmetricGroup(4): # needs sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # optional - sage.groups + sage: len(reps) # needs sage.groups 6 sage: gens = [[1,0,2,3],[0,1,3,2]] sage: reps = [] - sage: for p in SymmetricGroup(4): # optional - sage.groups + sage: for p in SymmetricGroup(4): # needs sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # optional - sage.groups + sage: len(reps) # needs sage.groups 6 sage: gens = [[1,2,0,3]] sage: reps = [] - sage: for p in SymmetricGroup(4): # optional - sage.groups + sage: for p in SymmetricGroup(4): # needs sage.groups ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # optional - sage.groups + sage: len(reps) # needs sage.groups 8 """ diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index c947d2ebdb0..3a0ba1489c3 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -1235,48 +1235,48 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm1 = [1,0] + list(range(2, m)) ....: perm2 = [(i+1)%n for i in range( n )] + list(range(n,m)) ....: SC_test_list_perms([perm1, perm2], m, limit, gap, 0, contains) - sage: for i in range(2,9): # optional - sage.groups + sage: for i in range(2,9): # needs sage.groups ....: test_Sn_on_m_points(i,i,1,0) - sage: for i in range(2,9): # optional - sage.groups + sage: for i in range(2,9): # needs sage.groups ....: test_Sn_on_m_points(i,i,0,1) - sage: for i in range(2,9): # long time # optional - sage.groups + sage: for i in range(2,9): # long time # needs sage.groups ....: test_Sn_on_m_points(i,i,1,1) - sage: test_Sn_on_m_points(8,8,1,1) # optional - sage.groups + sage: test_Sn_on_m_points(8,8,1,1) # needs sage.groups sage: def test_stab_chain_fns_1(n, gap, contains): ....: perm1 = sum([[2*i+1,2*i] for i in range(n)], []) ....: perm2 = [(i+1)%(2*n) for i in range( 2*n)] ....: SC_test_list_perms([perm1, perm2], 2*n, limit, gap, 0, contains) - sage: for n in range(1,11): # optional - sage.groups + sage: for n in range(1,11): # needs sage.groups ....: test_stab_chain_fns_1(n, 1, 0) - sage: for n in range(1,11): # optional - sage.groups + sage: for n in range(1,11): # needs sage.groups ....: test_stab_chain_fns_1(n, 0, 1) - sage: for n in range(1,9): # long time # optional - sage.groups + sage: for n in range(1,9): # long time # needs sage.groups ....: test_stab_chain_fns_1(n, 1, 1) - sage: test_stab_chain_fns_1(11, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_1(11, 1, 1) # needs sage.groups sage: def test_stab_chain_fns_2(n, gap, contains): ....: perms = [] ....: for p,e in factor(n): ....: perm1 = [(p*(i//p)) + ((i+1)%p) for i in range(n)] ....: perms.append(perm1) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(2,11): # optional - sage.groups + sage: for n in range(2,11): # needs sage.groups ....: test_stab_chain_fns_2(n, 1, 0) - sage: for n in range(2,11): # optional - sage.groups + sage: for n in range(2,11): # needs sage.groups ....: test_stab_chain_fns_2(n, 0, 1) - sage: for n in range(2,11): # long time # optional - sage.groups + sage: for n in range(2,11): # long time # needs sage.groups ....: test_stab_chain_fns_2(n, 1, 1) - sage: test_stab_chain_fns_2(11, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_2(11, 1, 1) # needs sage.groups sage: def test_stab_chain_fns_3(n, gap, contains): ....: perm1 = [(-i)%n for i in range( n )] ....: perm2 = [(i+1)%n for i in range( n )] ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in range(2,20): # optional - sage.groups + sage: for n in range(2,20): # needs sage.groups ....: test_stab_chain_fns_3(n, 1, 0) - sage: for n in range(2,20): # optional - sage.groups + sage: for n in range(2,20): # needs sage.groups ....: test_stab_chain_fns_3(n, 0, 1) - sage: for n in range(2,14): # long time # optional - sage.groups + sage: for n in range(2,14): # long time # needs sage.groups ....: test_stab_chain_fns_3(n, 1, 1) - sage: test_stab_chain_fns_3(20, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_3(20, 1, 1) # needs sage.groups sage: def test_stab_chain_fns_4(n, g, gap, contains): ....: perms = [] ....: for _ in range(g): @@ -1284,24 +1284,24 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm) ....: perms.append(perm) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(4,9): # long time # optional - sage.groups + sage: for n in range(4,9): # long time # needs sage.groups ....: test_stab_chain_fns_4(n, 1, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 3, 1, 0) - sage: for n in range(4,9): # not tested, known bug (see :trac:`32187`) # optional - sage.groups + sage: for n in range(4,9): # known bug, not tested # needs sage.groups ....: test_stab_chain_fns_4(n, 1, 0, 1) ....: for j in range(6): ....: test_stab_chain_fns_4(n, 2, 0, 1) ....: test_stab_chain_fns_4(n, 3, 0, 1) - sage: for n in range(4,8): # long time # optional - sage.groups + sage: for n in range(4,8): # long time # needs sage.groups ....: test_stab_chain_fns_4(n, 1, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 3, 1, 1) - sage: test_stab_chain_fns_4(8, 2, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_4(8, 2, 1, 1) # needs sage.groups sage: def test_stab_chain_fns_5(n, gap, contains): ....: perms = [] ....: m = n//3 @@ -1312,12 +1312,12 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm2) ....: perm2 = list(range(m)) + perm2 ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in [4..9]: # long time # optional - sage.groups + sage: for n in [4..9]: # long time # needs sage.groups ....: for _ in range(2): ....: test_stab_chain_fns_5(n, 1, 0) - sage: for n in [4..8]: # long time # optional - sage.groups + sage: for n in [4..8]: # long time # needs sage.groups ....: test_stab_chain_fns_5(n, 0, 1) - sage: for n in [4..9]: # long time # optional - sage.groups + sage: for n in [4..9]: # long time # needs sage.groups ....: test_stab_chain_fns_5(n, 1, 1) sage: def random_perm(x): ....: shuffle(x) @@ -1328,19 +1328,19 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm = sum([random_perm(list(range(i*(n//m),min(n,(i+1)*(n//m))))) for i in range(m)], []) ....: perms.append(perm) ....: SC_test_list_perms(perms, m*(n//m), limit, gap, 0, contains) - sage: for m in range(2,9): # long time # optional - sage.groups + sage: for m in range(2,9): # long time # needs sage.groups ....: for n in range(m,3*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 1, 0) - sage: for m in range(2,10): # optional - sage.groups + sage: for m in range(2,10): # needs sage.groups ....: for n in range(m,4*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 0, 1) - sage: test_stab_chain_fns_6(10,20,2, 1, 1) # optional - sage.groups - sage: test_stab_chain_fns_6(8,16,2, 1, 1) # optional - sage.groups - sage: test_stab_chain_fns_6(6,36,2, 1, 1) # optional - sage.groups - sage: test_stab_chain_fns_6(4,40,3, 1, 1) # optional - sage.groups - sage: test_stab_chain_fns_6(4,40,2, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_6(10,20,2, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_6(8,16,2, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_6(6,36,2, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_6(4,40,3, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_6(4,40,2, 1, 1) # needs sage.groups sage: def test_stab_chain_fns_7(n, cop, gap, contains): ....: perms = [] ....: for i in range(0,n//2,2): @@ -1352,17 +1352,17 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: else: ....: perms.append(p) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in [6..14]: # optional - sage.groups + sage: for n in [6..14]: # needs sage.groups ....: test_stab_chain_fns_7(n, 1, 1, 0) ....: test_stab_chain_fns_7(n, 0, 1, 0) - sage: for n in [6..30]: # optional - sage.groups + sage: for n in [6..30]: # needs sage.groups ....: test_stab_chain_fns_7(n, 1, 0, 1) ....: test_stab_chain_fns_7(n, 0, 0, 1) - sage: for n in [6..14]: # long time # optional - sage.groups + sage: for n in [6..14]: # long time # needs sage.groups ....: test_stab_chain_fns_7(n, 1, 1, 1) ....: test_stab_chain_fns_7(n, 0, 1, 1) - sage: test_stab_chain_fns_7(20, 1, 1, 1) # optional - sage.groups - sage: test_stab_chain_fns_7(20, 0, 1, 1) # optional - sage.groups + sage: test_stab_chain_fns_7(20, 1, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_7(20, 0, 1, 1) # needs sage.groups """ if gap: diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index d4546856b68..f324530f817 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -905,12 +905,12 @@ def orbit_partition(gamma, list_perm=False): sage: from sage.groups.perm_gps.partn_ref.refinement_graphs import orbit_partition sage: G = graphs.PetersenGraph() - sage: S = SymmetricGroup(10) # optional - sage.groups - sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') # optional - sage.groups - sage: orbit_partition(gamma) # optional - sage.groups + sage: S = SymmetricGroup(10) # needs sage.groups + sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') # needs sage.groups + sage: orbit_partition(gamma) # needs sage.groups [[1, 2, 3, 4, 0], [5, 6, 7], [8, 9]] - sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') # optional - sage.groups - sage: orbit_partition(gamma) # optional - sage.groups + sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') # needs sage.groups + sage: orbit_partition(gamma) # needs sage.groups [[1, 6], [2, 7], [3, 8], [4, 9], [5, 0]] """ if list_perm: diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 5ce9d33951e..e48564e0ea1 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -286,12 +286,13 @@ def PermutationGroup(gens=None, *args, **kwds): We can also make permutation groups from PARI groups:: - sage: H = pari('x^4 - 2*x^3 - 2*x + 1').polgalois() # optional - sage.libs.pari - sage: G = PariGroup(H, 4); G # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: H = pari('x^4 - 2*x^3 - 2*x + 1').polgalois() + sage: G = PariGroup(H, 4); G PARI group [8, -1, 3, "D(4)"] of degree 4 - sage: H = PermutationGroup(G); H # optional - sage.libs.pari + sage: H = PermutationGroup(G); H Transitive group number 3 of degree 4 - sage: H.gens() # optional - sage.libs.pari + sage: H.gens() ((1,2,3,4), (1,3)) We can also create permutation groups whose generators are GAP diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index cfc956e6185..226a74f2466 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -1045,7 +1045,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): :: - sage: g(x) # optional - sage.symbolic + sage: g(x) # needs sage.symbolic Traceback (most recent call last): ... ValueError: must be in the domain or a list, tuple or string From 56cd020bffb80d195b5a1b56963beab701c2f695 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 13 Jul 2023 22:29:06 -0700 Subject: [PATCH 31/64] sage.groups: Update # needs --- src/sage/groups/generic.py | 4 +- src/sage/groups/group.pyx | 6 +- .../perm_gps/partn_ref/data_structures.pyx | 71 ++++++++++--------- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 6724567454e..f89b3fcaf3a 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -575,7 +575,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No ``hash(x*y) == hash(x) + hash(y)``:: sage: I = IntegerModRing(next_prime(2^23)) # needs sage.libs.pari - sage: def test(): # needs sage.libs.pari + sage: def test(): ....: try: ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: @@ -1008,7 +1008,7 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N 69327408 sage: K. = GF(89**5) # needs sage.rings.finite_rings - sage: hs = lambda x: hash(x) + 15 # needs sage.rings.finite_rings + sage: hs = lambda x: hash(x) + 15 sage: discrete_log_lambda(a**(89**3 - 3), # long time (10s on sage.math, 2011), needs sage.rings.finite_rings ....: a, (89**2, 89**4), operation='*', hash_function=hs) 704966 diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index eed158d8628..cd2521e3478 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -35,11 +35,11 @@ def is_Group(x): EXAMPLES:: - sage: F. = FreeGroup() # needs sage.groups + sage: F. = FreeGroup() # needs sage.combinat sage: from sage.groups.group import is_Group - sage: is_Group(F) # needs sage.groups + sage: is_Group(F) # needs sage.combinat True - sage: is_Group("a string") # needs sage.groups + sage: is_Group("a string") False """ from sage.groups.old import Group as OldGroup diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index 3a0ba1489c3..f09cc3caa01 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -1229,54 +1229,55 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, TESTS:: + sage: # needs sage.groups sage: from sage.groups.perm_gps.partn_ref.data_structures import SC_test_list_perms sage: limit = 10^7 sage: def test_Sn_on_m_points(n, m, gap, contains): ....: perm1 = [1,0] + list(range(2, m)) ....: perm2 = [(i+1)%n for i in range( n )] + list(range(n,m)) ....: SC_test_list_perms([perm1, perm2], m, limit, gap, 0, contains) - sage: for i in range(2,9): # needs sage.groups + sage: for i in range(2,9): ....: test_Sn_on_m_points(i,i,1,0) - sage: for i in range(2,9): # needs sage.groups + sage: for i in range(2,9): ....: test_Sn_on_m_points(i,i,0,1) - sage: for i in range(2,9): # long time # needs sage.groups + sage: for i in range(2,9): # long time ....: test_Sn_on_m_points(i,i,1,1) - sage: test_Sn_on_m_points(8,8,1,1) # needs sage.groups + sage: test_Sn_on_m_points(8,8,1,1) sage: def test_stab_chain_fns_1(n, gap, contains): ....: perm1 = sum([[2*i+1,2*i] for i in range(n)], []) ....: perm2 = [(i+1)%(2*n) for i in range( 2*n)] ....: SC_test_list_perms([perm1, perm2], 2*n, limit, gap, 0, contains) - sage: for n in range(1,11): # needs sage.groups + sage: for n in range(1,11): ....: test_stab_chain_fns_1(n, 1, 0) - sage: for n in range(1,11): # needs sage.groups + sage: for n in range(1,11): ....: test_stab_chain_fns_1(n, 0, 1) - sage: for n in range(1,9): # long time # needs sage.groups + sage: for n in range(1,9): # long time ....: test_stab_chain_fns_1(n, 1, 1) - sage: test_stab_chain_fns_1(11, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_1(11, 1, 1) sage: def test_stab_chain_fns_2(n, gap, contains): ....: perms = [] ....: for p,e in factor(n): ....: perm1 = [(p*(i//p)) + ((i+1)%p) for i in range(n)] ....: perms.append(perm1) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(2,11): # needs sage.groups + sage: for n in range(2,11): ....: test_stab_chain_fns_2(n, 1, 0) - sage: for n in range(2,11): # needs sage.groups + sage: for n in range(2,11): ....: test_stab_chain_fns_2(n, 0, 1) - sage: for n in range(2,11): # long time # needs sage.groups + sage: for n in range(2,11): # long time ....: test_stab_chain_fns_2(n, 1, 1) - sage: test_stab_chain_fns_2(11, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_2(11, 1, 1) sage: def test_stab_chain_fns_3(n, gap, contains): ....: perm1 = [(-i)%n for i in range( n )] ....: perm2 = [(i+1)%n for i in range( n )] ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in range(2,20): # needs sage.groups + sage: for n in range(2,20): ....: test_stab_chain_fns_3(n, 1, 0) - sage: for n in range(2,20): # needs sage.groups + sage: for n in range(2,20): ....: test_stab_chain_fns_3(n, 0, 1) - sage: for n in range(2,14): # long time # needs sage.groups + sage: for n in range(2,14): # long time ....: test_stab_chain_fns_3(n, 1, 1) - sage: test_stab_chain_fns_3(20, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_3(20, 1, 1) sage: def test_stab_chain_fns_4(n, g, gap, contains): ....: perms = [] ....: for _ in range(g): @@ -1284,24 +1285,24 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm) ....: perms.append(perm) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(4,9): # long time # needs sage.groups + sage: for n in range(4,9): # long time ....: test_stab_chain_fns_4(n, 1, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 3, 1, 0) - sage: for n in range(4,9): # known bug, not tested # needs sage.groups + sage: for n in range(4,9): # known bug, not tested ....: test_stab_chain_fns_4(n, 1, 0, 1) ....: for j in range(6): ....: test_stab_chain_fns_4(n, 2, 0, 1) ....: test_stab_chain_fns_4(n, 3, 0, 1) - sage: for n in range(4,8): # long time # needs sage.groups + sage: for n in range(4,8): # long time ....: test_stab_chain_fns_4(n, 1, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 3, 1, 1) - sage: test_stab_chain_fns_4(8, 2, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_4(8, 2, 1, 1) sage: def test_stab_chain_fns_5(n, gap, contains): ....: perms = [] ....: m = n//3 @@ -1312,12 +1313,12 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm2) ....: perm2 = list(range(m)) + perm2 ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in [4..9]: # long time # needs sage.groups + sage: for n in [4..9]: # long time ....: for _ in range(2): ....: test_stab_chain_fns_5(n, 1, 0) - sage: for n in [4..8]: # long time # needs sage.groups + sage: for n in [4..8]: # long time ....: test_stab_chain_fns_5(n, 0, 1) - sage: for n in [4..9]: # long time # needs sage.groups + sage: for n in [4..9]: # long time ....: test_stab_chain_fns_5(n, 1, 1) sage: def random_perm(x): ....: shuffle(x) @@ -1328,19 +1329,19 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm = sum([random_perm(list(range(i*(n//m),min(n,(i+1)*(n//m))))) for i in range(m)], []) ....: perms.append(perm) ....: SC_test_list_perms(perms, m*(n//m), limit, gap, 0, contains) - sage: for m in range(2,9): # long time # needs sage.groups + sage: for m in range(2,9): # long time ....: for n in range(m,3*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 1, 0) - sage: for m in range(2,10): # needs sage.groups + sage: for m in range(2,10): ....: for n in range(m,4*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 0, 1) - sage: test_stab_chain_fns_6(10,20,2, 1, 1) # needs sage.groups - sage: test_stab_chain_fns_6(8,16,2, 1, 1) # needs sage.groups - sage: test_stab_chain_fns_6(6,36,2, 1, 1) # needs sage.groups - sage: test_stab_chain_fns_6(4,40,3, 1, 1) # needs sage.groups - sage: test_stab_chain_fns_6(4,40,2, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_6(10,20,2, 1, 1) + sage: test_stab_chain_fns_6(8,16,2, 1, 1) + sage: test_stab_chain_fns_6(6,36,2, 1, 1) + sage: test_stab_chain_fns_6(4,40,3, 1, 1) + sage: test_stab_chain_fns_6(4,40,2, 1, 1) sage: def test_stab_chain_fns_7(n, cop, gap, contains): ....: perms = [] ....: for i in range(0,n//2,2): @@ -1352,17 +1353,17 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: else: ....: perms.append(p) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in [6..14]: # needs sage.groups + sage: for n in [6..14]: ....: test_stab_chain_fns_7(n, 1, 1, 0) ....: test_stab_chain_fns_7(n, 0, 1, 0) - sage: for n in [6..30]: # needs sage.groups + sage: for n in [6..30]: ....: test_stab_chain_fns_7(n, 1, 0, 1) ....: test_stab_chain_fns_7(n, 0, 0, 1) - sage: for n in [6..14]: # long time # needs sage.groups + sage: for n in [6..14]: # long time ....: test_stab_chain_fns_7(n, 1, 1, 1) ....: test_stab_chain_fns_7(n, 0, 1, 1) - sage: test_stab_chain_fns_7(20, 1, 1, 1) # needs sage.groups - sage: test_stab_chain_fns_7(20, 0, 1, 1) # needs sage.groups + sage: test_stab_chain_fns_7(20, 1, 1, 1) + sage: test_stab_chain_fns_7(20, 0, 1, 1) """ if gap: From 720ed90b9772bff4091fd4386c701b1354df10ce Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 13 Jul 2023 23:55:44 -0700 Subject: [PATCH 32/64] sage.groups.matrix_gps: Update # needs --- src/sage/groups/matrix_gps/group_element.pyx | 4 ++-- src/sage/groups/matrix_gps/matrix_group.py | 16 ++++++++-------- src/sage/groups/matrix_gps/orthogonal.py | 10 +++++----- src/sage/groups/matrix_gps/symplectic.py | 6 +++--- src/sage/groups/matrix_gps/unitary.py | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index f19514515e7..3d884e81dac 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -106,8 +106,8 @@ cpdef is_MatrixGroupElement(x): sage: is_MatrixGroupElement('helloooo') False - sage: G = GL(2,3) # needs sage.rings.finite_rings - sage: is_MatrixGroupElement(G.an_element()) # needs sage.rings.finite_rings + sage: G = GL(2,3) + sage: is_MatrixGroupElement(G.an_element()) True """ return isinstance(x, (MatrixGroupElement_generic, MatrixGroupElement_gap)) diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index f94c859f315..d788fc48e9d 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -358,19 +358,19 @@ def sign_representation(self, base_ring=None, side="twosided"): EXAMPLES:: sage: G = GL(2, QQ) - sage: V = G.sign_representation() # needs sage.combinat - sage: e = G.an_element() # needs sage.combinat - sage: e # needs sage.combinat + sage: V = G.sign_representation() + sage: e = G.an_element() + sage: e [1 0] [0 1] - sage: V._default_sign(e) # needs sage.combinat + sage: V._default_sign(e) 1 - sage: m2 = V.an_element() # needs sage.combinat - sage: m2 # needs sage.combinat + sage: m2 = V.an_element() + sage: m2 2*B['v'] - sage: m2*e # needs sage.combinat + sage: m2*e 2*B['v'] - sage: m2*e*e # needs sage.combinat + sage: m2*e*e 2*B['v'] """ if base_ring is None: diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 424518f341a..e1e335743e7 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -294,13 +294,13 @@ def GO(n, R, e=0, var='a', invariant_form=None): [0 1 0] [1 0 0] [0 0 3] - sage: pm = Permutation([2,3,1]).to_matrix() # needs sage.combinat - sage: g = GO3(pm); g in GO3; g # needs sage.combinat + sage: pm = Permutation([2,3,1]).to_matrix() + sage: g = GO3(pm); g in GO3; g True [0 0 1] [1 0 0] [0 1 0] - sage: GO3m(pm) # needs sage.combinat + sage: GO3m(pm) Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -410,7 +410,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): [ 1 zeta3 0] [zeta3 2 0] [ 0 0 1] - sage: pm = Permutation([2,3,1]).to_matrix() # needs sage.combinat + sage: pm = Permutation([2,3,1]).to_matrix() sage: g = SO3(pm); g in SO3; g # needs sage.combinat sage.rings.number_field True [0 0 1] @@ -424,7 +424,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): [zeta3 2 0] [ 0 0 1] - sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # needs sage.combinat sage.rings.number_field + sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP diff --git a/src/sage/groups/matrix_gps/symplectic.py b/src/sage/groups/matrix_gps/symplectic.py index 58cd29d9717..0038e2bcb2b 100644 --- a/src/sage/groups/matrix_gps/symplectic.py +++ b/src/sage/groups/matrix_gps/symplectic.py @@ -110,14 +110,14 @@ def Sp(n, R, var='a', invariant_form=None): [ 0 0 0 2] [-1 0 0 0] [ 0 -2 0 0] - sage: pm = Permutation([2,1,4,3]).to_matrix() # needs sage.combinat - sage: g = Sp4(pm); g in Sp4; g # needs sage.combinat + sage: pm = Permutation([2,1,4,3]).to_matrix() + sage: g = Sp4(pm); g in Sp4; g True [0 1 0 0] [1 0 0 0] [0 0 0 1] [0 0 1 0] - sage: Sp4m(pm) # needs sage.combinat + sage: Sp4m(pm) Traceback (most recent call last): ... TypeError: matrix must be symplectic with respect to the alternating form diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 49e71eb45c2..9314178376b 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -231,7 +231,7 @@ def GU(n, R, var='a', invariant_form=None): [ 1 E(5) 0] [E(5)^4 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat + sage: pm = Permutation((1,2,3)).to_matrix() sage: g = G(pm); g in G; g # needs sage.combinat True [0 0 1] @@ -331,7 +331,7 @@ def SU(n, R, var='a', invariant_form=None): [ 1 zeta3 0] [-zeta3 - 1 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # needs sage.combinat + sage: pm = Permutation((1,2,3)).to_matrix() sage: G(pm) # needs sage.combinat [0 0 1] [1 0 0] From adc367a3b702d8278349cb347a2b31b513bb1dd6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 14 Jul 2023 00:19:37 -0700 Subject: [PATCH 33/64] sage.groups: Update # needs --- src/sage/groups/generic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index f89b3fcaf3a..faf8984a2f2 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -142,7 +142,7 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): sage: multiple(2, 5) 32 - sage: multiple(RealField()('2.5'), 4) # needs sage.libs.mpfr + sage: multiple(RealField()('2.5'), 4) # needs sage.rings.real_mpfr 39.0625000000000 sage: multiple(2, -3) 1/8 @@ -574,13 +574,14 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No The main limitation on the hash function is that we don't want to have ``hash(x*y) == hash(x) + hash(y)``:: - sage: I = IntegerModRing(next_prime(2^23)) # needs sage.libs.pari + sage: # needs sage.libs.pari + sage: I = IntegerModRing(next_prime(2^23)) sage: def test(): ....: try: ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: ....: print("FAILURE") - sage: test() # random failure # needs sage.libs.pari + sage: test() # random failure FAILURE If this happens, we can provide a better hash function:: From 651305094cc95ebfb0d311cc001b899ab046ab7a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 6 Aug 2023 18:31:01 -0700 Subject: [PATCH 34/64] sage.groups: Update # needs --- src/sage/groups/generic.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index faf8984a2f2..c4da4871ee3 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -540,7 +540,7 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No sage: discrete_log_rho(g^1234, g) # needs sage.rings.finite_rings 1234 - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(37^5) sage: E = EllipticCurve(F, [1,1]) sage: G = (3*31*2^4)*E.lift_x(a) @@ -997,9 +997,10 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) # needs sage.rings.finite_rings 1234567 - sage: F. = GF(37^5) # needs sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings - sage: P = E.lift_x(a); P # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes + sage: F. = GF(37^5) + sage: E = EllipticCurve(F, [1,1]) + sage: P = E.lift_x(a); P (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: @@ -1104,7 +1105,7 @@ def linear_relation(P, Q, operation='+', identity=None, inverse=None, op=None): An additive example (in an elliptic curve group):: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(3^6,'a') sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2, 0) @@ -1212,6 +1213,8 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: b = a^4 sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 + + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(k, [2,4]) sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: M = E.cardinality(); M @@ -1352,6 +1355,8 @@ def order_from_bounds(P, bounds, d=None, operation='+', sage: b = a^4 sage: order_from_bounds(b, (5^4, 5^5), operation='*') 781 + + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(k, [2,4]) sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: bounds = Hasse_bounds(5^5) From 9cbed2c3b14c327063e1851d532991a4e573eeb0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 6 Aug 2023 20:45:08 -0700 Subject: [PATCH 35/64] src/sage/groups: Update file-level doctest tag --- src/sage/groups/class_function.py | 2 +- src/sage/groups/pari_group.py | 2 +- src/sage/groups/perm_gps/partn_ref/double_coset.pyx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/groups/class_function.py b/src/sage/groups/class_function.py index adfaa487a88..c788a596809 100644 --- a/src/sage/groups/class_function.py +++ b/src/sage/groups/class_function.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Class functions of groups. diff --git a/src/sage/groups/pari_group.py b/src/sage/groups/pari_group.py index c0a3b835357..bbcb1c0a6c9 100644 --- a/src/sage/groups/pari_group.py +++ b/src/sage/groups/pari_group.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.libs.pari +# sage.doctest: needs sage.libs.pari r""" PARI Groups diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index e6d397c0cfe..e3c7bc75f05 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.groups +# sage.doctest: needs sage.groups r""" Double cosets From b5804cfa828f91270352fdfd692e96eaa0e737b6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:15 -0700 Subject: [PATCH 36/64] src/sage/groups: sage -fixdoctests --only-tags --- src/sage/groups/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index c4da4871ee3..319570c98ff 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1005,7 +1005,7 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N This will return a multiple of the order of P:: - sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # needs sage.rings.finite_rings + sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # needs sage.rings.finite_rings sage.schemes ....: operation='+') 69327408 From 3934ed8ecdbfc159089715b0cf9aabe47ceacdee Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 12 Aug 2023 18:54:20 -0700 Subject: [PATCH 37/64] Update # needs --- src/sage/groups/old.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 2b59e483bd2..761034cff65 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -121,7 +121,7 @@ cdef class Group(sage.structure.parent.Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # needs sage.modules sage.rings.finite_rings + sage: SL(2, 7).is_commutative() # needs sage.libs.gap sage.modules False """ return self.is_abelian() From 1a80d4168f255df8ba3699ca7e733b1bd41ae7ca Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 31 Aug 2023 22:10:01 -0700 Subject: [PATCH 38/64] sage.groups: Restore lost comments --- src/sage/groups/abelian_gps/abelian_group_gap.py | 2 +- src/sage/groups/additive_abelian/additive_abelian_wrapper.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py index 55b540cc6f7..04ebb9d3ed1 100644 --- a/src/sage/groups/abelian_gps/abelian_group_gap.py +++ b/src/sage/groups/abelian_gps/abelian_group_gap.py @@ -781,7 +781,7 @@ def __init__(self, ambient, gens): Check that we are in the correct category:: - sage: # optional - gap_packages + sage: # optional - gap_package_polycyclic sage: G = AbelianGroupGap([2,3,0]) sage: g = G.gens() sage: H1 = G.subgroup([g[0],g[1]]) diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 3b8c9ab7d9c..c97a0ae0c80 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -24,7 +24,7 @@ (0 : 1 : 0) sage: 3000000000000001 * M.0 (4 : -7 : 1) - sage: M == loads(dumps(M)) # known bug + sage: M == loads(dumps(M)) # known bug (https://github.com/sagemath/sage/issues/11599#comment:7) True TESTS: From 490cf3d90ce18676c0aae3222def6725b75e7e7c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 31 Aug 2023 23:57:27 -0700 Subject: [PATCH 39/64] sage.groups: More block tags, doctest cosmetics --- src/sage/groups/abelian_gps/abelian_group.py | 201 ++++++++++-------- .../abelian_gps/abelian_group_element.py | 15 +- .../groups/abelian_gps/dual_abelian_group.py | 84 ++++---- .../abelian_gps/dual_abelian_group_element.py | 14 +- src/sage/groups/abelian_gps/element_base.py | 25 +-- src/sage/groups/abelian_gps/values.py | 17 +- .../additive_abelian_wrapper.py | 13 +- src/sage/groups/affine_gps/affine_group.py | 2 +- src/sage/groups/affine_gps/euclidean_group.py | 2 +- src/sage/groups/artin.py | 98 +++++---- src/sage/groups/braid.py | 14 +- src/sage/groups/cactus_group.py | 1 + src/sage/groups/conjugacy_classes.py | 6 +- src/sage/groups/cubic_braid.py | 4 +- src/sage/groups/finitely_presented_named.py | 4 +- src/sage/groups/fqf_orthogonal.py | 17 +- src/sage/groups/free_group.py | 8 +- src/sage/groups/galois_group.py | 130 +++++------ src/sage/groups/generic.py | 42 ++-- src/sage/groups/group_exp.py | 8 +- src/sage/groups/group_semidirect_product.py | 46 ++-- src/sage/groups/indexed_free_group.py | 1 + src/sage/groups/kernel_subgroup.py | 20 +- src/sage/groups/libgap_mixin.py | 54 ++--- src/sage/groups/libgap_morphism.py | 26 +-- src/sage/groups/libgap_wrapper.pyx | 6 +- .../groups/matrix_gps/finitely_generated.py | 6 +- .../matrix_gps/finitely_generated_gap.py | 33 ++- .../groups/matrix_gps/group_element_gap.pyx | 2 +- src/sage/groups/matrix_gps/linear.py | 6 +- src/sage/groups/matrix_gps/linear_gap.py | 4 +- src/sage/groups/matrix_gps/matrix_group.py | 6 +- .../groups/matrix_gps/matrix_group_gap.py | 12 +- src/sage/groups/matrix_gps/named_group.py | 2 +- src/sage/groups/matrix_gps/orthogonal.py | 4 +- src/sage/groups/matrix_gps/orthogonal_gap.py | 4 +- src/sage/groups/matrix_gps/symplectic.py | 2 +- src/sage/groups/matrix_gps/symplectic_gap.py | 6 +- src/sage/groups/matrix_gps/unitary.py | 6 +- src/sage/groups/matrix_gps/unitary_gap.py | 10 +- src/sage/groups/misc_gps/argument_groups.py | 58 ++--- src/sage/groups/misc_gps/imaginary_groups.py | 32 +-- .../automorphism_group_canonical_label.pyx | 12 +- src/sage/groups/perm_gps/permgroup.py | 48 +++-- .../groups/perm_gps/permgroup_element.pyx | 24 ++- .../groups/perm_gps/permgroup_morphism.py | 4 +- src/sage/groups/perm_gps/permgroup_named.py | 96 +++++---- .../groups/perm_gps/symgp_conjugacy_class.py | 56 ++--- src/sage/groups/raag.py | 2 +- .../semimonomial_transformation.pyx | 27 +-- .../semimonomial_transformation_group.py | 42 ++-- 51 files changed, 737 insertions(+), 625 deletions(-) diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index efa54bac7d1..ac21449c631 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -254,35 +254,38 @@ def word_problem(words, g, verbose=False): EXAMPLES:: - sage: G. = AbelianGroup(3,[2,3,4]); G + sage: # needs sage.libs.gap + sage: G. = AbelianGroup(3, [2,3,4]); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 - sage: w = word_problem([a*b,a*c], b*c); w #random + sage: w = word_problem([a*b,a*c], b*c); w # random [[a*b, 1], [a*c, 1]] sage: prod([x^i for x,i in w]) == b*c True - sage: w = word_problem([a*c,c],a); w #random + sage: w = word_problem([a*c,c], a); w # random [[a*c, 1], [c, -1]] sage: prod([x^i for x,i in w]) == a True - sage: word_problem([a*c,c],a,verbose=True) #random + sage: word_problem([a*c,c], a, verbose=True) # random a = (a*c)^1*(c)^-1 [[a*c, 1], [c, -1]] :: - sage: A. = AbelianGroup(5,[4, 5, 5, 7, 8]) + sage: # needs sage.libs.gap + sage: A. = AbelianGroup(5, [4, 5, 5, 7, 8]) sage: b1 = a^3*b*c*d^2*e^5 sage: b2 = a^2*b*c^2*d^3*e^3 sage: b3 = a^7*b^3*c^5*d^4*e^4 sage: b4 = a^3*b^2*c^2*d^3*e^5 sage: b5 = a^2*b^4*c^2*d^4*e^5 - sage: w = word_problem([b1,b2,b3,b4,b5],e); w #random - [[a^3*b*c*d^2*e^5, 1], [a^2*b*c^2*d^3*e^3, 1], [a^3*b^3*d^4*e^4, 3], [a^2*b^4*c^2*d^4*e^5, 1]] + sage: w = word_problem([b1,b2,b3,b4,b5], e); w # random + [[a^3*b*c*d^2*e^5, 1], [a^2*b*c^2*d^3*e^3, 1], + [a^3*b^3*d^4*e^4, 3], [a^2*b^4*c^2*d^4*e^5, 1]] sage: prod([x^i for x,i in w]) == e True - sage: word_problem([a,b,c,d,e],e) + sage: word_problem([a,b,c,d,e], e) [[e, 1]] - sage: word_problem([a,b,c,d,e],b) + sage: word_problem([a,b,c,d,e], b) [[b, 1]] .. warning:: @@ -413,7 +416,7 @@ def AbelianGroup(n, gens_orders=None, names="f"): a^2*b^2*c^2*d^2 sage: d * b**2 * c**3 b^2*c^3*d - sage: F = AbelianGroup(3,[2]*3); F + sage: F = AbelianGroup(3, [2]*3); F Multiplicative Abelian group isomorphic to C2 x C2 x C2 sage: H = AbelianGroup([2,3], names="xy"); H Multiplicative Abelian group isomorphic to C2 x C3 @@ -447,7 +450,7 @@ def is_AbelianGroup(x): EXAMPLES:: sage: from sage.groups.abelian_gps.abelian_group import is_AbelianGroup - sage: F = AbelianGroup(5,[5,5,7,8,9],names = list("abcde")); F + sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9 sage: is_AbelianGroup(F) True @@ -487,9 +490,9 @@ class AbelianGroup_class(UniqueRepresentation, AbelianGroupBase): sage: Z2xZ3.is_isomorphic(Z6) True - sage: F = AbelianGroup(5,[5,5,7,8,9],names = list("abcde")); F + sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9 - sage: F = AbelianGroup(5,[2, 4, 12, 24, 120],names = list("abcde")); F + sage: F = AbelianGroup(5,[2, 4, 12, 24, 120], names=list("abcde")); F Multiplicative Abelian group isomorphic to C2 x C4 x C12 x C24 x C120 sage: F.elementary_divisors() (2, 4, 12, 24, 120) @@ -516,7 +519,7 @@ def __init__(self, generator_orders, names, category=None): TESTS:: - sage: G = AbelianGroup([0,5,0,7],names = list("abcd")); G + sage: G = AbelianGroup([0,5,0,7], names=list("abcd")); G Multiplicative Abelian group isomorphic to Z x C5 x Z x C7 sage: TestSuite(G).run() @@ -577,8 +580,8 @@ def is_subgroup(left, right): sage: G.is_subgroup(G) True - sage: H = G.subgroup([G.1]) - sage: H.is_subgroup(G) + sage: H = G.subgroup([G.1]) # needs sage.libs.gap + sage: H.is_subgroup(G) # needs sage.libs.gap True sage: G. = AbelianGroup(2) @@ -654,7 +657,7 @@ def __bool__(self) -> bool: EXAMPLES:: sage: T = AbelianGroup([2, 3]) - sage: bool(T) # indirect doctest + sage: bool(T) # indirect doctest True sage: bool(AbelianGroup([])) False @@ -683,11 +686,11 @@ def dual_group(self, names="X", base_ring=None): EXAMPLES:: sage: G = AbelianGroup([2]) - sage: G.dual_group() + sage: G.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z over Cyclotomic Field of order 2 and degree 1 - sage: G.dual_group().gens() + sage: G.dual_group().gens() # needs sage.rings.number_field (X,) - sage: G.dual_group(names='Z').gens() + sage: G.dual_group(names='Z').gens() # needs sage.rings.number_field (Z,) sage: G.dual_group(base_ring=QQ) @@ -736,13 +739,13 @@ def elementary_divisors(self): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3]) + sage: G = AbelianGroup(2, [2,3]) sage: G.elementary_divisors() (6,) sage: G = AbelianGroup(1, [6]) sage: G.elementary_divisors() (6,) - sage: G = AbelianGroup(2,[2,6]) + sage: G = AbelianGroup(2, [2,6]) sage: G Multiplicative Abelian group isomorphic to C2 x C6 sage: G.gens_orders() @@ -752,7 +755,7 @@ def elementary_divisors(self): sage: J = AbelianGroup([1,3,5,12]) sage: J.elementary_divisors() (3, 60) - sage: G = AbelianGroup(2,[0,6]) + sage: G = AbelianGroup(2, [0,6]) sage: G.elementary_divisors() (6, 0) sage: AbelianGroup([3,4,5]).elementary_divisors() @@ -845,12 +848,12 @@ def _libgap_(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: libgap(G) + sage: libgap(G) # needs sage.libs.gap The result is cached:: - sage: libgap(G) is libgap(G) + sage: libgap(G) is libgap(G) # needs sage.libs.gap True Requires the optional ``gap_packages`` for infinite groups:: @@ -878,7 +881,7 @@ def _gap_init_(self): sage: G = AbelianGroup([2,3,9]) sage: G._gap_init_() 'AbelianGroup([2, 3, 9])' - sage: gap(G) + sage: gap(G) # needs sage.libs.gap Group( [ f1, f2, f3 ] ) Requires the optional ``gap_packages`` for infinite groups:: @@ -933,10 +936,10 @@ def gens(self): EXAMPLES:: - sage: F = AbelianGroup(5,[3,2],names='abcde') + sage: F = AbelianGroup(5, [3,2], names='abcde') sage: F.gens() (a, b, c, d, e) - sage: [ g.order() for g in F.gens() ] + sage: [g.order() for g in F.gens()] [+Infinity, +Infinity, +Infinity, 3, 2] """ return tuple( self.gen(i) for i in range(self.ngens()) ) @@ -1059,12 +1062,12 @@ def is_cyclic(self): (2, 4) sage: H.is_cyclic() False - sage: H.permutation_group().is_cyclic() + sage: H.permutation_group().is_cyclic() # needs sage.groups False sage: T = AbelianGroup([]) sage: T.is_cyclic() True - sage: T = AbelianGroup(1,[0]); T + sage: T = AbelianGroup(1, [0]); T Multiplicative Abelian group isomorphic to Z sage: T.is_cyclic() True @@ -1094,10 +1097,10 @@ def order(self): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3]) + sage: G = AbelianGroup(2, [2,3]) sage: G.order() 6 - sage: G = AbelianGroup(3,[2,3,0]) + sage: G = AbelianGroup(3, [2,3,0]) sage: G.order() +Infinity """ @@ -1121,7 +1124,7 @@ def permutation_group(self): sage: G = AbelianGroup(2,[2,3]); G Multiplicative Abelian group isomorphic to C2 x C3 - sage: G.permutation_group() + sage: G.permutation_group() # needs sage.groups Permutation Group with generators [(3,4,5), (1,2)] TESTS: @@ -1198,27 +1201,29 @@ def subgroup(self, gensH, names="f"): INPUT: - ``gensH`` -- list of elements which are products of the - generators of the ambient abelian group G = self + generators of the ambient abelian group `G` = ``self`` EXAMPLES:: - sage: G. = AbelianGroup(3, [2,3,4]); G - Multiplicative Abelian group isomorphic to C2 x C3 x C4 - sage: H = G.subgroup([a*b,a]); H - Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a*b, a} - sage: H < G - True - sage: F = G.subgroup([a,b^2]) - sage: F - Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} - sage: F.gens() - (a, b^2) - sage: F = AbelianGroup(5,[30,64,729],names = list("abcde")) - sage: a,b,c,d,e = F.gens() - sage: F.subgroup([a,b]) - Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b} - sage: F.subgroup([c,e]) - Multiplicative Abelian subgroup isomorphic to C2 x C3 x C5 x C729 generated by {c, e} + sage: # needs sage.libs.gap + sage: G. = AbelianGroup(3, [2,3,4]); G + Multiplicative Abelian group isomorphic to C2 x C3 x C4 + sage: H = G.subgroup([a*b,a]); H + Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a*b, a} + sage: H < G + True + sage: F = G.subgroup([a,b^2]) + sage: F + Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} + sage: F.gens() + (a, b^2) + sage: F = AbelianGroup(5, [30,64,729], names=list("abcde")) + sage: a,b,c,d,e = F.gens() + sage: F.subgroup([a,b]) + Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b} + sage: F.subgroup([c,e]) + Multiplicative Abelian subgroup isomorphic to C2 x C3 x C5 x C729 + generated by {c, e} """ G = self gensH = tuple(gensH) @@ -1327,10 +1332,12 @@ def number_of_subgroups(self, order=None): EXAMPLES:: - sage: AbelianGroup([2,3]).number_of_subgroups() - 4 sage: AbelianGroup([2,0,0,3,0]).number_of_subgroups() +Infinity + + sage: # needs sage.combinat + sage: AbelianGroup([2,3]).number_of_subgroups() + 4 sage: AbelianGroup([2,4,8]).number_of_subgroups() 81 sage: AbelianGroup([2,4,8]).number_of_subgroups(order=4) @@ -1344,6 +1351,7 @@ def number_of_subgroups(self, order=None): TESTS:: + sage: # needs sage.combinat sage: AbelianGroup([]).number_of_subgroups() 1 sage: AbelianGroup([1,3,1]).number_of_subgroups() @@ -1352,7 +1360,7 @@ def number_of_subgroups(self, order=None): 0 sage: AbelianGroup([1,3,1]).number_of_subgroups(order=2) 0 - sage: AbelianGroup([1,3,0,1]).number_of_subgroups(order=3) + sage: AbelianGroup([1,3,0,1]).number_of_subgroups(order=3) # needs sage.libs.gap 1 sage: AbelianGroup([1,3,1]).number_of_subgroups(order=-2) Traceback (most recent call last): @@ -1442,12 +1450,12 @@ def subgroups(self, check=False): EXAMPLES:: - sage: AbelianGroup([2,3]).subgroups() + sage: AbelianGroup([2,3]).subgroups() # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {f0*f1^2}, Multiplicative Abelian subgroup isomorphic to C2 generated by {f0}, Multiplicative Abelian subgroup isomorphic to C3 generated by {f1}, Trivial Abelian subgroup] - sage: len(AbelianGroup([2,4,8]).subgroups()) + sage: len(AbelianGroup([2,4,8]).subgroups()) # needs sage.libs.gap 81 TESTS:: @@ -1458,10 +1466,10 @@ def subgroups(self, check=False): Check that :trac:`14196` is fixed:: sage: B = AbelianGroup([1,2]) - sage: B.subgroups() + sage: B.subgroups() # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 generated by {f1}, Trivial Abelian subgroup] - sage: B.subgroups(check=True) + sage: B.subgroups(check=True) # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 generated by {f1}, Trivial Abelian subgroup] """ @@ -1525,10 +1533,10 @@ def subgroup_reduced(self, elts, verbose=False): EXAMPLES:: sage: G = AbelianGroup([4,4]) - sage: G.subgroup( [ G([1,0]), G([1,2]) ]) + sage: G.subgroup( [ G([1,0]), G([1,2]) ]) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C4 generated by {f0, f0*f1^2} - sage: AbelianGroup([4,4]).subgroup_reduced( [ [1,0], [1,2] ]) + sage: AbelianGroup([4,4]).subgroup_reduced( [ [1,0], [1,2] ]) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C4 generated by {f0^2*f1^2, f0^3} """ @@ -1559,6 +1567,7 @@ def torsion_subgroup(self, n=None): EXAMPLES:: + sage: # needs sage.libs.gap sage: G = AbelianGroup([2, 3]) sage: G.torsion_subgroup() Multiplicative Abelian subgroup isomorphic to C2 x C3 generated @@ -1577,7 +1586,7 @@ def torsion_subgroup(self, n=None): :: sage: G = AbelianGroup([2, 2*3, 2*3*5, 0, 2*3*5*7, 2*3*5*7*11]) - sage: G.torsion_subgroup(5) + sage: G.torsion_subgroup(5) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C5 x C5 x C5 generated by {f2^6, f4^42, f5^462} """ if n is None: @@ -1610,7 +1619,8 @@ def __init__(self, ambient, gens, names="f", category=None): """ EXAMPLES:: - sage: F = AbelianGroup(5,[30,64,729],names = list("abcde")) + sage: # needs sage.libs.gap + sage: F = AbelianGroup(5, [30,64,729], names=list("abcde")) sage: a,b,c,d,e = F.gens() sage: F.subgroup([a^3,b]) Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a^3, b} @@ -1622,11 +1632,11 @@ def __init__(self, ambient, gens, names="f", category=None): Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b*c} sage: F.subgroup([b*c, d]) Multiplicative Abelian subgroup isomorphic to C64 x Z generated by {b*c, d} - sage: F.subgroup([a*b, c^6, d],names=list("xyz")) + sage: F.subgroup([a*b, c^6, d], names=list("xyz")) Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} sage: H. = F.subgroup([a*b, c^6, d]); H Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} - sage: G = F.subgroup([a*b, c^6, d],names = list("xyz")); G + sage: G = F.subgroup([a*b, c^6, d], names=list("xyz")); G Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} sage: x,y,z = G.gens() sage: x.order() @@ -1635,7 +1645,7 @@ def __init__(self, ambient, gens, names="f", category=None): 5 sage: z.order() 64 - sage: A = AbelianGroup(5,[3, 5, 5, 7, 8], names = "abcde") + sage: A = AbelianGroup(5, [3, 5, 5, 7, 8], names="abcde") sage: a,b,c,d,e = A.gens() sage: A.subgroup([a,b]) Multiplicative Abelian subgroup isomorphic to C3 x C5 generated by {a, b} @@ -1647,7 +1657,7 @@ def __init__(self, ambient, gens, names="f", category=None): Multiplicative Abelian subgroup isomorphic to C4 x C5 x C5 x C7 generated by {b, c, d, e^2} sage: B.gens_orders() (4, 5, 5, 7) - sage: A = AbelianGroup(4,[1009, 2003, 3001, 4001], names = "abcd") + sage: A = AbelianGroup(4,[1009, 2003, 3001, 4001], names="abcd") sage: a,b,c,d = A.gens() sage: B = A.subgroup([a^3,b,c,d]) sage: B.gens_orders() @@ -1656,7 +1666,7 @@ def __init__(self, ambient, gens, names="f", category=None): 24266473210027 sage: B.order() 24266473210027 - sage: A = AbelianGroup(4,[1008, 2003, 3001, 4001], names = "abcd") + sage: A = AbelianGroup(4, [1008, 2003, 3001, 4001], names="abcd") sage: a,b,c,d = A.gens() sage: B = A.subgroup([a^3,b,c,d]); B Multiplicative Abelian subgroup isomorphic @@ -1664,23 +1674,25 @@ def __init__(self, ambient, gens, names="f", category=None): Infinite groups can also be handled:: - sage: G = AbelianGroup([3,4,0], names = "abc") + sage: G = AbelianGroup([3,4,0], names="abc") sage: a,b,c = G.gens() - sage: F = G.subgroup([a, b^2, c]); F - Multiplicative Abelian subgroup isomorphic to C2 x C3 x Z generated by {a, b^2, c} + sage: F = G.subgroup([a, b^2, c]); F # needs sage.libs.gap + Multiplicative Abelian subgroup isomorphic to C2 x C3 x Z + generated by {a, b^2, c} - sage: F.gens_orders() + sage: F.gens_orders() # needs sage.libs.gap (2, 3, 0) - sage: F.gens() + sage: F.gens() # needs sage.libs.gap (a, b^2, c) - sage: F.order() + sage: F.order() # needs sage.libs.gap +Infinity Testing issue :trac:`18863`:: sage: G = AbelianGroup(5,[2]) - sage: G.subgroup([prod(g^k for g,k in zip(G.gens(),[1,-2,3,-4,5]))]) - Multiplicative Abelian subgroup isomorphic to Z generated by {f0*f1^-2*f2^3*f3^-4*f4} + sage: G.subgroup([prod(g^k for g,k in zip(G.gens(),[1,-2,3,-4,5]))]) # needs sage.libs.gap + Multiplicative Abelian subgroup isomorphic to Z + generated by {f0*f1^-2*f2^3*f3^-4*f4} """ from sage.libs.gap.libgap import libgap if not isinstance(ambient, AbelianGroup_class): @@ -1713,10 +1725,10 @@ def __contains__(self, x): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) + sage: A = G.subgroup([a]) # needs sage.libs.gap sage: a in G True - sage: a in A + sage: a in A # needs sage.libs.gap True TESTS: @@ -1725,22 +1737,22 @@ def __contains__(self, x): sage: G. = AbelianGroup(2, [4, 576]) sage: Hgens = [a^2, a*b^2] - sage: H = G.subgroup(Hgens) - sage: [g in H for g in (a^3, b^2, b^3, a^3*b^2, "junk")] + sage: H = G.subgroup(Hgens) # needs sage.libs.gap + sage: [g in H for g in (a^3, b^2, b^3, a^3*b^2, "junk")] # needs sage.libs.gap [False, False, False, True, False] Check that :trac:`31507` is fixed:: sage: G = AbelianGroup(2, gens_orders=[16, 16]) sage: f0, f1 = G.gens() - sage: H = G.subgroup([f0*f1^3]) - sage: [g in H for g in (f0, f0*f1^2, f0*f1^3, f0*f1^4)] + sage: H = G.subgroup([f0*f1^3]) # needs sage.libs.gap + sage: [g in H for g in (f0, f0*f1^2, f0*f1^3, f0*f1^4)] # needs sage.libs.gap [False, False, True, False] sage: G. = AbelianGroup(2) sage: Hgens = [a*b, a*b^-1] - sage: H = G.subgroup(Hgens) - sage: b^2 in H + sage: H = G.subgroup(Hgens) # needs sage.libs.gap + sage: b^2 in H # needs sage.libs.gap True """ if not isinstance(x, AbelianGroupElement): @@ -1769,8 +1781,8 @@ def ambient_group(self): EXAMPLES:: sage: G. = AbelianGroup([2,3,4]) - sage: H = G.subgroup([a, b^2]) - sage: H.ambient_group() is G + sage: H = G.subgroup([a, b^2]) # needs sage.libs.gap + sage: H.ambient_group() is G # needs sage.libs.gap True """ return self._ambient_group @@ -1795,15 +1807,16 @@ def equals(left, right): sage: G = AbelianGroup(3, [2,3,4], names="abc"); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 sage: a,b,c = G.gens() - sage: F = G.subgroup([a,b^2]); F + sage: F = G.subgroup([a,b^2]); F # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} - sage: F = AbelianGroup(2) sage: A = G.subgroup([a]) sage: B = G.subgroup([b]) @@ -1835,8 +1848,8 @@ def _repr_(self): sage: G. = AbelianGroup(2) sage: G._repr_() 'Multiplicative Abelian group isomorphic to Z x Z' - sage: A = G.subgroup([a]) - sage: A._repr_() + sage: A = G.subgroup([a]) # needs sage.libs.gap + sage: A._repr_() # needs sage.libs.gap 'Multiplicative Abelian subgroup isomorphic to Z generated by {a}' """ eldv = self._abinvs @@ -1859,10 +1872,10 @@ def gens(self): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) + sage: A = G.subgroup([a]) # needs sage.libs.gap sage: G.gens() (a, b) - sage: A.gens() + sage: A.gens() # needs sage.libs.gap (a,) """ return self._gens @@ -1874,8 +1887,8 @@ def gen(self, n): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) - sage: A.gen(0) + sage: A = G.subgroup([a]) # needs sage.libs.gap + sage: A.gen(0) # needs sage.libs.gap a """ return self._gens[n] diff --git a/src/sage/groups/abelian_gps/abelian_group_element.py b/src/sage/groups/abelian_gps/abelian_group_element.py index 1b0c9cd590c..6ae81844f98 100644 --- a/src/sage/groups/abelian_gps/abelian_group_element.py +++ b/src/sage/groups/abelian_gps/abelian_group_element.py @@ -97,16 +97,16 @@ def as_permutation(self): EXAMPLES:: - sage: G = AbelianGroup(3,[2,3,4],names="abc"); G + sage: G = AbelianGroup(3, [2,3,4], names="abc"); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 sage: a,b,c = G.gens() - sage: Gp = G.permutation_group(); Gp + sage: Gp = G.permutation_group(); Gp # needs sage.groups Permutation Group with generators [(6,7,8,9), (3,4,5), (1,2)] - sage: a.as_permutation() + sage: a.as_permutation() # needs sage.libs.gap (1,2) - sage: ap = a.as_permutation(); ap + sage: ap = a.as_permutation(); ap # needs sage.libs.gap (1,2) - sage: ap in Gp + sage: ap in Gp # needs sage.groups sage.libs.gap True """ from sage.libs.gap.libgap import libgap @@ -138,13 +138,14 @@ def word_problem(self, words): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3], names="xy") + sage: # needs sage.libs.gap + sage: G = AbelianGroup(2, [2,3], names="xy") sage: x,y = G.gens() sage: x.word_problem([x,y]) [[x, 1]] sage: y.word_problem([x,y]) [[y, 1]] - sage: v = (y*x).word_problem([x,y]); v #random + sage: v = (y*x).word_problem([x,y]); v # random [[x, 1], [y, 1]] sage: prod([x^i for x,i in v]) == y*x True diff --git a/src/sage/groups/abelian_gps/dual_abelian_group.py b/src/sage/groups/abelian_gps/dual_abelian_group.py index 2d5441daaca..2ee86f7f423 100644 --- a/src/sage/groups/abelian_gps/dual_abelian_group.py +++ b/src/sage/groups/abelian_gps/dual_abelian_group.py @@ -25,6 +25,7 @@ sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') sage: (a, b, c, d, e) = F.gens() + sage: # needs sage.rings.number_field sage: Fd = F.dual_group(names='ABCDE') sage: Fd.base_ring() Cyclotomic Field of order 2520 and degree 576 @@ -34,6 +35,7 @@ sage: A(b), A(c), A(d), A(e) (1, 1, 1, 1) + sage: # needs sage.rings.real_mpfr sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) sage: A,B,C,D,E = Fd.gens() sage: A(a) # abs tol 1e-8 @@ -78,6 +80,7 @@ def is_DualAbelianGroup(x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroup sage: F = AbelianGroup(5,[3,5,7,8,9], names=list("abcde")) sage: Fd = F.dual_group() @@ -100,11 +103,12 @@ class DualAbelianGroup_class(UniqueRepresentation, AbelianGroupBase): EXAMPLES:: sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") - sage: F.dual_group() + sage: F.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 2520 and degree 576 + sage: F = AbelianGroup(4,[15,7,8,9], names="abcd") - sage: F.dual_group(base_ring=CC) + sage: F.dual_group(base_ring=CC) # needs sage.rings.real_mpfr Dual of Abelian Group isomorphic to Z/15Z x Z/7Z x Z/8Z x Z/9Z over Complex Field with 53 bits of precision """ @@ -117,7 +121,7 @@ def __init__(self, G, names, base_ring): EXAMPLES:: sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") - sage: F.dual_group() + sage: F.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 2520 and degree 576 """ @@ -174,12 +178,13 @@ def _repr_(self): EXAMPLES:: sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') - sage: Fd = F.dual_group(names='ABCDE', base_ring=CyclotomicField(2*5*7*8*9)) - sage: Fd # indirect doctest + sage: Fd = F.dual_group(names='ABCDE', # needs sage.rings.number_field + ....: base_ring=CyclotomicField(2*5*7*8*9)) + sage: Fd # indirect doctest # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 5040 and degree 1152 - sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) - sage: Fd + sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) # needs sage.rings.real_mpfr + sage: Fd # needs sage.rings.real_mpfr Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Complex Field with 53 bits of precision """ @@ -202,8 +207,8 @@ def _latex_(self): EXAMPLES:: sage: F = AbelianGroup(3, [2]*3) - sage: Fd = F.dual_group() - sage: Fd._latex_() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: Fd._latex_() # needs sage.rings.number_field '$\\mathrm{DualAbelianGroup}( AbelianGroup ( 3, (2, 2, 2) ) )$' """ return r"$\mathrm{DualAbelianGroup}( AbelianGroup ( %s, %s ) )$" % (self.ngens(), self.gens_orders()) @@ -215,12 +220,13 @@ def random_element(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group(base_ring=CC) - sage: Gd.random_element().parent() is Gd + sage: Gd = G.dual_group(base_ring=CC) # needs sage.rings.real_mpfr + sage: Gd.random_element().parent() is Gd # needs sage.rings.real_mpfr True - sage: N = 43^2-1 - sage: G = AbelianGroup([N],names="a") + sage: # needs sage.rings.real_mpfr + sage: N = 43^2 - 1 + sage: G = AbelianGroup([N], names="a") sage: Gd = G.dual_group(names="A", base_ring=CC) sage: a, = G.gens() sage: A, = Gd.gens() @@ -243,7 +249,8 @@ def gen(self, i=0): EXAMPLES:: - sage: F = AbelianGroup(3,[1,2,3],names='a') + sage: # needs sage.rings.number_field + sage: F = AbelianGroup(3, [1,2,3], names='a') sage: Fd = F.dual_group(names="A") sage: Fd.0 1 @@ -270,8 +277,8 @@ def gens(self): EXAMPLES:: - sage: F = AbelianGroup([7,11]).dual_group() - sage: F.gens() + sage: F = AbelianGroup([7,11]).dual_group() # needs sage.rings.number_field + sage: F.gens() # needs sage.rings.number_field (X0, X1) """ n = self.group().ngens() @@ -284,8 +291,8 @@ def ngens(self): EXAMPLES:: sage: F = AbelianGroup([7]*100) - sage: Fd = F.dual_group() - sage: Fd.ngens() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: Fd.ngens() # needs sage.rings.number_field 100 """ return self.group().ngens() @@ -301,8 +308,8 @@ def gens_orders(self): EXAMPLES:: sage: F = AbelianGroup([5]*1000) - sage: Fd = F.dual_group() - sage: invs = Fd.gens_orders(); len(invs) + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: invs = Fd.gens_orders(); len(invs) # needs sage.rings.number_field 1000 """ return self.group().gens_orders() @@ -316,8 +323,8 @@ def invariants(self): EXAMPLES:: sage: F = AbelianGroup([5]*1000) - sage: Fd = F.dual_group() - sage: invs = Fd.gens_orders(); len(invs) + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: invs = Fd.gens_orders(); len(invs) # needs sage.rings.number_field 1000 """ # TODO: deprecate @@ -331,9 +338,9 @@ def __contains__(self, X): sage: F = AbelianGroup(5,[2, 3, 5, 7, 8], names="abcde") sage: a,b,c,d,e = F.gens() - sage: Fd = F.dual_group(names = "ABCDE") - sage: A,B,C,D,E = Fd.gens() - sage: A*B^2*D^7 in Fd + sage: Fd = F.dual_group(names="ABCDE") # needs sage.rings.number_field + sage: A,B,C,D,E = Fd.gens() # needs sage.rings.number_field + sage: A*B^2*D^7 in Fd # needs sage.rings.number_field True """ return X.parent() == self and is_DualAbelianGroupElement(X) @@ -345,8 +352,8 @@ def order(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group() - sage: Gd.order() + sage: Gd = G.dual_group() # needs sage.rings.number_field + sage: Gd.order() # needs sage.rings.number_field 54 """ G = self.group() @@ -359,10 +366,10 @@ def is_commutative(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group() - sage: Gd.is_commutative() + sage: Gd = G.dual_group() # needs sage.rings.number_field + sage: Gd.is_commutative() # needs sage.rings.number_field True - sage: Gd.is_abelian() + sage: Gd.is_abelian() # needs sage.rings.number_field True """ return True @@ -375,8 +382,8 @@ def list(self): EXAMPLES:: sage: G = AbelianGroup([2,3], names="ab") - sage: Gd = G.dual_group(names="AB") - sage: Gd.list() + sage: Gd = G.dual_group(names="AB") # needs sage.rings.number_field + sage: Gd.list() # needs sage.rings.number_field (1, B, B^2, A, A*B, A*B^2) """ if not self.is_finite(): @@ -391,18 +398,21 @@ def __iter__(self): EXAMPLES:: sage: G = AbelianGroup([2,3], names="ab") - sage: Gd = G.dual_group(names="AB") - sage: [X for X in Gd] + sage: Gd = G.dual_group(names="AB") # needs sage.rings.number_field + sage: [X for X in Gd] # needs sage.rings.number_field [1, B, B^2, A, A*B, A*B^2] - sage: N = 43^2-1 - sage: G = AbelianGroup([N],names="a") + + sage: # needs sage.rings.real_mpfr + sage: N = 43^2 - 1 + sage: G = AbelianGroup([N], names="a") sage: Gd = G.dual_group(names="A", base_ring=CC) sage: a, = G.gens() sage: A, = Gd.gens() sage: x = a^(N/4) sage: y = a^(N/3) sage: z = a^(N/14) - sage: len([X for X in Gd if abs(X(x)-1)>0.01 and abs(X(y)-1)>0.01 and abs(X(z)-1)>0.01]) + sage: len([X for X in Gd + ....: if abs(X(x)-1)>0.01 and abs(X(y)-1)>0.01 and abs(X(z)-1)>0.01]) 880 """ yield from self.list() diff --git a/src/sage/groups/abelian_gps/dual_abelian_group_element.py b/src/sage/groups/abelian_gps/dual_abelian_group_element.py index e32d7b09762..407323d4f34 100644 --- a/src/sage/groups/abelian_gps/dual_abelian_group_element.py +++ b/src/sage/groups/abelian_gps/dual_abelian_group_element.py @@ -8,13 +8,13 @@ sage: F Multiplicative Abelian group isomorphic to C2 x C3 x C5 x C7 x C8 - sage: Fd = F.dual_group(names="ABCDE") - sage: Fd + sage: Fd = F.dual_group(names="ABCDE"); Fd # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z x Z/3Z x Z/5Z x Z/7Z x Z/8Z over Cyclotomic Field of order 840 and degree 192 The elements of the dual group can be evaluated on elements of the original group:: + sage: # needs sage.rings.number_field sage: a,b,c,d,e = F.gens() sage: A,B,C,D,E = Fd.gens() sage: A*B^2*D^7 @@ -71,10 +71,10 @@ def is_DualAbelianGroupElement(x) -> bool: EXAMPLES:: sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroupElement - sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group() - sage: is_DualAbelianGroupElement(F) + sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group() # needs sage.rings.number_field + sage: is_DualAbelianGroupElement(F) # needs sage.rings.number_field False - sage: is_DualAbelianGroupElement(F.an_element()) + sage: is_DualAbelianGroupElement(F.an_element()) # needs sage.rings.number_field True """ return isinstance(x, DualAbelianGroupElement) @@ -96,6 +96,7 @@ def __call__(self, g): EXAMPLES:: + sage: # needs sage.rings.number_field sage: F = AbelianGroup(5, [2,3,5,7,8], names="abcde") sage: a,b,c,d,e = F.gens() sage: Fd = F.dual_group(names="ABCDE") @@ -117,7 +118,7 @@ def __call__(self, g): sage: a, = F.gens() sage: Fd = F.dual_group(names="A", base_ring=GF(29)) sage: A, = Fd.gens() - sage: A(a) + sage: A(a) # needs sage.libs.pari 16 """ F = self.parent().base_ring() @@ -146,6 +147,7 @@ def word_problem(self, words): EXAMPLES:: + sage: # needs sage.rings.number_field sage: G = AbelianGroup(5,[3, 5, 5, 7, 8], names="abcde") sage: Gd = G.dual_group(names="abcde") sage: a,b,c,d,e = Gd.gens() diff --git a/src/sage/groups/abelian_gps/element_base.py b/src/sage/groups/abelian_gps/element_base.py index 00abd05eb8c..6a46bd7f444 100644 --- a/src/sage/groups/abelian_gps/element_base.py +++ b/src/sage/groups/abelian_gps/element_base.py @@ -48,9 +48,9 @@ class AbelianGroupElementBase(MultiplicativeGroupElement): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group(names="ABC") - sage: A,B,C = Fd.gens() - sage: A*B^-1 in Fd + sage: Fd = F.dual_group(names="ABC") # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: A*B^-1 in Fd # needs sage.rings.number_field True """ @@ -61,9 +61,9 @@ def __init__(self, parent, exponents): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group(names="ABC") - sage: A,B,C = Fd.gens() - sage: A*B^-1 in Fd + sage: Fd = F.dual_group(names="ABC") # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: A*B^-1 in Fd # needs sage.rings.number_field True Check that :issue:`35216` is fixed:: @@ -125,7 +125,7 @@ def _libgap_(self): TESTS:: sage: F. = AbelianGroup([7,8,9]) - sage: libgap(a**2 * c) * libgap(b * c**2) + sage: libgap(a**2 * c) * libgap(b * c**2) # needs sage.libs.gap f1^2*f2*f6 """ from sage.misc.misc_c import prod @@ -147,6 +147,7 @@ def list(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: F = AbelianGroup(5,[2, 3, 5, 7, 8], names="abcde") sage: a,b,c,d,e = F.gens() sage: Ad = F.dual_group(names="ABCDE") @@ -208,8 +209,8 @@ def _richcmp_(self, other, op): sage: a > b True - sage: Gd. = G.dual_group() - sage: A > B + sage: Gd. = G.dual_group() # needs sage.rings.number_field + sage: A > B # needs sage.rings.number_field True """ return richcmp(self._exponents, other._exponents, op) @@ -226,9 +227,9 @@ def order(self): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group() - sage: A,B,C = Fd.gens() - sage: (B*C).order() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: (B*C).order() # needs sage.rings.number_field 72 sage: F = AbelianGroup(3,[7,8,9]); F diff --git a/src/sage/groups/abelian_gps/values.py b/src/sage/groups/abelian_gps/values.py index e476176cb7d..3db117123f0 100644 --- a/src/sage/groups/abelian_gps/values.py +++ b/src/sage/groups/abelian_gps/values.py @@ -48,6 +48,7 @@ :meth:`~AbelianGroupWithValues_class.values_group`, so you can use the group elements instead of the values:: + sage: # needs sage.rings.number_field sage: CF3. = CyclotomicField(3) sage: Z3. = AbelianGroupWithValues([zeta], [3]) sage: Z3.values_group() @@ -159,6 +160,7 @@ class AbelianGroupWithValuesEmbedding(Morphism): EXAMPLES:: + sage: # needs sage.symbolic sage: Z4. = AbelianGroupWithValues([I], [4]) sage: embedding = Z4.values_embedding(); embedding Generic morphism: @@ -178,9 +180,9 @@ def __init__(self, domain, codomain): TESTS:: - sage: Z4 = AbelianGroupWithValues([I], [4]) + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic sage: from sage.groups.abelian_gps.values import AbelianGroupWithValuesEmbedding - sage: AbelianGroupWithValuesEmbedding(Z4, Z4.values_group()) + sage: AbelianGroupWithValuesEmbedding(Z4, Z4.values_group()) # needs sage.symbolic Generic morphism: From: Multiplicative Abelian group isomorphic to C4 To: Number Field in I with defining polynomial x^2 + 1 with I = 1*I @@ -203,6 +205,7 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.symbolic sage: Z4. = AbelianGroupWithValues([I], [4]) sage: embedding = Z4.values_embedding() sage: embedding(g) @@ -417,7 +420,7 @@ def gen(self, i=0): EXAMPLES:: - sage: F = AbelianGroupWithValues([1,2,3,4,5], 5,[],names='a') + sage: F = AbelianGroupWithValues([1,2,3,4,5], 5, [], names='a') sage: F.0 a0 sage: F.0.value() @@ -473,8 +476,8 @@ def values_group(self): sage: G.values_group() Integer Ring - sage: Z4 = AbelianGroupWithValues([I], [4]) - sage: Z4.values_group() + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic + sage: Z4.values_group() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 with I = 1*I """ return self._values_group @@ -489,8 +492,8 @@ def values_embedding(self): EXAMPLES:: - sage: Z4 = AbelianGroupWithValues([I], [4]) - sage: Z4.values_embedding() + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic + sage: Z4.values_embedding() # needs sage.symbolic Generic morphism: From: Multiplicative Abelian group isomorphic to C4 To: Number Field in I with defining polynomial x^2 + 1 with I = 1*I diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index c97a0ae0c80..2a7496cb215 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -351,9 +351,9 @@ def discrete_log(self, x, gens=None): :: sage: x = polygen(ZZ, 'x') - sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # needs sage.rings.finite_rings - sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # needs sage.rings.finite_rings - sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # needs sage.rings.finite_rings + sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # needs sage.rings.finite_rings sage.schemes + sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # needs sage.rings.finite_rings sage.schemes + sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # needs sage.rings.finite_rings sage.schemes (123, 777) :: @@ -445,10 +445,9 @@ def torsion_subgroup(self, n=None): :: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(GF(487^2), [311,205]) - sage: T = E.abelian_group().torsion_subgroup(42) - sage: T + sage: T = E.abelian_group().torsion_subgroup(42); T Additive abelian group isomorphic to Z/42 + Z/6 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 @@ -576,7 +575,7 @@ def _discrete_log_pgroup(p, vals, aa, b): Check for :trac:`34716`:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(GF(487^2), [311,205]) sage: G = E.abelian_group().torsion_subgroup(42) sage: G.invariants() diff --git a/src/sage/groups/affine_gps/affine_group.py b/src/sage/groups/affine_gps/affine_group.py index 3688d39695c..7e8c167d448 100644 --- a/src/sage/groups/affine_gps/affine_group.py +++ b/src/sage/groups/affine_gps/affine_group.py @@ -133,7 +133,7 @@ class AffineGroup(UniqueRepresentation, Group): Affine Space of dimension 2 over Finite Field in a of size 2^2 sage: G = AffineGroup(A); G # needs sage.rings.finite_rings Affine Group of degree 2 over Finite Field in a of size 2^2 - sage: G is AffineGroup(2,4) # shorthand # needs sage.rings.finite_rings + sage: G is AffineGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V diff --git a/src/sage/groups/affine_gps/euclidean_group.py b/src/sage/groups/affine_gps/euclidean_group.py index 1da846aaba4..cff5630a30c 100644 --- a/src/sage/groups/affine_gps/euclidean_group.py +++ b/src/sage/groups/affine_gps/euclidean_group.py @@ -125,7 +125,7 @@ class EuclideanGroup(AffineGroup): Affine Space of dimension 2 over Finite Field in a of size 2^2 sage: G = EuclideanGroup(A); G # needs sage.rings.finite_rings Euclidean Group of degree 2 over Finite Field in a of size 2^2 - sage: G is EuclideanGroup(2,4) # shorthand # needs sage.rings.finite_rings + sage: G is EuclideanGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V diff --git a/src/sage/groups/artin.py b/src/sage/groups/artin.py index 0e91205c8e1..f2aa359cbeb 100644 --- a/src/sage/groups/artin.py +++ b/src/sage/groups/artin.py @@ -39,6 +39,7 @@ class ArtinGroupElement(FinitelyPresentedGroupElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A. = ArtinGroup(['B',3]) sage: A Artin group of type ['B', 3] @@ -57,9 +58,9 @@ def _latex_(self): TESTS:: - sage: A = ArtinGroup(['B',3]) - sage: b = A([1, 2, 3, -1, 2, -3]) - sage: b._latex_() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: b = A([1, 2, 3, -1, 2, -3]) # needs sage.rings.number_field + sage: b._latex_() # needs sage.rings.number_field '\\sigma_{1}\\sigma_{2}\\sigma_{3}\\sigma_{1}^{-1}\\sigma_{2}\\sigma_{3}^{-1}' sage: B = BraidGroup(4) @@ -80,6 +81,7 @@ def exponent_sum(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['E',6]) sage: b = A([1, 4, -3, 2]) sage: b.exponent_sum() @@ -109,6 +111,7 @@ def coxeter_group_element(self, W=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A. = ArtinGroup(['B',3]) sage: b = s1 * s2 / s3 / s2 sage: b.coxeter_group_element() @@ -134,6 +137,7 @@ def _richcmp_(self, other, op): TESTS:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['B',3]) sage: x = A([1, 2, 1]) sage: y = A([2, 1, 2]) @@ -162,6 +166,7 @@ def __hash__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: B. = ArtinGroup(['B',3]) sage: hash(s1*s3) == hash(s3*s1) True @@ -189,6 +194,7 @@ def left_normal_form(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['B',3]) sage: A([1]).left_normal_form() (1, s1) @@ -230,6 +236,7 @@ def _left_normal_form_coxeter(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['E',6]) sage: A([2, -4, 2, 3, 1, 3, 2, 1, -2])._left_normal_form_coxeter() ( @@ -345,9 +352,9 @@ class ArtinGroup(FinitelyPresentedGroup): EXAMPLES:: - sage: A. = ArtinGroup(['B',3]); A + sage: A. = ArtinGroup(['B',3]); A # needs sage.rings.number_field Artin group of type ['B', 3] - sage: ArtinGroup(['B',3]) + sage: ArtinGroup(['B',3]) # needs sage.rings.number_field Artin group of type ['B', 3] The input must always include the Coxeter data, but the ``names`` @@ -355,11 +362,11 @@ class ArtinGroup(FinitelyPresentedGroup): the explicit names of the generators. Otherwise the default prefix of ``'s'`` is used:: - sage: ArtinGroup(['B',2]).generators() + sage: ArtinGroup(['B',2]).generators() # needs sage.rings.number_field (s1, s2) - sage: ArtinGroup(['B',2], 'g').generators() + sage: ArtinGroup(['B',2], 'g').generators() # needs sage.rings.number_field (g1, g2) - sage: ArtinGroup(['B',2], 'x,y').generators() + sage: ArtinGroup(['B',2], 'x,y').generators() # needs sage.rings.number_field (x, y) REFERENCES: @@ -377,26 +384,28 @@ def __classcall_private__(cls, coxeter_data, names=None): TESTS:: + sage: # needs sage.rings.number_field sage: A1 = ArtinGroup(['B',3]) sage: A2 = ArtinGroup(['B',3], 's') sage: A3 = ArtinGroup(['B',3], ['s1','s2','s3']) sage: A1 is A2 and A2 is A3 True + sage: # needs sage.rings.number_field sage: A1 = ArtinGroup(['B',2], 'a,b') sage: A2 = ArtinGroup([[1,4],[4,1]], 'a,b') sage: A3. = ArtinGroup('B2') sage: A1 is A2 and A2 is A3 True - sage: ArtinGroup(['A',3]) is BraidGroup(4, 's1,s2,s3') + sage: ArtinGroup(['A',3]) is BraidGroup(4, 's1,s2,s3') # needs sage.rings.number_field True sage: G = graphs.PathGraph(3) sage: CM = CoxeterMatrix([[1,-1,2],[-1,1,-1],[2,-1,1]], index_set=G.vertices(sort=True)) - sage: A = groups.misc.Artin(CM) - sage: Ap = groups.misc.RightAngledArtin(G, 's') - sage: A is Ap + sage: A = groups.misc.Artin(CM) # needs sage.rings.number_field + sage: Ap = groups.misc.RightAngledArtin(G, 's') # needs sage.rings.number_field + sage: A is Ap # needs sage.rings.number_field True """ coxeter_data = CoxeterMatrix(coxeter_data) @@ -427,6 +436,7 @@ def __init__(self, coxeter_matrix, names): TESTS:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['D',4]) sage: TestSuite(A).run() sage: A = ArtinGroup(['B',3], ['x','y','z']) @@ -454,9 +464,9 @@ def _repr_(self): TESTS:: - sage: ArtinGroup(['B',3]) + sage: ArtinGroup(['B',3]) # needs sage.rings.number_field Artin group of type ['B', 3] - sage: ArtinGroup(['D',4], 'g') + sage: ArtinGroup(['D',4], 'g') # needs sage.rings.number_field Artin group of type ['D', 4] """ try: @@ -481,8 +491,8 @@ def cardinality(self): sage: G.cardinality() +Infinity - sage: A = ArtinGroup(['A',1]) - sage: A.cardinality() + sage: A = ArtinGroup(['A',1]) # needs sage.rings.number_field + sage: A.cardinality() # needs sage.rings.number_field +Infinity """ from sage.rings.infinity import Infinity @@ -506,8 +516,8 @@ def as_permutation_group(self): ... ValueError: the group is infinite - sage: A = ArtinGroup(['D',4], 'g') - sage: A.as_permutation_group() + sage: A = ArtinGroup(['D',4], 'g') # needs sage.rings.number_field + sage: A.as_permutation_group() # needs sage.rings.number_field Traceback (most recent call last): ... ValueError: the group is infinite @@ -520,8 +530,8 @@ def coxeter_type(self): EXAMPLES:: - sage: A = ArtinGroup(['D',4]) - sage: A.coxeter_type() + sage: A = ArtinGroup(['D',4]) # needs sage.rings.number_field + sage: A.coxeter_type() # needs sage.rings.number_field Coxeter type of ['D', 4] """ return self._coxeter_group.coxeter_type() @@ -532,8 +542,8 @@ def coxeter_matrix(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.coxeter_matrix() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.coxeter_matrix() # needs sage.rings.number_field [1 3 2] [3 1 4] [2 4 1] @@ -546,8 +556,8 @@ def coxeter_group(self): EXAMPLES:: - sage: A = ArtinGroup(['D',4]) - sage: A.coxeter_group() + sage: A = ArtinGroup(['D',4]) # needs sage.rings.number_field + sage: A.coxeter_group() # needs sage.rings.number_field Finite Coxeter group over Integer Ring with Coxeter matrix: [1 3 2 2] [3 1 3 3] @@ -566,8 +576,8 @@ def index_set(self): EXAMPLES:: - sage: A = ArtinGroup(['E',7]) - sage: A.index_set() + sage: A = ArtinGroup(['E',7]) # needs sage.rings.number_field + sage: A.index_set() # needs sage.rings.number_field (1, 2, 3, 4, 5, 6, 7) """ return self._coxeter_group.index_set() @@ -576,8 +586,8 @@ def _element_constructor_(self, x): """ TESTS:: - sage: A = ArtinGroup(['B',3]) - sage: A([2,1,-2,3,3,3,1]) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A([2,1,-2,3,3,3,1]) # needs sage.rings.number_field s2*s1*s2^-1*s3^3*s1 """ if x in self._coxeter_group: @@ -591,8 +601,8 @@ def an_element(self): EXAMPLES:: - sage: A = ArtinGroup(['B',2]) - sage: A.an_element() + sage: A = ArtinGroup(['B',2]) # needs sage.rings.number_field + sage: A.an_element() # needs sage.rings.number_field s1 """ return self.gen(0) @@ -603,8 +613,8 @@ def some_elements(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.some_elements() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.some_elements() # needs sage.rings.number_field [s1, s1*s2*s3, (s1*s2*s3)^3] """ rank = self.coxeter_matrix().rank() @@ -624,8 +634,8 @@ def _standard_lift_Tietze(self, w): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A._standard_lift_Tietze(A.coxeter_group().long_element()) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A._standard_lift_Tietze(A.coxeter_group().long_element()) # needs sage.rings.number_field [3, 2, 3, 1, 2, 3, 1, 2, 1] """ return w.reduced_word() @@ -642,8 +652,8 @@ def _standard_lift(self, w): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A._standard_lift(A.coxeter_group().long_element()) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A._standard_lift(A.coxeter_group().long_element()) # needs sage.rings.number_field s3*(s2*s3*s1)^2*s2*s1 sage: B = BraidGroup(5) @@ -671,7 +681,7 @@ class FiniteTypeArtinGroup(ArtinGroup): EXAMPLES:: - sage: ArtinGroup(['E',7]) + sage: ArtinGroup(['E',7]) # needs sage.rings.number_field Artin group of type ['E', 7] Since the word problem for finite-type Artin groups is solvable, their @@ -684,15 +694,15 @@ class FiniteTypeArtinGroup(ArtinGroup): ....: for w in Words(alphabet=group.gens(), length=length): ....: ret.add(prod(w)) ....: return ret - sage: A = ArtinGroup(['B',3]) - sage: GA = A.cayley_graph(elements=ball(A, 4), generators=A.gens()); GA + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: GA = A.cayley_graph(elements=ball(A, 4), generators=A.gens()); GA # needs sage.rings.number_field Digraph on 32 vertices Since the Artin group has nontrivial relations, this graph contains less vertices than the one associated to the free group (which is a tree):: sage: F = FreeGroup(3) - sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF + sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat Digraph on 40 vertices """ def delta(self): @@ -701,12 +711,12 @@ def delta(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.delta() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.delta() # needs sage.rings.number_field s3*(s2*s3*s1)^2*s2*s1 - sage: A = ArtinGroup(['G',2]) - sage: A.delta() + sage: A = ArtinGroup(['G',2]) # needs sage.rings.number_field + sage: A.delta() # needs sage.rings.number_field (s2*s1)^3 sage: B = BraidGroup(5) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index c2cc1951f9e..8141b6d7d45 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -1724,8 +1724,8 @@ def conjugating_braid(self, other): True sage: d1 * a / d1 == c False - sage: l = sage.groups.braid.conjugatingbraid(a,c) - sage: d1 == B._element_from_libbraiding(l) + sage: l = sage.groups.braid.conjugatingbraid(a,c) # needs sage.groups + sage: d1 == B._element_from_libbraiding(l) # needs sage.groups True sage: b = B([2, 2, 2, 2, 1]) sage: c = b * a / b @@ -1738,9 +1738,9 @@ def conjugating_braid(self, other): False sage: d1 s1^2*s0^2*s1^2*s0 - sage: l = sage.groups.braid.conjugatingbraid(a,c) - sage: d2 = B._element_from_libbraiding(l) - sage: len(d2.Tietze()) + sage: l = sage.groups.braid.conjugatingbraid(a,c) # needs sage.groups + sage: d2 = B._element_from_libbraiding(l) # needs sage.groups + sage: len(d2.Tietze()) # needs sage.groups 13 sage: c.conjugating_braid(b) is None True @@ -2984,7 +2984,7 @@ def dimension_of_TL_space(self, drain_size): The direct sum of endomorphism spaces of these vector spaces make up the entire Temperley--Lieb algebra:: - sage: import sage.combinat.diagram_algebras as da + sage: import sage.combinat.diagram_algebras as da # needs sage.combinat sage: B = BraidGroup(6) sage: dimensions = [B.dimension_of_TL_space(d)**2 for d in [0, 2, 4, 6]] sage: total_dim = sum(dimensions) @@ -3451,7 +3451,7 @@ def BraidGroup(n=None, names='s'): vertices than the one associated to the free group (which is a tree):: sage: F = FreeGroup(3) - sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF + sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat Digraph on 40 vertices TESTS:: diff --git a/src/sage/groups/cactus_group.py b/src/sage/groups/cactus_group.py index 959f80c9c48..a12fbb88563 100644 --- a/src/sage/groups/cactus_group.py +++ b/src/sage/groups/cactus_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Cactus Groups diff --git a/src/sage/groups/conjugacy_classes.py b/src/sage/groups/conjugacy_classes.py index fd79d60ee5b..4ad8200ef23 100644 --- a/src/sage/groups/conjugacy_classes.py +++ b/src/sage/groups/conjugacy_classes.py @@ -24,7 +24,7 @@ sage: G = SymmetricGroup(4) sage: g = G((1,2,3,4)) - sage: G.conjugacy_class(g) + sage: G.conjugacy_class(g) # needs sage.combinat Conjugacy class of cycle type [4] in Symmetric group of order 4! as a permutation group Conjugacy classes for groups of matrices:: @@ -90,7 +90,7 @@ def __init__(self, group, element): sage: ConjugacyClass(G,g) Conjugacy class of (1,2,3,4) in Symmetric group of order 4! as a permutation group - sage: TestSuite(G).run() + sage: TestSuite(G).run() # needs sage.rings.number_field """ self._parent = group self._representative = element @@ -432,6 +432,7 @@ def cardinality(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: W = WeylGroup(['C',6]) sage: cc = W.conjugacy_class(W.an_element()) sage: cc.cardinality() @@ -449,6 +450,7 @@ def __contains__(self, g): TESTS:: + sage: # needs sage.rings.number_field sage: W = WeylGroup(['C',6]) sage: g0,g1,g2,g3,g4,g5 = W.gens() sage: cc = W.conjugacy_class(g0) diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index 08818ccaff3..4533ed744dc 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -421,8 +421,8 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 2^2 - sage: F4. = GF(4) - sage: BuMa = ele.burau_matrix(root_bur=r64); BuMa + sage: F4. = GF(4) # needs sage.libs.pari + sage: BuMa = ele.burau_matrix(root_bur=r64); BuMa # needs sage.libs.pari [r64 + 1 1 r64 + 1] [r64 + 1 r64 0] [ 1 0 0] diff --git a/src/sage/groups/finitely_presented_named.py b/src/sage/groups/finitely_presented_named.py index 177f7908895..4968293e30d 100644 --- a/src/sage/groups/finitely_presented_named.py +++ b/src/sage/groups/finitely_presented_named.py @@ -548,7 +548,7 @@ def BinaryDihedralPresentation(n): TESTS:: - sage: for n in range(3, 9): + sage: for n in range(3, 9): # needs sage.modules ....: P = groups.presentation.BinaryDihedral(n) ....: M = groups.matrix.BinaryDihedral(n) ....: assert P.is_isomorphic(M) @@ -574,7 +574,7 @@ def CactusPresentation(n): EXAMPLES:: - sage: J3 = groups.presentation.Cactus(3); J3 + sage: J3 = groups.presentation.Cactus(3); J3 # needs sage.graphs Finitely presented group < s12, s13, s23 | s12^2, s13^2, s23^2, s13*s12*s13^-1*s23^-1, s13*s23*s13^-1*s12^-1 > """ diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py index 32a434d3bd9..bf9ab9000e2 100644 --- a/src/sage/groups/fqf_orthogonal.py +++ b/src/sage/groups/fqf_orthogonal.py @@ -8,19 +8,20 @@ EXAMPLES:: - sage: L = IntegralLattice("A2").twist(2) - sage: T = L.discriminant_group() - sage: Oq = T.orthogonal_group() + sage: L = IntegralLattice("A2").twist(2) # needs sage.graphs + sage: T = L.discriminant_group() # needs sage.graphs + sage: Oq = T.orthogonal_group() # needs sage.graphs The isometries act on elements of their domain:: - sage: g = Oq(matrix(ZZ, 2, [0, 3, 1, 2])) - sage: T.gen(0) * g + sage: g = Oq(matrix(ZZ, 2, [0, 3, 1, 2])) # needs sage.graphs + sage: T.gen(0) * g # needs sage.graphs (0, 3) Isometries are represented with respect to the Smith form generators of `T`:: + sage: # needs sage.graphs sage: L = IntegralLattice("A2").twist(2).direct_sum(IntegralLattice('U')) sage: T = L.discriminant_group().normal_form() sage: OT = T.orthogonal_group() @@ -216,6 +217,7 @@ def _element_constructor_(self, x, check=True): EXAMPLES:: + sage: # needs sage.graphs sage: L = IntegralLattice("A2").twist(2).direct_sum(IntegralLattice("A2")) sage: q = L.discriminant_group() sage: OL = L.orthogonal_group() @@ -230,18 +232,19 @@ def _element_constructor_(self, x, check=True): Note that the following does not work since it may lead to ambiguities, see :trac:`30669`:: - sage: Oq(f.matrix()) + sage: Oq(f.matrix()) # needs sage.graphs Traceback (most recent call last): ... ValueError: ... But a matrix in the covering works:: - sage: fbar == Oq(fbar.matrix()) + sage: fbar == Oq(fbar.matrix()) # needs sage.graphs True TESTS:: + sage: # needs sage.graphs sage: all(x*f==x*fbar for x in q.gens()) True sage: L = IntegralLattice("A2").twist(3) diff --git a/src/sage/groups/free_group.py b/src/sage/groups/free_group.py index 0c51deafc64..654a91c7372 100644 --- a/src/sage/groups/free_group.py +++ b/src/sage/groups/free_group.py @@ -89,11 +89,11 @@ def is_FreeGroup(x): EXAMPLES:: sage: from sage.groups.free_group import is_FreeGroup - sage: is_FreeGroup('a string') + sage: is_FreeGroup('a string') # needs sage.combinat False sage: is_FreeGroup(FreeGroup(0)) True - sage: is_FreeGroup(FreeGroup(index_set=ZZ)) + sage: is_FreeGroup(FreeGroup(index_set=ZZ)) # needs sage.combinat True """ if isinstance(x, FreeGroup_class): @@ -645,9 +645,9 @@ def FreeGroup(n=None, names='x', index_set=None, abelian=False, **kwds): We give two examples using the ``index_set`` option:: - sage: FreeGroup(index_set=ZZ) + sage: FreeGroup(index_set=ZZ) # needs sage.combinat Free group indexed by Integer Ring - sage: FreeGroup(index_set=ZZ, abelian=True) + sage: FreeGroup(index_set=ZZ, abelian=True) # needs sage.combinat Free abelian group indexed by Integer Ring TESTS:: diff --git a/src/sage/groups/galois_group.py b/src/sage/groups/galois_group.py index bc1b9a807f1..aef5fb2ee1d 100644 --- a/src/sage/groups/galois_group.py +++ b/src/sage/groups/galois_group.py @@ -31,9 +31,9 @@ def _alg_key(self, algorithm=None, recompute=False): sage: from sage.groups.galois_group import _alg_key sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: _alg_key(G, algorithm="pari", recompute=True) + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: _alg_key(G, algorithm="pari", recompute=True) # needs sage.rings.number_field 'pari' """ if recompute: @@ -55,9 +55,9 @@ def _default_algorithm(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G._default_algorithm + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._default_algorithm # needs sage.rings.number_field 'pari' """ return NotImplemented @@ -74,9 +74,9 @@ def _gcdata(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 - 2) - sage: G = K.galois_group() - sage: G._gcdata + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._gcdata # needs sage.rings.number_field (Number Field in ac with defining polynomial x^6 + 108, Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 @@ -91,6 +91,7 @@ def _get_algorithm(self, algorithm): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: G = K.galois_group() @@ -109,9 +110,9 @@ def _galois_closure(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group(names='b') - sage: G._galois_closure + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group(names='b') # needs sage.rings.number_field + sage: G._galois_closure # needs sage.rings.number_field Number Field in b with defining polynomial x^6 + 12*x^4 + 36*x^2 + 140 """ return self._gcdata[0] @@ -122,6 +123,7 @@ def splitting_field(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K = NumberField(x^3 - x + 1, 'a') sage: K.galois_group(names='b').splitting_field() @@ -139,9 +141,9 @@ def _gc_map(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group(names='b') - sage: G._gc_map + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group(names='b') # needs sage.rings.number_field + sage: G._gc_map # needs sage.rings.number_field Ring morphism: From: Number Field in a with defining polynomial x^3 + 2*x + 2 To: Number Field in b with defining polynomial x^6 + 12*x^4 + 36*x^2 + 140 @@ -162,9 +164,9 @@ def _field(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G._field + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._field # needs sage.rings.number_field Number Field in a with defining polynomial x^3 + 2*x + 2 """ return NotImplemented @@ -177,9 +179,9 @@ def _repr_(self): sage: from sage.groups.galois_group import GaloisGroup_perm sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: GaloisGroup_perm._repr_(G) + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: GaloisGroup_perm._repr_(G) # needs sage.rings.number_field 'Galois group of x^3 + 2*x + 2' """ f = self._field.defining_polynomial() @@ -193,6 +195,7 @@ def top_field(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: L = K.galois_closure('b') @@ -212,6 +215,7 @@ def _field_degree(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: L. = K.extension(x^2 + 3*a^2 + 8) @@ -229,11 +233,11 @@ def _field_degree(self): This behavior may change in the future:: - sage: GL._field_degree + sage: GL._field_degree # needs sage.rings.number_field 6 - sage: GL.transitive_label() + sage: GL.transitive_label() # needs sage.rings.number_field '6T2' - sage: GL + sage: GL # needs sage.rings.number_field Galois group 6T2 ([3]2) with order 6 of x^2 + 3*a^2 + 8 """ try: @@ -249,9 +253,9 @@ def transitive_label(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) - sage: G = K.galois_group() - sage: G.transitive_label() + sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G.transitive_label() # needs sage.rings.number_field '8T44' """ return "%sT%s" % (self._field_degree, self.transitive_number()) @@ -263,10 +267,10 @@ def is_galois(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) - sage: G = K.galois_group() + sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field sage: from sage.groups.galois_group import GaloisGroup_perm - sage: GaloisGroup_perm.is_galois(G) + sage: GaloisGroup_perm.is_galois(G) # needs sage.rings.number_field False """ return self.order() == self._field_degree @@ -283,6 +287,7 @@ def _ambient_group(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: L. = NumberField(x^4 + 1) sage: G = L.galois_group() @@ -309,6 +314,7 @@ def fixed_field(self, name=None, polred=None, threshold=None): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(3^12) sage: g = k.galois_group()([8]) sage: k0, embed = g.fixed_field() @@ -323,11 +329,12 @@ def _gcdata(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: L. = NumberField(x^4 + 1) sage: G = L.galois_group() sage: H = G.decomposition_group(L.primes_above(3)[0]) - sage: H.splitting_field() # indirect doctest + sage: H.splitting_field() # indirect doctest Number Field in a with defining polynomial x^4 + 1 """ return self._ambient_group._gcdata @@ -355,9 +362,9 @@ def transitive_number(self, algorithm=None, recompute=False): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G.transitive_number() + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G.transitive_number() # needs sage.rings.number_field 2 """ @@ -371,9 +378,9 @@ def _gens(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=False) - sage: G._gens + sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field + sage: G._gens # needs sage.rings.number_field [(1,2,3,5), (1,4,3,2,5)] """ return NotImplemented @@ -383,9 +390,9 @@ def __init__(self, field, algorithm=None, names=None, gc_numbering=False): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: TestSuite(G).run() + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: TestSuite(G).run() # needs sage.rings.number_field """ self._field = field self._default_algorithm = algorithm @@ -414,12 +421,12 @@ def _deg(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=False); G + sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=False); G # needs sage.rings.number_field Galois group 5T3 (5:4) with order 20 of x^5 - 2 - sage: G._deg + sage: G._deg # needs sage.rings.number_field 5 - sage: G = K.galois_group(gc_numbering=True); G._deg + sage: G = K.galois_group(gc_numbering=True); G._deg # needs sage.rings.number_field 20 """ if self._gc_numbering: @@ -437,8 +444,9 @@ def _domain(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) + sage: K. = NumberField(x^5 - 2) sage: G = K.galois_group(gc_numbering=False); G Galois group 5T3 (5:4) with order 20 of x^5 - 2 sage: G._domain @@ -456,9 +464,9 @@ def _domain_to_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=False) - sage: G._domain_to_gap[5] + sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field + sage: G._domain_to_gap[5] # needs sage.rings.number_field 5 """ return dict((key, i+1) for i, key in enumerate(self._domain)) @@ -471,9 +479,9 @@ def _domain_from_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=True) - sage: G._domain_from_gap[20] + sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=True) # needs sage.rings.number_field + sage: G._domain_from_gap[20] # needs sage.rings.number_field 20 """ return dict((i+1, key) for i, key in enumerate(self._domain)) @@ -484,7 +492,7 @@ def ngens(self): EXAMPLES:: - sage: QuadraticField(-23, 'a').galois_group().ngens() + sage: QuadraticField(-23, 'a').galois_group().ngens() # needs sage.rings.number_field 1 """ return len(self._gens) @@ -499,7 +507,7 @@ def __init__(self, field, generator_orders, algorithm=None, gen_names='sigma'): TESTS:: - sage: TestSuite(GF(9).galois_group()).run() + sage: TestSuite(GF(9).galois_group()).run() # needs sage.rings.finite_rings """ self._field = field self._default_algorithm = algorithm @@ -513,7 +521,7 @@ def is_galois(self): EXAMPLES:: - sage: GF(9).galois_group().is_galois() + sage: GF(9).galois_group().is_galois() # needs sage.rings.finite_rings True """ return True @@ -525,7 +533,7 @@ def _gcdata(self): EXAMPLES:: - sage: GF(3^2).galois_group()._gcdata + sage: GF(3^2).galois_group()._gcdata # needs sage.rings.finite_rings (Finite Field in z2 of size 3^2, Identity endomorphism of Finite Field in z2 of size 3^2) """ @@ -541,7 +549,7 @@ def permutation_group(self): EXAMPLES:: - sage: GF(3^10).galois_group().permutation_group() + sage: GF(3^10).galois_group().permutation_group() # needs sage.rings.finite_rings Permutation Group with generators [(1,2,3,4,5,6,7,8,9,10)] """ return PermutationGroup(gap_group=self._gap_().RegularActionHomomorphism().Image()) @@ -573,11 +581,11 @@ def transitive_number(self, algorithm=None, recompute=False): EXAMPLES:: - sage: GF(2^8).galois_group().transitive_number() + sage: GF(2^8).galois_group().transitive_number() # needs sage.rings.finite_rings 1 - sage: GF(3^32).galois_group().transitive_number() + sage: GF(3^32).galois_group().transitive_number() # needs sage.rings.finite_rings 33 - sage: GF(2^60).galois_group().transitive_number() + sage: GF(2^60).galois_group().transitive_number() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: transitive database only computed up to degree 47 @@ -597,9 +605,9 @@ def signature(self): EXAMPLES:: - sage: GF(3^2).galois_group().signature() + sage: GF(3^2).galois_group().signature() # needs sage.rings.finite_rings -1 - sage: GF(3^3).galois_group().signature() + sage: GF(3^3).galois_group().signature() # needs sage.rings.finite_rings 1 """ return ZZ(1) if (self._field.degree() % 2) else ZZ(-1) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 319570c98ff..83b53ab6e7d 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -29,7 +29,7 @@ sage: K = GF(3^6,'b') sage: b = K.gen() sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: discrete_log(a, b, K.order() - 1) 210 - Linear relation finder:: @@ -60,7 +60,7 @@ - Discrete logs:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F = GF(37^2,'a') sage: E = EllipticCurve(F,[1,1]) sage: F. = GF(37^2,'a') @@ -75,7 +75,7 @@ - Linear relation finder:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F. = GF(3^6,'a') sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) @@ -87,18 +87,18 @@ - Orders of elements:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: from sage.groups.generic import order_from_multiple, order_from_bounds sage: k. = GF(5^5) sage: E = EllipticCurve(k,[2,4]) sage: P = E(3*a^4 + 3*a , 2*a + 1 ) - sage: M = E.cardinality(); M + sage: M = E.cardinality(); M # needs sage.rings.number_field 3227 - sage: plist = M.prime_factors() - sage: order_from_multiple(P, M, plist, operation='+') + sage: plist = M.prime_factors() # needs sage.rings.number_field + sage: order_from_multiple(P, M, plist, operation='+') # needs sage.rings.number_field 3227 sage: Q = E(0,2) - sage: order_from_multiple(Q, M, plist, operation='+') + sage: order_from_multiple(Q, M, plist, operation='+') # needs sage.rings.number_field 7 sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') 7 @@ -162,7 +162,7 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): Idempotence is detected, making the following fast:: - sage: multiple(1,10^1000) + sage: multiple(1, 10^1000) 1 sage: # needs sage.schemes @@ -433,13 +433,13 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): An additive example in an elliptic curve group:: sage: F. = GF(37^5) # needs sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings - sage: P = E.lift_x(a); P # needs sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings sage.schemes + sage: P = E.lift_x(a); P # needs sage.rings.finite_rings sage.schemes (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: - sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # needs sage.rings.finite_rings + sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # needs sage.rings.finite_rings sage.schemes 69327408 AUTHOR: @@ -763,7 +763,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i an upper bound here:: sage: # needs sage.rings.number_field - sage: K. = QuadraticField(23) + sage: K. = QuadraticField(23) # needs sage.libs.flint sage: eps = 5*a - 24 # a fundamental unit sage: eps.multiplicative_order() +Infinity @@ -786,7 +786,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i An additive example: elliptic curve DLOG:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F = GF(37^2,'a') sage: E = EllipticCurve(F, [1,1]) sage: F. = GF(37^2,'a') @@ -835,7 +835,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i ... ValueError: no discrete log of 2 found to base 1 - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F = GF(37^2,'a') sage: E = EllipticCurve(F, [1,1]) sage: F. = GF(37^2,'a') @@ -1214,16 +1214,16 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: # needs sage.rings.finite_rings sage.schemes - sage: E = EllipticCurve(k, [2,4]) - sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: # needs sage.rings.number_field sage.schemes + sage: E = EllipticCurve(k, [2,4]) # needs sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a, 2*a + 1) # needs sage.rings.finite_rings sage: M = E.cardinality(); M 3227 sage: F = M.factor() - sage: order_from_multiple(P, M, factorization=F, operation='+') + sage: order_from_multiple(P, M, factorization=F, operation='+') # needs sage.rings.finite_rings 3227 sage: Q = E(0,2) - sage: order_from_multiple(Q, M, factorization=F, operation='+') + sage: order_from_multiple(Q, M, factorization=F, operation='+') # needs sage.rings.finite_rings 7 sage: K. = CyclotomicField(230) # needs sage.rings.number_field @@ -1440,7 +1440,7 @@ def merge_points(P1, P2, operation='+', sage: od == lcm(ob, oc) True - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) sage: P.order() diff --git a/src/sage/groups/group_exp.py b/src/sage/groups/group_exp.py index ffae5e73cb2..e019b0cbff4 100644 --- a/src/sage/groups/group_exp.py +++ b/src/sage/groups/group_exp.py @@ -71,8 +71,8 @@ class GroupExp(Functor): sage: L = RootSystem(['A',2]).ambient_space() sage: EL = E(L) - sage: W = L.weyl_group(prefix="s") - sage: s2 = W.simple_reflection(2) + sage: W = L.weyl_group(prefix="s") # needs sage.rings.number_field + sage: s2 = W.simple_reflection(2) # needs sage.rings.number_field sage: def my_action(mu): ....: return s2.action(mu) sage: from sage.categories.morphism import SetMorphism @@ -82,9 +82,9 @@ class GroupExp(Functor): Generic endomorphism of Multiplicative form of Ambient space of the Root system of type ['A', 2] sage: v = L.an_element(); v (2, 2, 3) - sage: y = F(EL(v)); y + sage: y = F(EL(v)); y # needs sage.rings.number_field (2, 3, 2) - sage: y.parent() + sage: y.parent() # needs sage.rings.number_field Multiplicative form of Ambient space of the Root system of type ['A', 2] """ diff --git a/src/sage/groups/group_semidirect_product.py b/src/sage/groups/group_semidirect_product.py index 3ac629b9411..67ada01f508 100644 --- a/src/sage/groups/group_semidirect_product.py +++ b/src/sage/groups/group_semidirect_product.py @@ -33,7 +33,8 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) # indirect doctest + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on Weyl Group of type ['A', 3] @@ -67,6 +68,7 @@ def __invert__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: L = RootSystem(['A',2]).root_lattice() sage: from sage.groups.group_exp import GroupExp sage: EL = GroupExp()(L) @@ -95,6 +97,7 @@ def to_opposite(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: L = RootSystem(['A',2]).root_lattice(); L Root lattice of the Root system of type ['A', 2] sage: from sage.groups.group_exp import GroupExp @@ -117,7 +120,10 @@ def to_opposite(self): sage: g.to_opposite() t[-2*alpha[1]] * s1*s2 sage: g.to_opposite().parent() - Semidirect product of Multiplicative form of Root lattice of the Root system of type ['A', 2] acted upon by Weyl Group of type ['A', 2] (as a matrix group acting on the root lattice) + Semidirect product of + Multiplicative form of Root lattice of the Root system of type ['A', 2] + acted upon by Weyl Group of type ['A', 2] + (as a matrix group acting on the root lattice) """ par = self.parent() Gop = par.opposite_semidirect_product() @@ -218,6 +224,8 @@ class GroupSemidirectProduct(CartesianProduct): t[(1, 0)] sage: x^2 t[(2, 0)] + + sage: # needs sage.rings.number_field sage: cartan_type = CartanType(['A',2]) sage: W = WeylGroup(cartan_type, prefix="s") sage: def twist(w,v): @@ -247,8 +255,9 @@ def __init__(self, G, H, twist=None, act_to_right=True, prefix0=None, ....: return y sage: import __main__ sage: __main__.twist = twist - sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) - sage: TestSuite(G).run() + sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist) + sage: TestSuite(G).run() # needs sage.rings.number_field The ``__main__`` business is a trick to pass the pickling test. """ @@ -289,7 +298,8 @@ def act_to_right(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist).act_to_right() + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist).act_to_right() True """ return self._act_to_right @@ -302,7 +312,8 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) # indirect doctest + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space) @@ -324,8 +335,9 @@ def _element_constructor_(self, x): ....: return y sage: import __main__ sage: __main__.twist = twist - sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist).an_element() - sage: TestSuite(g).run() + sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist).an_element() + sage: TestSuite(g).run() # needs sage.rings.number_field """ def type_error(): raise TypeError(f"{x} cannot be converted into an element of {self}") @@ -354,10 +366,10 @@ def one(self): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: one = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't').one(); one + sage: one = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t').one(); one 1 sage: one.cartesian_projection(0) [1 0] @@ -378,7 +390,7 @@ def group_generators(self): sage: import __main__ sage: __main__.twist = twist sage: EZ = GroupExp()(ZZ) - sage: GroupSemidirectProduct(EZ,EZ,twist,print_tuple=True).group_generators() + sage: GroupSemidirectProduct(EZ, EZ, twist, print_tuple=True).group_generators() ((1, 0), (0, 1)) """ def has_gens(G): @@ -404,10 +416,10 @@ def product(self, x, y): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: S = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't') + sage: S = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t') sage: g = G([[2,1],[3,1]]); g [2 1] [3 1] @@ -442,7 +454,8 @@ def opposite_semidirect_product(self): sage: G = GL(2,QQ) sage: L = QQ^2 sage: EL = GroupExp()(L) - sage: H = GroupSemidirectProduct(G, EL, twist = lambda g,v: EL(g*v.value), prefix1 = 't'); H + sage: H = GroupSemidirectProduct(G, EL, prefix1='t', + ....: twist=lambda g,v: EL(g*v.value)); H Semidirect product of General Linear Group of degree 2 over Rational Field acting on Multiplicative form of Vector space of dimension 2 over Rational Field @@ -479,8 +492,9 @@ def construction(self): sage: def twist(x,y): ....: return y - sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"), twist) - sage: H.construction() + sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + ....: WeylGroup(['A',3],prefix="t"), twist) + sage: H.construction() # needs sage.rings.number_field """ return None diff --git a/src/sage/groups/indexed_free_group.py b/src/sage/groups/indexed_free_group.py index 0cbcf9b8a2d..287ab021b1d 100644 --- a/src/sage/groups/indexed_free_group.py +++ b/src/sage/groups/indexed_free_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat """ Indexed Free Groups diff --git a/src/sage/groups/kernel_subgroup.py b/src/sage/groups/kernel_subgroup.py index 024e8f47b3b..605778784e4 100644 --- a/src/sage/groups/kernel_subgroup.py +++ b/src/sage/groups/kernel_subgroup.py @@ -94,8 +94,8 @@ def defining_morphism(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.defining_morphism() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.defining_morphism() # needs sage.rings.number_field Conversion via _from_cactus_group_element map: From: Cactus Group with 3 fruit To: Symmetric group of order 3! as a permutation group @@ -109,8 +109,8 @@ def ambient(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.ambient() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.ambient() # needs sage.rings.number_field Cactus Group with 3 fruit """ return self._morphism.domain() @@ -121,8 +121,8 @@ def _an_element_(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.an_element() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.an_element() # needs sage.rings.number_field 1 """ return self.element_class(self, self.ambient().one()) @@ -133,8 +133,8 @@ def lift(self, x): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.lift(PJ3.an_element()).parent() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.lift(PJ3.an_element()).parent() # needs sage.rings.number_field Cactus Group with 3 fruit """ return x.value @@ -145,6 +145,7 @@ def retract(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -161,6 +162,7 @@ def _element_constructor_(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -200,6 +202,7 @@ def _mul_(self, other): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -215,6 +218,7 @@ def __invert__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) diff --git a/src/sage/groups/libgap_mixin.py b/src/sage/groups/libgap_mixin.py index 6fb27280d8b..cf08db6e142 100644 --- a/src/sage/groups/libgap_mixin.py +++ b/src/sage/groups/libgap_mixin.py @@ -250,8 +250,8 @@ def conjugacy_classes_representatives(self): EXAMPLES:: - sage: G = SU(3,GF(2)) - sage: len(G.conjugacy_classes_representatives()) + sage: G = SU(3,GF(2)) # needs sage.libs.pari + sage: len(G.conjugacy_classes_representatives()) # needs sage.libs.pari 16 sage: G = GL(2,GF(3)) @@ -261,7 +261,7 @@ def conjugacy_classes_representatives(self): [0 1], [1 1], [0 2], [1 2], [1 0], [1 2], [1 1], [0 1] ) - sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) + sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) # needs sage.libs.pari 36 :: @@ -356,8 +356,8 @@ def center(self): EXAMPLES:: - sage: G = SU(3, GF(2)) - sage: G.center() + sage: G = SU(3, GF(2)) # needs sage.libs.pari + sage: G.center() # needs sage.libs.pari Subgroup with 1 generators ( [a 0 0] [0 a 0] @@ -374,7 +374,7 @@ def center(self): [0 2 0] [0 0 2] ) of General Linear Group of degree 3 over Finite Field of size 3 - sage: GU(3, GF(2)).center() + sage: GU(3, GF(2)).center() # needs sage.libs.pari Subgroup with 1 generators ( [a + 1 0 0] [ 0 a + 1 0] @@ -394,8 +394,8 @@ def center(self): [0 0 1], [0 1 1] ) - sage: GL = groups.matrix.GL(3, ZZ) - sage: GL.center() + sage: GL = groups.matrix.GL(3, ZZ) # needs sage.modules + sage: GL.center() # needs sage.modules Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -414,6 +414,7 @@ def centralizer(self, g): EXAMPLES:: + sage: # needs sage.modules sage: G = groups.matrix.GL(2, 3) sage: g = G([[1,1], [1,0]]) sage: C = G.centralizer(g); C @@ -424,12 +425,12 @@ def centralizer(self, g): sage: C.order() 8 - sage: S = G.subgroup([G([[2,0],[0,2]]), G([[0,1],[2,0]])]); S + sage: S = G.subgroup([G([[2,0],[0,2]]), G([[0,1],[2,0]])]); S # needs sage.modules Subgroup with 2 generators ( [2 0] [0 1] [0 2], [2 0] ) of General Linear Group of degree 2 over Finite Field of size 3 - sage: G.centralizer(S) + sage: G.centralizer(S) # needs sage.modules Subgroup with 3 generators ( [2 0] [0 1] [2 2] [0 2], [2 0], [1 2] @@ -438,8 +439,8 @@ def centralizer(self, g): sage: all(G.order() == G.centralizer(x).order() * G.conjugacy_class(x).cardinality() ....: for x in G) True - sage: H = groups.matrix.Heisenberg(2) - sage: H.centralizer(H.an_element()) + sage: H = groups.matrix.Heisenberg(2) # needs sage.modules + sage: H.centralizer(H.an_element()) # needs sage.modules Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -475,8 +476,8 @@ def subgroups(self): EXAMPLES:: - sage: G = groups.matrix.GL(2, 2) - sage: G.subgroups() + sage: G = groups.matrix.GL(2, 2) # needs sage.modules + sage: G.subgroups() # needs sage.modules [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [0 1] @@ -499,8 +500,8 @@ def subgroups(self): [1 1], [0 1] ) of General Linear Group of degree 2 over Finite Field of size 2] - sage: H = groups.matrix.Heisenberg(2) - sage: H.subgroups() + sage: H = groups.matrix.Heisenberg(2) # needs sage.modules + sage: H.subgroups() # needs sage.modules Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -520,8 +521,8 @@ def conjugacy_classes_subgroups(self): EXAMPLES:: - sage: G = groups.matrix.GL(2,2) - sage: G.conjugacy_classes_subgroups() + sage: G = groups.matrix.GL(2,2) # needs sage.modules + sage: G.conjugacy_classes_subgroups() # needs sage.modules [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [1 1] @@ -536,8 +537,8 @@ def conjugacy_classes_subgroups(self): [1 1], [0 1] ) of General Linear Group of degree 2 over Finite Field of size 2] - sage: H = groups.matrix.Heisenberg(2) - sage: H.conjugacy_classes_subgroups() + sage: H = groups.matrix.Heisenberg(2) # needs sage.modules + sage: H.conjugacy_classes_subgroups() # needs sage.modules Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -561,6 +562,7 @@ def group_id(self): sage: SymmetricGroup(4).group_id() [24, 12] + sage: # needs sage.modules sage: G = groups.matrix.GL(2, 2) sage: G.group_id() [6, 1] @@ -568,8 +570,8 @@ def group_id(self): sage: G.id() [48, 29] - sage: G = groups.matrix.GL(2, ZZ) - sage: G.group_id() + sage: G = groups.matrix.GL(2, ZZ) # needs sage.modules + sage: G.group_id() # needs sage.modules Traceback (most recent call last): ... GAPError: Error, the group identification for groups of size infinity is not available @@ -589,12 +591,12 @@ def exponent(self): EXAMPLES:: - sage: G = groups.matrix.GL(2, 3) - sage: G.exponent() + sage: G = groups.matrix.GL(2, 3) # needs sage.modules + sage: G.exponent() # needs sage.modules 24 - sage: H = groups.matrix.Heisenberg(2) - sage: H.exponent() + sage: H = groups.matrix.Heisenberg(2) # needs sage.modules + sage: H.exponent() # needs sage.modules Traceback (most recent call last): ... NotImplementedError: group must be finite diff --git a/src/sage/groups/libgap_morphism.py b/src/sage/groups/libgap_morphism.py index 68af4bf5ae2..f9e41a930d0 100644 --- a/src/sage/groups/libgap_morphism.py +++ b/src/sage/groups/libgap_morphism.py @@ -108,7 +108,7 @@ class GroupMorphism_libgap(Morphism): [1 0] [1 1] sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -136,7 +136,7 @@ class GroupMorphism_libgap(Morphism): sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -151,7 +151,7 @@ class GroupMorphism_libgap(Morphism): ) sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -206,8 +206,8 @@ class GroupMorphism_libgap(Morphism): We check that :trac:`19780` is fixed:: - sage: G = groups.matrix.SO(3, 3) - sage: H = groups.matrix.GL(3, 3) + sage: G = groups.matrix.SO(3, 3) # needs sage.modules + sage: H = groups.matrix.GL(3, 3) # needs sage.modules sage: phi = G.hom([H(x) for x in G.gens()]) sage: phi(G.one()).parent() General Linear Group of degree 3 over Finite Field of size 3 @@ -400,11 +400,11 @@ def pushforward(self, J, *args, **kwds): a sage: x.parent() Finitely presented group < a, b | a, b^3 > - sage: G = GU(3,2) - sage: P = PGU(3,2) - sage: pr = Hom(G, P).natural_map() + sage: G = GU(3,2) # needs sage.libs.pari + sage: P = PGU(3,2) # needs sage.libs.pari + sage: pr = Hom(G, P).natural_map() # needs sage.libs.pari sage: GS = G.subgroup([G.gen(0)]) - sage: pr.pushforward(GS) + sage: pr.pushforward(GS) # needs sage.libs.pari Subgroup generated by [(3,4,5)(10,18,14)(11,19,15)(12,20,16)(13,21,17)] of (The projective general unitary group of degree 3 over Finite Field of size 2) """ dom = self.domain() @@ -443,9 +443,9 @@ def _call_(self, g): The following tests we do fall back behind :trac:`10659`:: - sage: O = WeylGroup(['D',6]) - sage: r = prod(O.gens()) - sage: r_ = r^-1 + sage: O = WeylGroup(['D',6]) # needs sage.rings.number_field + sage: r = prod(O.gens()) # needs sage.rings.number_field + sage: r_ = r^-1 # needs sage.rings.number_field sage: f = O.hom([r*x*r_ for x in O.gens()]) # long time (19s on sage.math, 2011) sage: [f(x) for x in O.gens()] # long time [ @@ -564,6 +564,7 @@ def section(self): EXAMPLES:: + sage: # needs sage.libs.pari sage: G = GU(3,2) sage: P = PGU(3,2) sage: pr = Hom(G, P).natural_map() @@ -644,6 +645,7 @@ def _element_constructor_(self, x, check=True, **options): A group homomorphism between a finitely presented group and a subgroup of a permutation group:: + sage: # needs sage.libs.pari sage: PG = PGU(6,2) sage: g, h = PG.gens() sage: p1 = h^-3*(h^-1*g^-1)^2*h*g*h^2*g^-1*h^2*g*h^-5*g^-1 diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx index c65afa447e5..a19ee98e9a1 100644 --- a/src/sage/groups/libgap_wrapper.pyx +++ b/src/sage/groups/libgap_wrapper.pyx @@ -244,8 +244,8 @@ class ParentLibGAP(SageObject): Checking that :trac:`19270` is fixed:: - sage: gens = [w.matrix() for w in WeylGroup(['B', 3])] - sage: G = MatrixGroup(gens) + sage: gens = [w.matrix() for w in WeylGroup(['B', 3])] # needs sage.rings.number_field + sage: G = MatrixGroup(gens) # needs sage.rings.number_field sage: import itertools sage: diagonals = itertools.product((1,-1), repeat=3) sage: subgroup_gens = [diagonal_matrix(L) for L in diagonals] @@ -256,7 +256,7 @@ class ParentLibGAP(SageObject): Check that :trac:`19010` is fixed:: - sage: G = WeylGroup(['B',3]) + sage: G = WeylGroup(['B',3]) # needs sage.rings.number_field sage: H = G.subgroup([G[14], G[17]]) sage: all(g*h in G and h*g in G for g in G for h in H) True diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index 1fcdccdd2bb..3204d2f7c01 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -176,7 +176,7 @@ def QuaternionMatrixGroupGF3(): TESTS:: - sage: groups.matrix.QuaternionGF3() # needs sage.rings.finite_rings + sage: groups.matrix.QuaternionGF3() # needs sage.modules sage.rings.finite_rings Matrix group over Finite Field of size 3 with 2 generators ( [1 1] [2 1] [1 2], [1 1] @@ -186,8 +186,8 @@ def QuaternionMatrixGroupGF3(): sage: QP = Q.as_permutation_group() # needs sage.rings.finite_rings sage: QP.is_isomorphic(QuaternionGroup()) # needs sage.rings.finite_rings True - sage: H = DihedralGroup(4) # needs sage.groups sage.rings.finite_rings - sage: H.order() # needs sage.groups sage.rings.finite_rings + sage: H = DihedralGroup(4) # needs sage.groups + sage: H.order() # needs sage.groups 8 sage: QP.is_abelian(), H.is_abelian() # needs sage.groups sage.rings.finite_rings (False, False) diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index a171742b60a..84ad62123a2 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -109,8 +109,8 @@ def as_permutation_group(self, algorithm=None, seed=None): sage: MS = MatrixSpace(GF(2), 5, 5) sage: A = MS([[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,0,0]]) - sage: G = MatrixGroup([A]) - sage: G.as_permutation_group().order() + sage: G = MatrixGroup([A]) # needs sage.libs.pari + sage: G.as_permutation_group().order() # needs sage.libs.pari 2 A finite subgroup of `GL(12,\ZZ)` as a permutation group:: @@ -165,7 +165,7 @@ def as_permutation_group(self, algorithm=None, seed=None): The above example in `GL(12,\ZZ)`, reduced modulo 7:: sage: MS = MatrixSpace(GF(7), 12, 12) - sage: G = MatrixGroup([MS(g) for g in GG.GeneratorsOfGroup()]) + sage: G = MatrixGroup([MS(g) for g in GG.GeneratorsOfGroup()]) # needs sage.libs.pari sage: G.cardinality() 21499084800 sage: P = G.as_permutation_group() @@ -179,10 +179,11 @@ def as_permutation_group(self, algorithm=None, seed=None): Check that :trac:`25706` still works after :trac:`26903`:: + sage: # needs sage.libs.pari sage: MG = GU(3,2).as_matrix_group() sage: PG = MG.as_permutation_group() sage: mg = MG.an_element() - sage: PG(mg).order() # particular element depends on the set of GAP packages installed + sage: PG(mg).order() # particular element depends on the set of GAP packages installed 6 """ # Note that the output of IsomorphismPermGroup() depends on @@ -212,8 +213,8 @@ def module_composition_factors(self, algorithm=None): sage: F = GF(3); MS = MatrixSpace(F,4,4) sage: M = MS(0) sage: M[0,1]=1;M[1,2]=1;M[2,3]=1;M[3,0]=1 - sage: G = MatrixGroup([M]) - sage: G.module_composition_factors() + sage: G = MatrixGroup([M]) # needs sage.libs.pari + sage: G.module_composition_factors() # needs sage.libs.pari [(Finite Field of size 3, 1, True), (Finite Field of size 3, 1, True), (Finite Field of size 3, 2, True)] @@ -286,6 +287,7 @@ def invariant_generators(self): sage: G.invariant_generators() [x1^2 + 3*x2^2, x1^6 + 15*x1^4*x2^2 + 15*x1^2*x2^4 + 33*x2^6] + sage: # needs sage.rings.number_field sage: F = CyclotomicField(8) sage: z = F.gen() sage: a = z+1/z @@ -449,6 +451,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): Tetrahedral Group:: + sage: # needs sage.rings.number_field sage.symbolic sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: Tetra.molien_series(prec=30) @@ -479,20 +482,22 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): Octahedral Group:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(8) - sage: a = v-v^3 #sqrt(2) + sage: a = v-v^3 #sqrt(2) sage: i = v^2 - sage: Octa = MatrixGroup([(-1+i)/2, (-1+i)/2, (1+i)/2, (-1-i)/2], + sage: Octa = MatrixGroup([(-1+i)/2, (-1+i)/2, (1+i)/2, (-1-i)/2], # needs sage.symbolic ....: [(1+i)/a, 0, 0, (1-i)/a]) - sage: Octa.molien_series(prec=30) + sage: Octa.molien_series(prec=30) # needs sage.symbolic 1 + t^8 + t^12 + t^16 + t^18 + t^20 + 2*t^24 + t^26 + t^28 + O(t^30) Icosahedral Group:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(10) sage: z5 = v^2 sage: i = z5^5 - sage: a = 2*z5^3 + 2*z5^2 + 1 #sqrt(5) + sage: a = 2*z5^3 + 2*z5^2 + 1 #sqrt(5) sage: Ico = MatrixGroup([[z5^3,0, 0,z5^2], ....: [0,1, -1,0], ....: [(z5^4-z5)/a, (z5^2-z5^3)/a, (z5^2-z5^3)/a, -(z5^4-z5)/a]]) @@ -511,7 +516,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): sage: K = GF(5) sage: S = MatrixGroup(SymmetricGroup(4)) - sage: G = MatrixGroup([matrix(K, 4, 4, [K(y) for u in m.list() for y in u]) + sage: G = MatrixGroup([matrix(K, 4, 4, [K(y) for u in m.list() for y in u]) # needs sage.libs.pari ....: for m in S.gens()]) sage: G.molien_series(return_series=False) 1/(t^10 - t^9 - t^8 + 2*t^5 - t^2 - t + 1) @@ -632,6 +637,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.number_field sage: G = MatrixGroup(CyclicPermutationGroup(4)) sage: chi = G.character(G.character_table()[3]) sage: K. = CyclotomicField(4) @@ -645,6 +651,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) @@ -659,6 +666,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.number_field sage.symbolic sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: chi = Tetra.character(Tetra.character_table()[4]) @@ -717,6 +725,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.finite_rings sage: K = GF(3^2,'t') sage: G = MatrixGroup([matrix(K, 2, 2, [0,K.gen(), 1,0])]) sage: R. = GF(3)[] @@ -725,6 +734,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.finite_rings sage: K = GF(3^2,'t') sage: G = MatrixGroup([matrix(GF(3), 2, 2, [0,1, 1,0])]) sage: R. = K[] @@ -866,6 +876,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) diff --git a/src/sage/groups/matrix_gps/group_element_gap.pyx b/src/sage/groups/matrix_gps/group_element_gap.pyx index c26ddebde71..6e8150aaad7 100644 --- a/src/sage/groups/matrix_gps/group_element_gap.pyx +++ b/src/sage/groups/matrix_gps/group_element_gap.pyx @@ -223,7 +223,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): sage: F = GF(3); MS = MatrixSpace(F,2,2) sage: G = MatrixGroup([MS([1,1,0,1])]) sage: g = G.gen(0) - sage: M = matrix(GF(9), g); M; parent(M) + sage: M = matrix(GF(9), g); M; parent(M) # needs sage.libs.pari [1 1] [0 1] Full MatrixSpace of 2 by 2 dense matrices over Finite Field in z2 of size 3^2 diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 4cd6f1d73b1..6fbb4e1bdc1 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -146,9 +146,9 @@ def GL(n, R, var='a'): sage: groups.matrix.GL(2, 3) # needs sage.groups sage.rings.finite_rings General Linear Group of degree 2 over Finite Field of size 3 - sage: groups.matrix.GL(1, ZZ).category() # needs sage.groups + sage: groups.matrix.GL(1, ZZ).category() # needs sage.groups sage.modules Category of groups - sage: groups.matrix.GL(1, QQ).category() # needs sage.groups + sage: groups.matrix.GL(1, QQ).category() # needs sage.groups sage.modules Category of infinite groups """ degree, ring = normalize_args_vectorspace(n, R, var='a') @@ -241,7 +241,7 @@ def SL(n, R, var='a'): TESTS:: - sage: groups.matrix.SL(2, 3) # needs sage.rings.finite_rings + sage: groups.matrix.SL(2, 3) # needs sage.modules sage.rings.finite_rings Special Linear Group of degree 2 over Finite Field of size 3 """ degree, ring = normalize_args_vectorspace(n, R, var='a') diff --git a/src/sage/groups/matrix_gps/linear_gap.py b/src/sage/groups/matrix_gps/linear_gap.py index 37d33d5d2be..9f608ab5c62 100644 --- a/src/sage/groups/matrix_gps/linear_gap.py +++ b/src/sage/groups/matrix_gps/linear_gap.py @@ -15,9 +15,9 @@ class LinearMatrixGroup_gap(NamedMatrixGroup_gap, LinearMatrixGroup_generic, Fin Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field sage: G = GL(3,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field True """ pass diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index d788fc48e9d..ad452396058 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -191,7 +191,7 @@ def subgroup(self, generators, check=True): EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field sage: UCF = UniversalCyclotomicField() sage: G = GL(3, UCF) sage: e3 = UCF.gen(3); e5 = UCF.gen(5) @@ -316,8 +316,8 @@ def _repr_option(self, key): EXAMPLES:: - sage: SO3 = groups.matrix.SO(3, QQ) # needs sage.groups - sage: SO3._repr_option('element_ascii_art') # needs sage.groups + sage: SO3 = groups.matrix.SO(3, QQ) # needs sage.groups sage.modules + sage: SO3._repr_option('element_ascii_art') # needs sage.groups sage.modules True """ if key == 'element_ascii_art': diff --git a/src/sage/groups/matrix_gps/matrix_group_gap.py b/src/sage/groups/matrix_gps/matrix_group_gap.py index b4c06acbd0f..9205951ccdd 100644 --- a/src/sage/groups/matrix_gps/matrix_group_gap.py +++ b/src/sage/groups/matrix_gps/matrix_group_gap.py @@ -154,8 +154,8 @@ def __iter__(self): infinite groups can be dealt with:: sage: import itertools - sage: W = WeylGroup(["A",3,1]) - sage: list(itertools.islice(W, int(4))) + sage: W = WeylGroup(["A",3,1]) # needs sage.rings.number_field + sage: list(itertools.islice(W, int(4))) # needs sage.rings.number_field [ [1 0 0 0] [-1 1 0 1] [ 1 0 0 0] [ 1 0 0 0] [0 1 0 0] [ 0 1 0 0] [ 1 -1 1 0] [ 0 1 0 0] @@ -238,6 +238,7 @@ def subgroup(self, generators, check=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: UCF = UniversalCyclotomicField() sage: G = GL(3, UCF) sage: e3 = UCF.gen(3); e5 = UCF.gen(5) @@ -249,6 +250,7 @@ def subgroup(self, generators, check=True): [ 4 3 2] ) of General Linear Group of degree 3 over Universal Cyclotomic Field + sage: # needs sage.rings.number_field sage: CF3 = CyclotomicField(3) sage: G = GL(3, CF3) sage: e3 = CF3.gen() @@ -262,15 +264,17 @@ def subgroup(self, generators, check=True): TESTS:: - sage: TestSuite(G).run() - sage: TestSuite(S).run() + sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(S).run() # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',7]) sage: s = W.simple_reflections() sage: G = W.subgroup([s[1]]) sage: G.category() Category of finite groups + sage: # needs sage.rings.number_field sage: W = WeylGroup(['A',2]) sage: s = W.simple_reflections() sage: G = W.subgroup([s[1]]) diff --git a/src/sage/groups/matrix_gps/named_group.py b/src/sage/groups/matrix_gps/named_group.py index 55c64763b03..dea27976793 100644 --- a/src/sage/groups/matrix_gps/named_group.py +++ b/src/sage/groups/matrix_gps/named_group.py @@ -293,7 +293,7 @@ def __richcmp__(self, other, op): True sage: # needs sage.rings.finite_rings - sage: G = groups.matrix.GL(4,2) + sage: G = groups.matrix.GL(4,2) # needs sage.modules sage: H = MatrixGroup(G.gens()) sage: G == H True diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index e1e335743e7..e4f4c07e2b6 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -324,7 +324,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): TESTS:: sage: TestSuite(GO3).run() - sage: groups.matrix.GO(2, 3, e=-1) # needs sage.rings.finite_rings + sage: groups.matrix.GO(2, 3, e=-1) # needs sage.modules sage.rings.finite_rings General Orthogonal Group of degree 2 and form parameter -1 over Finite Field of size 3 """ return _OG(n, R, False, e=e, var=var, invariant_form=invariant_form) @@ -434,7 +434,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): TESTS:: sage: TestSuite(SO3m).run() # needs sage.rings.number_field - sage: groups.matrix.SO(2, 3, e=1) # needs sage.rings.number_field + sage: groups.matrix.SO(2, 3, e=1) # needs sage.modules sage.rings.number_field Special Orthogonal Group of degree 2 and form parameter 1 over Finite Field of size 3 """ return _OG(n, R, True, e=e, var=var, invariant_form=invariant_form) diff --git a/src/sage/groups/matrix_gps/orthogonal_gap.py b/src/sage/groups/matrix_gps/orthogonal_gap.py index 17dabb698f2..0a5f75ba17f 100644 --- a/src/sage/groups/matrix_gps/orthogonal_gap.py +++ b/src/sage/groups/matrix_gps/orthogonal_gap.py @@ -31,9 +31,9 @@ class OrthogonalMatrixGroup_gap(OrthogonalMatrixGroup_generic, NamedMatrixGroup_ Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field sage: G = GO(3,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field True """ @cached_method diff --git a/src/sage/groups/matrix_gps/symplectic.py b/src/sage/groups/matrix_gps/symplectic.py index 0038e2bcb2b..f2521c0ff82 100644 --- a/src/sage/groups/matrix_gps/symplectic.py +++ b/src/sage/groups/matrix_gps/symplectic.py @@ -135,7 +135,7 @@ def Sp(n, R, var='a', invariant_form=None): sage: TestSuite(Sp4).run() sage: TestSuite(Sp4m).run() - sage: groups.matrix.Sp(2, 3) # needs sage.rings.finite_rings + sage: groups.matrix.Sp(2, 3) # needs sage.modules sage.rings.finite_rings Symplectic Group of degree 2 over Finite Field of size 3 sage: G = Sp(4,5) diff --git a/src/sage/groups/matrix_gps/symplectic_gap.py b/src/sage/groups/matrix_gps/symplectic_gap.py index adeefea218f..16cde0ee961 100644 --- a/src/sage/groups/matrix_gps/symplectic_gap.py +++ b/src/sage/groups/matrix_gps/symplectic_gap.py @@ -27,7 +27,7 @@ class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_ EXAMPLES:: - sage: Sp(2,4) + sage: Sp(2,4) # needs sage.libs.pari Symplectic Group of degree 2 over Finite Field in a of size 2^2 sage: latex(Sp(4,5)) @@ -37,9 +37,9 @@ class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_ Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field sage: G = Sp(4,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field True """ diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 9314178376b..81a49c9ff88 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -216,7 +216,7 @@ def GU(n, R, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: # needs sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) sage: G = GU(3, UCF) @@ -257,7 +257,7 @@ def GU(n, R, var='a', invariant_form=None): TESTS:: - sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(G).run() # needs sage.libs.gap sage.rings.number_field sage: groups.matrix.GU(2, 3) # needs sage.groups sage.rings.finite_rings General Unitary Group of degree 2 over Finite Field in a of size 3^2 """ @@ -352,7 +352,7 @@ def SU(n, R, var='a', invariant_form=None): TESTS:: sage: TestSuite(Gm).run() # needs sage.rings.number_field - sage: groups.matrix.SU(2, 3) # needs sage.rings.finite_rings + sage: groups.matrix.SU(2, 3) # needs sage.modules sage.rings.finite_rings Special Unitary Group of degree 2 over Finite Field in a of size 3^2 """ return _UG(n, R, True, var=var, invariant_form=invariant_form) diff --git a/src/sage/groups/matrix_gps/unitary_gap.py b/src/sage/groups/matrix_gps/unitary_gap.py index 02b0456decb..5119096af56 100644 --- a/src/sage/groups/matrix_gps/unitary_gap.py +++ b/src/sage/groups/matrix_gps/unitary_gap.py @@ -29,9 +29,9 @@ class UnitaryMatrixGroup_gap(UnitaryMatrixGroup_generic, NamedMatrixGroup_gap, F Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap - sage: G = GU(3,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field + sage: G = GU(3,3) # needs sage.libs.pari + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.libs.pari sage.rings.number_field True """ @@ -46,8 +46,8 @@ def invariant_form(self): EXAMPLES:: - sage: G32 = GU(3,2) - sage: G32.invariant_form() + sage: G32 = GU(3,2) # needs sage.libs.pari + sage: G32.invariant_form() # needs sage.libs.pari [0 0 1] [0 1 0] [1 0 0] diff --git a/src/sage/groups/misc_gps/argument_groups.py b/src/sage/groups/misc_gps/argument_groups.py index d6128ee7fdb..1c949a57f51 100644 --- a/src/sage/groups/misc_gps/argument_groups.py +++ b/src/sage/groups/misc_gps/argument_groups.py @@ -191,13 +191,13 @@ def _eq_(self, other): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I) == C(I) + sage: C(I) == C(I) # needs sage.symbolic True As we do not have normalization in :class:`ArgumentByElement`, then following, although equal, is not equal:: - sage: C(I) == C(2*I) + sage: C(I) == C(2*I) # needs sage.symbolic False """ return self._element_ == other._element_ @@ -256,12 +256,12 @@ def _act_on_(self, other, is_left): :: sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup - sage: C = ArgumentByElementGroup(SR) - sage: C(-1) * 4 + sage: C = ArgumentByElementGroup(SR) # needs sage.symbolic + sage: C(-1) * 4 # needs sage.symbolic -4 sage: _.parent() Symbolic Ring - sage: 4 * C(-1) + sage: 4 * C(-1) # needs sage.symbolic -4 sage: _.parent() Symbolic Ring @@ -704,10 +704,10 @@ def _element_constructor_(self, data, exponent=None, **kwds): sage: U(exponent=1/3) zeta3 - sage: C. = CyclotomicField(6) - sage: z, U(z) + sage: C. = CyclotomicField(6) # needs sage.rings.number_field + sage: z, U(z) # needs sage.rings.number_field (z, zeta6) - sage: z^2, U(z^2) + sage: z^2, U(z^2) # needs sage.rings.number_field (z - 1, zeta3) sage: U(ZZ(-1)) @@ -805,12 +805,12 @@ def _create_element_in_extension_(self, exponent): sage: from sage.groups.misc_gps.argument_groups import UnitCircleGroup, RootsOfUnityGroup sage: C = UnitCircleGroup(QQ) - sage: C._create_element_in_extension_(2.12).parent() + sage: C._create_element_in_extension_(2.12).parent() # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ sage: U = RootsOfUnityGroup() - sage: U._create_element_in_extension_(2.12).parent() + sage: U._create_element_in_extension_(2.12).parent() # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ """ @@ -1070,7 +1070,7 @@ def __init__(self, parent, element, normalize=True): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(1+2*I) # indirect doctest + sage: C(1+2*I) # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) """ super().__init__(parent, element, normalize=normalize) @@ -1108,7 +1108,7 @@ def _repr_(self): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(2+3*I) # indirect doctest + sage: C(2+3*I) # indirect doctest # needs sage.symbolic e^(I*arg(2.00000000000000 + 3.00000000000000*I)) """ return 'e^(I*arg({}))'.format(self._element_) @@ -1131,7 +1131,7 @@ def _symbolic_(self, R=None): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(ZZ) - sage: C(-2)._symbolic_() + sage: C(-2)._symbolic_() # needs sage.symbolic -1 sage: _.parent() Symbolic Ring @@ -1153,7 +1153,7 @@ def _mul_(self, other): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I) * C(1 + I) # indirect doctest + sage: C(I) * C(1 + I) # indirect doctest # needs sage.symbolic e^(I*arg(-1.00000000000000 + 1.00000000000000*I)) """ P = self.parent() @@ -1168,12 +1168,12 @@ def __pow__(self, exponent): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I)^5 # indirect doctest + sage: C(I)^5 # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000*I)) sage: _.parent() Unit Circle Group with Argument of Elements in Complex Field with 53 bits of precision - sage: C(1+I)^3 # indirect doctest + sage: C(1+I)^3 # indirect doctest # needs sage.symbolic e^(I*arg(-2.00000000000000 + 2.00000000000000*I)) sage: _.parent() Unit Circle Group with Argument of Elements in @@ -1208,7 +1208,7 @@ def __invert__(self): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: ~C(I) # indirect doctest + sage: ~C(I) # indirect doctest # needs sage.symbolic e^(I*arg(-1.00000000000000*I)) """ P = self.parent() @@ -1233,7 +1233,7 @@ class ArgumentByElementGroup(AbstractArgumentGroup): sage: C = ArgumentByElementGroup(CC); C Unit Circle Group with Argument of Elements in Complex Field with 53 bits of precision - sage: C(1 + 2*I) + sage: C(1 + 2*I) # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) """ @@ -1283,7 +1283,7 @@ def _element_constructor_(self, data, **kwds): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(1 + 2*I) # indirect doctest + sage: C(1 + 2*I) # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) sage: C(1) e^(I*arg(1.00000000000000)) @@ -1545,7 +1545,7 @@ def _act_on_(self, other, is_left): -4.00000000000000 sage: _.parent() Complex Field with 53 bits of precision - sage: S(-1) * SR.var('x') + sage: S(-1) * SR.var('x') # needs sage.symbolic -x sage: _.parent() Symbolic Ring @@ -1760,9 +1760,10 @@ class ArgumentGroupFactory(UniqueFactory): sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup - sage: ArgumentGroup('UU') + sage: ArgumentGroup('UU') # needs sage.rings.number_field Group of Roots of Unity + sage: # needs sage.rings.number_field sage: ArgumentGroup(ZZ) Sign Group sage: ArgumentGroup(QQ) @@ -1772,19 +1773,19 @@ class ArgumentGroupFactory(UniqueFactory): sage: ArgumentGroup(AA) Sign Group - sage: ArgumentGroup(RR) + sage: ArgumentGroup(RR) # needs sage.rings.number_field Sign Group - sage: ArgumentGroup('Arg_RR') + sage: ArgumentGroup('Arg_RR') # needs sage.rings.number_field Sign Group - sage: ArgumentGroup(RIF) + sage: ArgumentGroup(RIF) # needs sage.rings.real_interval_field Sign Group sage: ArgumentGroup(RBF) Sign Group - sage: ArgumentGroup(CC) + sage: ArgumentGroup(CC) # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ - sage: ArgumentGroup('Arg_CC') + sage: ArgumentGroup('Arg_CC') # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ sage: ArgumentGroup(CIF) @@ -1794,7 +1795,7 @@ class ArgumentGroupFactory(UniqueFactory): Unit Circle Group with Exponents in Real ball field with 53 bits of precision modulo ZZ - sage: ArgumentGroup(CyclotomicField(3)) + sage: ArgumentGroup(CyclotomicField(3)) # needs sage.rings.number_field Unit Circle Group with Argument of Elements in Cyclotomic Field of order 3 and degree 2 """ @@ -1813,6 +1814,7 @@ def create_key_and_extra_args(self, sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup + sage: # needs sage.rings.number_field sage: ArgumentGroup(specification='UU') Group of Roots of Unity sage: ArgumentGroup('UU') is ArgumentGroup(exponents=QQ) # indirect doctest @@ -1887,7 +1889,7 @@ def create_object(self, version, key, **kwds): TESTS:: sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup - sage: ArgumentGroup('UU') # indirect doctest + sage: ArgumentGroup('UU') # indirect doctest # needs sage.rings.number_field Group of Roots of Unity """ cls, args = key diff --git a/src/sage/groups/misc_gps/imaginary_groups.py b/src/sage/groups/misc_gps/imaginary_groups.py index ff2d34ddade..fa0a9d5083e 100644 --- a/src/sage/groups/misc_gps/imaginary_groups.py +++ b/src/sage/groups/misc_gps/imaginary_groups.py @@ -81,9 +81,9 @@ def imag(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: J(I).imag() + sage: J(I).imag() # needs sage.symbolic 1 - sage: imag_part(J(I)) # indirect doctest + sage: imag_part(J(I)) # indirect doctest # needs sage.symbolic 1 """ return self._imag_ @@ -96,9 +96,9 @@ def real(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: J(I).real() + sage: J(I).real() # needs sage.symbolic 0 - sage: real_part(J(I)) # indirect doctest + sage: real_part(J(I)) # indirect doctest # needs sage.symbolic 0 """ return self.parent().base().zero() @@ -111,7 +111,7 @@ def __hash__(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: hash(J(I)) # indirect doctest, random + sage: hash(J(I)) # indirect doctest, random # needs sage.symbolic 42 """ return hash((self.parent(), self._imag_)) @@ -247,9 +247,9 @@ class ImaginaryGroup(UniqueRepresentation, Parent): 0 sage: J(imag=100) 100*I - sage: J(3*I) + sage: J(3*I) # needs sage.symbolic 3*I - sage: J(1+2*I) + sage: J(1+2*I) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 2*I + 1 is not in @@ -393,36 +393,36 @@ def _element_constructor_(self, data, imag=None): sage: J(imag=100) 100*I - sage: J(3*I) + sage: J(3*I) # needs sage.symbolic 3*I - sage: J(1+2*I) + sage: J(1+2*I) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 2*I + 1 is not in Imaginary Group over Integer Ring because it is not purely imaginary - sage: i = CC(I) - sage: J(3*i) + sage: i = CC(I) # needs sage.symbolic + sage: J(3*i) # needs sage.symbolic 3*I - sage: J(1+2*i) + sage: J(1+2*i) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 1.00000000000000 + 2.00000000000000*I is not in Imaginary Group over Integer Ring because it is not purely imaginary sage: i = CBF(I) - sage: J(3*i) + sage: J(3*i) # needs sage.symbolic 3*I - sage: J(1+2*i) + sage: J(1+2*i) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 1.000000000000000 + 2.000000000000000*I is not in Imaginary Group over Integer Ring because it is not purely imaginary sage: i = CIF(I) - sage: J(3*i) + sage: J(3*i) # needs sage.symbolic 3*I - sage: J(1+2*i) + sage: J(1+2*i) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 1 + 2*I is not in diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 4c10f364a07..0282ffc6494 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -236,30 +236,30 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]): [5, 0, 1, 2, 3, 4] sage: gens = [[1,2,3,0]] sage: reps = [] - sage: for p in SymmetricGroup(4): # needs sage.groups + sage: for p in SymmetricGroup(4): ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # needs sage.groups + sage: len(reps) 6 sage: gens = [[1,0,2,3],[0,1,3,2]] sage: reps = [] - sage: for p in SymmetricGroup(4): # needs sage.groups + sage: for p in SymmetricGroup(4): ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # needs sage.groups + sage: len(reps) 6 sage: gens = [[1,2,0,3]] sage: reps = [] - sage: for p in SymmetricGroup(4): # needs sage.groups + sage: for p in SymmetricGroup(4): ....: p = [p(i)-1 for i in range(1,5)] ....: r = coset_rep(p, gens) ....: if r not in reps: ....: reps.append(r) - sage: len(reps) # needs sage.groups + sage: len(reps) 8 """ diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index e48564e0ea1..8e716427db0 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -335,10 +335,10 @@ def PermutationGroup(gens=None, *args, **kwds): We can create a permutation group from a group action:: sage: a = lambda x: (2*x) % 7 - sage: H = PermutationGroup(action=a, domain=range(7)) - sage: H.orbits() + sage: H = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: H.orbits() # needs sage.libs.pari ((0,), (1, 2, 4), (3, 6, 5)) - sage: H.gens() + sage: H.gens() # needs sage.libs.pari ((1,2,4), (3,6,5)) Note that we provide generators for the acting group. The @@ -362,7 +362,7 @@ def PermutationGroup(gens=None, *args, **kwds): i.e., in bijection with integer partitions:: sage: a = lambda g, x: g*x*g^-1 - sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, + sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, # needs sage.combinat ....: domain=SymmetricGroup(n)).orbits()) ....: for n in range(1, 8)] [1, 2, 3, 5, 7, 11, 15] @@ -669,6 +669,7 @@ def gap(self): the following test shows, that support for the ``self._libgap`` attribute is needed in the constructor of the class:: + sage: # needs sage.libs.pari sage: PG = PGU(6,2) sage: g, h = PG.gens() sage: p1 = h^-3*(h^-1*g^-1)^2*h*g*h^2*g^-1*h^2*g*h^-5*g^-1 @@ -927,6 +928,7 @@ def _coerce_map_from_(self, G): If this permutation group has been constructed via ``as_permutation_group`` method (from finite matrix groups):: + sage: # needs sage.libs.pari sage: MG = GU(3,2).as_matrix_group() sage: PG = MG.as_permutation_group() sage: f = PG._coerce_map_from_(MG) @@ -2944,6 +2946,7 @@ def _subgroup_constructor(self, libgap_group): EXAMPLES:: + sage: # needs sage.libs.pari sage: G = PGU(3,2); G The projective general unitary group of degree 3 over Finite Field of size 2 sage: g1, g2 = G.gens() @@ -3372,7 +3375,7 @@ def character_table(self): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3)]]) sage: G.order() 12 - sage: G.character_table() + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1] [ 1 -zeta3 - 1 zeta3 1] [ 1 zeta3 -zeta3 - 1 1] @@ -3387,7 +3390,7 @@ def character_table(self): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: G.order() 8 - sage: G.character_table() + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1 1] [ 1 -1 -1 1 1] [ 1 -1 1 -1 1] @@ -3399,6 +3402,7 @@ def character_table(self): :: + sage: # needs sage.rings.number_field sage: SymmetricGroup(2).character_table() [ 1 -1] [ 1 1] @@ -3461,8 +3465,8 @@ def irreducible_characters(self): EXAMPLES:: - sage: irr = SymmetricGroup(3).irreducible_characters() - sage: [x.values() for x in irr] + sage: irr = SymmetricGroup(3).irreducible_characters() # needs sage.rings.number_field + sage: [x.values() for x in irr] # needs sage.rings.number_field [[1, -1, 1], [2, 0, -1], [1, 1, 1]] """ return [ClassFunction_libgap(self, irr) for irr in self._libgap_().Irr()] @@ -3473,7 +3477,7 @@ def trivial_character(self): EXAMPLES:: - sage: SymmetricGroup(3).trivial_character() + sage: SymmetricGroup(3).trivial_character() # needs sage.rings.number_field Character of Symmetric group of order 3! as a permutation group """ values = [1]*self._libgap_().NrConjugacyClasses().sage() @@ -3489,7 +3493,7 @@ def character(self, values): sage: G = AlternatingGroup(4) sage: n = len(G.conjugacy_classes_representatives()) - sage: G.character([1]*n) + sage: G.character([1]*n) # needs sage.rings.number_field Character of Alternating group of order 4!/2 as a permutation group """ return ClassFunction_libgap(self, values) @@ -3512,13 +3516,13 @@ def conjugacy_classes_representatives(self): :: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes_representatives() + sage: G.conjugacy_classes_representatives() # needs sage.combinat [(), (1,2), (1,2)(3,4), (1,2,3), (1,2,3)(4,5), (1,2,3,4), (1,2,3,4,5)] :: sage: S = SymmetricGroup(['a','b','c']) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [(), ('a','b'), ('a','b','c')] AUTHORS: @@ -5166,9 +5170,9 @@ class PermutationGroup_action(PermutationGroup_generic): sage: n = 3 sage: a = lambda x: SetPartition([[e % n + 1 for e in b] for b in x]) - sage: S = SetPartitions(n) - sage: G = PermutationGroup(action=a, domain=S) - sage: G.orbits() + sage: S = SetPartitions(n) # needs sage.combinat + sage: G = PermutationGroup(action=a, domain=S) # needs sage.combinat + sage: G.orbits() # needs sage.combinat (({{1}, {2}, {3}},), ({{1, 2}, {3}}, {{1}, {2, 3}}, {{1, 3}, {2}}), ({{1, 2, 3}},)) @@ -5177,13 +5181,13 @@ class PermutationGroup_action(PermutationGroup_generic): sage: a = lambda g, x: g*x*g^-1 sage: S = SymmetricGroup(3) - sage: G = PermutationGroup(S.gens(), action=a, domain=S) - sage: G.orbits() + sage: G = PermutationGroup(S.gens(), action=a, domain=S) # needs sage.combinat + sage: G.orbits() # needs sage.combinat (((),), ((1,3,2), (1,2,3)), ((2,3), (1,3), (1,2))) The trivial action of the symmetric group:: - sage: PermutationGroup(SymmetricGroup(3).gens(), + sage: PermutationGroup(SymmetricGroup(3).gens(), # needs sage.combinat ....: action=lambda g, x: x, domain=[1]) Permutation Group with generators [()] """ @@ -5214,8 +5218,8 @@ def __init__(self, gens, action, domain, gap_group=None, category=None, canonica EXAMPLES:: sage: a = lambda x: (2*x) % 7 - sage: G = PermutationGroup(action=a, domain=range(7)) - sage: G.orbits() + sage: G = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: G.orbits() # needs sage.combinat ((0,), (1, 2, 4), (3, 6, 5)) """ @@ -5255,8 +5259,8 @@ def orbits(self): EXAMPLES:: sage: a = lambda x: (2*x) % 7 - sage: G = PermutationGroup(action=a, domain=range(7)) - sage: G.orbits() + sage: G = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: G.orbits() # needs sage.combinat ((0,), (1, 2, 4), (3, 6, 5)) """ return self._orbits diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 226a74f2466..061c784498a 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -367,11 +367,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S = SymmetricGroup(5) sage: S(Permutation([5,1,4,3,2])) (1,5,2)(3,4) - sage: S(gp.Vecsmall([5,1,4,3,2])) + sage: S(gp.Vecsmall([5,1,4,3,2])) # needs sage.libs.pari (1,5,2)(3,4) sage: S(gap.PermList([5,1,4,3,2])) (1,5,2)(3,4) - sage: S(pari.Vecsmall([5,1,4,3,2])) + sage: S(pari.Vecsmall([5,1,4,3,2])) # needs sage.libs.pari (1,5,2)(3,4) sage: S(libgap.PermList([5,1,4,3,2])) (1,5,2)(3,4) @@ -853,14 +853,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S(p_libgap) == p True - sage: P = PGU(8,2) - sage: p, q = P.gens() + sage: P = PGU(8,2) # needs sage.libs.pari + sage: p, q = P.gens() # needs sage.libs.pari sage: p_libgap = p.gap() TESTS:: - sage: P = PGU(8,2) - sage: p, q = P.gens() + sage: P = PGU(8,2) # needs sage.libs.pari + sage: p, q = P.gens() # needs sage.libs.pari sage: p_pexpect = gap(p) sage: p_libgap == p_pexpect True @@ -1557,6 +1557,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): TESTS:: + sage: # needs sage.libs.pari sage: prod(primes(150)) 1492182350939279320058875736615841068547583863326864530410 sage: L = [tuple(range(sum(primes(p))+1, sum(primes(p))+1+p)) for p in primes(150)] @@ -1842,6 +1843,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): EXAMPLES:: + sage: # needs sage.combinat sage: G = DihedralGroup(3) sage: [g.cycle_type() for g in G] [[1, 1, 1], [3], [3], [2, 1], [2, 1], [2, 1]] @@ -1890,13 +1892,13 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): False sage: s = S.simple_reflections() sage: x = s[1]*s[2] - sage: x.has_descent(1, side = "right") + sage: x.has_descent(1, side="right") False - sage: x.has_descent(2, side = "right") + sage: x.has_descent(2, side="right") True - sage: x.has_descent(1, side = "left") + sage: x.has_descent(1, side="left") True - sage: x.has_descent(2, side = "left") + sage: x.has_descent(2, side="left") False sage: S._test_has_descent() @@ -2063,7 +2065,7 @@ cdef class SymmetricGroupElement(PermutationGroupElement): EXAMPLES:: sage: S = SymmetricGroup(3) - sage: [x.absolute_length() for x in S] + sage: [x.absolute_length() for x in S] # needs sage.combinat [0, 2, 2, 1, 1, 1] """ from sage.combinat.permutation import Permutation diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 2af6fac46ea..9f80dc5b2fb 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -119,8 +119,8 @@ def image(self, J): sage: R. = QQ[] sage: f = x^4 + x^2 - 3 - sage: L. = f.splitting_field() - sage: G = L.galois_group() + sage: L. = f.splitting_field() # needs sage.rings.number_field + sage: G = L.galois_group() # needs sage.rings.number_field sage: D4 = DihedralGroup(4) sage: h = D4.isomorphism_to(G) sage: h.image(D4).is_isomorphic(G) diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index a5066e8ada5..75e26765b3a 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -250,9 +250,9 @@ def __init__(self, domain=None): TESTS:: - sage: TestSuite(SymmetricGroup(0)).run() - sage: TestSuite(SymmetricGroup(1)).run() - sage: TestSuite(SymmetricGroup(3)).run() + sage: TestSuite(SymmetricGroup(0)).run() # needs sage.rings.number_field + sage: TestSuite(SymmetricGroup(1)).run() # needs sage.rings.number_field + sage: TestSuite(SymmetricGroup(3)).run() # needs sage.rings.number_field """ from sage.categories.finite_weyl_groups import FiniteWeylGroups from sage.categories.finite_permutation_groups import FinitePermutationGroups @@ -338,14 +338,14 @@ def _coerce_map_from_(self, G): EXAMPLES:: - sage: J3 = groups.misc.Cactus(3) + sage: J3 = groups.misc.Cactus(3) # needs sage.rings.number_field sage: S5 = SymmetricGroup(5) - sage: S5.coerce_map_from(J3) + sage: S5.coerce_map_from(J3) # needs sage.rings.number_field Conversion via _from_cactus_group_element map: From: Cactus Group with 3 fruit To: Symmetric group of order 5! as a permutation group sage: S2 = SymmetricGroup(2) - sage: S2._coerce_map_from_(J3) is None + sage: S2._coerce_map_from_(J3) is None # needs sage.rings.number_field True """ from sage.groups.cactus_group import CactusGroup @@ -359,6 +359,7 @@ def _from_cactus_group_element(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.gens() sage: elt = s12*s23*s13 @@ -391,7 +392,7 @@ def coxeter_matrix(self): EXAMPLES:: - sage: A = SymmetricGroup([2,3,7,'a']); A.coxeter_matrix() + sage: A = SymmetricGroup([2,3,7,'a']); A.coxeter_matrix() # needs sage.graphs [1 3 2] [3 1 3] [2 3 1] @@ -484,10 +485,10 @@ def major_index(self, parameter=None): EXAMPLES:: sage: S4 = SymmetricGroup(4) - sage: S4.major_index() + sage: S4.major_index() # needs sage.combinat q^6 + 3*q^5 + 5*q^4 + 6*q^3 + 5*q^2 + 3*q + 1 sage: K. = QQ[] - sage: S4.major_index(t) + sage: S4.major_index(t) # needs sage.combinat t^6 + 3*t^5 + 5*t^4 + 6*t^3 + 5*t^2 + 3*t + 1 """ from sage.combinat.q_analogues import q_factorial @@ -506,14 +507,14 @@ def conjugacy_classes_representatives(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes_representatives() + sage: G.conjugacy_classes_representatives() # needs sage.combinat [(), (1,2), (1,2)(3,4), (1,2,3), (1,2,3)(4,5), (1,2,3,4), (1,2,3,4,5)] :: sage: S = SymmetricGroup(['a','b','c']) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [(), ('a','b'), ('a','b','c')] TESTS: @@ -521,10 +522,10 @@ def conjugacy_classes_representatives(self): Check some border cases:: sage: S = SymmetricGroup(0) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [()] sage: S = SymmetricGroup(1) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [()] """ from sage.combinat.partition import Partitions_n @@ -540,7 +541,7 @@ def conjugacy_classes_iterator(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() + sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() # needs sage.combinat True """ from sage.combinat.partition import Partitions_n @@ -556,7 +557,7 @@ def conjugacy_classes(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes() + sage: G.conjugacy_classes() # needs sage.combinat [Conjugacy class of cycle type [1, 1, 1, 1, 1] in Symmetric group of order 5! as a permutation group, Conjugacy class of cycle type [2, 1, 1, 1] in @@ -591,7 +592,7 @@ def conjugacy_class(self, g): sage: G = SymmetricGroup(5) sage: g = G((1,2,3,4)) - sage: G.conjugacy_class(g) + sage: G.conjugacy_class(g) # needs sage.combinat Conjugacy class of cycle type [4, 1] in Symmetric group of order 5! as a permutation group """ @@ -615,37 +616,37 @@ def algebra(self, base_ring, category=None): EXAMPLES:: sage: S4 = SymmetricGroup(4) - sage: S4.algebra(QQ) + sage: S4.algebra(QQ) # needs sage.combinat Symmetric group algebra of order 4 over Rational Field sage: S3 = SymmetricGroup([1,2,3]) - sage: A = S3.algebra(QQ); A + sage: A = S3.algebra(QQ); A # needs sage.combinat Symmetric group algebra of order 3 over Rational Field sage: a = S3.an_element(); a (2,3) - sage: A(a) + sage: A(a) # needs sage.combinat (2,3) We illustrate the choice of the category:: - sage: A.category() + sage: A.category() # needs sage.combinat Join of Category of coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field - sage: A = S3.algebra(QQ, category=Semigroups()) - sage: A.category() + sage: A = S3.algebra(QQ, category=Semigroups()) # needs sage.combinat + sage: A.category() # needs sage.combinat Category of finite dimensional unital cellular semigroup algebras over Rational Field In the following case, a usual group algebra is returned:: sage: S = SymmetricGroup([2,3,5]) - sage: S.algebra(QQ) + sage: S.algebra(QQ) # needs sage.combinat Algebra of Symmetric group of order 3! as a permutation group over Rational Field sage: a = S.an_element(); a (3,5) - sage: S.algebra(QQ)(a) + sage: S.algebra(QQ)(a) # needs sage.combinat (3,5) """ from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra @@ -2649,7 +2650,7 @@ def __init__(self, n, q, name='a'): sage: G.order() 24 - sage: G = PGL(2, 9, 'b'); G + sage: G = PGL(2, 9, 'b'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,10,9,8,4,7,6,5), (1,2,4)(5,6,8)(7,9,10)] sage: G.base_ring() Finite Field in b of size 3^2 @@ -2713,11 +2714,11 @@ def __init__(self, n, q, name='a'): We create two groups over nontrivial finite fields:: - sage: G = PSL(2, 4, 'b'); G + sage: G = PSL(2, 4, 'b'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,4,5), (1,2,3)] sage: G.base_ring() Finite Field in b of size 2^2 - sage: G = PSL(2, 8); G + sage: G = PSL(2, 8); G # needs sage.rings.finite_rings Permutation Group with generators [(3,8,6,4,9,7,5), (1,2,3)(4,7,5)(6,9,8)] sage: G.base_ring() Finite Field in a of size 2^3 @@ -2897,7 +2898,7 @@ def __init__(self, n, q, name='a'): sage: G.base_ring() Finite Field of size 3 - sage: G = PSp(2, 8, name='alpha'); G + sage: G = PSp(2, 8, name='alpha'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,8,6,4,9,7,5), (1,2,3)(4,7,5)(6,9,8)] sage: G.base_ring() Finite Field in alpha of size 2^3 @@ -2935,7 +2936,7 @@ def field_of_definition(self): """ EXAMPLES:: - sage: PSU(2,3).field_of_definition() + sage: PSU(2,3).field_of_definition() # needs sage.rings.finite_rings Finite Field in a of size 3^2 """ return self._field_of_definition @@ -2962,17 +2963,17 @@ def __init__(self, n, q, name='a'): EXAMPLES:: - sage: PSU(2,3) + sage: PSU(2,3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 - sage: G = PSU(2, 8, name='alpha'); G + sage: G = PSU(2, 8, name='alpha'); G # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field in alpha of size 2^3 - sage: G.base_ring() + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^3 TESTS:: - sage: groups.permutation.PSU(2, 3) + sage: groups.permutation.PSU(2, 3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 """ id = 'PSU(%s,%s)' % (n, q) @@ -2986,7 +2987,7 @@ def _repr_(self): """ EXAMPLES:: - sage: PSU(2,3) + sage: PSU(2,3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 """ @@ -3014,18 +3015,18 @@ def __init__(self, n, q, name='a'): EXAMPLES:: - sage: PGU(2,3) + sage: PGU(2,3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 - sage: G = PGU(2, 8, name='alpha'); G + sage: G = PGU(2, 8, name='alpha'); G # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field in alpha of size 2^3 - sage: G.base_ring() + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^3 TESTS:: - sage: groups.permutation.PGU(2, 3) + sage: groups.permutation.PGU(2, 3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 """ id = 'PGU(%s,%s)' % (n, q) @@ -3039,7 +3040,7 @@ def _repr_(self): """ EXAMPLES:: - sage: PGU(2,3) + sage: PGU(2,3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 """ @@ -3072,12 +3073,13 @@ def __init__(self, q, name='a'): EXAMPLES:: - sage: SuzukiGroup(8) + sage: SuzukiGroup(8) # needs sage.rings.finite_rings Permutation Group with generators [(1,2)(3,10)(4,42)(5,18)(6,50)(7,26)(8,58)(9,34)(12,28)(13,45)(14,44)(15,23)(16,31)(17,21)(19,39)(20,38)(22,25)(24,61)(27,60)(29,65)(30,55)(32,33)(35,52)(36,49)(37,59)(40,54)(41,62)(43,53)(46,48)(47,56)(51,63)(57,64), (1,28,10,44)(3,50,11,42)(4,43,53,64)(5,9,39,52)(6,36,63,13)(7,51,60,57)(8,33,37,16)(12,24,55,29)(14,30,48,47)(15,19,61,54)(17,59,22,62)(18,23,34,31)(20,38,49,25)(21,26,45,58)(27,32,41,65)(35,46,40,56)] - sage: print(SuzukiGroup(8)) + sage: print(SuzukiGroup(8)) # needs sage.rings.finite_rings The Suzuki group over Finite Field in a of size 2^3 + sage: # needs sage.rings.finite_rings sage: G = SuzukiGroup(32, name='alpha') sage: G.order() 32537600 @@ -3088,7 +3090,7 @@ def __init__(self, q, name='a'): TESTS:: - sage: groups.permutation.Suzuki(8) + sage: groups.permutation.Suzuki(8) # needs sage.rings.finite_rings Permutation Group with generators [(1,2)(3,10)(4,42)(5,18)(6,50)(7,26)(8,58)(9,34)(12,28)(13,45)(14,44)(15,23)(16,31)(17,21)(19,39)(20,38)(22,25)(24,61)(27,60)(29,65)(30,55)(32,33)(35,52)(36,49)(37,59)(40,54)(41,62)(43,53)(46,48)(47,56)(51,63)(57,64), (1,28,10,44)(3,50,11,42)(4,43,53,64)(5,9,39,52)(6,36,63,13)(7,51,60,57)(8,33,37,16)(12,24,55,29)(14,30,48,47)(15,19,61,54)(17,59,22,62)(18,23,34,31)(20,38,49,25)(21,26,45,58)(27,32,41,65)(35,46,40,56)] @@ -3109,8 +3111,8 @@ def base_ring(self): """ EXAMPLES:: - sage: G = SuzukiGroup(32, name='alpha') - sage: G.base_ring() + sage: G = SuzukiGroup(32, name='alpha') # needs sage.rings.finite_rings + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^5 """ return self._base_ring @@ -3119,8 +3121,8 @@ def __str__(self): """ EXAMPLES:: - sage: G = SuzukiGroup(32, name='alpha') - sage: print(G) + sage: G = SuzukiGroup(32, name='alpha') # needs sage.rings.finite_rings + sage: print(G) # needs sage.rings.finite_rings The Suzuki group over Finite Field in alpha of size 2^5 """ @@ -3478,7 +3480,7 @@ class SmallPermutationGroup(PermutationGroup_generic): ((1,2)(3,5)(4,10)(6,8)(7,12)(9,11), (1,3)(2,5)(4,7)(6,9)(8,11)(10,12), (1,4,8)(2,6,10)(3,7,11)(5,9,12)) - sage: G.character_table() + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1 1 1] [ 1 -1 -1 1 1 -1] [ 1 -1 1 1 -1 1] diff --git a/src/sage/groups/perm_gps/symgp_conjugacy_class.py b/src/sage/groups/perm_gps/symgp_conjugacy_class.py index d6112df67af..5a8d5f435fa 100644 --- a/src/sage/groups/perm_gps/symgp_conjugacy_class.py +++ b/src/sage/groups/perm_gps/symgp_conjugacy_class.py @@ -28,8 +28,8 @@ def __init__(self, domain, part): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: type(C._part) + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: type(C._part) # needs sage.combinat """ P = Partitions_n(len(domain)) @@ -44,7 +44,7 @@ def _repr_(self): EXAMPLES:: sage: G = SymmetricGroup(4) - sage: G.conjugacy_class(Partition([4])) + sage: G.conjugacy_class(Partition([4])) # needs sage.combinat Conjugacy class of cycle type [4] in Symmetric group of order 4! as a permutation group """ @@ -59,9 +59,9 @@ def __eq__(self, other): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: Cp = G.conjugacy_class(g) - sage: C == Cp + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: Cp = G.conjugacy_class(g) # needs sage.combinat + sage: C == Cp # needs sage.combinat True """ if not isinstance(other, SymmetricGroupConjugacyClassMixin): @@ -76,9 +76,9 @@ def __ne__(self, other): sage: G = SymmetricGroup(5) sage: g = G([(1,3), (2,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: Cp = G.conjugacy_class(g) - sage: C != Cp + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: Cp = G.conjugacy_class(g) # needs sage.combinat + sage: C != Cp # needs sage.combinat False """ return not (self == other) @@ -91,7 +91,7 @@ def partition(self): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat """ return self._part @@ -111,6 +111,7 @@ def __init__(self, group, part): EXAMPLES:: + sage: # needs sage.combinat sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) sage: C = G.conjugacy_class(g) @@ -133,8 +134,8 @@ def __iter__(self): EXAMPLES:: sage: G = SymmetricGroup(4) - sage: C = G.conjugacy_class(Partition([3,1])) - sage: for x in C: x + sage: C = G.conjugacy_class(Partition([3,1])) # needs sage.combinat + sage: for x in C: x # needs sage.combinat (2,3,4) (2,4,3) (1,2,3) @@ -160,9 +161,9 @@ def set(self): sage: G = SymmetricGroup(3) sage: g = G((1,2)) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat sage: S = [(2,3), (1,2), (1,3)] - sage: C.set() == Set(G(x) for x in S) + sage: C.set() == Set(G(x) for x in S) # needs sage.combinat True """ if not self._set: @@ -186,6 +187,7 @@ def __init__(self, P, part): EXAMPLES:: + sage: # needs sage.combinat sage: G = Permutations(5) sage: g = G([2, 1, 4, 5, 3]) sage: C = G.conjugacy_class(g) @@ -208,8 +210,8 @@ def __iter__(self): EXAMPLES:: sage: G = Permutations(4) - sage: C = G.conjugacy_class(Partition([3,1])) - sage: for x in C: x + sage: C = G.conjugacy_class(Partition([3,1])) # needs sage.combinat + sage: for x in C: x # needs sage.combinat [1, 3, 4, 2] [1, 4, 2, 3] [2, 3, 1, 4] @@ -235,9 +237,9 @@ def set(self): sage: G = Permutations(3) sage: g = G([2, 1, 3]) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat sage: S = [[1, 3, 2], [2, 1, 3], [3, 2, 1]] - sage: C.set() == Set(G(x) for x in S) + sage: C.set() == Set(G(x) for x in S) # needs sage.combinat True """ if not self._set: @@ -272,9 +274,9 @@ def default_representative(part, G): EXAMPLES:: - sage: from sage.groups.perm_gps.symgp_conjugacy_class import default_representative + sage: from sage.groups.perm_gps.symgp_conjugacy_class import default_representative # needs sage.combinat sage: S = SymmetricGroup(4) - sage: for p in Partitions(4): + sage: for p in Partitions(4): # needs sage.combinat ....: print(default_representative(p, S)) (1,2,3,4) (1,2,3) @@ -312,8 +314,8 @@ def conjugacy_class_iterator(part, S=None): EXAMPLES:: - sage: from sage.groups.perm_gps.symgp_conjugacy_class import conjugacy_class_iterator - sage: for p in conjugacy_class_iterator([2,2]): print(p) + sage: from sage.groups.perm_gps.symgp_conjugacy_class import conjugacy_class_iterator # needs sage.combinat + sage: for p in conjugacy_class_iterator([2,2]): print(p) # needs sage.combinat [(1, 2), (3, 4)] [(1, 4), (2, 3)] [(1, 3), (2, 4)] @@ -321,7 +323,7 @@ def conjugacy_class_iterator(part, S=None): In order to get permutations, one just has to wrap:: sage: S = SymmetricGroup(5) - sage: for p in conjugacy_class_iterator([3,2]): print(S(p)) + sage: for p in conjugacy_class_iterator([3,2]): print(S(p)) # needs sage.combinat (1,3)(2,4,5) (1,3)(2,5,4) (1,2)(3,4,5) @@ -334,15 +336,15 @@ def conjugacy_class_iterator(part, S=None): the conjugacy class:: sage: s = lambda p: sum(1 for _ in conjugacy_class_iterator(p)) - sage: all(s(p) == p.conjugacy_class_size() for p in Partitions(5)) + sage: all(s(p) == p.conjugacy_class_size() for p in Partitions(5)) # needs sage.combinat True It is also possible to specify any underlying set:: - sage: it = conjugacy_class_iterator([2,2,2], 'abcdef') - sage: sorted(flatten(next(it))) + sage: it = conjugacy_class_iterator([2,2,2], 'abcdef') # needs sage.combinat + sage: sorted(flatten(next(it))) # needs sage.combinat ['a', 'b', 'c', 'd', 'e', 'f'] - sage: all(len(x) == 2 for x in next(it)) + sage: all(len(x) == 2 for x in next(it)) # needs sage.combinat True """ n = sum(part) diff --git a/src/sage/groups/raag.py b/src/sage/groups/raag.py index 736430e8af2..4bd3787d484 100644 --- a/src/sage/groups/raag.py +++ b/src/sage/groups/raag.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.graphs sage.rings.number_field r""" Right-Angled Artin Groups diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx index d84683ce5ee..ae9ce18efb1 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Elements of a semimonomial transformation group @@ -9,13 +10,13 @@ the semidirect product of the monomial transformation group of degree `n` The multiplication of two elements `(\phi, \pi, \alpha)(\psi, \sigma, \beta)` with - - `\phi, \psi \in {R^{\times}}^n` +- `\phi, \psi \in {R^{\times}}^n` - - `\pi, \sigma \in S_n` (with the multiplication `\pi\sigma` - done from left to right (like in GAP) -- - that is, `(\pi\sigma)(i) = \sigma(\pi(i))` for all `i`.) +- `\pi, \sigma \in S_n` (with the multiplication `\pi\sigma` + done from left to right (like in GAP) -- + that is, `(\pi\sigma)(i) = \sigma(\pi(i))` for all `i`.) - - `\alpha, \beta \in Aut(R)` +- `\alpha, \beta \in Aut(R)` is defined by @@ -114,7 +115,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): ((2*a + 1, 1, 2, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: S(g) ((2, a, 1, 2); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) - sage: S(1) # the one element in the group + sage: S(1) # the one element in the group ((1, 1, 1, 1); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ def __init__(self, parent, v, perm, alpha): @@ -127,7 +128,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: S = SemimonomialTransformationGroup(F, 4) - sage: g = S(v = [2, a, 1, 2]) #indirect doctest + sage: g = S(v = [2, a, 1, 2]) #indirect doctest """ MultiplicativeGroupElement.__init__(self, parent) self.v = tuple(v) @@ -152,7 +153,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: s = SemimonomialTransformationGroup(F, 4).an_element() - sage: t = copy(s) #indirect doctest + sage: t = copy(s) # indirect doctest sage: t is s False sage: t == s @@ -203,7 +204,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: s = SemimonomialTransformationGroup(F, 4).an_element() - sage: s*s #indirect doctest + sage: s*s # indirect doctest ((a, 2*a + 1, 1, 1); (1,3)(2,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ cdef SemimonomialTransformation right = _right @@ -223,7 +224,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: S = SemimonomialTransformationGroup(F, 4) sage: s = S.an_element() - sage: s*s**(-1) == S(1) # indirect doctest + sage: s*s**(-1) == S(1) # indirect doctest True """ cdef i @@ -240,7 +241,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): EXAMPLES:: sage: F. = GF(9) - sage: SemimonomialTransformationGroup(F, 4).an_element() # indirect doctest + sage: SemimonomialTransformationGroup(F, 4).an_element() # indirect doctest ((a, 1, 1, 1); (1,4,3,2), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) """ return "(%s; %s, %s)"%(self.v, self.perm.cycle_string(), @@ -254,9 +255,9 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: g = SemimonomialTransformationGroup(F, 4).gens() - sage: g[0] > g[1] # indirect doctest + sage: g[0] > g[1] # indirect doctest True - sage: g[1] != g[2] # indirect doctest + sage: g[1] != g[2] # indirect doctest True """ cdef SemimonomialTransformation right = _right diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py b/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py index 78c485bfc02..40bbed2c6bb 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Semimonomial transformation group @@ -105,13 +106,17 @@ class SemimonomialTransformationGroup(FiniteGroup, UniqueRepresentation): sage: g = S(v = [2, a, 1, 2]) sage: h = S(perm = Permutation('(1,2,3,4)'), autom=F.hom([a**3])) sage: g*h - ((2, a, 1, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) + ((2, a, 1, 2); (1,2,3,4), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: h*g - ((2*a + 1, 1, 2, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) + ((2*a + 1, 1, 2, 2); (1,2,3,4), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: S(g) - ((2, a, 1, 2); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) + ((2, a, 1, 2); (), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) sage: S(1) - ((1, 1, 1, 1); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) + ((1, 1, 1, 1); (), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ Element = SemimonomialTransformation @@ -256,7 +261,7 @@ def _an_element_(self): EXAMPLES:: sage: F. = GF(4) - sage: SemimonomialTransformationGroup(F, 3).an_element() # indirect doctest + sage: SemimonomialTransformationGroup(F, 3).an_element() # indirect doctest ((a, 1, 1); (1,3,2), Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a + 1) """ R = self.base_ring() @@ -275,9 +280,9 @@ def __contains__(self, item) -> bool: sage: F. = GF(4) sage: S = SemimonomialTransformationGroup(F, 3) - sage: 1 in S # indirect doctest + sage: 1 in S # indirect doctest True - sage: a in S # indirect doctest + sage: a in S # indirect doctest False """ try: @@ -294,11 +299,14 @@ def gens(self) -> tuple: sage: F. = GF(4) sage: SemimonomialTransformationGroup(F, 3).gens() - (((a, 1, 1); (), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (1,2,3), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (1,2), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a + 1)) + (((a, 1, 1); (), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (1,2,3), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (1,2), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a + 1)) """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup R = self.base_ring() @@ -349,7 +357,7 @@ def _get_action_(self, X, op, self_on_left): sage: s*v # indirect doctest (0, 1, 0) sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] @@ -376,7 +384,7 @@ def _repr_(self) -> str: EXAMPLES:: sage: F. = GF(4) - sage: SemimonomialTransformationGroup(F, 3) # indirect doctest + sage: SemimonomialTransformationGroup(F, 3) # indirect doctest Semimonomial transformation group over Finite Field in a of size 2^2 of degree 3 """ return ('Semimonomial transformation group over %s' % self.base_ring() + @@ -389,7 +397,7 @@ def _latex_(self) -> str: EXAMPLES:: sage: F. = GF(4) - sage: latex(SemimonomialTransformationGroup(F, 3)) # indirect doctest + sage: latex(SemimonomialTransformationGroup(F, 3)) # indirect doctest \left(\Bold{F}_{2^{2}}^3\wr\langle (1,2,3), (1,2) \rangle \right) \rtimes \operatorname{Aut}(\Bold{F}_{2^{2}}) """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup @@ -470,7 +478,7 @@ def __init__(self, G, M, check=True): sage: F. = GF(4) sage: s = SemimonomialTransformationGroup(F, 3).an_element() sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] @@ -497,7 +505,7 @@ def _act_(self, a, b): sage: F. = GF(4) sage: s = SemimonomialTransformationGroup(F, 3).an_element() sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] From 55e201cf1e16b61e489de457f2d1ce2597561b2b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 00:23:48 -0700 Subject: [PATCH 40/64] sage.groups: More block tags, tag corrections --- src/sage/groups/cubic_braid.py | 40 +++++++++++++++++++++++----------- src/sage/groups/generic.py | 4 ++-- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index 4533ed744dc..5c72c9a7aef 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -389,13 +389,15 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, sage: C3. = CubicBraidGroup(3) sage: ele = c1*c2*c1 + + sage: # needs sage.rings.number_field sage: BuMa = ele.burau_matrix(); BuMa [ -zeta3 1 zeta3] [ -zeta3 zeta3 + 1 0] [ 1 0 0] sage: BuMa.base_ring() Cyclotomic Field of order 3 and degree 2 - sage: BuMa == ele.burau_matrix(characteristic = 0) + sage: BuMa == ele.burau_matrix(characteristic=0) True sage: BuMa = ele.burau_matrix(domain=QQ); BuMa [-t + 1 1 t - 1] @@ -403,26 +405,29 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Number Field in t with defining polynomial t^2 - t + 1 - sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # needs sage.rings.number_field sage.symbolic + sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # needs sage.symbolic [ 1/2*sqrt3*I + 1/2 1 -1/2*sqrt3*I - 1/2] [ 1/2*sqrt3*I + 1/2 -1/2*sqrt3*I + 1/2 0] [ 1 0 0] - sage: BuMa.base_ring() # needs sage.rings.number_field sage.symbolic + sage: BuMa.base_ring() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field + sage: BuMa = ele.burau_matrix(characteristic=7); BuMa [3 1 4] [3 5 0] [1 0 0] sage: BuMa.base_ring() Finite Field of size 7 + + sage: # needs sage.rings.finite_rings sage: BuMa = ele.burau_matrix(characteristic=2); BuMa [t + 1 1 t + 1] [t + 1 t 0] [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 2^2 - sage: F4. = GF(4) # needs sage.libs.pari - sage: BuMa = ele.burau_matrix(root_bur=r64); BuMa # needs sage.libs.pari + sage: F4. = GF(4) + sage: BuMa = ele.burau_matrix(root_bur=r64); BuMa [r64 + 1 1 r64 + 1] [r64 + 1 r64 0] [ 1 0 0] @@ -434,18 +439,20 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 5^2 - sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa # needs sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa [ 0 zeta12^3] [zeta12^3 0] - sage: BuMa * H * BuMaAd == H # needs sage.rings.number_field + sage: BuMa * H * BuMaAd == H True - sage: BuMa.base_ring() # needs sage.rings.number_field + sage: BuMa.base_ring() Cyclotomic Field of order 12 and degree 4 - sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # needs sage.rings.number_field sage.symbolic + sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # needs sage.symbolic ....: reduced='unitary'); BuMa [0 I] [I 0] - sage: BuMa.base_ring() # needs sage.rings.number_field sage.symbolic + sage: BuMa.base_ring() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field """ braid = self.braid() @@ -634,13 +641,15 @@ class CubicBraidGroup(FinitelyPresentedGroup): #I Forcing finiteness test True sage: U3.as_classical_group() - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) sage: C3.as_classical_group() Subgroup with 2 generators ( [ E(3)^2 0] [ 1 -E(12)^7] [-E(12)^7 1], [ 0 E(3)^2] - ) of General Unitary Group of degree 2 over Universal Cyclotomic Field with respect to positive definite hermitian form + ) of General Unitary Group of degree 2 over Universal Cyclotomic Field + with respect to positive definite hermitian form [-E(12)^7 + E(12)^11 -1] [ -1 -E(12)^7 + E(12)^11] @@ -1479,6 +1488,7 @@ def as_matrix_group(self, root_bur=None, domain=None, characteristic=None, var=' EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: C5 = CubicBraidGroup(5) sage: C5Mch5 = C5.as_matrix_group(characteristic=5); C5Mch5 Matrix group over Finite Field in t of size 5^2 with 4 generators ( @@ -1656,6 +1666,7 @@ def as_classical_group(self, embedded=False): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: U3 = AssionGroupU(3) sage: U3Cl = U3.as_classical_group(); U3Cl Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), @@ -1684,6 +1695,8 @@ def as_classical_group(self, embedded=False): General Unitary Group of degree 3 over Finite Field in a of size 2^2 sage: U3Clemb.ambient() == U4Cl True + + sage: # needs sage.rings.number_field sage: C4 = CubicBraidGroup(4) sage: C4Cl = C4.as_classical_group(); C4Cl Subgroup with 3 generators ( @@ -1915,7 +1928,8 @@ def centralizing_element(self, embedded=False): sage: U3 = AssionGroupU(3); U3 Assion group on 3 strands of type U sage: U3Cl = U3.as_classical_group(); U3Cl - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) sage: c = U3.centralizing_element(); c (1,16)(2,9)(3,10)(4,19)(6,12)(7,20)(13,21)(14,15) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 83b53ab6e7d..805aba7a11b 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1217,12 +1217,12 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: # needs sage.rings.number_field sage.schemes sage: E = EllipticCurve(k, [2,4]) # needs sage.rings.finite_rings sage: P = E(3*a^4 + 3*a, 2*a + 1) # needs sage.rings.finite_rings - sage: M = E.cardinality(); M + sage: M = E.cardinality(); M # needs sage.rings.finite_rings 3227 sage: F = M.factor() sage: order_from_multiple(P, M, factorization=F, operation='+') # needs sage.rings.finite_rings 3227 - sage: Q = E(0,2) + sage: Q = E(0,2) # needs sage.rings.finite_rings sage: order_from_multiple(Q, M, factorization=F, operation='+') # needs sage.rings.finite_rings 7 From 0ae88e779a57f793701257908b5edb6221f366ad Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 10:29:56 -0700 Subject: [PATCH 41/64] sage.groups: More block tags, tag corrections --- src/sage/groups/generic.py | 33 ++++++++++--------- .../matrix_gps/finitely_generated_gap.py | 17 ++++++---- .../perm_gps/partn_ref/data_structures.pyx | 2 +- .../perm_gps/partn_ref/refinement_graphs.pyx | 20 ++++++----- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 805aba7a11b..c07cd72db64 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1214,31 +1214,34 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: # needs sage.rings.number_field sage.schemes - sage: E = EllipticCurve(k, [2,4]) # needs sage.rings.finite_rings - sage: P = E(3*a^4 + 3*a, 2*a + 1) # needs sage.rings.finite_rings - sage: M = E.cardinality(); M # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.schemes + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: M = E.cardinality(); M 3227 sage: F = M.factor() - sage: order_from_multiple(P, M, factorization=F, operation='+') # needs sage.rings.finite_rings + sage: order_from_multiple(P, M, factorization=F, operation='+') 3227 - sage: Q = E(0,2) # needs sage.rings.finite_rings - sage: order_from_multiple(Q, M, factorization=F, operation='+') # needs sage.rings.finite_rings + sage: Q = E(0,2) + sage: order_from_multiple(Q, M, factorization=F, operation='+') 7 - sage: K. = CyclotomicField(230) # needs sage.rings.number_field - sage: w = z^50 # needs sage.rings.number_field - sage: order_from_multiple(w, 230, operation='*') # needs sage.rings.finite_rings sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(230) + sage: w = z^50 + sage: order_from_multiple(w, 230, operation='*') # needs sage.rings.finite_rings 23 - sage: F = GF(2^1279,'a') # needs sage.rings.finite_rings - sage: n = F.cardinality() - 1 # Mersenne prime # needs sage.rings.finite_rings - sage: order_from_multiple(F.random_element(), n, # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^1279,'a') + sage: n = F.cardinality() - 1 # Mersenne prime + sage: order_from_multiple(F.random_element(), n, ....: factorization=[(n,1)], operation='*') == n True - sage: K. = GF(3^60) # needs sage.rings.finite_rings - sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(3^60) + sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) 42391158275216203514294433200 """ Z = integer_ring.ZZ diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index 84ad62123a2..ff838701e71 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -212,14 +212,14 @@ def module_composition_factors(self, algorithm=None): sage: F = GF(3); MS = MatrixSpace(F,4,4) sage: M = MS(0) - sage: M[0,1]=1;M[1,2]=1;M[2,3]=1;M[3,0]=1 + sage: M[0,1]=1; M[1,2]=1; M[2,3]=1; M[3,0]=1 sage: G = MatrixGroup([M]) # needs sage.libs.pari sage: G.module_composition_factors() # needs sage.libs.pari [(Finite Field of size 3, 1, True), (Finite Field of size 3, 1, True), (Finite Field of size 3, 2, True)] sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])] + sage: gens = [MS([[0,1],[-1,0]]), MS([[1,1],[2,3]])] sage: G = MatrixGroup(gens) sage: G.module_composition_factors() [(Finite Field of size 7, 2, True)] @@ -280,8 +280,9 @@ def invariant_generators(self): sage: q = 4; a = 2 sage: MS = MatrixSpace(QQ, 2, 2) - sage: gen1 = [[1/a,(q-1)/a],[1/a, -1/a]]; gen2 = [[1,0],[0,-1]]; gen3 = [[-1,0],[0,1]] - sage: G = MatrixGroup([MS(gen1),MS(gen2),MS(gen3)]) + sage: gen1 = [[1/a, (q-1)/a], [1/a, -1/a]] + sage: gen2 = [[1,0], [0,-1]]; gen3 = [[-1,0], [0,1]] + sage: G = MatrixGroup([MS(gen1), MS(gen2), MS(gen3)]) sage: G.cardinality() 12 sage: G.invariant_generators() @@ -484,7 +485,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): sage: # needs sage.rings.number_field sage: K. = CyclotomicField(8) - sage: a = v-v^3 #sqrt(2) + sage: a = v - v^3 # sqrt(2) sage: i = v^2 sage: Octa = MatrixGroup([(-1+i)/2, (-1+i)/2, (1+i)/2, (-1-i)/2], # needs sage.symbolic ....: [(1+i)/a, 0, 0, (1-i)/a]) @@ -500,7 +501,8 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): sage: a = 2*z5^3 + 2*z5^2 + 1 #sqrt(5) sage: Ico = MatrixGroup([[z5^3,0, 0,z5^2], ....: [0,1, -1,0], - ....: [(z5^4-z5)/a, (z5^2-z5^3)/a, (z5^2-z5^3)/a, -(z5^4-z5)/a]]) + ....: [(z5^4-z5)/a, (z5^2-z5^3)/a, + ....: (z5^2-z5^3)/a, -(z5^4-z5)/a]]) sage: Ico.molien_series(prec=40) 1 + t^12 + t^20 + t^24 + t^30 + t^32 + t^36 + O(t^40) @@ -516,7 +518,8 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): sage: K = GF(5) sage: S = MatrixGroup(SymmetricGroup(4)) - sage: G = MatrixGroup([matrix(K, 4, 4, [K(y) for u in m.list() for y in u]) # needs sage.libs.pari + sage: G = MatrixGroup([matrix(K, 4, 4, # needs sage.libs.pari + ....: [K(y) for u in m.list() for y in u]) ....: for m in S.gens()]) sage: G.molien_series(return_series=False) 1/(t^10 - t^9 - t^8 + 2*t^5 - t^2 - t + 1) diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index f09cc3caa01..ea5409fdfcd 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -1292,7 +1292,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 3, 1, 0) - sage: for n in range(4,9): # known bug, not tested + sage: for n in range(4,9): # known bug (see :trac:`32187`), not tested ....: test_stab_chain_fns_4(n, 1, 0, 1) ....: for j in range(6): ....: test_stab_chain_fns_4(n, 2, 0, 1) diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index f324530f817..8a5c1278a70 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -304,7 +304,10 @@ def search_tree(G_in, partition, lab=True, dig=False, dict_rep=False, certificat ....: if bde.has_arc(i,j): ....: bdg.add_edge(i,j) sage: a, b.graph6_string() - ([[0, 19, 3, 2, 6, 5, 4, 17, 18, 11, 10, 9, 13, 12, 16, 15, 14, 7, 8, 1], [0, 1, 8, 9, 13, 14, 7, 6, 2, 3, 19, 18, 17, 4, 5, 15, 16, 12, 11, 10], [1, 8, 9, 10, 11, 12, 13, 14, 7, 6, 2, 3, 4, 5, 15, 16, 17, 18, 19, 0]], 'S?[PG__OQ@?_?_?P?CO?_?AE?EC?Ac?@O') + ([[0, 19, 3, 2, 6, 5, 4, 17, 18, 11, 10, 9, 13, 12, 16, 15, 14, 7, 8, 1], + [0, 1, 8, 9, 13, 14, 7, 6, 2, 3, 19, 18, 17, 4, 5, 15, 16, 12, 11, 10], + [1, 8, 9, 10, 11, 12, 13, 14, 7, 6, 2, 3, 4, 5, 15, 16, 17, 18, 19, 0]], + 'S?[PG__OQ@?_?_?P?CO?_?AE?EC?Ac?@O') sage: a == asp True sage: a == ade @@ -903,14 +906,15 @@ def orbit_partition(gamma, list_perm=False): EXAMPLES:: + sage: # needs sage.groups sage: from sage.groups.perm_gps.partn_ref.refinement_graphs import orbit_partition sage: G = graphs.PetersenGraph() - sage: S = SymmetricGroup(10) # needs sage.groups - sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') # needs sage.groups - sage: orbit_partition(gamma) # needs sage.groups + sage: S = SymmetricGroup(10) + sage: gamma = S('(10,1,2,3,4)(5,6,7)(8,9)') + sage: orbit_partition(gamma) [[1, 2, 3, 4, 0], [5, 6, 7], [8, 9]] - sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') # needs sage.groups - sage: orbit_partition(gamma) # needs sage.groups + sage: gamma = S('(10,5)(1,6)(2,7)(3,8)(4,9)') + sage: orbit_partition(gamma) [[1, 6], [2, 7], [3, 8], [4, 9], [5, 0]] """ if list_perm: @@ -1294,7 +1298,7 @@ def generate_dense_graphs_edge_addition(int n, bint loops, G=None, depth=None, 34 156 1044 - sage: generate_dense_graphs_edge_addition(8,0) # long time - about 14 seconds at 2.4 GHz + sage: generate_dense_graphs_edge_addition(8,0) # long time (about 14 seconds at 2.4 GHz) 12346 """ @@ -1563,7 +1567,7 @@ def generate_dense_graphs_vert_addition(int n, base_G=None, 53 209 1253 - sage: generate_dense_graphs_vert_addition(8) # long time + sage: generate_dense_graphs_vert_addition(8) # long time 13599 TESTS:: From b0dbe78a62889f662f40823b91d7e7ed587c3f40 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 12:42:01 -0700 Subject: [PATCH 42/64] sage.groups.matrix_gps: Remove some unnecessary # needs --- .../groups/matrix_gps/finitely_generated.py | 30 ++++++++--------- .../matrix_gps/finitely_generated_gap.py | 12 +++---- src/sage/groups/matrix_gps/linear.py | 32 +++++++++---------- src/sage/groups/matrix_gps/linear_gap.py | 4 +-- src/sage/groups/matrix_gps/matrix_group.py | 16 +++++----- src/sage/groups/matrix_gps/named_group.py | 8 ++--- src/sage/groups/matrix_gps/orthogonal.py | 14 ++++---- src/sage/groups/matrix_gps/orthogonal_gap.py | 4 +-- src/sage/groups/matrix_gps/symplectic.py | 10 +++--- src/sage/groups/matrix_gps/symplectic_gap.py | 4 +-- src/sage/groups/matrix_gps/unitary_gap.py | 2 +- 11 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index 3204d2f7c01..d0ec214bb3b 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -9,7 +9,7 @@ sage: F = GF(3) sage: gens = [matrix(F, 2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] sage: G = MatrixGroup(gens) - sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] @@ -19,8 +19,8 @@ subgroups of matrix groups:: sage: SL2Z = SL(2, ZZ) - sage: S, T = SL2Z.gens() # needs sage.libs.gap - sage: SL2Z.subgroup([T^2]) # needs sage.libs.gap + sage: S, T = SL2Z.gens() + sage: SL2Z.subgroup([T^2]) Subgroup with 1 generators ( [1 2] [0 1] @@ -162,7 +162,7 @@ def QuaternionMatrixGroupGF3(): sage: from sage.groups.matrix_gps.finitely_generated import QuaternionMatrixGroupGF3 sage: Q = QuaternionMatrixGroupGF3() - sage: Q.order() # needs sage.rings.finite_rings + sage: Q.order() 8 sage: aye = Q.gens()[0]; aye [1 1] @@ -183,15 +183,15 @@ def QuaternionMatrixGroupGF3(): ) sage: Q = QuaternionMatrixGroupGF3() - sage: QP = Q.as_permutation_group() # needs sage.rings.finite_rings - sage: QP.is_isomorphic(QuaternionGroup()) # needs sage.rings.finite_rings + sage: QP = Q.as_permutation_group() + sage: QP.is_isomorphic(QuaternionGroup()) True sage: H = DihedralGroup(4) # needs sage.groups sage: H.order() # needs sage.groups 8 - sage: QP.is_abelian(), H.is_abelian() # needs sage.groups sage.rings.finite_rings + sage: QP.is_abelian(), H.is_abelian() # needs sage.groups (False, False) - sage: QP.is_isomorphic(H) # needs sage.groups sage.rings.finite_rings + sage: QP.is_isomorphic(H) # needs sage.groups False """ from sage.rings.finite_rings.finite_field_constructor import FiniteField @@ -341,8 +341,8 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): False sage: G = GL(2, GF(3)) - sage: H = G.as_matrix_group() # needs sage.rings.finite_rings - sage: H == G, G == H # needs sage.rings.finite_rings + sage: H = G.as_matrix_group() + sage: H == G, G == H (True, True) """ @@ -417,11 +417,11 @@ def gen(self, i): sage: H = GL(2, GF(3)) sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) - sage: G = H.subgroup([h1, h2]) # needs sage.rings.finite_rings - sage: G.gen(0) # needs sage.rings.finite_rings + sage: G = H.subgroup([h1, h2]) + sage: G.gen(0) [1 0] [2 1] - sage: G.gen(0).matrix() == h1.matrix() # needs sage.rings.finite_rings + sage: G.gen(0).matrix() == h1.matrix() True """ return self.gens()[i] @@ -438,8 +438,8 @@ def ngens(self): sage: H = GL(2, GF(3)) sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) - sage: G = H.subgroup([h1, h2]) # needs sage.rings.finite_rings - sage: G.ngens() # needs sage.rings.finite_rings + sage: G = H.subgroup([h1, h2]) + sage: G.ngens() 2 """ return len(self._gens_matrix) diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index ff838701e71..9cc9a30826f 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -109,8 +109,8 @@ def as_permutation_group(self, algorithm=None, seed=None): sage: MS = MatrixSpace(GF(2), 5, 5) sage: A = MS([[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,0,0]]) - sage: G = MatrixGroup([A]) # needs sage.libs.pari - sage: G.as_permutation_group().order() # needs sage.libs.pari + sage: G = MatrixGroup([A]) + sage: G.as_permutation_group().order() 2 A finite subgroup of `GL(12,\ZZ)` as a permutation group:: @@ -165,7 +165,7 @@ def as_permutation_group(self, algorithm=None, seed=None): The above example in `GL(12,\ZZ)`, reduced modulo 7:: sage: MS = MatrixSpace(GF(7), 12, 12) - sage: G = MatrixGroup([MS(g) for g in GG.GeneratorsOfGroup()]) # needs sage.libs.pari + sage: G = MatrixGroup([MS(g) for g in GG.GeneratorsOfGroup()]) sage: G.cardinality() 21499084800 sage: P = G.as_permutation_group() @@ -213,8 +213,8 @@ def module_composition_factors(self, algorithm=None): sage: F = GF(3); MS = MatrixSpace(F,4,4) sage: M = MS(0) sage: M[0,1]=1; M[1,2]=1; M[2,3]=1; M[3,0]=1 - sage: G = MatrixGroup([M]) # needs sage.libs.pari - sage: G.module_composition_factors() # needs sage.libs.pari + sage: G = MatrixGroup([M]) + sage: G.module_composition_factors() [(Finite Field of size 3, 1, True), (Finite Field of size 3, 1, True), (Finite Field of size 3, 2, True)] @@ -518,7 +518,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): sage: K = GF(5) sage: S = MatrixGroup(SymmetricGroup(4)) - sage: G = MatrixGroup([matrix(K, 4, 4, # needs sage.libs.pari + sage: G = MatrixGroup([matrix(K, 4, 4, ....: [K(y) for u in m.list() for y in u]) ....: for m in S.gens()]) sage: G.molien_series(return_series=False) diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 6fbb4e1bdc1..4053c6c50f6 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -16,15 +16,15 @@ Special Linear Group of degree 2 over Integer Ring sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # needs sage.rings.finite_rings + sage: G.is_finite() True - sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) sage: G = SL(6, GF(5)) - sage: G.gens() # needs sage.rings.finite_rings + sage: G.gens() ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -94,13 +94,13 @@ def GL(n, R, var='a'): EXAMPLES:: sage: G = GL(6, GF(5)) - sage: G.order() # needs sage.rings.finite_rings + sage: G.order() 11064475422000000000000000 sage: G.base_ring() Finite Field of size 5 sage: G.category() Category of finite groups - sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: TestSuite(G).run() sage: G = GL(6, QQ) sage: G.category() @@ -123,20 +123,20 @@ def GL(n, R, var='a'): sage: F = GF(3); MS = MatrixSpace(F, 2, 2) sage: gens = [MS([[2,0], [0,1]]), MS([[2,1], [2,0]])] sage: G = MatrixGroup(gens) - sage: G.order() # needs sage.rings.finite_rings + sage: G.order() 48 - sage: G.cardinality() # needs sage.rings.finite_rings + sage: G.cardinality() 48 sage: H = GL(2,F) - sage: H.order() # needs sage.rings.finite_rings + sage: H.order() 48 - sage: H == G # needs sage.rings.finite_rings + sage: H == G True - sage: H.gens() == G.gens() # needs sage.rings.finite_rings + sage: H.gens() == G.gens() True - sage: H.as_matrix_group() == H # needs sage.rings.finite_rings + sage: H.as_matrix_group() == H True - sage: H.gens() # needs sage.rings.finite_rings + sage: H.gens() ( [2 0] [2 1] [0 1], [2 0] @@ -213,15 +213,15 @@ def SL(n, R, var='a'): Special Linear Group of degree 15 over Finite Field of size 7 sage: G.category() Category of finite groups - sage: G.order() # needs sage.rings.finite_rings + sage: G.order() 1956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000 - sage: len(G.gens()) # needs sage.rings.finite_rings + sage: len(G.gens()) 2 sage: G = SL(2, ZZ); G Special Linear Group of degree 2 over Integer Ring sage: G.category() Category of infinite groups - sage: G.gens() # needs sage.libs.gap + sage: G.gens() ( [ 0 1] [1 1] [-1 0], [0 1] @@ -231,7 +231,7 @@ def SL(n, R, var='a'): sage: G = SL(3, ZZ); G Special Linear Group of degree 3 over Integer Ring - sage: G.gens() # needs sage.libs.gap + sage: G.gens() ( [0 1 0] [ 0 1 0] [1 1 0] [0 0 1] [-1 0 0] [0 1 0] diff --git a/src/sage/groups/matrix_gps/linear_gap.py b/src/sage/groups/matrix_gps/linear_gap.py index 9f608ab5c62..37d33d5d2be 100644 --- a/src/sage/groups/matrix_gps/linear_gap.py +++ b/src/sage/groups/matrix_gps/linear_gap.py @@ -15,9 +15,9 @@ class LinearMatrixGroup_gap(NamedMatrixGroup_gap, LinearMatrixGroup_generic, Fin Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap sage: G = GL(3,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) True """ pass diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index ad452396058..c0c22456320 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -7,16 +7,16 @@ sage: G = GL(2,5); G General Linear Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: TestSuite(G).run() - sage: g = G.1; g # needs sage.rings.finite_rings + sage: g = G.1; g [4 1] [4 0] - sage: TestSuite(g).run() # needs sage.rings.finite_rings + sage: TestSuite(g).run() We test that :trac:`9437` is fixed:: - sage: len(list(SL(2, Zmod(4)))) # needs sage.libs.gap + sage: len(list(SL(2, Zmod(4)))) 48 AUTHORS: @@ -168,7 +168,7 @@ def as_matrix_group(self): ) sage: G = GO(3,GF(5)) - sage: G.as_matrix_group() # needs sage.rings.finite_rings + sage: G.as_matrix_group() Matrix group over Finite Field of size 5 with 2 generators ( [2 0 0] [0 1 0] [0 3 0] [1 4 4] @@ -480,10 +480,10 @@ def __richcmp__(self, other, op): EXAMPLES:: sage: G = GL(2,3) - sage: H = MatrixGroup(G.gens()) # needs sage.rings.finite_rings - sage: H == G # needs sage.rings.finite_rings + sage: H = MatrixGroup(G.gens()) + sage: H == G True - sage: G == H # needs sage.rings.finite_rings + sage: G == H True sage: MS = MatrixSpace(QQ, 2, 2) diff --git a/src/sage/groups/matrix_gps/named_group.py b/src/sage/groups/matrix_gps/named_group.py index dea27976793..4568c43d326 100644 --- a/src/sage/groups/matrix_gps/named_group.py +++ b/src/sage/groups/matrix_gps/named_group.py @@ -10,15 +10,15 @@ Special Linear Group of degree 2 over Integer Ring sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # needs sage.rings.finite_rings + sage: G.is_finite() True - sage: G.conjugacy_classes_representatives() # needs sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) sage: G = SL(6, GF(5)) - sage: G.gens() # needs sage.rings.finite_rings + sage: G.gens() ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -289,7 +289,7 @@ def __richcmp__(self, other, op): EXAMPLES:: sage: G = GL(2,3) - sage: G == MatrixGroup(G.gens()) # needs sage.rings.finite_rings + sage: G == MatrixGroup(G.gens()) True sage: # needs sage.rings.finite_rings diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index e4f4c07e2b6..77aed23d9eb 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -39,7 +39,7 @@ sage: G = SO(4, GF(7), 1); G Special Orthogonal Group of degree 4 and form parameter 1 over Finite Field of size 7 - sage: G.random_element() # random # needs sage.rings.finite_rings + sage: G.random_element() # random [4 3 5 2] [6 6 4 0] [0 4 6 0] @@ -270,9 +270,9 @@ def GO(n, R, e=0, var='a', invariant_form=None): sage: GO(3, GF(7)) General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: GO(3, GF(7)).order() # needs sage.rings.finite_rings + sage: GO(3, GF(7)).order() 672 - sage: GO(3, GF(7)).gens() # needs sage.rings.finite_rings + sage: GO(3, GF(7)).gens() ( [3 0 0] [0 1 0] [0 5 0] [1 6 6] @@ -380,14 +380,14 @@ def SO(n, R, e=None, var='a', invariant_form=None): Special Orthogonal Group of degree 3 over Finite Field of size 5 sage: G = SO(3,GF(5)) - sage: G.gens() # needs sage.rings.finite_rings + sage: G.gens() ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] [0 0 1], [0 3 1], [2 0 4] ) sage: G = SO(3,GF(5)) - sage: G.as_matrix_group() # needs sage.rings.finite_rings + sage: G.as_matrix_group() Matrix group over Finite Field of size 5 with 3 generators ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] @@ -483,10 +483,10 @@ def invariant_bilinear_form(self): EXAMPLES:: - sage: GO(2,3,+1).invariant_bilinear_form() # needs sage.rings.finite_rings + sage: GO(2,3,+1).invariant_bilinear_form() [0 1] [1 0] - sage: GO(2,3,-1).invariant_bilinear_form() # needs sage.rings.finite_rings + sage: GO(2,3,-1).invariant_bilinear_form() [2 1] [1 1] sage: G = GO(4, QQ) diff --git a/src/sage/groups/matrix_gps/orthogonal_gap.py b/src/sage/groups/matrix_gps/orthogonal_gap.py index 0a5f75ba17f..17dabb698f2 100644 --- a/src/sage/groups/matrix_gps/orthogonal_gap.py +++ b/src/sage/groups/matrix_gps/orthogonal_gap.py @@ -31,9 +31,9 @@ class OrthogonalMatrixGroup_gap(OrthogonalMatrixGroup_generic, NamedMatrixGroup_ Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap sage: G = GO(3,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) True """ @cached_method diff --git a/src/sage/groups/matrix_gps/symplectic.py b/src/sage/groups/matrix_gps/symplectic.py index f2521c0ff82..3a7e7258fe9 100644 --- a/src/sage/groups/matrix_gps/symplectic.py +++ b/src/sage/groups/matrix_gps/symplectic.py @@ -5,15 +5,15 @@ sage: G = Sp(4, GF(7)); G Symplectic Group of degree 4 over Finite Field of size 7 - sage: g = prod(G.gens()); g # needs sage.rings.finite_rings + sage: g = prod(G.gens()); g [3 0 3 0] [1 0 0 0] [0 1 0 1] [0 2 0 0] - sage: m = g.matrix() # needs sage.rings.finite_rings - sage: m * G.invariant_form() * m.transpose() == G.invariant_form() # needs sage.rings.finite_rings + sage: m = g.matrix() + sage: m * G.invariant_form() * m.transpose() == G.invariant_form() True - sage: G.order() # needs sage.rings.finite_rings + sage: G.order() 276595200 AUTHORS: @@ -139,7 +139,7 @@ def Sp(n, R, var='a', invariant_form=None): Symplectic Group of degree 2 over Finite Field of size 3 sage: G = Sp(4,5) - sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: TestSuite(G).run() """ degree, ring = normalize_args_vectorspace(n, R, var=var) if degree % 2: diff --git a/src/sage/groups/matrix_gps/symplectic_gap.py b/src/sage/groups/matrix_gps/symplectic_gap.py index 16cde0ee961..2a18c37a5eb 100644 --- a/src/sage/groups/matrix_gps/symplectic_gap.py +++ b/src/sage/groups/matrix_gps/symplectic_gap.py @@ -37,9 +37,9 @@ class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_ Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap sage: G = Sp(4,3) - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.rings.number_field + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) True """ diff --git a/src/sage/groups/matrix_gps/unitary_gap.py b/src/sage/groups/matrix_gps/unitary_gap.py index 5119096af56..bbcdb898359 100644 --- a/src/sage/groups/matrix_gps/unitary_gap.py +++ b/src/sage/groups/matrix_gps/unitary_gap.py @@ -29,7 +29,7 @@ class UnitaryMatrixGroup_gap(UnitaryMatrixGroup_generic, NamedMatrixGroup_gap, F Check that :trac:`20867` is fixed:: - sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap # needs sage.rings.number_field + sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap sage: G = GU(3,3) # needs sage.libs.pari sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.libs.pari sage.rings.number_field True From fd374b1fe45e58faf9ceca961d2df93f17f25ffb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 11:57:43 -0700 Subject: [PATCH 43/64] src/sage/groups/matrix_gps/coxeter_group.py: Move import from number_field into method --- src/sage/groups/matrix_gps/coxeter_group.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/groups/matrix_gps/coxeter_group.py b/src/sage/groups/matrix_gps/coxeter_group.py index 537cf1e9cea..b14f5a9a49e 100644 --- a/src/sage/groups/matrix_gps/coxeter_group.py +++ b/src/sage/groups/matrix_gps/coxeter_group.py @@ -1,3 +1,4 @@ +# sage_setup: distribution = sagemath-modules """ Coxeter Groups As Matrix Groups @@ -30,7 +31,6 @@ from sage.misc.cachefunc import cached_method from sage.rings.integer_ring import ZZ from sage.rings.infinity import infinity -from sage.rings.number_field.number_field import QuadraticField from sage.sets.family import Family from sage.structure.unique_representation import UniqueRepresentation @@ -216,6 +216,7 @@ def __classcall_private__(cls, data, base_ring=None, index_set=None): if data.is_simply_laced(): base_ring = ZZ elif data.is_finite(): + from sage.rings.number_field.number_field import QuadraticField letter = data.coxeter_type().cartan_type().type() if letter in ['B', 'C', 'F']: base_ring = QuadraticField(2) From 9ce430008cccf150695f8353140479777d5e7ceb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 12:04:04 -0700 Subject: [PATCH 44/64] src/sage/groups/matrix_gps/finitely_generated_gap.py: Move imports from number_field into methods --- src/sage/groups/matrix_gps/finitely_generated_gap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index 9cc9a30826f..7e130961ab6 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -34,10 +34,8 @@ from sage.modules.free_module_element import vector from sage.rings.fraction_field import FractionField from sage.rings.integer_ring import ZZ -from sage.rings.number_field.number_field import CyclotomicField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.power_series_ring import PowerSeriesRing -from sage.rings.qqbar import QQbar from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence @@ -562,6 +560,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): w = F.roots(ring=R.algebraic_closure(), multiplicities=False)[0] # don't need to extend further in this case since the order of # the roots of unity in the character divide the order of the group + from sage.rings.number_field.number_field import CyclotomicField L = CyclotomicField(N, 'v') v = L.gen() # construct Molien series @@ -751,6 +750,7 @@ def reynolds_operator(self, poly, chi=None): C = FractionField(self.base_ring()) if chi is None: # then this is the trivial character if R.characteristic() == 0: + from sage.rings.qqbar import QQbar # non-modular case if C == QQbar or R == QQbar: L = QQbar @@ -783,6 +783,7 @@ def reynolds_operator(self, poly, chi=None): # non-trivial character case K = chi.values()[0].parent() if R.characteristic() == 0: + from sage.rings.qqbar import QQbar # extend base_ring to compositum if C == QQbar or K == QQbar or R == QQbar: L = QQbar From 3410a400e63e797096bbf65adb2e936084b44a25 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 13:25:01 -0700 Subject: [PATCH 45/64] src/sage/groups/group_semidirect_product.py: Doctest cosmetics --- src/sage/groups/group_semidirect_product.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/groups/group_semidirect_product.py b/src/sage/groups/group_semidirect_product.py index 67ada01f508..2e809e43d87 100644 --- a/src/sage/groups/group_semidirect_product.py +++ b/src/sage/groups/group_semidirect_product.py @@ -147,7 +147,7 @@ class GroupSemidirectProduct(CartesianProduct): - ``prefix0`` -- (default: ``None``) optional string - ``prefix1`` -- (default: ``None``) optional string - ``print_tuple`` -- ``True`` or ``False`` (default: ``False``) - - ``category`` -- A category (default: Groups()) + - ``category`` -- A category (default: ``Groups()``) A semidirect product of groups `G` and `H` is a group structure on the Cartesian product `G \times H` whose product agrees with that @@ -213,10 +213,10 @@ class GroupSemidirectProduct(CartesianProduct): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: H = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't'); H + sage: H = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t'); H Semidirect product of General Linear Group of degree 2 over Rational Field acting on Multiplicative form of Vector space of dimension 2 over Rational Field @@ -230,7 +230,7 @@ class GroupSemidirectProduct(CartesianProduct): sage: W = WeylGroup(cartan_type, prefix="s") sage: def twist(w,v): ....: return w*v*(~w) - sage: WW = GroupSemidirectProduct(W,W, twist=twist, print_tuple=True) + sage: WW = GroupSemidirectProduct(W, W, twist=twist, print_tuple=True) sage: s = Family(cartan_type.index_set(), lambda i: W.simple_reflection(i)) sage: y = WW((s[1],s[2])); y (s1, s2) @@ -298,7 +298,7 @@ def act_to_right(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field ....: WeylGroup(['A',3],prefix="t"), twist).act_to_right() True """ From ade8009fdd32909e778d74971380f15863c9b642 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 13:28:05 -0700 Subject: [PATCH 46/64] sage.groups.matrix_gps: Fix # needs --- .../matrix_gps/finitely_generated_gap.py | 47 +++++++++++-------- src/sage/groups/matrix_gps/heisenberg.py | 1 + src/sage/groups/matrix_gps/isometries.py | 9 ++-- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index 7e130961ab6..5864f64afd3 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -210,7 +210,7 @@ def module_composition_factors(self, algorithm=None): sage: F = GF(3); MS = MatrixSpace(F,4,4) sage: M = MS(0) - sage: M[0,1]=1; M[1,2]=1; M[2,3]=1; M[3,0]=1 + sage: M[0,1] = 1; M[1,2] = 1; M[2,3] = 1; M[3,0] = 1 sage: G = MatrixGroup([M]) sage: G.module_composition_factors() [(Finite Field of size 3, 1, True), @@ -271,7 +271,7 @@ def invariant_generators(self): sage: F = GF(7); MS = MatrixSpace(F,2,2) sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])] sage: G = MatrixGroup(gens) - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^7*x2 - x1*x2^7, x1^12 - 2*x1^9*x2^3 - x1^6*x2^6 + 2*x1^3*x2^9 + x2^12, x1^18 + 2*x1^15*x2^3 + 3*x1^12*x2^6 + 3*x1^6*x2^12 - 2*x1^3*x2^15 + x2^18] @@ -283,7 +283,7 @@ def invariant_generators(self): sage: G = MatrixGroup([MS(gen1), MS(gen2), MS(gen3)]) sage: G.cardinality() 12 - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^2 + 3*x2^2, x1^6 + 15*x1^4*x2^2 + 15*x1^2*x2^4 + 33*x2^6] sage: # needs sage.rings.number_field @@ -295,7 +295,7 @@ def invariant_generators(self): sage: g1 = MS([[1/a, 1/a], [1/a, -1/a]]) sage: g2 = MS([[-b, 0], [0, b]]) sage: G = MatrixGroup([g1,g2]) - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^4 + 2*x1^2*x2^2 + x2^4, x1^5*x2 - x1*x2^5, x1^8 + 28/9*x1^6*x2^2 + 70/9*x1^4*x2^4 + 28/9*x1^2*x2^6 + x2^8] @@ -443,14 +443,14 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): Traceback (most recent call last): ... NotImplementedError: only implemented for finite groups - sage: MatrixGroup(matrix(GF(3),2,2,[1,1,0,1])).molien_series() + sage: MatrixGroup(matrix(GF(3),2,2,[1,1,0,1])).molien_series() # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: characteristic cannot divide group order Tetrahedral Group:: - sage: # needs sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: Tetra.molien_series(prec=30) @@ -468,12 +468,12 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.groups sage.rings.number_field sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: mol = S3.molien_series(prec=10); mol 1 + t + 2*t^2 + 3*t^3 + 4*t^4 + 5*t^5 + 7*t^6 + 8*t^7 + 10*t^8 + 12*t^9 + O(t^10) sage: mol.parent() Power Series Ring in t over Integer Ring - sage: mol = S3.molien_series(prec=oo); mol 1 + t + 2*t^2 + 3*t^3 + 4*t^4 + 5*t^5 + 7*t^6 + O(t^7) sage: mol.parent() @@ -506,6 +506,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) sage: G.molien_series(chi, prec=10) @@ -514,6 +515,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.groups sage.rings.number_field sage: K = GF(5) sage: S = MatrixGroup(SymmetricGroup(4)) sage: G = MatrixGroup([matrix(K, 4, 4, @@ -524,6 +526,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.rings.number_field sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0, 0,-i^3], [i^2,0, 0,-i^2]]) sage: chi = G.character(G.character_table()[4]) @@ -634,12 +637,12 @@ def reynolds_operator(self, poly, chi=None): sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: R. = QQ[] sage: f = x*y*z^3 - sage: S3.reynolds_operator(f) + sage: S3.reynolds_operator(f) # needs sage.rings.number_field 1/3*x^3*y*z + 1/3*x*y^3*z + 1/3*x*y*z^3 :: - sage: # needs sage.rings.number_field + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(CyclicPermutationGroup(4)) sage: chi = G.character(G.character_table()[3]) sage: K. = CyclotomicField(4) @@ -653,7 +656,7 @@ def reynolds_operator(self, poly, chi=None): :: - sage: # needs sage.rings.number_field + sage: # needs sage.groups sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) @@ -668,7 +671,7 @@ def reynolds_operator(self, poly, chi=None): :: - sage: # needs sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: chi = Tetra.character(Tetra.character_table()[4]) @@ -688,6 +691,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(DihedralGroup(4)) sage: chi = G.character(G.character_table()[1]) sage: R. = QQ[] @@ -715,10 +719,10 @@ def reynolds_operator(self, poly, chi=None): sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0, 0,-i^3], [i^2,0, 0,-i^2]]) - sage: chi = G.character(G.character_table()[4]) + sage: chi = G.character(G.character_table()[4]) # needs sage.rings.number_field sage: R. = GF(7)[] sage: f = w^5*x + x^6 - sage: G.reynolds_operator(f, chi) + sage: G.reynolds_operator(f, chi) # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: nontrivial characters not implemented for characteristic > 0 @@ -845,6 +849,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): EXAMPLES:: + sage: # needs sage.groups sage.rings.number_field sage: Gr = MatrixGroup(SymmetricGroup(2)) sage: sorted(Gr.invariants_of_degree(3)) [x0^2*x1 + x0*x1^2, x0^3 + x1^3] @@ -854,6 +859,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.groups sage.rings.number_field sage: R. = QQ[] sage: Gr = MatrixGroup(DihedralGroup(3)) sage: ct = Gr.character_table() @@ -866,11 +872,12 @@ def invariants_of_degree(self, deg, chi=None, R=None): sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0,0,-i^3],[i^2,0,0,-i^2]]) - sage: G.invariants_of_degree(25) + sage: G.invariants_of_degree(25) # needs sage.rings.number_field [] :: + sage: # needs sage.groups sage: G = MatrixGroup(SymmetricGroup(5)) sage: R = QQ['x,y'] sage: G.invariants_of_degree(3, R=R) @@ -880,7 +887,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: - sage: # needs sage.rings.number_field + sage: # needs sage.groups sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) @@ -893,6 +900,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.groups sage.rings.number_field sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: chi = S3.character(S3.character_table()[0]) sage: sorted(S3.invariants_of_degree(5, chi=chi)) @@ -922,13 +930,14 @@ def invariants_of_degree(self, deg, chi=None, R=None): def _new_invariant_is_linearly_independent(F, invariants): """ - EXAMPLES :: + EXAMPLES:: + sage: gens = [matrix(QQ, [[-1,1],[-1,0]]), matrix(QQ, [[0,1],[1,0]])] sage: G = MatrixGroup(gens) - sage: s = Sequence(G.invariants_of_degree(14)) - sage: s.coefficient_matrix()[0].rank() + sage: s = Sequence(G.invariants_of_degree(14)) # needs sage.rings.number_field + sage: s.coefficient_matrix()[0].rank() # needs sage.rings.number_field 3 - sage: len(s) + sage: len(s) # needs sage.rings.number_field 3 """ if len(invariants)==0: diff --git a/src/sage/groups/matrix_gps/heisenberg.py b/src/sage/groups/matrix_gps/heisenberg.py index 17705a55cde..8a262ddf1c7 100644 --- a/src/sage/groups/matrix_gps/heisenberg.py +++ b/src/sage/groups/matrix_gps/heisenberg.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap sage.modules """ Heisenberg Group diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py index 3810a80cadc..cbc88ccb184 100644 --- a/src/sage/groups/matrix_gps/isometries.py +++ b/src/sage/groups/matrix_gps/isometries.py @@ -8,9 +8,8 @@ EXAMPLES:: - sage: L = IntegralLattice("D4") - sage: O = L.orthogonal_group() - sage: O + sage: L = IntegralLattice("D4") # needs sage.graphs + sage: O = L.orthogonal_group(); O # needs sage.graphs Group of isometries with 3 generators ( [0 0 0 1] [ 1 1 0 0] [ 1 0 0 0] [0 1 0 0] [ 0 0 1 0] [-1 -1 -1 -1] @@ -20,9 +19,9 @@ Basic functionality is provided by GAP:: - sage: O.cardinality() + sage: O.cardinality() # needs sage.graphs 1152 - sage: len(O.conjugacy_classes_representatives()) + sage: len(O.conjugacy_classes_representatives()) # needs sage.graphs 25 AUTHORS: From 2ec7684520fde9e20e8dac16f76a522ef6ace91d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 13:29:49 -0700 Subject: [PATCH 47/64] src/sage/combinat/root_system/coxeter_group.py: Make imports of ReflectionGroup, WeylGroup lazy --- src/sage/combinat/root_system/coxeter_group.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/root_system/coxeter_group.py b/src/sage/combinat/root_system/coxeter_group.py index 33c8858d5f8..f33003b35f6 100644 --- a/src/sage/combinat/root_system/coxeter_group.py +++ b/src/sage/combinat/root_system/coxeter_group.py @@ -9,9 +9,11 @@ # https://www.gnu.org/licenses/ # *************************************************************************** -from sage.combinat.root_system.weyl_group import WeylGroup -from sage.combinat.root_system.reflection_group_real import ReflectionGroup from sage.combinat.root_system.cartan_type import CartanType +from sage.misc.lazy_import import lazy_import + +lazy_import('from sage.combinat.root_system.reflection_group_real', 'ReflectionGroup') +lazy_import('sage.combinat.root_system.weyl_group', 'WeylGroup') def CoxeterGroup(data, implementation="reflection", base_ring=None, index_set=None): From 8f47096743227bc6aa535371c9110d800b52c8b9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 17:55:14 -0700 Subject: [PATCH 48/64] sage.groups.matrix_gps: Use file and block tags --- src/sage/groups/matrix_gps/binary_dihedral.py | 1 + src/sage/groups/matrix_gps/coxeter_group.py | 38 +++++++++----- src/sage/groups/matrix_gps/group_element.pyx | 51 +++++++++---------- src/sage/groups/matrix_gps/unitary.py | 2 +- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/sage/groups/matrix_gps/binary_dihedral.py b/src/sage/groups/matrix_gps/binary_dihedral.py index c8813eeabd4..ccce9eeb17b 100644 --- a/src/sage/groups/matrix_gps/binary_dihedral.py +++ b/src/sage/groups/matrix_gps/binary_dihedral.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap sage.modules sage.rings.number_field """ Binary Dihedral Groups diff --git a/src/sage/groups/matrix_gps/coxeter_group.py b/src/sage/groups/matrix_gps/coxeter_group.py index b14f5a9a49e..27d65a55a37 100644 --- a/src/sage/groups/matrix_gps/coxeter_group.py +++ b/src/sage/groups/matrix_gps/coxeter_group.py @@ -1,4 +1,4 @@ -# sage_setup: distribution = sagemath-modules +# sage.doctest: needs sage.graphs """ Coxeter Groups As Matrix Groups @@ -79,8 +79,8 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene We can create Coxeter groups from Coxeter matrices:: - sage: W = CoxeterGroup([[1, 6, 3], [6, 1, 10], [3, 10, 1]]) - sage: W + sage: # needs sage.rings.number_field + sage: W = CoxeterGroup([[1, 6, 3], [6, 1, 10], [3, 10, 1]]); W Coxeter group over Universal Cyclotomic Field with Coxeter matrix: [ 1 6 3] [ 6 1 10] @@ -99,6 +99,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene [ 0 1 0] [ 1 E(20) - E(20)^9 -1] ) + sage: m = matrix([[1,3,3,3], [3,1,3,2], [3,3,1,2], [3,2,2,1]]) sage: W = CoxeterGroup(m) sage: W.gens() @@ -140,7 +141,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene [3 1 3 2] [3 3 1 2] [3 2 2 1] - sage: CoxeterGroup([[1,4],[4,1]], base_ring=QQ) + sage: CoxeterGroup([[1,4],[4,1]], base_ring=QQ) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unable to convert sqrt(2) to a rational @@ -149,6 +150,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene graphs, we can input a Coxeter graph. Following the standard convention, edges with no label (i.e. labelled by ``None``) are treated as 3:: + sage: # needs sage.rings.number_field sage: G = Graph([(0,3,None), (1,3,15), (2,3,7), (0,1,3)]) sage: W = CoxeterGroup(G); W Coxeter group over Universal Cyclotomic Field with Coxeter matrix: @@ -163,6 +165,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene Because there currently is no class for `\ZZ \cup \{ \infty \}`, labels of `\infty` are given by `-1` in the Coxeter matrix:: + sage: # needs sage.rings.number_field sage: G = Graph([(0,1,None), (1,2,4), (0,2,oo)]) sage: W = CoxeterGroup(G) sage: W.coxeter_matrix() @@ -173,16 +176,14 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene We can also create Coxeter groups from Cartan types using the ``implementation`` keyword:: - sage: W = CoxeterGroup(['D',5], implementation="reflection") - sage: W + sage: W = CoxeterGroup(['D',5], implementation="reflection"); W Finite Coxeter group over Integer Ring with Coxeter matrix: [1 3 2 2 2] [3 1 3 2 2] [2 3 1 3 3] [2 2 3 1 2] [2 2 3 2 1] - sage: W = CoxeterGroup(['H',3], implementation="reflection") - sage: W + sage: W = CoxeterGroup(['H',3], implementation="reflection"); W # needs sage.rings.number_field Finite Coxeter group over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? with Coxeter matrix: @@ -240,6 +241,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): sage: W = CoxeterGroup([[1,3,2],[3,1,3],[2,3,1]]) sage: TestSuite(W).run() # long time + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]], base_ring=QQbar) sage: TestSuite(W).run() # long time sage: W = CoxeterGroup([[1,3,2],[3,1,6],[2,6,1]]) @@ -251,6 +254,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): sage: CoxeterGroup(['D',4], base_ring=QQ).category() Category of finite irreducible coxeter groups + + sage: # needs sage.rings.number_field sage: CoxeterGroup(['H',4], base_ring=QQbar).category() Category of finite irreducible coxeter groups sage: F = CoxeterGroups().Finite() @@ -335,7 +340,7 @@ def _repr_(self): EXAMPLES:: - sage: CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]]) + sage: CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]]) # needs sage.rings.number_field Finite Coxeter group over Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? with Coxeter matrix: [1 3 2] [3 1 4] @@ -352,6 +357,7 @@ def _coerce_map_from_(self, P): EXAMPLES:: + sage: # needs sage.combinat sage: W = CoxeterGroup(["A",4]) sage: W2 = WeylGroup(["A",4]) sage: W._coerce_map_from_(W2) @@ -377,7 +383,7 @@ def coxeter_matrix(self): sage: W.coxeter_matrix() [1 3] [3 1] - sage: W = CoxeterGroup(['H',3]) + sage: W = CoxeterGroup(['H',3]) # needs sage.rings.number_field sage: W.coxeter_matrix() [1 3 2] [3 1 5] @@ -403,7 +409,7 @@ def bilinear_form(self): EXAMPLES:: sage: W = CoxeterGroup(['D',4]) - sage: W.bilinear_form() + sage: W.bilinear_form() # needs sage.symbolic [ 1 -1/2 0 0] [-1/2 1 -1/2 -1/2] [ 0 -1/2 1 0] @@ -417,6 +423,7 @@ def is_finite(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: [l for l in range(2, 9) if ....: CoxeterGroup([[1,3,2],[3,1,l],[2,l,1]]).is_finite()] [2, 3, 4, 5] @@ -471,6 +478,7 @@ def order(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: W = CoxeterGroup([[1,3],[3,1]]) sage: W.order() 6 @@ -584,6 +592,8 @@ def positive_roots(self): sage: W = CoxeterGroup(['A',3], implementation='reflection') sage: W.positive_roots() ((1, 0, 0), (1, 1, 0), (0, 1, 0), (1, 1, 1), (0, 1, 1), (0, 0, 1)) + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',5], implementation='reflection') sage: W.positive_roots() ((1, 0), @@ -640,6 +650,8 @@ def roots(self): (-1, -1, -1), (0, -1, -1), (0, 0, -1)) + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',5], implementation='reflection') sage: len(W.roots()) 10 @@ -680,7 +692,7 @@ def fundamental_weights(self): EXAMPLES:: sage: W = CoxeterGroup(['A',3], implementation='reflection') - sage: W.fundamental_weights() + sage: W.fundamental_weights() # needs sage.symbolic Finite family {1: (3/2, 1, 1/2), 2: (1, 2, 1), 3: (1/2, 1, 3/2)} """ simple_weights = self.bilinear_form().inverse() @@ -697,7 +709,7 @@ def fundamental_weight(self, i): EXAMPLES:: sage: W = CoxeterGroup(['A',3], implementation='reflection') - sage: W.fundamental_weight(1) + sage: W.fundamental_weight(1) # needs sage.symbolic (3/2, 1, 1/2) """ return self.fundamental_weights()[i] diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 3d884e81dac..6c72c5429ab 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -3,7 +3,6 @@ Matrix Group Elements EXAMPLES:: - sage: # needs sage.rings.finite_rings sage: F = GF(3); MS = MatrixSpace(F, 2, 2) sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] sage: G = MatrixGroup(gens); G @@ -138,8 +137,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.an_element(); g # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element(); g # needs sage.graphs [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -150,9 +149,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.an_element() # needs sage.combinat sage.libs.gap - sage: TestSuite(g).run() # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: TestSuite(g).run() # needs sage.graphs """ if convert: M = parent.matrix_space()(M) @@ -173,9 +172,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.an_element() # needs sage.combinat sage.libs.gap - sage: hash(g) # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: hash(g) # needs sage.graphs 660522311176098153 # 64-bit -606138007 # 32-bit """ @@ -187,9 +186,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.an_element() # needs sage.combinat sage.libs.gap - sage: loads(g.dumps()) == g # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: loads(g.dumps()) == g # needs sage.graphs True """ return (_unpickle_generic_element, (self.parent(), self._matrix,)) @@ -200,8 +199,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: W.an_element() # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: W.an_element() # needs sage.graphs [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -212,9 +211,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.an_element() # needs sage.combinat sage.libs.gap - sage: latex(g) # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: latex(g) # needs sage.graphs \left(\begin{array}{rrr} 0 & 0 & -1 \\ 1 & 0 & -1 \\ @@ -319,9 +318,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # needs sage.combinat sage.libs.gap - sage: g = W.gen(0) # needs sage.combinat sage.libs.gap - sage: matrix(RDF, g) # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # needs sage.graphs + sage: g = W.gen(0) # needs sage.graphs + sage: matrix(RDF, g) # needs sage.graphs [-1.0 1.0 0.0] [ 0.0 1.0 0.0] [ 0.0 0.0 1.0] @@ -357,14 +356,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3]) # needs sage.combinat sage.libs.gap - sage: g = W.gen(0) # needs sage.combinat sage.libs.gap - sage: g.is_one() # needs sage.combinat sage.libs.gap + sage: # needs sage.graphs + sage: W = CoxeterGroup(['A',3]) + sage: g = W.gen(0) + sage: g.is_one() False - - sage: W.an_element().is_one() # needs sage.combinat sage.libs.gap + sage: W.an_element().is_one() False - sage: W.one().is_one() # needs sage.combinat sage.libs.gap + sage: W.one().is_one() True """ return self._matrix.is_one() diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 81a49c9ff88..22dd25b1a4b 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -245,7 +245,7 @@ def GU(n, R, var='a', invariant_form=None): [E(5)^4 2 0] [ 0 0 1] - sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # needs sage.rings.number_field + sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # needs sage.libs.pari Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP From f545f7c41e3b005b2d47ed79401232de9a4c56fa Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 18:16:57 -0700 Subject: [PATCH 49/64] src/sage/groups/affine_gps: Remove unnecessary tags --- src/sage/groups/affine_gps/affine_group.py | 18 +++++++++--------- src/sage/groups/affine_gps/euclidean_group.py | 2 +- src/sage/groups/affine_gps/group_element.py | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sage/groups/affine_gps/affine_group.py b/src/sage/groups/affine_gps/affine_group.py index 7e8c167d448..bfcdd282df1 100644 --- a/src/sage/groups/affine_gps/affine_group.py +++ b/src/sage/groups/affine_gps/affine_group.py @@ -204,7 +204,7 @@ def __init__(self, degree, ring): sage: G = AffineGroup(2, GF(5)); G Affine Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: TestSuite(G).run() sage: G.category() Category of finite groups @@ -289,7 +289,7 @@ def cardinality(self): EXAMPLES:: - sage: AffineGroup(6, GF(5)).cardinality() # needs sage.rings.finite_rings + sage: AffineGroup(6, GF(5)).cardinality() 172882428468750000000000000000 sage: AffineGroup(6, ZZ).cardinality() +Infinity @@ -306,10 +306,10 @@ def degree(self): EXAMPLES:: sage: G = AffineGroup(6, GF(5)) - sage: g = G.an_element() # needs sage.rings.finite_rings + sage: g = G.an_element() sage: G.degree() 6 - sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() # needs sage.rings.finite_rings + sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() True """ return self._degree @@ -465,12 +465,12 @@ def random_element(self): EXAMPLES:: sage: G = AffineGroup(4, GF(3)) - sage: G.random_element() # random # needs sage.rings.finite_rings + sage: G.random_element() # random [2 0 1 2] [1] [2 1 1 2] [2] x |-> [1 0 2 2] x + [2] [1 1 1 1] [2] - sage: G.random_element() in G # needs sage.rings.finite_rings + sage: G.random_element() in G True """ A = self._GL.random_element() @@ -485,7 +485,7 @@ def _an_element_(self): TESTS:: sage: G = AffineGroup(4,5) - sage: G.an_element() in G # needs sage.rings.finite_rings + sage: G.an_element() in G True """ A = self._GL.an_element() @@ -499,7 +499,7 @@ def some_elements(self): EXAMPLES:: sage: G = AffineGroup(4,5) - sage: G.some_elements() # needs sage.rings.finite_rings + sage: G.some_elements() [ [2 0 0 0] [1] [0 1 0 0] [0] x |-> [0 0 1 0] x + [0] @@ -512,7 +512,7 @@ def some_elements(self): [0 1 0 0] [...] x |-> [0 0 1 0] x + [...] [0 0 0 1] [...]] - sage: all(v.parent() is G for v in G.some_elements()) # needs sage.rings.finite_rings + sage: all(v.parent() is G for v in G.some_elements()) True sage: G = AffineGroup(2,QQ) diff --git a/src/sage/groups/affine_gps/euclidean_group.py b/src/sage/groups/affine_gps/euclidean_group.py index cff5630a30c..07349c40292 100644 --- a/src/sage/groups/affine_gps/euclidean_group.py +++ b/src/sage/groups/affine_gps/euclidean_group.py @@ -146,7 +146,7 @@ class EuclideanGroup(AffineGroup): True sage: G = EuclideanGroup(2, GF(5)); G Euclidean Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # needs sage.rings.finite_rings + sage: TestSuite(G).run() REFERENCES: diff --git a/src/sage/groups/affine_gps/group_element.py b/src/sage/groups/affine_gps/group_element.py index b1ad28203df..74d8b684bbb 100644 --- a/src/sage/groups/affine_gps/group_element.py +++ b/src/sage/groups/affine_gps/group_element.py @@ -79,10 +79,10 @@ class AffineGroupElement(MultiplicativeGroupElement): EXAMPLES:: sage: G = AffineGroup(2, GF(3)) - sage: g = G.random_element() # needs sage.rings.finite_rings - sage: type(g) # needs sage.rings.finite_rings + sage: g = G.random_element() + sage: type(g) - sage: G(g.matrix()) == g # needs sage.rings.finite_rings + sage: G(g.matrix()) == g True sage: G(2) [2 0] [0] @@ -109,8 +109,8 @@ def __init__(self, parent, A, b=0, convert=True, check=True): TESTS:: sage: G = AffineGroup(4, GF(5)) - sage: g = G.random_element() # needs sage.rings.finite_rings - sage: TestSuite(g).run() # needs sage.rings.finite_rings + sage: g = G.random_element() + sage: TestSuite(g).run() """ try: A = A.matrix() @@ -201,9 +201,9 @@ def matrix(self): Composition of affine group elements equals multiplication of the matrices:: - sage: g1 = G.random_element() # needs sage.rings.finite_rings - sage: g2 = G.random_element() # needs sage.rings.finite_rings - sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() # needs sage.rings.finite_rings + sage: g1 = G.random_element() + sage: g2 = G.random_element() + sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() True """ A = self._A From 0151c23aab51fb6e2ad7ece215ec51ca88e14df2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 18:42:44 -0700 Subject: [PATCH 50/64] sage.groups: Update # needs --- src/sage/groups/group_exp.py | 8 +- src/sage/groups/group_semidirect_product.py | 18 ++-- src/sage/groups/libgap_mixin.py | 96 ++++++++++---------- src/sage/groups/libgap_morphism.py | 34 ++++--- src/sage/groups/libgap_wrapper.pyx | 6 +- src/sage/groups/matrix_gps/group_element.pyx | 6 +- 6 files changed, 87 insertions(+), 81 deletions(-) diff --git a/src/sage/groups/group_exp.py b/src/sage/groups/group_exp.py index e019b0cbff4..ffae5e73cb2 100644 --- a/src/sage/groups/group_exp.py +++ b/src/sage/groups/group_exp.py @@ -71,8 +71,8 @@ class GroupExp(Functor): sage: L = RootSystem(['A',2]).ambient_space() sage: EL = E(L) - sage: W = L.weyl_group(prefix="s") # needs sage.rings.number_field - sage: s2 = W.simple_reflection(2) # needs sage.rings.number_field + sage: W = L.weyl_group(prefix="s") + sage: s2 = W.simple_reflection(2) sage: def my_action(mu): ....: return s2.action(mu) sage: from sage.categories.morphism import SetMorphism @@ -82,9 +82,9 @@ class GroupExp(Functor): Generic endomorphism of Multiplicative form of Ambient space of the Root system of type ['A', 2] sage: v = L.an_element(); v (2, 2, 3) - sage: y = F(EL(v)); y # needs sage.rings.number_field + sage: y = F(EL(v)); y (2, 3, 2) - sage: y.parent() # needs sage.rings.number_field + sage: y.parent() Multiplicative form of Ambient space of the Root system of type ['A', 2] """ diff --git a/src/sage/groups/group_semidirect_product.py b/src/sage/groups/group_semidirect_product.py index 2e809e43d87..1805dbbc53a 100644 --- a/src/sage/groups/group_semidirect_product.py +++ b/src/sage/groups/group_semidirect_product.py @@ -33,7 +33,7 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest # needs sage.rings.number_field + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on @@ -255,9 +255,9 @@ def __init__(self, G, H, twist=None, act_to_right=True, prefix0=None, ....: return y sage: import __main__ sage: __main__.twist = twist - sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), ....: WeylGroup(['A',3],prefix="t"), twist) - sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(G).run() The ``__main__`` business is a trick to pass the pickling test. """ @@ -298,7 +298,7 @@ def act_to_right(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), ....: WeylGroup(['A',3],prefix="t"), twist).act_to_right() True """ @@ -312,7 +312,7 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest # needs sage.rings.number_field + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on Weyl Group @@ -335,9 +335,9 @@ def _element_constructor_(self, x): ....: return y sage: import __main__ sage: __main__.twist = twist - sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), ....: WeylGroup(['A',3],prefix="t"), twist).an_element() - sage: TestSuite(g).run() # needs sage.rings.number_field + sage: TestSuite(g).run() """ def type_error(): raise TypeError(f"{x} cannot be converted into an element of {self}") @@ -492,9 +492,9 @@ def construction(self): sage: def twist(x,y): ....: return y - sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # needs sage.rings.number_field + sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), ....: WeylGroup(['A',3],prefix="t"), twist) - sage: H.construction() # needs sage.rings.number_field + sage: H.construction() """ return None diff --git a/src/sage/groups/libgap_mixin.py b/src/sage/groups/libgap_mixin.py index cf08db6e142..e2da04e9ed3 100644 --- a/src/sage/groups/libgap_mixin.py +++ b/src/sage/groups/libgap_mixin.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules """ Mix-in Class for GAP-based Groups @@ -250,8 +251,8 @@ def conjugacy_classes_representatives(self): EXAMPLES:: - sage: G = SU(3,GF(2)) # needs sage.libs.pari - sage: len(G.conjugacy_classes_representatives()) # needs sage.libs.pari + sage: G = SU(3,GF(2)) # needs sage.rings.finite_rings + sage: len(G.conjugacy_classes_representatives()) # needs sage.rings.finite_rings 16 sage: G = GL(2,GF(3)) @@ -261,7 +262,7 @@ def conjugacy_classes_representatives(self): [0 1], [1 1], [0 2], [1 2], [1 0], [1 2], [1 1], [0 1] ) - sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) # needs sage.libs.pari + sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) # needs sage.rings.finite_rings 36 :: @@ -338,8 +339,8 @@ class function on the conjugacy classes, in that order. EXAMPLES:: sage: G = GL(2,GF(3)) - sage: chi = G.class_function(range(8)) - sage: list(chi) + sage: chi = G.class_function(range(8)) # needs sage.rings.number_field + sage: list(chi) # needs sage.rings.number_field [0, 1, 2, 3, 4, 5, 6, 7] """ from sage.groups.class_function import ClassFunction_libgap @@ -356,8 +357,8 @@ def center(self): EXAMPLES:: - sage: G = SU(3, GF(2)) # needs sage.libs.pari - sage: G.center() # needs sage.libs.pari + sage: G = SU(3, GF(2)) # needs sage.rings.finite_rings + sage: G.center() # needs sage.rings.finite_rings Subgroup with 1 generators ( [a 0 0] [0 a 0] @@ -374,7 +375,7 @@ def center(self): [0 2 0] [0 0 2] ) of General Linear Group of degree 3 over Finite Field of size 3 - sage: GU(3, GF(2)).center() # needs sage.libs.pari + sage: GU(3, GF(2)).center() # needs sage.rings.finite_rings Subgroup with 1 generators ( [a + 1 0 0] [ 0 a + 1 0] @@ -394,8 +395,8 @@ def center(self): [0 0 1], [0 1 1] ) - sage: GL = groups.matrix.GL(3, ZZ) # needs sage.modules - sage: GL.center() # needs sage.modules + sage: GL = groups.matrix.GL(3, ZZ) + sage: GL.center() Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -414,7 +415,6 @@ def centralizer(self, g): EXAMPLES:: - sage: # needs sage.modules sage: G = groups.matrix.GL(2, 3) sage: g = G([[1,1], [1,0]]) sage: C = G.centralizer(g); C @@ -425,12 +425,12 @@ def centralizer(self, g): sage: C.order() 8 - sage: S = G.subgroup([G([[2,0],[0,2]]), G([[0,1],[2,0]])]); S # needs sage.modules + sage: S = G.subgroup([G([[2,0],[0,2]]), G([[0,1],[2,0]])]); S Subgroup with 2 generators ( [2 0] [0 1] [0 2], [2 0] ) of General Linear Group of degree 2 over Finite Field of size 3 - sage: G.centralizer(S) # needs sage.modules + sage: G.centralizer(S) Subgroup with 3 generators ( [2 0] [0 1] [2 2] [0 2], [2 0], [1 2] @@ -439,8 +439,8 @@ def centralizer(self, g): sage: all(G.order() == G.centralizer(x).order() * G.conjugacy_class(x).cardinality() ....: for x in G) True - sage: H = groups.matrix.Heisenberg(2) # needs sage.modules - sage: H.centralizer(H.an_element()) # needs sage.modules + sage: H = groups.matrix.Heisenberg(2) + sage: H.centralizer(H.an_element()) Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -476,9 +476,10 @@ def subgroups(self): EXAMPLES:: - sage: G = groups.matrix.GL(2, 2) # needs sage.modules - sage: G.subgroups() # needs sage.modules - [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, + sage: G = groups.matrix.GL(2, 2) + sage: G.subgroups() + [Subgroup with 0 generators () + of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [0 1] [1 0] @@ -500,8 +501,8 @@ def subgroups(self): [1 1], [0 1] ) of General Linear Group of degree 2 over Finite Field of size 2] - sage: H = groups.matrix.Heisenberg(2) # needs sage.modules - sage: H.subgroups() # needs sage.modules + sage: H = groups.matrix.Heisenberg(2) + sage: H.subgroups() Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -521,9 +522,10 @@ def conjugacy_classes_subgroups(self): EXAMPLES:: - sage: G = groups.matrix.GL(2,2) # needs sage.modules - sage: G.conjugacy_classes_subgroups() # needs sage.modules - [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, + sage: G = groups.matrix.GL(2,2) + sage: G.conjugacy_classes_subgroups() + [Subgroup with 0 generators () + of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [1 1] [0 1] @@ -537,8 +539,8 @@ def conjugacy_classes_subgroups(self): [1 1], [0 1] ) of General Linear Group of degree 2 over Finite Field of size 2] - sage: H = groups.matrix.Heisenberg(2) # needs sage.modules - sage: H.conjugacy_classes_subgroups() # needs sage.modules + sage: H = groups.matrix.Heisenberg(2) + sage: H.conjugacy_classes_subgroups() Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -562,7 +564,6 @@ def group_id(self): sage: SymmetricGroup(4).group_id() [24, 12] - sage: # needs sage.modules sage: G = groups.matrix.GL(2, 2) sage: G.group_id() [6, 1] @@ -570,8 +571,8 @@ def group_id(self): sage: G.id() [48, 29] - sage: G = groups.matrix.GL(2, ZZ) # needs sage.modules - sage: G.group_id() # needs sage.modules + sage: G = groups.matrix.GL(2, ZZ) + sage: G.group_id() Traceback (most recent call last): ... GAPError: Error, the group identification for groups of size infinity is not available @@ -591,12 +592,12 @@ def exponent(self): EXAMPLES:: - sage: G = groups.matrix.GL(2, 3) # needs sage.modules - sage: G.exponent() # needs sage.modules + sage: G = groups.matrix.GL(2, 3) + sage: G.exponent() 24 - sage: H = groups.matrix.Heisenberg(2) # needs sage.modules - sage: H.exponent() # needs sage.modules + sage: H = groups.matrix.Heisenberg(2) + sage: H.exponent() Traceback (most recent call last): ... NotImplementedError: group must be finite @@ -624,10 +625,10 @@ def intersection(self, other): [-2 -1 2] [ 0 0 1] ) of Matrix group over Rational Field with 2 generators ( - [ 0 1/2 0] [ 0 1/2 0] - [ 2 0 0] [ -2 -1 2] - [ 0 0 1], [ 0 0 1] - ) + [ 0 1/2 0] [ 0 1/2 0] + [ 2 0 0] [ -2 -1 2] + [ 0 0 1], [ 0 0 1] + ) sage: GL(3,ZZ).intersection(G) Subgroup with 1 generators ( [ 1 0 0] @@ -635,11 +636,12 @@ def intersection(self, other): [ 0 0 1] ) of General Linear Group of degree 3 over Integer Ring sage: G.intersection(SL(3,ZZ)) - Subgroup with 0 generators () of Matrix group over Rational Field with 2 generators ( - [ 0 1/2 0] [ 0 1/2 0] - [ 2 0 0] [ -2 -1 2] - [ 0 0 1], [ 0 0 1] - ) + Subgroup with 0 generators () + of Matrix group over Rational Field with 2 generators ( + [ 0 1/2 0] [ 0 1/2 0] + [ 2 0 0] [ -2 -1 2] + [ 0 0 1], [ 0 0 1] + ) """ G = self.gap() H = other.gap() @@ -658,7 +660,7 @@ def irreducible_characters(self): EXAMPLES:: sage: G = GL(2,2) - sage: G.irreducible_characters() + sage: G.irreducible_characters() # needs sage.rings.number_field (Character of General Linear Group of degree 2 over Finite Field of size 2, Character of General Linear Group of degree 2 over Finite Field of size 2, Character of General Linear Group of degree 2 over Finite Field of size 2) @@ -693,7 +695,7 @@ def character(self, values): EXAMPLES:: sage: G = MatrixGroup(AlternatingGroup(4)) - sage: G.character([1]*len(G.conjugacy_classes_representatives())) + sage: G.character([1]*len(G.conjugacy_classes_representatives())) # needs sage.rings.number_field Character of Matrix group over Integer Ring with 12 generators :: @@ -716,7 +718,7 @@ def trivial_character(self): EXAMPLES:: - sage: MatrixGroup(SymmetricGroup(3)).trivial_character() + sage: MatrixGroup(SymmetricGroup(3)).trivial_character() # needs sage.rings.number_field Character of Matrix group over Integer Ring with 6 generators :: @@ -744,10 +746,10 @@ def character_table(self): EXAMPLES:: - sage: MatrixGroup(SymmetricGroup(2)).character_table() + sage: MatrixGroup(SymmetricGroup(2)).character_table() # needs sage.rings.number_field [ 1 -1] [ 1 1] - sage: MatrixGroup(SymmetricGroup(3)).character_table() + sage: MatrixGroup(SymmetricGroup(3)).character_table() # needs sage.rings.number_field [ 1 1 -1] [ 2 -1 0] [ 1 1 1] @@ -799,7 +801,7 @@ def random_element(self): True sage: F = GF(5); MS = MatrixSpace(F,2,2) - sage: gens = [MS([[1,2],[-1,1]]),MS([[1,1],[0,1]])] + sage: gens = [MS([[1,2],[-1,1]]), MS([[1,1],[0,1]])] sage: G = MatrixGroup(gens) sage: G.random_element() # random [1 3] diff --git a/src/sage/groups/libgap_morphism.py b/src/sage/groups/libgap_morphism.py index f9e41a930d0..a559b6ef504 100644 --- a/src/sage/groups/libgap_morphism.py +++ b/src/sage/groups/libgap_morphism.py @@ -206,15 +206,16 @@ class GroupMorphism_libgap(Morphism): We check that :trac:`19780` is fixed:: - sage: G = groups.matrix.SO(3, 3) # needs sage.modules - sage: H = groups.matrix.GL(3, 3) # needs sage.modules + sage: G = groups.matrix.SO(3, 3) + sage: H = groups.matrix.GL(3, 3) sage: phi = G.hom([H(x) for x in G.gens()]) sage: phi(G.one()).parent() General Linear Group of degree 3 over Finite Field of size 3 - sage: MS = MatrixSpace(SR, 2, 2) # needs sage.symbolic - sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # needs sage.symbolic - sage: G.Hom(G) # needs sage.symbolic + sage: # needs sage.symbolic + sage: MS = MatrixSpace(SR, 2, 2) + sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) + sage: G.Hom(G) Set of Morphisms from Matrix group over Symbolic Ring with 2 generators ( [1 0] [1 2] [0 1], [3 4] @@ -400,12 +401,15 @@ def pushforward(self, J, *args, **kwds): a sage: x.parent() Finitely presented group < a, b | a, b^3 > - sage: G = GU(3,2) # needs sage.libs.pari - sage: P = PGU(3,2) # needs sage.libs.pari - sage: pr = Hom(G, P).natural_map() # needs sage.libs.pari + + sage: # needs sage.rings.finite_rings + sage: G = GU(3,2) + sage: P = PGU(3,2) + sage: pr = Hom(G, P).natural_map() sage: GS = G.subgroup([G.gen(0)]) - sage: pr.pushforward(GS) # needs sage.libs.pari - Subgroup generated by [(3,4,5)(10,18,14)(11,19,15)(12,20,16)(13,21,17)] of (The projective general unitary group of degree 3 over Finite Field of size 2) + sage: pr.pushforward(GS) + Subgroup generated by [(3,4,5)(10,18,14)(11,19,15)(12,20,16)(13,21,17)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) """ dom = self.domain() codom = self.codomain() @@ -443,9 +447,9 @@ def _call_(self, g): The following tests we do fall back behind :trac:`10659`:: - sage: O = WeylGroup(['D',6]) # needs sage.rings.number_field - sage: r = prod(O.gens()) # needs sage.rings.number_field - sage: r_ = r^-1 # needs sage.rings.number_field + sage: O = WeylGroup(['D',6]) + sage: r = prod(O.gens()) + sage: r_ = r^-1 sage: f = O.hom([r*x*r_ for x in O.gens()]) # long time (19s on sage.math, 2011) sage: [f(x) for x in O.gens()] # long time [ @@ -564,7 +568,7 @@ def section(self): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.rings.finite_rings sage: G = GU(3,2) sage: P = PGU(3,2) sage: pr = Hom(G, P).natural_map() @@ -645,7 +649,7 @@ def _element_constructor_(self, x, check=True, **options): A group homomorphism between a finitely presented group and a subgroup of a permutation group:: - sage: # needs sage.libs.pari + sage: # needs sage.rings.finite_rings sage: PG = PGU(6,2) sage: g, h = PG.gens() sage: p1 = h^-3*(h^-1*g^-1)^2*h*g*h^2*g^-1*h^2*g*h^-5*g^-1 diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx index a19ee98e9a1..c65afa447e5 100644 --- a/src/sage/groups/libgap_wrapper.pyx +++ b/src/sage/groups/libgap_wrapper.pyx @@ -244,8 +244,8 @@ class ParentLibGAP(SageObject): Checking that :trac:`19270` is fixed:: - sage: gens = [w.matrix() for w in WeylGroup(['B', 3])] # needs sage.rings.number_field - sage: G = MatrixGroup(gens) # needs sage.rings.number_field + sage: gens = [w.matrix() for w in WeylGroup(['B', 3])] + sage: G = MatrixGroup(gens) sage: import itertools sage: diagonals = itertools.product((1,-1), repeat=3) sage: subgroup_gens = [diagonal_matrix(L) for L in diagonals] @@ -256,7 +256,7 @@ class ParentLibGAP(SageObject): Check that :trac:`19010` is fixed:: - sage: G = WeylGroup(['B',3]) # needs sage.rings.number_field + sage: G = WeylGroup(['B',3]) sage: H = G.subgroup([G[14], G[17]]) sage: all(g*h in G and h*g in G for g in G for h in H) True diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 6c72c5429ab..2764e33a7a8 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -19,7 +19,7 @@ You cannot add two matrices, since this is not a group operation. You can coerce matrices back to the matrix space and add them there:: - sage: g + h # needs sage.rings.finite_rings + sage: g + h Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: @@ -32,14 +32,14 @@ there:: [0 1], [0 1] )' - sage: g.matrix() + h.matrix() # needs sage.rings.finite_rings + sage: g.matrix() + h.matrix() [2 0] [0 2] Similarly, you cannot multiply group elements by scalars but you can do it with the underlying matrices:: - sage: 2*g # needs sage.rings.finite_rings + sage: 2*g Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Integer Ring' From cabcb5663f955096393ef7da7495b6a5eb7bd5d2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 18:54:43 -0700 Subject: [PATCH 51/64] sage.groups: Update # needs --- src/sage/groups/generic.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index c07cd72db64..192e7a46ce8 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -91,14 +91,14 @@ sage: from sage.groups.generic import order_from_multiple, order_from_bounds sage: k. = GF(5^5) sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) - sage: M = E.cardinality(); M # needs sage.rings.number_field + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: M = E.cardinality(); M 3227 - sage: plist = M.prime_factors() # needs sage.rings.number_field - sage: order_from_multiple(P, M, plist, operation='+') # needs sage.rings.number_field + sage: plist = M.prime_factors() + sage: order_from_multiple(P, M, plist, operation='+') 3227 sage: Q = E(0,2) - sage: order_from_multiple(Q, M, plist, operation='+') # needs sage.rings.number_field + sage: order_from_multiple(Q, M, plist, operation='+') 7 sage: order_from_bounds(Q, Hasse_bounds(5^5), operation='+') 7 @@ -432,9 +432,10 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): An additive example in an elliptic curve group:: - sage: F. = GF(37^5) # needs sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1]) # needs sage.rings.finite_rings sage.schemes - sage: P = E.lift_x(a); P # needs sage.rings.finite_rings sage.schemes + sage: # needs sage.rings.finite_rings sage.schemes + sage: F. = GF(37^5) + sage: E = EllipticCurve(F, [1,1]) + sage: P = E.lift_x(a); P (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) This will return a multiple of the order of P:: @@ -733,7 +734,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: K = GF(3^6, 'b') sage: b = K.gen() sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: discrete_log(a, b, K.order() - 1) 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -763,7 +764,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i an upper bound here:: sage: # needs sage.rings.number_field - sage: K. = QuadraticField(23) # needs sage.libs.flint + sage: K. = QuadraticField(23) sage: eps = 5*a - 24 # a fundamental unit sage: eps.multiplicative_order() +Infinity @@ -1229,7 +1230,7 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: # needs sage.rings.number_field sage: K. = CyclotomicField(230) sage: w = z^50 - sage: order_from_multiple(w, 230, operation='*') # needs sage.rings.finite_rings + sage: order_from_multiple(w, 230, operation='*') 23 sage: # needs sage.rings.finite_rings @@ -1369,9 +1370,10 @@ def order_from_bounds(P, bounds, d=None, operation='+', sage: order_from_bounds(P, bounds, 7, operation='+') 3227 - sage: K. = CyclotomicField(230) # needs sage.rings.number_field - sage: w = z^50 # needs sage.rings.number_field - sage: order_from_bounds(w, (200, 250), operation='*') # needs sage.rings.finite_rings sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(230) + sage: w = z^50 + sage: order_from_bounds(w, (200, 250), operation='*') 23 """ from operator import mul, add From 373857422dc45c97838b950bb97093067ab24b05 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 19:15:20 -0700 Subject: [PATCH 52/64] sage.groups: Update # needs --- src/sage/groups/matrix_gps/orthogonal.py | 26 +++++++++---------- src/sage/groups/matrix_gps/symplectic_gap.py | 2 +- src/sage/groups/matrix_gps/unitary_gap.py | 9 ++++--- .../groups/perm_gps/permgroup_element.pyx | 8 +++--- .../groups/perm_gps/permgroup_morphism.py | 5 ++-- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 77aed23d9eb..b05be536955 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -324,7 +324,7 @@ def GO(n, R, e=0, var='a', invariant_form=None): TESTS:: sage: TestSuite(GO3).run() - sage: groups.matrix.GO(2, 3, e=-1) # needs sage.modules sage.rings.finite_rings + sage: groups.matrix.GO(2, 3, e=-1) General Orthogonal Group of degree 2 and form parameter -1 over Finite Field of size 3 """ return _OG(n, R, False, e=e, var=var, invariant_form=invariant_form) @@ -375,8 +375,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): EXAMPLES:: - sage: G = SO(3,GF(5)) - sage: G + sage: G = SO(3,GF(5)); G Special Orthogonal Group of degree 3 over Finite Field of size 5 sage: G = SO(3,GF(5)) @@ -396,27 +395,28 @@ def SO(n, R, e=None, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # needs sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) # needs sage.rings.number_field - sage: SO3 = SO(3, CF3) # needs sage.rings.number_field - sage: SO3m = SO(3, CF3, invariant_form=m) # needs sage.rings.number_field - sage: SO3 == SO3m # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) + sage: SO3 = SO(3, CF3) + sage: SO3m = SO(3, CF3, invariant_form=m) + sage: SO3 == SO3m False - sage: SO3.invariant_form() # needs sage.rings.number_field + sage: SO3.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: SO3m.invariant_form() # needs sage.rings.number_field + sage: SO3m.invariant_form() [ 1 zeta3 0] [zeta3 2 0] [ 0 0 1] sage: pm = Permutation([2,3,1]).to_matrix() - sage: g = SO3(pm); g in SO3; g # needs sage.combinat sage.rings.number_field + sage: g = SO3(pm); g in SO3; g True [0 0 1] [1 0 0] [0 1 0] - sage: SO3m(pm) # needs sage.combinat sage.rings.number_field + sage: SO3m(pm) Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -434,7 +434,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): TESTS:: sage: TestSuite(SO3m).run() # needs sage.rings.number_field - sage: groups.matrix.SO(2, 3, e=1) # needs sage.modules sage.rings.number_field + sage: groups.matrix.SO(2, 3, e=1) Special Orthogonal Group of degree 2 and form parameter 1 over Finite Field of size 3 """ return _OG(n, R, True, e=e, var=var, invariant_form=invariant_form) diff --git a/src/sage/groups/matrix_gps/symplectic_gap.py b/src/sage/groups/matrix_gps/symplectic_gap.py index 2a18c37a5eb..96bf1fb5a75 100644 --- a/src/sage/groups/matrix_gps/symplectic_gap.py +++ b/src/sage/groups/matrix_gps/symplectic_gap.py @@ -27,7 +27,7 @@ class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_ EXAMPLES:: - sage: Sp(2,4) # needs sage.libs.pari + sage: Sp(2,4) # needs sage.rings.finite_rings Symplectic Group of degree 2 over Finite Field in a of size 2^2 sage: latex(Sp(4,5)) diff --git a/src/sage/groups/matrix_gps/unitary_gap.py b/src/sage/groups/matrix_gps/unitary_gap.py index bbcdb898359..0aa547f32e2 100644 --- a/src/sage/groups/matrix_gps/unitary_gap.py +++ b/src/sage/groups/matrix_gps/unitary_gap.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Unitary Groups `GU(n,q)` and `SU(n,q)` with GAP """ @@ -30,8 +31,8 @@ class UnitaryMatrixGroup_gap(UnitaryMatrixGroup_generic, NamedMatrixGroup_gap, F Check that :trac:`20867` is fixed:: sage: from sage.groups.matrix_gps.finitely_generated_gap import FinitelyGeneratedMatrixGroup_gap - sage: G = GU(3,3) # needs sage.libs.pari - sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) # needs sage.libs.pari sage.rings.number_field + sage: G = GU(3,3) + sage: isinstance(G, FinitelyGeneratedMatrixGroup_gap) True """ @@ -46,8 +47,8 @@ def invariant_form(self): EXAMPLES:: - sage: G32 = GU(3,2) # needs sage.libs.pari - sage: G32.invariant_form() # needs sage.libs.pari + sage: G32 = GU(3,2) + sage: G32.invariant_form() [0 0 1] [0 1 0] [1 0 0] diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 061c784498a..2046d93ab4b 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -853,14 +853,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S(p_libgap) == p True - sage: P = PGU(8,2) # needs sage.libs.pari - sage: p, q = P.gens() # needs sage.libs.pari + sage: P = PGU(8,2) # needs sage.rings.finite_rings + sage: p, q = P.gens() # needs sage.rings.finite_rings sage: p_libgap = p.gap() TESTS:: - sage: P = PGU(8,2) # needs sage.libs.pari - sage: p, q = P.gens() # needs sage.libs.pari + sage: P = PGU(8,2) # needs sage.rings.finite_rings + sage: p, q = P.gens() # needs sage.rings.finite_rings sage: p_pexpect = gap(p) sage: p_libgap == p_pexpect True diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 9f80dc5b2fb..8a941c98546 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -117,10 +117,11 @@ def image(self, J): Check that :trac:`28324` is fixed:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^4 + x^2 - 3 - sage: L. = f.splitting_field() # needs sage.rings.number_field - sage: G = L.galois_group() # needs sage.rings.number_field + sage: L. = f.splitting_field() + sage: G = L.galois_group() sage: D4 = DihedralGroup(4) sage: h = D4.isomorphism_to(G) sage: h.image(D4).is_isomorphic(G) From 607cb9c214bffc77528d01d4cdeb351ec54243d8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 1 Sep 2023 19:19:09 -0700 Subject: [PATCH 53/64] sage.groups.matrix_gps: Update # needs --- src/sage/groups/matrix_gps/group_element_gap.pyx | 2 +- src/sage/groups/matrix_gps/linear.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sage/groups/matrix_gps/group_element_gap.pyx b/src/sage/groups/matrix_gps/group_element_gap.pyx index 6e8150aaad7..b07c0f01a44 100644 --- a/src/sage/groups/matrix_gps/group_element_gap.pyx +++ b/src/sage/groups/matrix_gps/group_element_gap.pyx @@ -223,7 +223,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): sage: F = GF(3); MS = MatrixSpace(F,2,2) sage: G = MatrixGroup([MS([1,1,0,1])]) sage: g = G.gen(0) - sage: M = matrix(GF(9), g); M; parent(M) # needs sage.libs.pari + sage: M = matrix(GF(9), g); M; parent(M) # needs sage.rings.finite_rings [1 1] [0 1] Full MatrixSpace of 2 by 2 dense matrices over Finite Field in z2 of size 3^2 diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 4053c6c50f6..d13904dec51 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -110,12 +110,12 @@ def GL(n, R, var='a'): Here is the Cayley graph of (relatively small) finite General Linear Group:: sage: g = GL(2,3) - sage: d = g.cayley_graph(); d # needs sage.graphs sage.rings.finite_rings + sage: d = g.cayley_graph(); d # needs sage.graphs Digraph on 48 vertices - sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # needs sage.graphs sage.plot sage.rings.finite_rings + sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # needs sage.graphs sage.plot ....: vertex_labels=False) Graphics object consisting of 144 graphics primitives - sage: d.plot3d(color_by_label=True) # long time # needs sage.graphs sage.plot sage.rings.finite_rings + sage: d.plot3d(color_by_label=True) # long time # needs sage.graphs sage.plot Graphics3d Object :: @@ -144,11 +144,11 @@ def GL(n, R, var='a'): TESTS:: - sage: groups.matrix.GL(2, 3) # needs sage.groups sage.rings.finite_rings + sage: groups.matrix.GL(2, 3) General Linear Group of degree 2 over Finite Field of size 3 - sage: groups.matrix.GL(1, ZZ).category() # needs sage.groups sage.modules + sage: groups.matrix.GL(1, ZZ).category() Category of groups - sage: groups.matrix.GL(1, QQ).category() # needs sage.groups sage.modules + sage: groups.matrix.GL(1, QQ).category() Category of infinite groups """ degree, ring = normalize_args_vectorspace(n, R, var='a') @@ -241,7 +241,7 @@ def SL(n, R, var='a'): TESTS:: - sage: groups.matrix.SL(2, 3) # needs sage.modules sage.rings.finite_rings + sage: groups.matrix.SL(2, 3) Special Linear Group of degree 2 over Finite Field of size 3 """ degree, ring = normalize_args_vectorspace(n, R, var='a') From ed9fcb476c3b4a08e97623bb60c14a33f743e33c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:11:02 -0700 Subject: [PATCH 54/64] src/sage/sets/set_from_iterator.py: update doctest output --- src/sage/sets/set_from_iterator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/sets/set_from_iterator.py b/src/sage/sets/set_from_iterator.py index 11f12e6d5ea..4c92deb5d52 100644 --- a/src/sage/sets/set_from_iterator.py +++ b/src/sage/sets/set_from_iterator.py @@ -509,7 +509,7 @@ def _sage_src_lines_(self): sage: S[0][2] ' Return the number of elements of this group.\n' sage: S[0][25] - ' return Integer(1)\n' + ' if not gens:\n' """ from sage.misc.sageinspect import sage_getsourcelines return sage_getsourcelines(self.f) From 46f4200a128ad3c080e319b02c5480ee97299c01 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:21:40 -0700 Subject: [PATCH 55/64] src/sage/groups/braid.py: More block tags, doctest cosmetics, add missing tags --- src/sage/groups/braid.py | 61 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index 8141b6d7d45..5cbba413849 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -1092,22 +1092,23 @@ def jones_polynomial(self, variab=None, skein_normalization=False): Different representations of the trefoil and one of its mirror:: + sage: # needs sage.symbolic sage: B = BraidGroup(2) sage: b = B([-1, -1, -1]) - sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) -A^-16 + A^-12 + A^-4 - sage: b.jones_polynomial() # needs sage.symbolic + sage: b.jones_polynomial() 1/t + 1/t^3 - 1/t^4 sage: B = BraidGroup(3) sage: b = B([-1, -2, -1, -2]) - sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) -A^-16 + A^-12 + A^-4 sage: R. = LaurentPolynomialRing(GF(2)) - sage: b.jones_polynomial(skein_normalization=True, variab=x) # needs sage.symbolic + sage: b.jones_polynomial(skein_normalization=True, variab=x) x^-16 + x^-12 + x^-4 sage: B = BraidGroup(3) sage: b = B([1, 2, 1, 2]) - sage: b.jones_polynomial(skein_normalization=True) # needs sage.symbolic + sage: b.jones_polynomial(skein_normalization=True) A^4 + A^12 - A^16 K11n42 (the mirror of the "Kinoshita-Terasaka" knot) and K11n34 (the @@ -1496,15 +1497,15 @@ def left_normal_form(self, algorithm='libbraiding'): sage: b = B([-2, 2, -4, -4, 4, -5, -1, 4, -1, 1]) sage: L1 = b.left_normal_form(); L1 (s0^-1*s1^-1*s2^-1*s3^-1*s4^-1*s0^-1*s1^-1*s2^-1*s3^-1*s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1, - s0*s2*s1*s0*s3*s2*s1*s0*s4*s3*s2*s1, - s3) + s0*s2*s1*s0*s3*s2*s1*s0*s4*s3*s2*s1, + s3) sage: L1 == b.left_normal_form() True sage: B([1]).left_normal_form(algorithm='artin') (1, s0) sage: B([-3]).left_normal_form(algorithm='artin') (s0^-1*s1^-1*s2^-1*s3^-1*s4^-1*s0^-1*s1^-1*s2^-1*s3^-1*s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1, - s0*s1*s0*s2*s1*s3*s2*s1*s0*s4*s3*s2*s1*s0) + s0*s1*s0*s2*s1*s3*s2*s1*s0*s4*s3*s2*s1*s0) sage: B = BraidGroup(3) sage: B([1,2,-1]).left_normal_form() (s0^-1*s1^-1*s0^-1, s1*s0, s0*s1) @@ -1637,9 +1638,9 @@ def super_summit_set(self): sage: b = B([1, 2, -1, -2, -2, 1]) sage: b.super_summit_set() [s0^-1*s1^-1*s0^-2*s1^2*s0^2, - (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^3*s1, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^3*s1^2, - s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^3*s0] + (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^3*s1, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^3*s1^2, + s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^3*s0] """ l = supersummitset(self) @@ -1882,17 +1883,17 @@ def ultra_summit_set(self): [[s0*s1*s0^2, (s0*s1)^2]] sage: a.ultra_summit_set() [[(s0^-1*s1^-1*s0^-1)^2*s1^3*s0^2*s1^3, - (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^2*s1^4, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^5, - s0^-1*s1^-1*s0^-2*s1^5*s0, - (s0^-1*s1^-1*s0^-1)^2*s1^5*s0^2*s1, - (s0^-1*s1^-1*s0^-1)^2*s1^4*s0^2*s1^2], - [s0^-1*s1^-1*s0^-2*s1^-1*s0^2*s1^2*s0^3, - s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^2*s0^4, - s0^-1*s1^-1*s0^-2*s1*s0^5, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^6*s1, - s0^-1*s1^-1*s0^-2*s1^-1*s0^4*s1^2*s0, - s0^-1*s1^-1*s0^-2*s1^-1*s0^3*s1^2*s0^2]] + (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^2*s1^4, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^5, + s0^-1*s1^-1*s0^-2*s1^5*s0, + (s0^-1*s1^-1*s0^-1)^2*s1^5*s0^2*s1, + (s0^-1*s1^-1*s0^-1)^2*s1^4*s0^2*s1^2], + [s0^-1*s1^-1*s0^-2*s1^-1*s0^2*s1^2*s0^3, + s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^2*s0^4, + s0^-1*s1^-1*s0^-2*s1*s0^5, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^6*s1, + s0^-1*s1^-1*s0^-2*s1^-1*s0^4*s1^2*s0, + s0^-1*s1^-1*s0^-2*s1^-1*s0^3*s1^2*s0^2]] """ uss = ultrasummitset(self) B = self.parent() @@ -2564,10 +2565,10 @@ def __init__(self, names): d*f*d^-1*f^-1, e*f*e*f^-1*e^-1*f^-1) - sage: BraidGroup([]) - Traceback (most recent call last): - ... - ValueError: the number of strands must be at least 2 + sage: BraidGroup([]) + Traceback (most recent call last): + ... + ValueError: the number of strands must be at least 2 """ n = len(names) # n is the number of generators, not the number of strands @@ -2616,7 +2617,7 @@ def _repr_(self): TESTS:: sage: B1 = BraidGroup(5) - sage: B1 # indirect doctest + sage: B1 # indirect doctest Braid group on 5 strands """ return "Braid group on %s strands" % self._nstrands @@ -2988,7 +2989,7 @@ def dimension_of_TL_space(self, drain_size): sage: B = BraidGroup(6) sage: dimensions = [B.dimension_of_TL_space(d)**2 for d in [0, 2, 4, 6]] sage: total_dim = sum(dimensions) - sage: total_dim == len(list(da.temperley_lieb_diagrams(6))) # long time + sage: total_dim == len(list(da.temperley_lieb_diagrams(6))) # long time, needs sage.combinat True """ n = self.strands() @@ -3444,14 +3445,14 @@ def BraidGroup(n=None, names='s'): ....: ret.add(prod(w)) ....: return ret sage: B = BraidGroup(4) - sage: GB = B.cayley_graph(elements=ball(B, 4), generators=B.gens()); GB + sage: GB = B.cayley_graph(elements=ball(B, 4), generators=B.gens()); GB # needs sage.combinat sage.graphs Digraph on 31 vertices Since the braid group has nontrivial relations, this graph contains less vertices than the one associated to the free group (which is a tree):: sage: F = FreeGroup(3) - sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat + sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat sage.graphs Digraph on 40 vertices TESTS:: From ea6d9f3cc404d630966c4533daa7e0658a8a3b38 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:24:32 -0700 Subject: [PATCH 56/64] src/sage/groups/galois_group.py: More block tags, doctest cosmetics --- src/sage/groups/galois_group.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sage/groups/galois_group.py b/src/sage/groups/galois_group.py index aef5fb2ee1d..ed9e6d61bd4 100644 --- a/src/sage/groups/galois_group.py +++ b/src/sage/groups/galois_group.py @@ -378,7 +378,7 @@ def _gens(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field sage: G._gens # needs sage.rings.number_field [(1,2,3,5), (1,4,3,2,5)] @@ -420,13 +420,14 @@ def _deg(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) # needs sage.rings.number_field - sage: G = K.galois_group(gc_numbering=False); G # needs sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: G = K.galois_group(gc_numbering=False); G Galois group 5T3 (5:4) with order 20 of x^5 - 2 - sage: G._deg # needs sage.rings.number_field + sage: G._deg 5 - sage: G = K.galois_group(gc_numbering=True); G._deg # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=True); G._deg 20 """ if self._gc_numbering: @@ -464,7 +465,7 @@ def _domain_to_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field sage: G._domain_to_gap[5] # needs sage.rings.number_field 5 @@ -479,7 +480,7 @@ def _domain_from_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) # needs sage.rings.number_field + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field sage: G = K.galois_group(gc_numbering=True) # needs sage.rings.number_field sage: G._domain_from_gap[20] # needs sage.rings.number_field 20 @@ -545,7 +546,8 @@ def permutation_group(self): r""" Return a permutation group giving the action on the roots of a defining polynomial. - This is the regular representation for the abelian group, which is not necessarily the smallest degree permutation representation. + This is the regular representation for the abelian group, which is + not necessarily the smallest degree permutation representation. EXAMPLES:: From 7ee72c7915e30bf038c683409915684383a4437a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:26:33 -0700 Subject: [PATCH 57/64] src/sage/groups/misc_gps/imaginary_groups.py: More block tags --- src/sage/groups/misc_gps/imaginary_groups.py | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/sage/groups/misc_gps/imaginary_groups.py b/src/sage/groups/misc_gps/imaginary_groups.py index fa0a9d5083e..41fe79f9959 100644 --- a/src/sage/groups/misc_gps/imaginary_groups.py +++ b/src/sage/groups/misc_gps/imaginary_groups.py @@ -249,7 +249,7 @@ class ImaginaryGroup(UniqueRepresentation, Parent): 100*I sage: J(3*I) # needs sage.symbolic 3*I - sage: J(1+2*I) # needs sage.symbolic + sage: J(1 + 2*I) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 2*I + 1 is not in @@ -393,36 +393,37 @@ def _element_constructor_(self, data, imag=None): sage: J(imag=100) 100*I - sage: J(3*I) # needs sage.symbolic + sage: # needs sage.symbolic + sage: J(3*I) 3*I - sage: J(1+2*I) # needs sage.symbolic + sage: J(1+2*I) Traceback (most recent call last): ... ValueError: 2*I + 1 is not in Imaginary Group over Integer Ring because it is not purely imaginary - sage: i = CC(I) # needs sage.symbolic - sage: J(3*i) # needs sage.symbolic + sage: i = CC(I) + sage: J(3*i) 3*I - sage: J(1+2*i) # needs sage.symbolic + sage: J(1+2*i) Traceback (most recent call last): ... ValueError: 1.00000000000000 + 2.00000000000000*I is not in Imaginary Group over Integer Ring because it is not purely imaginary sage: i = CBF(I) - sage: J(3*i) # needs sage.symbolic + sage: J(3*i) 3*I - sage: J(1+2*i) # needs sage.symbolic + sage: J(1+2*i) Traceback (most recent call last): ... ValueError: 1.000000000000000 + 2.000000000000000*I is not in Imaginary Group over Integer Ring because it is not purely imaginary sage: i = CIF(I) - sage: J(3*i) # needs sage.symbolic + sage: J(3*i) 3*I - sage: J(1+2*i) # needs sage.symbolic + sage: J(1+2*i) Traceback (most recent call last): ... ValueError: 1 + 2*I is not in From 808c0f8699610839c738f90340a08e536c618a0c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:27:42 -0700 Subject: [PATCH 58/64] src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx: Fix file-level tag --- .../perm_gps/partn_ref/automorphism_group_canonical_label.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 0282ffc6494..f59db412e8f 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.groups +# sage.doctest: needs sage.groups r""" Automorphism groups and canonical labels From c8318020881efc57cf50402c9738d7c73a3518fd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:35:17 -0700 Subject: [PATCH 59/64] src/sage/groups/perm_gps/permgroup_element.pyx: More block tags --- src/sage/groups/perm_gps/permgroup_element.pyx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 2046d93ab4b..3166cb51a6e 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -853,14 +853,16 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S(p_libgap) == p True - sage: P = PGU(8,2) # needs sage.rings.finite_rings - sage: p, q = P.gens() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P = PGU(8,2) + sage: p, q = P.gens() sage: p_libgap = p.gap() TESTS:: - sage: P = PGU(8,2) # needs sage.rings.finite_rings - sage: p, q = P.gens() # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P = PGU(8,2) + sage: p, q = P.gens() sage: p_pexpect = gap(p) sage: p_libgap == p_pexpect True From 39fc225844822199a4954e69e87db15636a5cfad Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:35:28 -0700 Subject: [PATCH 60/64] src/sage/groups/perm_gps/permgroup_element.pyx: Make docstrings raw --- .../groups/perm_gps/permgroup_element.pyx | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index 3166cb51a6e..2522b5c346d 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -153,7 +153,7 @@ cdef int etuple_index_cmp(const void * a, const void * b) nogil: return (( a)[0] > ( b)[0]) - (( a)[0] < ( b)[0]) def make_permgroup_element(G, x): - """ + r""" Return a :class:`PermutationGroupElement` given the permutation group ``G`` and the permutation ``x`` in list notation. @@ -173,7 +173,7 @@ def make_permgroup_element(G, x): return make_permgroup_element_v2(G, x, domain) def make_permgroup_element_v2(G, x, domain): - """ + r""" Return a :class:`PermutationGroupElement` given the permutation group ``G``, the permutation ``x`` in list notation, and the domain ``domain`` of the permutation group. @@ -200,7 +200,7 @@ def make_permgroup_element_v2(G, x, domain): return G.element_class(x, G, check=False) def is_PermutationGroupElement(x): - """ + r""" Return ``True`` if ``x`` is a :class:`PermutationGroupElement`. EXAMPLES:: @@ -213,7 +213,7 @@ def is_PermutationGroupElement(x): return isinstance(x, PermutationGroupElement) cdef class PermutationGroupElement(MultiplicativeGroupElement): - """ + r""" An element of a permutation group. EXAMPLES:: @@ -263,7 +263,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): There are several ways to define a permutation group element: - Define a permutation group `G`, then use - ``G.gens()`` and multiplication \* to construct + ``G.gens()`` and multiplication ``*`` to construct elements. - Define a permutation group `G`, then use, e.g., @@ -793,7 +793,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def __reduce__(self): - """ + r""" Returns a function and its arguments needed to create this permutation group element. This is used in pickling. @@ -827,7 +827,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return other def _gap_(self, gap=None): - """ + r""" TESTS:: sage: g = PermutationGroupElement([(1,2,3),(4,5)]); g @@ -900,7 +900,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): gap = _libgap_ def _gap_init_(self): - """ + r""" Returns a GAP string representation for this PermutationGroupElement. @@ -912,9 +912,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): """ return 'PermList(%s)' % self._gap_list() - def _repr_(self): - """ + r""" Return string representation of this permutation. EXAMPLES: @@ -957,8 +956,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): for cycle in self.cycle_tuples()) def __getitem__(self, i): - """ - Return the ith permutation cycle in the disjoint cycle + r""" + Return the ``i``-th permutation cycle in the disjoint cycle representation of self. INPUT: @@ -979,7 +978,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return self.cycles()[i] cpdef _richcmp_(self, other, int op): - """ + r""" Compare group elements ``self`` and ``other``. EXAMPLES:: @@ -1025,7 +1024,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return rich_to_bool(op, 0) def __call__(self, i): - """ + r""" Returns the image of the integer i under this permutation. Alternately, if i is a list, tuple or string, returns the result of self acting on i. @@ -1088,7 +1087,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return from_gap[i] cpdef list _act_on_list_on_position(self, list x): - """ + r""" Returns the right action of ``self`` on the list ``x``. This is the action on positions. @@ -1116,7 +1115,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [ x[self.perm[i]] for i in range(self.n) ] cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x): - """ + r""" Returns the right action of ``self`` on the ClonableIntArray ``x``. This is the action on positions. @@ -1300,7 +1299,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return coercion_model.bin_op(left, right, operator.mul) cpdef _mul_(left, _right): - """ + r""" EXAMPLES:: sage: S = SymmetricGroup(['a', 'b']) @@ -1317,7 +1316,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return prod cpdef PermutationGroupElement _generate_new(self, list v): - """ + r""" Generate a new permutation group element with the same parent as ``self`` from ``v``. @@ -1335,7 +1334,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return new cpdef PermutationGroupElement _generate_new_GAP(self, lst_in): - """ + r""" Generate a new permutation group element with the same parent as ``self`` from the GAP list ``lst_in``. @@ -1368,7 +1367,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return new def __invert__(self): - """ + r""" Return the inverse of this permutation. EXAMPLES:: @@ -1386,7 +1385,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return inv cpdef _gap_list(self): - """ + r""" Returns this permutation in list notation compatible with the GAP numbering. @@ -1410,7 +1409,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [self.perm[i]+1 for i from 0 <= i < self.n] def _gap_cycle_string(self): - """ + r""" Returns a cycle string for this permutation compatible with the GAP numbering. @@ -1434,7 +1433,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return Permutation(self._gap_list()).cycle_string() cpdef domain(self): - """ + r""" Return the domain of ``self``. EXAMPLES:: @@ -1467,7 +1466,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [from_gap[self.perm[i]+1] for i from 0 <= i < self.n] def __hash__(self): - """ + r""" Return a hash for this permutation. EXAMPLES:: @@ -1496,7 +1495,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return ans def tuple(self): - """ + r""" Return tuple of images of the domain under ``self``. EXAMPLES:: @@ -1518,7 +1517,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return tuple([from_gap[self.perm[i]+1] for i in range(self.n)]) def dict(self): - """ + r""" Return a dictionary associating each element of the domain with its image. @@ -1542,7 +1541,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return {e:from_gap[self.perm[i-1]+1] for e,i in to_gap.iteritems()} def multiplicative_order(self): - """ + r""" Return the order of this group element, which is the smallest positive integer `n` for which `g^n = 1`. @@ -1663,7 +1662,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def orbit(self, n, bint sorted=True): - """ + r""" Return the orbit of the integer `n` under this group element, as a sorted list. @@ -1707,7 +1706,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return from_gap[n] def cycles(self): - """ + r""" Return ``self`` as a list of disjoint cycles. EXAMPLES:: @@ -1742,7 +1741,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return L def cycle_tuples(self, singletons=False): - """ + r""" Return ``self`` as a list of disjoint cycles, represented as tuples rather than permutation group elements. @@ -1801,7 +1800,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return L def cycle_string(self, singletons=False): - """ + r""" Return string representation of this permutation. EXAMPLES:: @@ -1927,7 +1926,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return (to_gap[self(i)] > to_gap[self(i1)]) is not positive def matrix(self): - """ + r""" Return a deg `\times` deg permutation matrix associated to the permutation ``self``. @@ -1951,7 +1950,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return M(entries) def word_problem(self, words, display=True, as_list=False): - """ + r""" Try to solve the word problem for ``self``. INPUT: @@ -2049,11 +2048,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): cdef class SymmetricGroupElement(PermutationGroupElement): - """ + r""" An element of the symmetric group. """ def absolute_length(self): - """ + r""" Return the absolute length of ``self``. The absolute length is the size minus the number of its disjoint @@ -2074,7 +2073,7 @@ cdef class SymmetricGroupElement(PermutationGroupElement): return Permutation(self).absolute_length() def has_left_descent(self, i): - """ + r""" Return whether `i` is a left descent of ``self``. EXAMPLES:: @@ -2088,7 +2087,7 @@ cdef class SymmetricGroupElement(PermutationGroupElement): cdef bint is_valid_permutation(int* perm, int n): - """ + r""" This is used in the __init__ method. Returns True iff the first n elements of perm are literally a From 556ebad92909c407edce2dc3e41a34fd65f758e5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 2 Sep 2023 11:39:11 -0700 Subject: [PATCH 61/64] src/sage/groups/perm_gps/permgroup_morphism.py: Make docstrings raw --- .../groups/perm_gps/permgroup_morphism.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 8a941c98546..0a86068790b 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -43,11 +43,11 @@ class PermutationGroupMorphism(Morphism): - """ + r""" A set-theoretic map between PermutationGroups. """ def _repr_type(self): - """ + r""" Return the type of this morphism. This is used for printing the morphism. @@ -62,7 +62,7 @@ def _repr_type(self): return "Permutation group" def kernel(self): - """ + r""" Return the kernel of this homomorphism as a permutation group. EXAMPLES:: @@ -87,9 +87,10 @@ def kernel(self): return self.domain().subgroup(gap_group=self._gap_().Kernel()) def image(self, J): - """ - `J` must be a subgroup of the domain `G`. Computes the subgroup of the codomain `H` - which is the image of `J`. + r""" + Compute the subgroup of the codomain `H` which is the image of `J`. + + `J` must be a subgroup of the domain `G`. EXAMPLES:: @@ -139,9 +140,9 @@ def image(self, J): return H.subgroup(gap_group=G) def __call__(self, g): - """ + r""" Some python code for wrapping GAP's ``Images`` function but only for - permutation groups. This returns an error if g is not in G. + permutation groups. This raises an error if g is not in G. EXAMPLES:: @@ -162,7 +163,7 @@ class PermutationGroupMorphism_id(PermutationGroupMorphism): class PermutationGroupMorphism_from_gap(PermutationGroupMorphism): def __init__(self, G, H, gap_hom): - """ + r""" This is a Python trick to allow Sage programmers to create a group homomorphism using GAP using very general constructions. An example of its usage is in the direct_product instance method of the @@ -193,7 +194,7 @@ def __init__(self, G, H, gap_hom): self._gap_hom = gap_hom def _repr_defn(self): - """ + r""" Return the definition of this morphism. This is used when printing the morphism. @@ -210,7 +211,7 @@ def _repr_defn(self): return str(self._gap_hom).replace('\n', '') def _gap_(self, gap=None): - """ + r""" Return a GAP version of this morphism. EXAMPLES:: @@ -225,7 +226,7 @@ def _gap_(self, gap=None): return self._gap_hom def __call__(self, g): - """ + r""" Some python code for wrapping GAP's Images function but only for permutation groups. This returns an error if g is not in G. @@ -243,7 +244,7 @@ def __call__(self, g): class PermutationGroupMorphism_im_gens(PermutationGroupMorphism): def __init__(self, G, H, gens=None): - """ + r""" Some python code for wrapping GAP's ``GroupHomomorphismByImages`` function but only for permutation groups. Can be expensive if G is large. This returns "fail" if gens does not generate self or if the map @@ -279,7 +280,7 @@ def __init__(self, G, H, gens=None): self._images = [H(img) for img in gens] def _repr_defn(self): - """ + r""" Return the definition of this morphism. This is used when printing the morphism. @@ -295,7 +296,7 @@ def _repr_defn(self): return "%s -> %s" % (list(self.domain().gens()), self._images) def _gap_(self): - """ + r""" Return a GAP representation of this morphism. EXAMPLES:: @@ -311,7 +312,7 @@ def _gap_(self): def is_PermutationGroupMorphism(f) -> bool: - """ + r""" Return ``True`` if the argument ``f`` is a :class:`PermutationGroupMorphism`. EXAMPLES:: From 2d0a7faccaba51251c520cb193df28296d9728bf Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 12:57:37 -0700 Subject: [PATCH 62/64] src/sage/groups/generic.py: Fix doctest dataflow warnings --- src/sage/groups/generic.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 192e7a46ce8..17deee71ef6 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -1208,8 +1208,9 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, EXAMPLES:: - sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_multiple + + sage: # needs sage.rings.finite_rings sage: k. = GF(5^5) sage: b = a^4 sage: order_from_multiple(b, 5^5 - 1, operation='*') @@ -1353,8 +1354,9 @@ def order_from_bounds(P, bounds, d=None, operation='+', EXAMPLES:: - sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_bounds + + sage: # needs sage.rings.finite_rings sage: k. = GF(5^5) sage: b = a^4 sage: order_from_bounds(b, (5^4, 5^5), operation='*') From 12f6ef88f3567ff07c96ac904f9bfe8807485da4 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 10 Sep 2023 17:41:17 -0700 Subject: [PATCH 63/64] bootstrap: Use 'ENABLE_SYSTEM_SITE_PACKAGES=yes sage-get-system-packages install-requires' --- bootstrap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap b/bootstrap index 5156f369c38..aa5755cfc63 100755 --- a/bootstrap +++ b/bootstrap @@ -98,8 +98,8 @@ SAGE_SPKG_CONFIGURE_$(echo ${pkgname} | tr '[a-z]' '[A-Z]')" if test -f "$DIR/requirements.txt" -o -f "$DIR/install-requires.txt"; then # A Python package SPKG_TREE_VAR=SAGE_VENV - echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4 - echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4 + echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(ENABLE_SYSTEM_SITE_PACKAGES=yes sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4 + echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(ENABLE_SYSTEM_SITE_PACKAGES=yes sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4 fi fi spkg_configures="$spkg_configures From 0785206ee752d10d1e4774d7e5feb04d84624aca Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 13 Sep 2023 11:56:15 -0700 Subject: [PATCH 64/64] Update pyproject.toml files to use version info from build/pkgs/setuptools_wheel, not the ancient build/pkgs/setuptools --- build/pkgs/setuptools_wheel/install-requires.txt | 2 +- pkgs/sagemath-bliss/pyproject.toml.m4 | 2 +- pkgs/sagemath-categories/pyproject.toml.m4 | 2 +- pkgs/sagemath-coxeter3/pyproject.toml.m4 | 2 +- pkgs/sagemath-environment/pyproject.toml.m4 | 2 +- pkgs/sagemath-mcqd/pyproject.toml.m4 | 2 +- pkgs/sagemath-meataxe/pyproject.toml.m4 | 2 +- pkgs/sagemath-objects/pyproject.toml.m4 | 2 +- pkgs/sagemath-repl/pyproject.toml.m4 | 2 +- pkgs/sagemath-sirocco/pyproject.toml.m4 | 2 +- pkgs/sagemath-tdlib/pyproject.toml.m4 | 2 +- src/pyproject.toml.m4 | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/pkgs/setuptools_wheel/install-requires.txt b/build/pkgs/setuptools_wheel/install-requires.txt index d1dc532ceab..d3767a68c8f 100644 --- a/build/pkgs/setuptools_wheel/install-requires.txt +++ b/build/pkgs/setuptools_wheel/install-requires.txt @@ -1 +1 @@ -# We use this file to mark the package as a Python package +setuptools >= 65.6 diff --git a/pkgs/sagemath-bliss/pyproject.toml.m4 b/pkgs/sagemath-bliss/pyproject.toml.m4 index 439482ad26b..1cbcdf7e162 100644 --- a/pkgs/sagemath-bliss/pyproject.toml.m4 +++ b/pkgs/sagemath-bliss/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_conf SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 index 6ce29ddcb71..cf4c97f1fd1 100644 --- a/pkgs/sagemath-categories/pyproject.toml.m4 +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-coxeter3/pyproject.toml.m4 b/pkgs/sagemath-coxeter3/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-coxeter3/pyproject.toml.m4 +++ b/pkgs/sagemath-coxeter3/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-environment/pyproject.toml.m4 b/pkgs/sagemath-environment/pyproject.toml.m4 index 7f62a86cd69..fb2db955ed5 100644 --- a/pkgs/sagemath-environment/pyproject.toml.m4 +++ b/pkgs/sagemath-environment/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" diff --git a/pkgs/sagemath-mcqd/pyproject.toml.m4 b/pkgs/sagemath-mcqd/pyproject.toml.m4 index d28ff179a00..7e651119193 100644 --- a/pkgs/sagemath-mcqd/pyproject.toml.m4 +++ b/pkgs/sagemath-mcqd/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-meataxe/pyproject.toml.m4 b/pkgs/sagemath-meataxe/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-meataxe/pyproject.toml.m4 +++ b/pkgs/sagemath-meataxe/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 index 0c5558f3412..d8fda57a8f8 100644 --- a/pkgs/sagemath-objects/pyproject.toml.m4 +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-repl/pyproject.toml.m4 b/pkgs/sagemath-repl/pyproject.toml.m4 index 7f62a86cd69..fb2db955ed5 100644 --- a/pkgs/sagemath-repl/pyproject.toml.m4 +++ b/pkgs/sagemath-repl/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" diff --git a/pkgs/sagemath-sirocco/pyproject.toml.m4 b/pkgs/sagemath-sirocco/pyproject.toml.m4 index 1b000bd5c3b..99894dd5e5e 100644 --- a/pkgs/sagemath-sirocco/pyproject.toml.m4 +++ b/pkgs/sagemath-sirocco/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-tdlib/pyproject.toml.m4 b/pkgs/sagemath-tdlib/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-tdlib/pyproject.toml.m4 +++ b/pkgs/sagemath-tdlib/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/src/pyproject.toml.m4 b/src/pyproject.toml.m4 index 56f1b2b03ab..f707b6f890e 100644 --- a/src/pyproject.toml.m4 +++ b/src/pyproject.toml.m4 @@ -6,7 +6,7 @@ requires = [ # https://github.com/pypa/pip/issues/6144 esyscmd(`sage-get-system-packages install-requires-toml \ sage_conf \ - setuptools \ + setuptools_wheel \ wheel \ sage_setup \ cypari \