Skip to content

Commit 3624943

Browse files
author
Release Manager
committed
gh-39084: linting : some fixes for pyx files in modular found using `cython-lint` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39084 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents 8fc386b + 5875eaf commit 3624943

File tree

7 files changed

+95
-95
lines changed

7 files changed

+95
-95
lines changed

src/sage/modular/arithgroup/congroup.pyx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ from sage.rings.integer_ring import ZZ
3131
Mat2Z = MatrixSpace(ZZ, 2)
3232

3333
cdef Matrix_integer_dense genS, genT, genI
34-
genS = Matrix_integer_dense(Mat2Z, [0,-1, 1, 0], True, True)
34+
genS = Matrix_integer_dense(Mat2Z, [0, -1, 1, 0], True, True)
3535
genT = Matrix_integer_dense(Mat2Z, [1, 1, 0, 1], True, True)
3636
genI = Matrix_integer_dense(Mat2Z, [1, 0, 0, 1], True, True)
3737

@@ -123,7 +123,7 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t):
123123
# try to find another coset representative.
124124
cc = M*random.randrange(-halfmax, halfmax+1)
125125
dd = random.randrange(-halfmax, halfmax+1)
126-
g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa)
126+
g = arith_int.c_xgcd_int(-cc, dd, &bb, &aa)
127127
if g == 0:
128128
continue
129129
cc = cc // g
@@ -297,22 +297,24 @@ def generators_helper(coset_reps, level):
297297
[21 5], [ 7 -1], [-7 1]
298298
]
299299
"""
300-
cdef Matrix_integer_dense x,y,z,v,vSmod,vTmod
300+
cdef Matrix_integer_dense x, y, z, v, vSmod, vTmod
301301

302302
crs = coset_reps.list()
303303
try:
304-
reps = [Matrix_integer_dense(Mat2Z,lift_to_sl2z(c, d, level),False,True) for c,d in crs]
304+
reps = [Matrix_integer_dense(Mat2Z, lift_to_sl2z(c, d, level),
305+
False, True) for c, d in crs]
305306
except Exception:
306307
raise ArithmeticError("Error lifting to SL2Z: level=%s crs=%s" % (level, crs))
307308
ans = []
308309
cdef Py_ssize_t i
309310
for i in range(len(crs)):
310311
x = reps[i]
311-
v = Matrix_integer_dense(Mat2Z,[crs[i][0],crs[i][1],0,0],False,True)
312+
v = Matrix_integer_dense(Mat2Z, [crs[i][0], crs[i][1], 0, 0],
313+
False, True)
312314
vSmod = (v*genS)
313315
vTmod = (v*genT)
314-
y_index = coset_reps.normalize(vSmod[0,0],vSmod[0,1])
315-
z_index = coset_reps.normalize(vTmod[0,0],vTmod[0,1])
316+
y_index = coset_reps.normalize(vSmod[0, 0], vSmod[0, 1])
317+
z_index = coset_reps.normalize(vTmod[0, 0], vTmod[0, 1])
316318
y_index = crs.index(y_index)
317319
z_index = crs.index(z_index)
318320
y = reps[y_index]

src/sage/modular/arithgroup/farey_symbol.pyx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ based on the *KFarey* package by Chris Kurth. Implemented as C++ module
1313
for speed.
1414
"""
1515

16-
#*****************************************************************************
16+
# ****************************************************************************
1717
# Copyright (C) 2011 Hartmut Monien <[email protected]>
1818
#
1919
# This program is free software: you can redistribute it and/or modify
2020
# it under the terms of the GNU General Public License as published by
2121
# the Free Software Foundation, either version 2 of the License, or
2222
# (at your option) any later version.
23-
# http://www.gnu.org/licenses/
24-
#*****************************************************************************
23+
# https://www.gnu.org/licenses/
24+
# ****************************************************************************
2525

2626
from cpython.object cimport PyObject_RichCompare
2727
from itertools import groupby
@@ -206,11 +206,11 @@ cdef class Farey:
206206
self.this_ptr = new cpp_farey(data)
207207
sig_off()
208208
return
209-
## to accelerate the calculation of the FareySymbol
210-
## we implement the tests for the standard congruence groups
211-
## in the c++ module. For a general group the test if an element
212-
## of SL2Z is in the group the python __contains__ attribute
213-
## of the group is called
209+
# to accelerate the calculation of the FareySymbol
210+
# we implement the tests for the standard congruence groups
211+
# in the c++ module. For a general group the test if an element
212+
# of SL2Z is in the group the python __contains__ attribute
213+
# of the group is called
214214
cdef int p
215215
if hasattr(group, "level"):
216216
p = group.level()
@@ -285,19 +285,19 @@ cdef class Farey:
285285
a, b, c, d = pm.matrix().list()
286286
newval = gens_dict.get(SL2Z([a, b, c, d]))
287287
if newval is not None:
288-
ans.append((newval,1))
288+
ans.append((newval, 1))
289289
continue
290290
newval = gens_dict.get(SL2Z([-a, -b, -c, -d]))
291291
if newval is not None:
292-
ans.append((newval,-1))
292+
ans.append((newval, -1))
293293
continue
294294
newval = gens_dict.get(SL2Z([d, -b, -c, a]))
295295
if newval is not None:
296-
ans.append((-newval,1))
296+
ans.append((-newval, 1))
297297
continue
298298
newval = gens_dict.get(SL2Z([-d, b, c, -a]))
299299
if newval is not None:
300-
ans.append((-newval,-1))
300+
ans.append((-newval, -1))
301301
continue
302302
raise RuntimeError("This should have not happened")
303303
return ans
@@ -453,7 +453,7 @@ cdef class Farey:
453453
result = self.this_ptr.word_problem(a.value, b.value, c.value, d.value, cpp_beta)
454454
sig_off()
455455
beta = convert_to_SL2Z(cpp_beta[0])**-1
456-
mbeta = SL2Z([-beta.a(),-beta.b(),-beta.c(),-beta.d()])
456+
mbeta = SL2Z([-beta.a(), -beta.b(), -beta.c(), -beta.d()])
457457
V = self.pairing_matrices_to_tietze_index()
458458
sgn = 1
459459
tietze = []
@@ -500,7 +500,7 @@ cdef class Farey:
500500
tietze.reverse()
501501
gens = self.generators()
502502
if check:
503-
tmp = SL2Z([1,0,0,1])
503+
tmp = SL2Z([1, 0, 0, 1])
504504
for i in range(len(tietze)):
505505
t = tietze[i]
506506
tmp = tmp * gens[t-1] if t > 0 else tmp * gens[-t-1]**-1
@@ -1009,7 +1009,7 @@ cdef class Farey:
10091009
fill=options['fill'],
10101010
linestyle=options['linestyle'],
10111011
thickness=options['thickness'])
1012-
## show pairings
1012+
# show pairings
10131013
p = self.pairings()
10141014
x = self.fractions()
10151015
if options['show_pairing']:
@@ -1033,7 +1033,7 @@ cdef class Farey:
10331033
return g
10341034

10351035

1036-
#--- conversions ------------------------------------------------------------
1036+
# ----- conversions ---------------------------------
10371037

10381038
cdef public long convert_to_long(n) noexcept:
10391039
cdef long m = n

src/sage/modular/modsym/heilbronn.pyx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ cdef class Heilbronn:
202202
b[i] = (u * self.list.v[4*i+1]) % N + (v * self.list.v[4*i+3]) % N
203203
else:
204204
for i in range(self.length):
205-
a[i] = llong_prod_mod(u,self.list.v[4*i],N) + llong_prod_mod(v,self.list.v[4*i+2], N)
206-
b[i] = llong_prod_mod(u,self.list.v[4*i+1],N) + llong_prod_mod(v,self.list.v[4*i+3], N)
205+
a[i] = llong_prod_mod(u, self.list.v[4*i], N) + llong_prod_mod(v, self.list.v[4*i+2], N)
206+
b[i] = llong_prod_mod(u, self.list.v[4*i+1], N) + llong_prod_mod(v, self.list.v[4*i+3], N)
207207
sig_off()
208208

209209
cdef apply_to_polypart(self, fmpz_poly_t* ans, int i, int k):
@@ -283,8 +283,8 @@ cdef class Heilbronn:
283283
else:
284284
for i in range(self.length):
285285
sig_check()
286-
a = llong_prod_mod(u,self.list.v[4*i],N) + llong_prod_mod(v,self.list.v[4*i+2], N)
287-
b = llong_prod_mod(u,self.list.v[4*i+1],N) + llong_prod_mod(v,self.list.v[4*i+3], N)
286+
a = llong_prod_mod(u, self.list.v[4*i], N) + llong_prod_mod(v, self.list.v[4*i+2], N)
287+
b = llong_prod_mod(u, self.list.v[4*i+1], N) + llong_prod_mod(v, self.list.v[4*i+3], N)
288288
export.c_p1_normalize_llong(N, a, b, &c, &d, &s, 0)
289289
X = (c, d)
290290
if X in M:
@@ -368,15 +368,15 @@ cdef class HeilbronnCremona(Heilbronn):
368368
L = &self.list
369369
p = self.p
370370

371-
list_append4(L, 1,0,0,p)
371+
list_append4(L, 1, 0, 0, p)
372372

373373
# When p==2, then Heilbronn matrices are
374374
# [[1,0,0,2], [2,0,0,1], [2,1,0,1], [1,0,1,2]]
375375
# which are not given by the algorithm below.
376376
if p == 2:
377-
list_append4(L, 2,0,0,1)
378-
list_append4(L, 2,1,0,1)
379-
list_append4(L, 1,0,1,2)
377+
list_append4(L, 2, 0, 0, 1)
378+
list_append4(L, 2, 1, 0, 1)
379+
list_append4(L, 1, 0, 1, 2)
380380
self.length = 4
381381
return
382382

@@ -489,20 +489,20 @@ cdef class HeilbronnMerel(Heilbronn):
489489

490490
sig_on()
491491
for a in range(1, n+1):
492-
## We have ad-bc=n so c=0 and ad=n, or b=(ad-n)/c
493-
## Must have ad - n >= 0, so d must be >= Ceiling(n/a).
492+
# We have ad-bc=n so c=0 and ad=n, or b=(ad-n)/c
493+
# Must have ad - n >= 0, so d must be >= Ceiling(n/a).
494494
q = n // a
495495
if q*a == n:
496496
d = q
497497
for b in range(a):
498-
list_append4(L, a,b,0,d)
498+
list_append4(L, a, b, 0, d)
499499
for c in range(1, d):
500-
list_append4(L, a,0,c,d)
500+
list_append4(L, a, 0, c, d)
501501
for d in range(q+1, n+1):
502502
bc = (<llong>a) * (<llong>d) - (<llong>n)
503-
## Divisor c of bc must satisfy Floor(bc/c) lt a and c lt d.
504-
## c ge (bc div a + 1) <=> Floor(bc/c) lt a (for integers)
505-
## c le d - 1 <=> c lt d
503+
# Divisor c of bc must satisfy Floor(bc/c) lt a and c lt d.
504+
# c ge (bc div a + 1) <=> Floor(bc/c) lt a (for integers)
505+
# c le d - 1 <=> c lt d
506506
for c in range(bc // a + 1, d):
507507
if bc % c == 0:
508508
list_append4(L, a, bc // c, c, d)
@@ -569,7 +569,7 @@ def hecke_images_gamma0_weight2(int u, int v, int N, indices, R):
569569
cdef Heilbronn H
570570

571571
t = verbose("computing non-reduced images of symbol under Hecke operators",
572-
level=1, caller_name='hecke_images_gamma0_weight2')
572+
level=1, caller_name='hecke_images_gamma0_weight2')
573573
for i, n in enumerate(indices):
574574
# List the Heilbronn matrices of determinant n defined by Cremona or Merel
575575
H = HeilbronnCremona(n) if is_prime(n) else HeilbronnMerel(n)
@@ -601,25 +601,25 @@ def hecke_images_gamma0_weight2(int u, int v, int N, indices, R):
601601
sig_free(b)
602602

603603
t = verbose("finished computing non-reduced images",
604-
t, level=1, caller_name='hecke_images_gamma0_weight2')
604+
t, level=1, caller_name='hecke_images_gamma0_weight2')
605605

606606
t = verbose("Now reducing images of symbol",
607-
level=1, caller_name='hecke_images_gamma0_weight2')
607+
level=1, caller_name='hecke_images_gamma0_weight2')
608608

609609
# Return the product T * R, whose rows are the image of (u,v) under
610610
# the Hecke operators T_n for n in indices.
611611
if max(indices) <= 30: # In this case T tends to be very sparse
612612
ans = T.sparse_matrix()._matrix_times_matrix_dense(R)
613613
verbose("did reduction using sparse multiplication",
614-
t, level=1, caller_name='hecke_images_gamma0_weight2')
614+
t, level=1, caller_name='hecke_images_gamma0_weight2')
615615
elif R.is_sparse():
616616
ans = T * R.dense_matrix()
617617
verbose("did reduction using dense multiplication",
618-
t, level=1, caller_name='hecke_images_gamma0_weight2')
618+
t, level=1, caller_name='hecke_images_gamma0_weight2')
619619
else:
620620
ans = T * R
621621
verbose("did reduction using dense multiplication",
622-
t, level=1, caller_name='hecke_images_gamma0_weight2')
622+
t, level=1, caller_name='hecke_images_gamma0_weight2')
623623

624624
if original_base_ring != QQ:
625625
ans = ans.change_ring(original_base_ring)
@@ -700,7 +700,7 @@ def hecke_images_nonquad_character_weight2(int u, int v, int N, indices, chi, R)
700700
cdef Heilbronn H
701701

702702
t = verbose("computing non-reduced images of symbol under Hecke operators",
703-
level=1, caller_name='hecke_images_character_weight2')
703+
level=1, caller_name='hecke_images_character_weight2')
704704

705705
# Make a matrix over the rational numbers each of whose columns
706706
# are the values of the character chi.

src/sage/modular/modsym/manin_symbol.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ cdef class ManinSymbol(Element):
401401
N=int(N)
402402
if N < 1:
403403
raise ArithmeticError("N must be positive")
404-
a,b,c,d = self.lift_to_sl2z()
404+
a, b, c, d = self.lift_to_sl2z()
405405
return Cusp(b, d), Cusp(a, c)
406406

407407
def weight(self):
@@ -453,8 +453,7 @@ cdef class ManinSymbol(Element):
453453
# TODO: It would likely be much better to do this slightly more directly
454454
from sage.modular.modsym.modular_symbols import ModularSymbol
455455
x = ModularSymbol(self.parent(), self.i, 0, Infinity)
456-
a,b,c,d = self.lift_to_sl2z()
457-
return x.apply([a,b,c,d])
456+
return x.apply(self.lift_to_sl2z())
458457

459458

460459
def _print_polypart(i, j):

src/sage/modular/modsym/p1list.pxd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ cdef class export:
66
int compute_s) except -1
77

88
cdef int c_p1_normalize_llong(self, int N, int u, int v,
9-
int* uu, int* vv, int* ss,
10-
int compute_s) except -1
9+
int* uu, int* vv, int* ss,
10+
int compute_s) except -1
1111

1212

1313
cdef class P1List:
@@ -22,7 +22,7 @@ cdef class P1List:
2222
# for normalizing an element does not need to be used
2323
# every time the user calls the normalize function.
2424
cdef int (*_normalize)(int N, int u, int v,
25-
int* uu, int* vv, int* ss,
26-
int compute_s) except -1
25+
int* uu, int* vv, int* ss,
26+
int compute_s) except -1
2727
cpdef index(self, int u, int v)
2828
cdef index_and_scalar(self, int u, int v, int* i, int* s)

0 commit comments

Comments
 (0)