Skip to content

Commit 9b1e18f

Browse files
author
Release Manager
committed
gh-36664: ruff auto-fix for C4 in modular
this was scripted using ``` ruff check --select=C4 --fix src/sage/modular/ ``` and is about simplifying list,set,dict comprehensions ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36664 Reported by: Frédéric Chapoton Reviewer(s): David Ayotte
2 parents 3253ed9 + 46a1441 commit 9b1e18f

24 files changed

+61
-61
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=c769dfca6414cc453b22e64863aee153c4041e6f
3-
md5=b098e551614a15569894e0b99b4909ff
4-
cksum=2514200459
2+
sha1=09ed008d1bdba4837fdb078f8f50a67cac9a9d7f
3+
md5=eeed6bf17634e46f99f44c1f8dcd010a
4+
cksum=1753047461
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b2813506039143e6f0abe859ab67a343abf72c2e
1+
c3f06e4734ef325db812d73dcdb2bf846b590104

src/sage/modular/abvar/abvar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,8 +2060,8 @@ def newform_level(self, none_if_not_known=False):
20602060
if none_if_not_known:
20612061
return None
20622062
level = LCM([f.level() for f in self.newform_decomposition('a')])
2063-
groups = sorted(set([f.group() for f in
2064-
self.newform_decomposition('a')]))
2063+
groups = sorted({f.group() for f in
2064+
self.newform_decomposition('a')})
20652065
if len(groups) == 1:
20662066
groups = groups[0]
20672067
self.__newform_level = level, groups
@@ -3870,7 +3870,7 @@ def _factors_with_same_label(self, other):
38703870
if not isinstance(other, ModularAbelianVariety_abstract):
38713871
raise TypeError("other must be an abelian variety")
38723872
D = self.decomposition()
3873-
C = set([A.newform_label() for A in other.decomposition()])
3873+
C = {A.newform_label() for A in other.decomposition()}
38743874
Z = []
38753875
for X in D:
38763876
lbl = X.newform_label()
@@ -4899,7 +4899,7 @@ def tamagawa_number_bounds(self, p):
48994899
else:
49004900
raise NotImplementedError("Atkin-Lehner at p must act as a scalar")
49014901
else:
4902-
mul_primes = sorted(set([p] + [q for q in prime_range(2, 2 * self.dimension() + 2)]))
4902+
mul_primes = sorted(set([p] + list(prime_range(2, 2 * self.dimension() + 2))))
49034903
div = Integer(div)
49044904
mul = Integer(mul)
49054905
mul_primes = tuple(mul_primes)

src/sage/modular/abvar/homspace.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@
168168
- Craig Citro, Robert Bradshaw (2008-03): Rewrote with modabvar overhaul
169169
"""
170170

171-
#*****************************************************************************
171+
# ****************************************************************************
172172
# Copyright (C) 2007 William Stein <[email protected]>
173173
#
174174
# This program is free software: you can redistribute it and/or modify
175175
# it under the terms of the GNU General Public License as published by
176176
# the Free Software Foundation, either version 2 of the License, or
177177
# (at your option) any later version.
178-
# http://www.gnu.org/licenses/
179-
#*****************************************************************************
178+
# https://www.gnu.org/licenses/
179+
# ****************************************************************************
180180

181181

182182
from copy import copy
@@ -188,7 +188,6 @@
188188

189189
from . import morphism
190190

191-
import sage.rings.integer_ring
192191
from sage.rings.infinity import Infinity
193192

194193
from sage.rings.ring import Ring
@@ -276,7 +275,7 @@ def _matrix_space(self):
276275
sage: Hom(J0(11), J0(22))._matrix_space
277276
Full MatrixSpace of 2 by 4 dense matrices over Integer Ring
278277
"""
279-
return MatrixSpace(ZZ,2*self.domain().dimension(), 2*self.codomain().dimension())
278+
return MatrixSpace(ZZ, 2*self.domain().dimension(), 2*self.codomain().dimension())
280279

281280
def _element_constructor_from_element_class(self, *args, **keywords):
282281
"""
@@ -479,7 +478,7 @@ def free_module(self):
479478
"""
480479
self.calculate_generators()
481480
V = ZZ**(4*self.domain().dimension() * self.codomain().dimension())
482-
return V.submodule([ V(m.matrix().list()) for m in self.gens() ])
481+
return V.submodule([V(m.matrix().list()) for m in self.gens()])
483482

484483
def gen(self, i=0):
485484
"""
@@ -570,7 +569,7 @@ def calculate_generators(self):
570569
return
571570

572571
if (self.domain() == self.codomain()) and (self.domain().dimension() == 1):
573-
self._gens = tuple([ identity_matrix(ZZ,2) ])
572+
self._gens = (identity_matrix(ZZ, 2),)
574573
return
575574

576575
phi = self.domain()._isogeny_to_product_of_powers()
@@ -583,9 +582,9 @@ def calculate_generators(self):
583582
Mt = psi.complementary_isogeny().matrix()
584583

585584
R = ZZ**(4*self.domain().dimension()*self.codomain().dimension())
586-
gens = R.submodule([ (M*self._get_matrix(g)*Mt).list()
587-
for g in im_gens ]).saturation().basis()
588-
self._gens = tuple([ self._get_matrix(g) for g in gens ])
585+
gens = R.submodule([(M*self._get_matrix(g)*Mt).list()
586+
for g in im_gens]).saturation().basis()
587+
self._gens = tuple([self._get_matrix(g) for g in gens])
589588

590589
def _calculate_product_gens(self):
591590
"""
@@ -746,7 +745,8 @@ def _calculate_simple_gens(self):
746745
Mf = f.matrix()
747746
Mg = g.matrix()
748747

749-
return [ Mf * self._get_matrix(e) * Mg for e in ls ]
748+
return [Mf * self._get_matrix(e) * Mg for e in ls]
749+
750750

751751
# NOTE/WARNING/TODO: Below in the __init__, etc. we do *not* check
752752
# that the input gens are give something that spans a sub*ring*, as apposed
@@ -820,7 +820,7 @@ def __init__(self, A, gens=None, category=None):
820820
if gens is None:
821821
self._gens = None
822822
else:
823-
self._gens = tuple([ self._get_matrix(g) for g in gens ])
823+
self._gens = tuple([self._get_matrix(g) for g in gens])
824824
self._is_full_ring = gens is None
825825

826826
def _repr_(self):
@@ -903,7 +903,7 @@ def index_in_saturation(self):
903903
A = self.abelian_variety()
904904
d = A.dimension()
905905
M = ZZ**(4*d**2)
906-
gens = [ x.matrix().list() for x in self.gens() ]
906+
gens = [x.matrix().list() for x in self.gens()]
907907
R = M.submodule(gens)
908908
return R.index_in_saturation()
909909

@@ -934,8 +934,8 @@ def discriminant(self):
934934
2
935935
"""
936936
g = self.gens()
937-
M = Matrix(ZZ,len(g), [ (g[i]*g[j]).trace()
938-
for i in range(len(g)) for j in range(len(g)) ])
937+
M = Matrix(ZZ, len(g), [(g[i]*g[j]).trace()
938+
for i in range(len(g)) for j in range(len(g))])
939939
return M.determinant()
940940

941941
def image_of_hecke_algebra(self, check_every=1):
@@ -1002,18 +1002,18 @@ def image_of_hecke_algebra(self, check_every=1):
10021002
EndVecZ = ZZ**(4*d**2)
10031003

10041004
if d == 1:
1005-
self.__hecke_algebra_image = EndomorphismSubring(A, [[1,0,0,1]])
1005+
self.__hecke_algebra_image = EndomorphismSubring(A, [[1, 0, 0, 1]])
10061006
return self.__hecke_algebra_image
10071007

10081008
V = EndVecZ.submodule([A.hecke_operator(1).matrix().list()])
10091009

1010-
for n in range(2,M.sturm_bound()+1):
1010+
for n in range(2, M.sturm_bound()+1):
10111011
if (check_every > 0 and
10121012
n % check_every == 0 and
10131013
V.dimension() == d and
10141014
V.index_in_saturation() == 1):
10151015
break
1016-
V += EndVecZ.submodule([ A.hecke_operator(n).matrix().list() ])
1016+
V += EndVecZ.submodule([A.hecke_operator(n).matrix().list()])
10171017

10181018
self.__hecke_algebra_image = EndomorphismSubring(A, V.basis())
10191019
return self.__hecke_algebra_image

src/sage/modular/arithgroup/arithgroup_perm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ def cusp_widths(self,exp=False):
17981798
"""
17991799
inv = self.S2()**2
18001800
L = self.L()
1801-
cusps = set(c[0] for c in L.cycle_tuples(singletons=True))
1801+
cusps = {c[0] for c in L.cycle_tuples(singletons=True)}
18021802
if exp:
18031803
widths = {}
18041804
else:
@@ -2603,7 +2603,7 @@ def odd_subgroups(self):
26032603
s3 = PermutationConstructor([x + tuple(y + n for y in x) for x in s3cycs])
26042604
H = ArithmeticSubgroup_Permutation(S2=s2,S3=s3)
26052605

2606-
bucket = set([H])
2606+
bucket = {H}
26072607
res = [H]
26082608
# We use a set *and* a list since checking whether an element is in a
26092609
# set is very fast, but on the other hand we want the order the results

src/sage/modular/arithgroup/congroup_gammaH.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _normalize_H(H, level):
146146
for h in H:
147147
if gcd(h, level) > 1:
148148
raise ArithmeticError('The generators %s must be units modulo %s' % (H, level))
149-
H = set(u for u in H if u > 1)
149+
H = {u for u in H if u > 1}
150150
final_H = set()
151151
for h in H:
152152
inv_h = h.inverse_mod(level)
@@ -1140,7 +1140,7 @@ def ncusps(self):
11401140
c = ZZ(0)
11411141
for d in (d for d in N.divisors() if d**2 <= N):
11421142
Nd = lcm(d, N // d)
1143-
Hd = set([x % Nd for x in H])
1143+
Hd = {x % Nd for x in H}
11441144
lenHd = len(Hd)
11451145
if Nd - 1 not in Hd:
11461146
lenHd *= 2
@@ -1182,7 +1182,7 @@ def nregcusps(self):
11821182
c = ZZ(0)
11831183
for d in (d for d in divisors(N) if d**2 <= N):
11841184
Nd = lcm(d, N // d)
1185-
Hd = set([x % Nd for x in H])
1185+
Hd = {x % Nd for x in H}
11861186
if Nd - 1 not in Hd:
11871187
summand = euler_phi(d) * euler_phi(N // d) // (2 * len(Hd))
11881188
if d**2 == N:
@@ -1395,7 +1395,7 @@ def _list_subgroup(N, gens):
13951395
sage: sage.modular.arithgroup.congroup_gammaH._list_subgroup(11, [3])
13961396
[1, 3, 4, 5, 9]
13971397
"""
1398-
H = set([1])
1398+
H = {1}
13991399
N = int(N)
14001400
for g in gens:
14011401
if gcd(g, N) != 1:
@@ -1405,7 +1405,7 @@ def _list_subgroup(N, gens):
14051405
while not (gk in H):
14061406
gk = (gk * g) % N
14071407
sbgrp.append(gk)
1408-
H = set([(x * h) % N for x in sbgrp for h in H])
1408+
H = {(x * h) % N for x in sbgrp for h in H}
14091409
return sorted(H)
14101410

14111411

src/sage/modular/btquotients/btquotient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3710,7 +3710,7 @@ def _compute_quotient(self, check=True):
37103710
'from expected.')
37113711

37123712
self._nontorsion_generators = nontorsion_generators
3713-
self._boundary = dict([(vv.rep, vv) for vv in vertex_list])
3713+
self._boundary = {vv.rep: vv for vv in vertex_list}
37143714
self._edge_list = edge_list
37153715
self._vertex_list = vertex_list
37163716
self._num_edges = num_edges

src/sage/modular/dirichlet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ def galois_orbit(self, sort=True):
12821282
P = self.parent()
12831283
z = self.element()
12841284
o = int(z.additive_order())
1285-
Auts = set([m % o for m in P._automorphisms()])
1285+
Auts = {m % o for m in P._automorphisms()}
12861286
v = [P.element_class(P, m * z, check=False) for m in Auts]
12871287
if sort:
12881288
v.sort()

src/sage/modular/etaproducts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def basis(self, reduce=True):
558558
nf = (i < S.ncols() and S[i, i]) or 0 # ?
559559
good_vects.append((vect * 24 / gcd(nf, 24)).list())
560560
for v in good_vects:
561-
v.append(-sum([r for r in v]))
561+
v.append(-sum(list(v)))
562562
dicts = []
563563
for v in good_vects:
564564
dicts.append({})

src/sage/modular/hypergeometric_motive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def wild_primes(self):
661661
[2, 3, 5]
662662
"""
663663
gamma = self.gamma_array()
664-
return sorted(set([p for n in gamma.keys() for (p, _) in n.factor()]))
664+
return sorted({p for n in gamma.keys() for (p, _) in n.factor()})
665665

666666
def zigzag(self, x, flip_beta=False):
667667
r"""

0 commit comments

Comments
 (0)