Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various details in group (ruff and pycodestyle) #36851

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/groups/abelian_gps/abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,11 +1387,11 @@ def number_of_subgroups(self, order=None):
sylow_types = defaultdict(list)
for p, e in primary_factors:
sylow_types[p].append(e)
subgroups_orders_kwds = dict()
subgroups_orders_kwds = {}

if order is None:
for p, p_exps in sylow_types.items():
subgroups_orders_kwds[p] = dict(max_sum=sum(p_exps))
subgroups_orders_kwds[p] = {'max_sum': sum(p_exps)}
else:
order = Integer(order)
if order < 1:
Expand All @@ -1403,7 +1403,7 @@ def number_of_subgroups(self, order=None):
for p in (set(sylow_types) - set(order_exps)):
del sylow_types[p]
for p in sylow_types:
subgroups_orders_kwds[p] = dict(n=order_exps[p])
subgroups_orders_kwds[p] = {'n': order_exps[p]}

result = Integer(1)
for p, p_exps in sylow_types.items():
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/abelian_gps/abelian_group_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def _libgap_(self):
sage: libgap(phi)
[ f1, f2 ] -> [ f1*f4, f2 ]
"""
G = libgap(self.domain())
H = libgap(self.codomain())
G = libgap(self.domain())
H = libgap(self.codomain())
in_G = [libgap(g) for g in self.domaingens]
in_H = [libgap(h) for h in self.codomaingens]
return G.GroupHomomorphismByImages(H, in_G, in_H)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/additive_abelian/qmodnz.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def some_elements(self):
sage: len(L)
92
"""
return list(set(self(x) for x in QQ.some_elements()))
return list({self(x) for x in QQ.some_elements()})

def random_element(self):
r"""
Expand Down
1 change: 0 additions & 1 deletion src/sage/groups/affine_gps/group_element.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Elements of Affine Groups

Expand Down
1 change: 0 additions & 1 deletion src/sage/groups/artin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Artin Groups

Expand Down
5 changes: 2 additions & 3 deletions src/sage/groups/braid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Braid groups

Expand Down Expand Up @@ -2068,7 +2067,7 @@ def reverse(self):
sage: br.is_conjugated(b)
False
"""
t = [i for i in self.Tietze()]
t = list(self.Tietze())
t.reverse()
return self.parent()(tuple(t))

Expand Down Expand Up @@ -2842,7 +2841,7 @@ def _links_gould_representation(self, symbolics=False):
# quantum trace operator on two fold tensor space
E = mu.parent().one()
mu2 = E.tensor_product(mu)
return tuple([[R, RI], mu2])
return ([R, RI], mu2)

from sage.matrix.matrix_space import MatrixSpace
Ed = MatrixSpace(BR, d, d, sparse=sparse).one()
Expand Down
1 change: 0 additions & 1 deletion src/sage/groups/conjugacy_classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Conjugacy classes of groups

Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/cubic_braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def degrees(self):
raise TypeError('not a finite reflection group')
if self.strands() > 5:
raise TypeError('not a finite reflection group')
d_table = {1: tuple(), 2: (3,), 3: (4, 6),
d_table = {1: (), 2: (3,), 3: (4, 6),
4: (6, 9, 12), 5: (12, 18, 24, 30)}
return tuple(Integer(deg) for deg in d_table[self.strands()])

Expand All @@ -887,7 +887,7 @@ def codegrees(self):
raise TypeError('not a finite reflection group')
if self.strands() > 5:
raise TypeError('not a finite reflection group')
d_table = {1: tuple(), 2: (0,), 3: (0, 2),
d_table = {1: (), 2: (0,), 3: (0, 2),
4: (0, 3, 6), 5: (0, 6, 12, 18)}
return tuple(Integer(deg) for deg in d_table[self.strands()])

Expand Down
8 changes: 4 additions & 4 deletions src/sage/groups/finitely_presented.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def __reduce__(self):
(Finitely presented group < a, b, c | a*b*c*a^-1*c^-1*b^-1, a*b*c*b^-1*a^-1*c^-1 >,
((1, 2, 3),))
"""
return (self.parent(), tuple([self.Tietze()]))
return (self.parent(), (self.Tietze(),))

def _repr_(self):
"""
Expand Down Expand Up @@ -1830,7 +1830,7 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, groebner=False):
S = R.polynomial_ring()
K = R.base_ring()
id_rels = R.ideal(rels)
res = dict()
res = {}
bound = n + 1
for j in range(bound + 1):
J = id_rels + A.fitting_ideal(j)
Expand All @@ -1847,7 +1847,7 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, groebner=False):
return res
if R.ngens() == 1:
res = {j: gcd(S(p) for p in res[j].gens()) for j in range(bound + 1)}
char_var = dict()
char_var = {}
strict = True
j = 0
while strict and j <= bound:
Expand All @@ -1862,7 +1862,7 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, groebner=False):
strict = False
j += 1
return char_var
char_var = dict()
char_var = {}
strict = True
j = 0
while strict and j <= bound:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/fqf_orthogonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def orbits(G, L):
# separating the different primes here would speed things up
b_cand = [[b for b in B if b.q() == a.q() and b.order() == a.order()] for a in A.smith_form_gens()]

G = B.orthogonal_group(tuple())
G = B.orthogonal_group(())
ambient = G.ambient()
waiting = [[]]
while len(waiting) > 0:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/groups/free_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _lexi_gen(zeroes=False):
"""
count = Integer(0)
while True:
mwrap, ind = count.quo_rem(26)
mwrap, ind = count.quo_rem(26)
if mwrap == 0 and not zeroes:
name = ''
else:
Expand Down Expand Up @@ -505,12 +505,12 @@ def syllables(self):
"""
g = self.gap().UnderlyingElement()
k = g.NumberSyllables().sage()
exponent_syllable = libgap.eval('ExponentSyllable')
exponent_syllable = libgap.eval('ExponentSyllable')
generator_syllable = libgap.eval('GeneratorSyllable')
result = []
gen = self.parent().gen
for i in range(k):
exponent = exponent_syllable(g, i+1).sage()
exponent = exponent_syllable(g, i+1).sage()
generator = gen(generator_syllable(g, i+1).sage() - 1)
result.append( (generator, exponent) )
return tuple(result)
Expand Down Expand Up @@ -880,7 +880,7 @@ def _element_constructor_(self, *args, **kwds):
except AttributeError:
return self.element_class(self, x, **kwds)
if isinstance(P, FreeGroup_class):
names = set(P._names[abs(i)-1] for i in x.Tietze())
names = {P._names[abs(i)-1] for i in x.Tietze()}
if names.issubset(self._names):
return self([i.sign()*(self._names.index(P._names[abs(i)-1])+1)
for i in x.Tietze()])
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/galois_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def _domain_to_gap(self):
sage: G._domain_to_gap[5] # needs sage.rings.number_field
5
"""
return dict((key, i+1) for i, key in enumerate(self._domain))
return {key: i+1 for i, key in enumerate(self._domain)}

@lazy_attribute
def _domain_from_gap(self):
Expand All @@ -485,7 +485,7 @@ def _domain_from_gap(self):
sage: G._domain_from_gap[20] # needs sage.rings.number_field
20
"""
return dict((i+1, key) for i, key in enumerate(self._domain))
return {i+1: key for i, key in enumerate(self._domain)}

def ngens(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/groups/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None):
raise ValueError("no solution in bsgs()")

m = ran.isqrt() + 1 # we need sqrt(ran) rounded up
table = dict() # will hold pairs (a^(lb+i),lb+i) for i in range(m)
table = {} # will hold pairs (a^(lb+i),lb+i) for i in range(m)

d = c
for i0 in xsrange(m):
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N
width = Integer(ub - lb)
N = width.isqrt() + 1

M = dict()
M = {}
for s in range(10): # to avoid infinite loops
# random walk function setup
k = 0
Expand All @@ -1060,7 +1060,7 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N
c += r
if mut:
H.set_immutable()
mem = set([H])
mem = {H}
# second random walk
H = a
d = 0
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/indexed_free_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _element_constructor_(self, x=None):
1
"""
if isinstance(x, (list, tuple)):
d = dict()
d = {}
for k, v in x:
if k in d:
d[k] += v
Expand Down
8 changes: 4 additions & 4 deletions src/sage/groups/libgap_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,12 @@ def character_table(self):
"""
#code from function in permgroup.py, but modified for
#how gap handles these groups.
G = self._gap_()
cl = self.conjugacy_classes()
G = self._gap_()
cl = self.conjugacy_classes()
from sage.rings.integer import Integer
n = Integer(len(cl))
n = Integer(len(cl))
irrG = G.Irr()
ct = [[irrG[i][j] for j in range(n)] for i in range(n)]
ct = [[irrG[i][j] for j in range(n)] for i in range(n)]

from sage.rings.number_field.number_field import CyclotomicField
e = irrG.Flat().Conductor()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/matrix_gps/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ def SL(n, R, var='a'):
except AttributeError:
cat = Groups()
name = 'Special Linear Group of degree {0} over {1}'.format(degree, ring)
ltx = 'SL({0}, {1})'.format(degree, latex(ring))
ltx = 'SL({0}, {1})'.format(degree, latex(ring))
try:
from .linear_gap import LinearMatrixGroup_gap
except ImportError:
pass
else:
try:
cmd = 'SL({0}, {1})'.format(degree, ring._gap_init_())
cmd = 'SL({0}, {1})'.format(degree, ring._gap_init_())
return LinearMatrixGroup_gap(degree, ring, True, name, ltx, cmd,
category=cat)
except ValueError:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/groups/matrix_gps/orthogonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def _OG(n, R, special, e=0, var='a', invariant_form=None):

name = '{0} Orthogonal Group of degree {1} over {2} {3}\n{4}'.format(
prefix, degree, ring, inserted_text,invariant_form)
ltx = r'\text{{{0}O}}_{{{1}}}({2})\text{{ {3} }}{4}'.format(
ltx = r'\text{{{0}O}}_{{{1}}}({2})\text{{ {3} }}{4}'.format(
ltx_prefix, degree, latex(ring), inserted_text,
latex(invariant_form))
else:
name = '{0} Orthogonal Group of degree {1} over {2}'.format(prefix, degree, ring)
ltx = r'\text{{{0}O}}_{{{1}}}({2})'.format(ltx_prefix, degree, latex(ring))
ltx = r'\text{{{0}O}}_{{{1}}}({2})'.format(ltx_prefix, degree, latex(ring))
else:
name = '{0} Orthogonal Group of degree {1} and form parameter {2} over {3}'.format(prefix, degree, e, ring)
ltx = r'\text{{{0}O}}_{{{1}}}({2}, {3})'.format(ltx_prefix, degree,
ltx = r'\text{{{0}O}}_{{{1}}}({2}, {3})'.format(ltx_prefix, degree,
latex(ring),
'+' if e == 1 else '-')

Expand Down Expand Up @@ -517,7 +517,7 @@ def invariant_bilinear_form(self):
return m

invariant_quadratic_form = invariant_bilinear_form # this is identical in the generic case
invariant_form = invariant_bilinear_form # alias (analogues to symplectic and unitary cases)
invariant_form = invariant_bilinear_form # alias (analogues to symplectic and unitary cases)

def _check_matrix(self, x, *args):
"""a
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/matrix_gps/symplectic.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ def Sp(n, R, var='a', invariant_form=None):

name = 'Symplectic Group of degree {0} over {1} with respect to alternating bilinear form\n{2}'.format(
degree, ring, invariant_form)
ltx = r'\text{{Sp}}_{{{0}}}({1})\text{{ with respect to alternating bilinear form}}{2}'.format(
ltx = r'\text{{Sp}}_{{{0}}}({1})\text{{ with respect to alternating bilinear form}}{2}'.format(
degree, latex(ring), latex(invariant_form))
else:
name = 'Symplectic Group of degree {0} over {1}'.format(degree, ring)
ltx = r'\text{{Sp}}_{{{0}}}({1})'.format(degree, latex(ring))
ltx = r'\text{{Sp}}_{{{0}}}({1})'.format(degree, latex(ring))

try:
from .symplectic_gap import SymplecticMatrixGroup_gap
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/matrix_gps/unitary.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ def _UG(n, R, special, var='a', invariant_form=None):

name = '{0} Unitary Group of degree {1} over {2} {3}\n{4}'.format(prefix,
degree, ring, inserted_text, invariant_form)
ltx = r'\text{{{0}U}}_{{{1}}}({2})\text{{ {3} }}{4}'.format(latex_prefix,
ltx = r'\text{{{0}U}}_{{{1}}}({2})\text{{ {3} }}{4}'.format(latex_prefix,
degree, latex(ring), inserted_text, latex(invariant_form))
else:
name = '{0} Unitary Group of degree {1} over {2}'.format(prefix, degree, ring)
ltx = r'\text{{{0}U}}_{{{1}}}({2})'.format(latex_prefix, degree, latex(ring))
ltx = r'\text{{{0}U}}_{{{1}}}({2})'.format(latex_prefix, degree, latex(ring))

if isinstance(ring, FiniteField):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/cubegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ def plot3d_cube(self, mv, title=True):
P.axes(show=False)
if title:
t1 = text('Up, Front, and Right faces. ' , (-0.2, -2.5))
t2 = text(' sagemath.org', (0.8, -3.1),rgbcolor=lgrey)
t2 = text(' sagemath.org', (0.8, -3.1),rgbcolor=lgrey)
t3 = text(" ", (3.5, 0), rgbcolor=white)
P = P + t1 + t2 + t3
P.axes(show=False)
Expand Down
16 changes: 8 additions & 8 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def __init__(self, gens=None, gap_group=None, canonicalize=True,

# Handle the case where only the GAP group is specified.
if gens is None:
gens = [gen for gen in gap_group.GeneratorsOfGroup()]
gens = list(gap_group.GeneratorsOfGroup())

if domain is None:
gens = [standardize_generator(x, as_cycles=True) for x in gens]
Expand All @@ -524,8 +524,8 @@ def __init__(self, gens=None, gap_group=None, canonicalize=True,

self._domain = domain
self._deg = len(self._domain)
self._domain_to_gap = dict((key, i+1) for i, key in enumerate(self._domain))
self._domain_from_gap = dict((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)}

if not gens: # length 0
gens = [()]
Expand Down Expand Up @@ -1043,7 +1043,7 @@ def list(self):
sage: G.list()
[(), (1,2)]
"""
return [x for x in self]
return list(self)

def __contains__(self, item):
"""
Expand Down Expand Up @@ -3446,11 +3446,11 @@ def character_table(self):
- David Joyner and William Stein (2006-01-04)

"""
G = self._libgap_()
cl = G.ConjugacyClasses()
n = Integer(cl.Length())
G = self._libgap_()
cl = G.ConjugacyClasses()
n = Integer(cl.Length())
irrG = G.Irr()
ct = [[irrG[i, j] for j in range(n)] for i in range(n)]
ct = [[irrG[i, j] for j in range(n)] for i in range(n)]

from sage.rings.number_field.number_field import CyclotomicField
e = irrG.Flat().Conductor()
Expand Down
Loading
Loading