-
-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #34647: some details in permutation groups
mostly a few pep8 changes URL: https://trac.sagemath.org/34647 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Travis Scrimshaw
- Loading branch information
Showing
6 changed files
with
54 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
from .permgroup_named import (SymmetricGroup, AlternatingGroup, | ||
DihedralGroup, SplitMetacyclicGroup, SemidihedralGroup, CyclicPermutationGroup, | ||
DiCyclicGroup, TransitiveGroup, PGL, PSL, PSp,PSU,PGU, | ||
MathieuGroup, KleinFourGroup, QuaternionGroup, | ||
PrimitiveGroup, PrimitiveGroups, | ||
SuzukiGroup, TransitiveGroups, GeneralDihedralGroup) | ||
DihedralGroup, SplitMetacyclicGroup, | ||
SemidihedralGroup, CyclicPermutationGroup, | ||
DiCyclicGroup, TransitiveGroup, | ||
PGL, PSL, PSp, PSU, PGU, | ||
MathieuGroup, KleinFourGroup, QuaternionGroup, | ||
PrimitiveGroup, PrimitiveGroups, | ||
SuzukiGroup, TransitiveGroups, | ||
GeneralDihedralGroup) | ||
|
||
from .permgroup import PermutationGroup, PermutationGroup_generic, PermutationGroup_subgroup, direct_product_permgroups | ||
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) | ||
PermutationGroupMorphism_im_gens, | ||
PermutationGroupMorphism_id) | ||
PermutationGroupMorphism = PermutationGroupMorphism_im_gens | ||
|
||
from .cubegroup import CubeGroup, RubiksCube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
objects have a more group theoretic flavor than the more combinatorial | ||
:class:`~sage.combinat.permutation.Permutation`. | ||
""" | ||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2006 William Stein <[email protected]> | ||
# Copyright (C) 2006 David Joyner | ||
# Copyright (C) 2019 Vincent Delecroix <[email protected]> | ||
|
@@ -16,16 +16,17 @@ | |
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
from . import permgroup_element | ||
from sage.misc.sage_eval import sage_eval | ||
from sage.misc.lazy_import import lazy_import | ||
from sage.interfaces.gap import GapElement | ||
lazy_import('sage.combinat.permutation', ['Permutation', 'from_cycles']) | ||
from sage.libs.pari.all import pari_gen | ||
from sage.libs.gap.element import GapElement_Permutation | ||
lazy_import('sage.combinat.permutation', ['Permutation', 'from_cycles']) | ||
|
||
|
||
def PermutationGroupElement(g, parent=None, check=True): | ||
r""" | ||
|
@@ -118,6 +119,7 @@ def PermutationGroupElement(g, parent=None, check=True): | |
|
||
return parent.element_class(g, parent, check) | ||
|
||
|
||
def string_to_tuples(g): | ||
""" | ||
EXAMPLES:: | ||
|
@@ -136,10 +138,11 @@ def string_to_tuples(g): | |
raise ValueError("g (= %s) must be a string" % g) | ||
elif g == '()': | ||
return [] | ||
g = g.replace('\n','').replace(' ', '').replace(')(', '),(').replace(')', ',)') | ||
g = g.replace('\n', '').replace(' ', '').replace(')(', '),(').replace(')', ',)') | ||
g = '[' + g + ']' | ||
return sage_eval(g, preparse=False) | ||
|
||
|
||
def standardize_generator(g, convert_dict=None, as_cycles=False): | ||
r""" | ||
Standardize the input for permutation group elements to a list | ||
|
@@ -258,6 +261,6 @@ def standardize_generator(g, convert_dict=None, as_cycles=False): | |
if convert_dict is not None and needs_conversion: | ||
g = [tuple([convert_dict[x] for x in cycle]) for cycle in g] | ||
if not as_cycles: | ||
degree = max([1] + [max(cycle+(1,)) for cycle in g]) | ||
degree = max([1] + [max(cycle + (1,)) for cycle in g]) | ||
g = from_cycles(degree, g) | ||
return g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,9 @@ EXAMPLES:: | |
REFERENCE: | ||
- [1] McKay, Brendan D. Practical Graph Isomorphism. Congressus Numerantium, | ||
- [1] McKay, Brendan D. *Practical Graph Isomorphism*. Congressus Numerantium, | ||
Vol. 30 (1981), pp. 45-87. | ||
""" | ||
|
||
# **************************************************************************** | ||
# Copyright (C) 2006 - 2011 Robert L. Miller <[email protected]> | ||
# | ||
|
@@ -643,9 +642,8 @@ cdef int compare_graphs(int *gamma_1, int *gamma_2, void *S1, void *S2, int degr | |
r""" | ||
Compare gamma_1(S1) and gamma_2(S2). | ||
Return return -1 if gamma_1(S1) < gamma_2(S2), 0 if gamma_1(S1) == | ||
gamma_2(S2), 1 if gamma_1(S1) > gamma_2(S2). (Just like the python | ||
\code{cmp}) function. | ||
Return -1 if gamma_1(S1) < gamma_2(S2), 0 if gamma_1(S1) == | ||
gamma_2(S2), 1 if gamma_1(S1) > gamma_2(S2). | ||
INPUT: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,24 +30,26 @@ | |
Cyclic group of order 4 as a permutation group | ||
""" | ||
|
||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2006 David Joyner and William Stein <[email protected]> | ||
# | ||
# Distributed under the terms of the GNU General Public License (GPL) | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
from sage.categories.morphism import Morphism | ||
from sage.groups.perm_gps.permgroup import PermutationGroup, PermutationGroup_generic | ||
|
||
|
||
class PermutationGroupMorphism(Morphism): | ||
""" | ||
A set-theoretic map between PermutationGroups. | ||
""" | ||
def _repr_type(self): | ||
""" | ||
Returns the type of this morphism. This is used for printing | ||
the morphism. | ||
Return the type of this morphism. | ||
This is used for printing the morphism. | ||
EXAMPLES:: | ||
|
@@ -60,7 +62,7 @@ def _repr_type(self): | |
|
||
def kernel(self): | ||
""" | ||
Returns the kernel of this homomorphism as a permutation group. | ||
Return the kernel of this homomorphism as a permutation group. | ||
EXAMPLES:: | ||
|
@@ -134,7 +136,7 @@ def image(self, J): | |
def __call__(self, g): | ||
""" | ||
Some python code for wrapping GAP's Images function but only for | ||
permutation groups. Returns an error if g is not in G. | ||
permutation groups. This returns an error if g is not in G. | ||
EXAMPLES:: | ||
|
@@ -148,9 +150,11 @@ def __call__(self, g): | |
""" | ||
return self.image(g) | ||
|
||
|
||
class PermutationGroupMorphism_id(PermutationGroupMorphism): | ||
pass | ||
|
||
|
||
class PermutationGroupMorphism_from_gap(PermutationGroupMorphism): | ||
def __init__(self, G, H, gap_hom): | ||
""" | ||
|
@@ -201,7 +205,7 @@ def _repr_defn(self): | |
|
||
def _gap_(self, gap=None): | ||
""" | ||
Returns a GAP version of this morphism. | ||
Return a GAP version of this morphism. | ||
EXAMPLES:: | ||
|
@@ -217,7 +221,7 @@ def _gap_(self, gap=None): | |
def __call__(self, g): | ||
""" | ||
Some python code for wrapping GAP's Images function but only for | ||
permutation groups. Returns an error if g is not in G. | ||
permutation groups. This returns an error if g is not in G. | ||
EXAMPLES:: | ||
|
@@ -236,7 +240,7 @@ def __init__(self, G, H, gens=None): | |
""" | ||
Some python code for wrapping GAP's GroupHomomorphismByImages | ||
function but only for permutation groups. Can be expensive if G is | ||
large. Returns "fail" if gens does not generate self or if the map | ||
large. This returns "fail" if gens does not generate self or if the map | ||
does not extend to a group homomorphism, self - other. | ||
EXAMPLES:: | ||
|
@@ -270,8 +274,9 @@ def __init__(self, G, H, gens=None): | |
|
||
def _repr_defn(self): | ||
""" | ||
Returns the definition of this morphism. This is used when | ||
printing the morphism. | ||
Return the definition of this morphism. | ||
This is used when printing the morphism. | ||
EXAMPLES:: | ||
|
@@ -281,11 +286,11 @@ def _repr_defn(self): | |
sage: phi._repr_defn() | ||
'[(1,2,3,4)] -> [(1,2,3,4)]' | ||
""" | ||
return "%s -> %s"%(list(self.domain().gens()), self._images) | ||
return "%s -> %s" % (list(self.domain().gens()), self._images) | ||
|
||
def _gap_(self): | ||
""" | ||
Returns a GAP representation of this morphism. | ||
Return a GAP representation of this morphism. | ||
EXAMPLES:: | ||
|
@@ -298,9 +303,10 @@ def _gap_(self): | |
""" | ||
return self.domain()._gap_().GroupHomomorphismByImages(self.codomain(), self.domain().gens(), self._images) | ||
|
||
def is_PermutationGroupMorphism(f): | ||
|
||
def is_PermutationGroupMorphism(f) -> bool: | ||
""" | ||
Returns True if the argument ``f`` is a PermutationGroupMorphism. | ||
Return True if the argument ``f`` is a PermutationGroupMorphism. | ||
EXAMPLES:: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters