Skip to content

Commit

Permalink
gh-38701: some minor details in named permgroups
Browse files Browse the repository at this point in the history
    
just fixing a few very minor details in the modified file

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
    
URL: #38701
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Sep 27, 2024
2 parents 58ffd78 + 841de79 commit 493af85
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/sage/groups/perm_gps/permgroup_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ def __classcall__(cls, domain):
try:
domain = Integer(domain)
except TypeError:
raise TypeError("domain (={}) must be an integer >= 0 or a finite set (but domain has type {})".format(domain, type(domain)))
raise TypeError(f"domain (={domain}) must be an integer >= 0 or a finite set (but domain has type {type(domain)})")

if domain < 0:
raise ValueError("domain (={}) must be an integer >= 0 or a list".format(domain))
raise ValueError(f"domain (={domain}) must be an integer >= 0 or a list")
domain = list(range(1, domain + 1))
v = FiniteEnumeratedSet(domain)
else:
Expand Down Expand Up @@ -273,8 +273,8 @@ def __init__(self, domain=None):

self._domain = domain
self._deg = len(self._domain)
self._domain_to_gap = {key: i+1 for i, key in enumerate(self._domain)}
self._domain_from_gap = {i+1: key for i, key in enumerate(self._domain)}
self._domain_to_gap = {key: i + 1 for i, key in enumerate(self._domain)}
self._domain_from_gap = {i + 1: key for i, key in enumerate(self._domain)}

# Create the generators for the symmetric group
if self._deg <= 1:
Expand All @@ -299,7 +299,7 @@ def _gap_init_(self, gap=None):
sage: S._gap_init_()
'SymmetricGroup(3)'
"""
return 'SymmetricGroup({})'.format(self.degree())
return f'SymmetricGroup({self.degree()})'

@cached_method
def index_set(self):
Expand Down Expand Up @@ -340,7 +340,7 @@ def _repr_(self):
sage: A = SymmetricGroup([2,3,7]); A
Symmetric group of order 3! as a permutation group
"""
return "Symmetric group of order {}! as a permutation group".format(self.degree())
return f"Symmetric group of order {self.degree()}! as a permutation group"

def _coerce_map_from_(self, G):
"""
Expand Down Expand Up @@ -702,11 +702,9 @@ def algebra(self, base_ring, category=None):
(3,5)
"""
from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra
domain = self.domain()
if list(domain) == list(range(1, len(domain) + 1)):
if all(i == j for i, j in enumerate(self.domain(), start=1)):
return SymmetricGroupAlgebra(base_ring, self, category=category)
else:
return super().algebra(base_ring)
return super().algebra(base_ring)

Element = SymmetricGroupElement

Expand Down Expand Up @@ -2190,7 +2188,7 @@ def __call__(self, G):
for H in self:
if H.is_isomorphic(G):
return H
raise ValueError("{} is not a transitive group of degree {}".format(G, self._degree))
raise ValueError(f"{G} is not a transitive group of degree {self._degree}")

@cached_method
def cardinality(self):
Expand Down Expand Up @@ -2696,7 +2694,7 @@ def __init__(self, n, q, name='a'):
self._base_ring = GF(q, name=name)
self._n = n

def __str__(self):
def __str__(self) -> str:
"""
EXAMPLES::
Expand Down Expand Up @@ -2773,16 +2771,13 @@ def __init__(self, n, q, name='a'):
q = q.cardinality()
if q not in NonNegativeIntegers():
raise ValueError('q must be a prime power or a finite field')
if n == 1:
id = 'Group([()])'
else:
id = 'PSL(%s,%s)' % (n, q)
id = 'Group([()])' if n == 1 else f'PSL({n},{q})'
PermutationGroup_generic.__init__(self, gap_group=id)
self._q = q
self._base_ring = GF(q, name=name)
self._n = n

def __str__(self):
def __str__(self) -> str:
"""
EXAMPLES::
Expand Down Expand Up @@ -2939,7 +2934,7 @@ def __init__(self, n, q, name='a'):
self._base_ring = GF(q, name=name)
self._n = n

def __str__(self):
def __str__(self) -> str:
"""
EXAMPLES::
Expand Down Expand Up @@ -3132,7 +3127,7 @@ def base_ring(self):
"""
return self._base_ring

def __str__(self):
def __str__(self) -> str:
"""
EXAMPLES::
Expand Down

0 comments on commit 493af85

Please sign in to comment.