Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
make PermutationGroup_generic.gens return a tuple, to ensure immutabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
mantepse committed May 9, 2022
1 parent 3f65072 commit da2c2e5
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/sage/categories/pushout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3522,7 +3522,7 @@ def __init__(self, gens, domain):
PermutationGroupFunctor[(1,2)]
"""
Functor.__init__(self, Groups(), Groups())
self._gens = gens
self._gens = tuple(gens)
self._domain = domain

def _repr_(self):
Expand All @@ -3534,7 +3534,7 @@ def _repr_(self):
sage: PF
PermutationGroupFunctor[(1,2)]
"""
return "PermutationGroupFunctor%s" % self.gens()
return "PermutationGroupFunctor%s" % list(self.gens())

def __call__(self, R):
"""
Expand All @@ -3556,7 +3556,7 @@ def gens(self):
sage: P1 = PermutationGroup([[(1,2)]])
sage: PF, P = P1.construction()
sage: PF.gens()
[(1,2)]
((1,2),)
"""
return self._gens

Expand Down
8 changes: 4 additions & 4 deletions src/sage/coding/codecan/autgroup_can_label.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ columns do share the same coloring::
sage: A = [a.get_perm() for a in P.get_autom_gens()]
sage: H = SymmetricGroup(21).subgroup(A)
sage: H.orbits()
[[1],
[2],
[3, 5, 4],
[6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18]]
((1,),
(2,),
(3, 5, 4),
(6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
We can also restrict the group action to linear isometries::
Expand Down
22 changes: 11 additions & 11 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22250,17 +22250,17 @@ def automorphism_group(self, partition=None, verbosity=0,
sage: for g in L:
....: G = g.automorphism_group()
....: G.order(), G.gens()
(24, [(2,3), (1,2), (0,1)])
(4, [(2,3), (0,1)])
(2, [(1,2)])
(6, [(1,2), (0,1)])
(6, [(2,3), (1,2)])
(8, [(1,2), (0,1)(2,3)])
(2, [(0,1)(2,3)])
(2, [(1,2)])
(8, [(2,3), (0,1), (0,2)(1,3)])
(4, [(2,3), (0,1)])
(24, [(2,3), (1,2), (0,1)])
(24, ((2,3), (1,2), (0,1)))
(4, ((2,3), (0,1)))
(2, ((1,2),))
(6, ((1,2), (0,1)))
(6, ((2,3), (1,2)))
(8, ((1,2), (0,1)(2,3)))
(2, ((0,1)(2,3),))
(2, ((1,2),))
(8, ((2,3), (0,1), (0,2)(1,3)))
(4, ((2,3), (0,1)))
(24, ((2,3), (1,2), (0,1)))
sage: C = graphs.CubeGraph(4)
sage: G = C.automorphism_group()
sage: M = G.character_table() # random order of rows, thus abs() below
Expand Down
28 changes: 14 additions & 14 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def PermutationGroup(gens=None, *args, **kwds):
sage: H = PermutationGroup(G); H
Transitive group number 3 of degree 4
sage: H.gens()
[(1,2,3,4), (1,3)]
((1,2,3,4), (1,3))
We can also create permutation groups whose generators are Gap
permutation objects::
Expand Down Expand Up @@ -486,9 +486,9 @@ def __init__(self, gens=None, gap_group=None, canonicalize=True,

if not gens: # length 0
gens = [()]
gens = [self.element_class(x, self, check=False) for x in gens]
gens = tuple(self.element_class(x, self, check=False) for x in gens)
if canonicalize:
gens = sorted(set(gens))
gens = tuple(sorted(set(gens)))
self._gens = gens

_libgap = None
Expand Down Expand Up @@ -1181,14 +1181,14 @@ def gens(self):
sage: G = PermutationGroup([[(1,2,3)], [(1,2)]])
sage: G.gens()
[(1,2), (1,2,3)]
((1,2), (1,2,3))
Note that the generators need not be minimal, though duplicates are
removed::
sage: G = PermutationGroup([[(1,2)], [(1,3)], [(2,3)], [(1,2)]])
sage: G.gens()
[(2,3), (1,2), (1,3)]
((2,3), (1,2), (1,3))
We can use index notation to access the generators returned by
``self.gens``::
Expand Down Expand Up @@ -1258,7 +1258,7 @@ def gen(self, i=None):
sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4
Permutation Group with generators [(2,3,4), (1,2,3)]
sage: A4.gens()
[(2,3,4), (1,2,3)]
((2,3,4), (1,2,3))
sage: A4.gen(0)
(2,3,4)
sage: A4.gen(1)
Expand Down Expand Up @@ -1998,7 +1998,7 @@ def _repr_(self):
sage: AlternatingGroup(4)._repr_()
'Alternating group of order 4!/2 as a permutation group'
"""
return "Permutation Group with generators %s"%self.gens()
return "Permutation Group with generators %s" % list(self.gens())

def _latex_(self):
r"""
Expand Down Expand Up @@ -2645,7 +2645,7 @@ def semidirect_product(self, N, mapping, check=True):
sage: S.is_isomorphic(DihedralGroup(8))
True
sage: S.gens()
[(3,4,5,6,7,8,9,10), (1,2)(4,10)(5,9)(6,8)]
((3,4,5,6,7,8,9,10), (1,2)(4,10)(5,9)(6,8))
A more complicated example can be drawn from [TW1980]_.
It is there given that a semidirect product of $D_4$ and $C_3$
Expand Down Expand Up @@ -2745,7 +2745,7 @@ def semidirect_product(self, N, mapping, check=True):
raise ValueError(msg)

# create a parallel list of the automorphisms of N in GAP
libgap.eval('N := Group({})'.format(N.gens()))
libgap.eval('N := Group({})'.format(list(N.gens())))
gens_string = ",".join(str(x) for x in N.gens())
homomorphism_cmd = 'alpha := GroupHomomorphismByImages(N, N, [{0}],[{1}])'
libgap.eval('morphisms := []')
Expand Down Expand Up @@ -2799,7 +2799,7 @@ def holomorph(self):
sage: D4 = DihedralGroup(4)
sage: H = D4.holomorph()
sage: H.gens()
[(3,8)(4,7), (2,3,5,8), (2,5)(3,8), (1,4,6,7)(2,3,5,8), (1,8)(2,7)(3,6)(4,5)]
((3,8)(4,7), (2,3,5,8), (2,5)(3,8), (1,4,6,7)(2,3,5,8), (1,8)(2,7)(3,6)(4,5))
sage: G = H.subgroup([H.gens()[0],H.gens()[1],H.gens()[2]])
sage: N = H.subgroup([H.gens()[3],H.gens()[4]])
sage: N.is_normal(H)
Expand All @@ -2820,7 +2820,7 @@ def holomorph(self):
- Kevin Halasz (2012-08-14)
"""

libgap.eval('G := Group({})'.format(self.gens()))
libgap.eval('G := Group({})'.format(list(self.gens())))
libgap.eval('aut := AutomorphismGroup(G)')
libgap.eval('alpha := InverseGeneralMapping(NiceMonomorphism(aut))')
libgap.eval('product := SemidirectProduct(NiceObject(aut),alpha,G)')
Expand Down Expand Up @@ -4777,7 +4777,7 @@ class PermutationGroup_subgroup(PermutationGroup_generic):
sage: K.ambient_group()
Dihedral group of order 8 as a permutation group
sage: K.gens()
[(1,2,3,4)]
((1,2,3,4),)
"""
def __init__(self, ambient, gens=None, gap_group=None, domain=None,
category=None, canonicalize=True, check=True):
Expand Down Expand Up @@ -4809,7 +4809,7 @@ def __init__(self, ambient, gens=None, gap_group=None, domain=None,
sage: G = DihedralGroup(4)
sage: H = CyclicPermutationGroup(4)
sage: gens = H.gens(); gens
[(1,2,3,4)]
((1,2,3,4),)
sage: S = G.subgroup(gens)
sage: S
Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group)
Expand Down Expand Up @@ -4947,7 +4947,7 @@ def _repr_(self):
sage: S._repr_()
'Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group)'
"""
return "Subgroup generated by %s of (%s)" % (self.gens(), self.ambient_group())
return "Subgroup generated by %s of (%s)" % (list(self.gens()), self.ambient_group())

def _latex_(self):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/permgroup_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def _repr_defn(self):
sage: phi._repr_defn()
'[(1,2,3,4)] -> [(1,2,3,4)]'
"""
return "%s -> %s"%(self.domain().gens(), self._images)
return "%s -> %s"%(list(self.domain().gens()), self._images)

def _gap_(self):
"""
Expand Down
16 changes: 8 additions & 8 deletions src/sage/groups/perm_gps/permgroup_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ class GeneralDihedralGroup(PermutationGroup_generic):
sage: G.order()
18
sage: G.gens()
[(4,5,6), (2,3)(5,6), (1,2,3)]
((4,5,6), (2,3)(5,6), (1,2,3))
sage: a = G.gens()[2]; b = G.gens()[0]; c = G.gens()[1]
sage: a.order() == 3, b.order() == 3, c.order() == 2
(True, True, True)
Expand All @@ -1212,7 +1212,7 @@ class GeneralDihedralGroup(PermutationGroup_generic):
sage: G.order()
16
sage: G.gens()
[(7,8), (5,6), (3,4), (1,2)]
((7,8), (5,6), (3,4), (1,2))
sage: G.is_abelian()
True
sage: H = KleinFourGroup()
Expand Down Expand Up @@ -1385,10 +1385,10 @@ def __init__(self, n):
sage: DihedralGroup(2)
Dihedral group of order 4 as a permutation group
sage: DihedralGroup(2).gens()
[(3,4), (1,2)]
((3,4), (1,2))
sage: DihedralGroup(5).gens()
[(1,2,3,4,5), (1,5)(2,4)]
((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)]
Expand All @@ -1401,7 +1401,7 @@ def __init__(self, n):
sage: G
Dihedral group of order 10 as a permutation group
sage: G.gens()
[(1,2,3,4,5), (1,5)(2,4)]
((1,2,3,4,5), (1,5)(2,4))
sage: DihedralGroup(0)
Traceback (most recent call last):
Expand Down Expand Up @@ -1644,7 +1644,7 @@ def __init__(self,m):
sage: len([H for H in G.subgroups() if H.is_cyclic() and H.order() == 8])
1
sage: G.gens()
[(2,4)(3,7)(6,8), (1,2,3,4,5,6,7,8)]
((2,4)(3,7)(6,8), (1,2,3,4,5,6,7,8))
sage: x = G.gens()[1]; y = G.gens()[0]
sage: x.order() == 2^3; y.order() == 2
True
Expand Down Expand Up @@ -1783,7 +1783,7 @@ def __init__(self, d, n):
sage: G = TransitiveGroup(5, 2); G
Transitive group number 2 of degree 5
sage: G.gens()
[(1,2,3,4,5), (1,4)(2,3)]
((1,2,3,4,5), (1,4)(2,3))
sage: G.category()
Category of finite enumerated permutation groups
Expand Down Expand Up @@ -2170,7 +2170,7 @@ class PrimitiveGroup(PermutationGroup_unique):
sage: G = PrimitiveGroup(5, 2); G
D(2*5)
sage: G.gens()
[(2,4)(3,5), (1,2,3,5,4)]
((2,4)(3,5), (1,2,3,5,4))
sage: G.category()
Category of finite enumerated permutation groups
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_rational_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,7 @@ cdef class Polynomial_rational_flint(Polynomial):
sage: G = f.galois_group(); G
Transitive group number 5 of degree 4
sage: G.gens()
[(1,2), (1,2,3,4)]
((1,2), (1,2,3,4))
sage: G.order()
24
Expand Down
4 changes: 2 additions & 2 deletions src/sage/tests/books/judson-abstract-algebra/actions-sage.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
~~~~~~~~~~~~~~~~~~~~~~ ::
sage: A.orbits()
[[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5]]
((0, 10), (1, 9), (2, 8), (3, 7), (4, 6), (5,))
~~~~~~~~~~~~~~~~~~~~~~ ::
Expand All @@ -169,6 +169,6 @@
sage: G = SymmetricGroup(4)
sage: S = G.stabilizer(4)
sage: S.orbits()
[[1, 2, 3], [4]]
((1, 2, 3), (4,))
"""
20 changes: 10 additions & 10 deletions src/sage/tests/books/judson-abstract-algebra/galois-sage.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,16 @@
sage: sg = P.subgroups()
sage: [H.gens() for H in sg]
[[()],
[(1,4)(2,3)],
[(2,3)],
[(1,4)],
[(1,2)(3,4)],
[(1,3)(2,4)],
[(2,3), (1,4)(2,3)],
[(1,2,4,3), (1,4)(2,3)],
[(1,2)(3,4), (1,4)(2,3)],
[(2,3), (1,2,4,3), (1,4)(2,3)]]
[((),),
((1,4)(2,3),),
((2,3),),
((1,4),),
((1,2)(3,4),),
((1,3)(2,4),),
((2,3), (1,4)(2,3)),
((1,2,4,3), (1,4)(2,3)),
((1,2)(3,4), (1,4)(2,3)),
((2,3), (1,2,4,3), (1,4)(2,3))]
~~~~~~~~~~~~~~~~~~~~~~ ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
sage: results = G.direct_product(H)
sage: phi = results[2]
sage: H.gens()
[(1,2,3,4), (1,4)(2,3)]
((1,2,3,4), (1,4)(2,3))
~~~~~~~~~~~~~~~~~~~~~~ ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
sage: G = DihedralGroup(5)
sage: H = DihedralGroup(20)
sage: G.gens()
[(1,2,3,4,5), (1,5)(2,4)]
((1,2,3,4,5), (1,5)(2,4))
~~~~~~~~~~~~~~~~~~~~~~ ::
sage: H.gens()
[(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20),
(1,20)(2,19)(3,18)(4,17)(5,16)(6,15)(7,14)(8,13)(9,12)(10,11)]
((1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20),
(1,20)(2,19)(3,18)(4,17)(5,16)(6,15)(7,14)(8,13)(9,12)(10,11))
~~~~~~~~~~~~~~~~~~~~~~ ::
Expand Down

0 comments on commit da2c2e5

Please sign in to comment.