Skip to content

Commit

Permalink
Trac #33824: make gens and orbits of PermutationGroup immutable
Browse files Browse the repository at this point in the history
We don't want the following to happen:
{{{
sage: G = PermutationGroup([ [(3,4)], [(1,3)] ])
sage: O = G.orbits(); O
[[1, 3, 4], [2]]
sage: O[0] = 1
sage: G.orbits()
[1, [2]]

sage: G = PermutationGroup([[2,1]]); G
Permutation Group with generators [(1,2)]
sage: g = G.gens()
sage: g[0] = 1
sage: G.gens()
[1]
}}}
Therefore, we change the return type of `gens` and `orbits` to be a
tuple of tuples.  We keep the `_repr_` of `PermutationGroup_generic`,
because the output is more compact.

Note that `gens` returns a tuple for all other groups I checked.

URL: https://trac.sagemath.org/33824
Reported by: mantepse
Ticket author(s): Martin Rubey
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed May 22, 2022
2 parents af23627 + 90005e7 commit b400962
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 150 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 @@ -22419,17 +22419,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
Loading

0 comments on commit b400962

Please sign in to comment.