From aaf1de3effe27200c2bbae439bdcdea4cb945a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 15 Apr 2023 09:00:25 +0200 Subject: [PATCH 1/2] some cython-linting in modular/ folder --- .../modular/arithgroup/arithgroup_element.pyx | 12 ++-- src/sage/modular/arithgroup/congroup.pyx | 41 ++++++------ src/sage/modular/arithgroup/farey_symbol.pyx | 30 ++++----- src/sage/modular/hypergeometric_misc.pxd | 1 - src/sage/modular/hypergeometric_misc.pyx | 7 +- .../modular/modform/eis_series_cython.pyx | 4 +- .../modform/l_series_gross_zagier_coeffs.pyx | 1 - src/sage/modular/modsym/apply.pyx | 3 +- src/sage/modular/modsym/heilbronn.pyx | 34 +++++----- src/sage/modular/modsym/manin_symbol.pyx | 5 +- src/sage/modular/modsym/p1list.pxd | 3 +- src/sage/modular/modsym/p1list.pyx | 65 ++++++++++--------- src/sage/modular/pollack_stevens/dist.pxd | 1 - src/sage/modular/pollack_stevens/dist.pyx | 19 ++---- 14 files changed, 103 insertions(+), 123 deletions(-) diff --git a/src/sage/modular/arithgroup/arithgroup_element.pyx b/src/sage/modular/arithgroup/arithgroup_element.pyx index 579cbc654cc..6851ef1c5f4 100644 --- a/src/sage/modular/arithgroup/arithgroup_element.pyx +++ b/src/sage/modular/arithgroup/arithgroup_element.pyx @@ -1,10 +1,9 @@ """ Elements of arithmetic subgroups """ - -################################################################################ +# ############################################################################## # -# Copyright (C) 2009, The Sage Group -- http://www.sagemath.org/ +# Copyright (C) 2009, The Sage Group -- https://www.sagemath.org/ # # Distributed under the terms of the GNU General Public License (GPL) # @@ -12,12 +11,11 @@ Elements of arithmetic subgroups # # https://www.gnu.org/licenses/ # -################################################################################ +# ############################################################################## -from sage.structure.element cimport MultiplicativeGroupElement, MonoidElement, Element +from sage.structure.element cimport MultiplicativeGroupElement from sage.structure.richcmp cimport richcmp from sage.rings.integer_ring import ZZ -from sage.modular.cusps import Cusp from sage.matrix.matrix_space import MatrixSpace from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense @@ -109,7 +107,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement): sage: unpickle_build(si, (Gamma0(13), {'_ArithmeticSubgroupElement__x': x})) """ from .congroup_sl2z import SL2Z - oldparent, kwdict = state + _, kwdict = state self._parent = SL2Z if '_ArithmeticSubgroupElement__x' in kwdict: self.__x = M2Z(kwdict['_ArithmeticSubgroupElement__x']) diff --git a/src/sage/modular/arithgroup/congroup.pyx b/src/sage/modular/arithgroup/congroup.pyx index 86109c9b1eb..a14e7eac0a1 100644 --- a/src/sage/modular/arithgroup/congroup.pyx +++ b/src/sage/modular/arithgroup/congroup.pyx @@ -105,10 +105,10 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t): 14 """ if N % M != 0: - raise ArithmeticError("M (=%s) must be a divisor of N (=%s)" % (M,N)) + raise ArithmeticError(f"M (={M}) must be a divisor of N (={N})") - if (N/M) % t != 0: - raise ArithmeticError("t (=%s) must be a divisor of N/M (=%s)"%(t,N/M)) + if (N // M) % t != 0: + raise ArithmeticError(f"t (={t}) must be a divisor of N/M (={N//M})") cdef int n, i, j, k, aa, bb, cc, dd, g, Ndivt, halfmax, is_new cdef int* R @@ -122,7 +122,7 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t): while k < n: # try to find another coset representative. cc = M*random.randrange(-halfmax, halfmax+1) - dd = random.randrange(-halfmax, halfmax+1) + dd = random.randrange(-halfmax, halfmax+1) g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa) if g == 0: continue @@ -134,8 +134,8 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t): is_new = 1 for i from 0 <= i < k: j = 4*i - if (R[j+1]*aa - R[j]*bb)%t == 0 and \ - (R[j+3]*cc - R[j+2]*dd)%Ndivt == 0: + if (R[j+1]*aa - R[j]*bb) % t == 0 and \ + (R[j+3]*cc - R[j+2]*dd) % Ndivt == 0: is_new = 0 break # If our matrix is new add it to the list. @@ -148,12 +148,13 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t): # Return the list left multiplied by T. S = [] - for i from 0 <= i < k: + for i in range(k): j = 4*i S.append([R[j], R[j+1], R[j+2]*t, R[j+3]*t]) sig_free(R) return S + def degeneracy_coset_representatives_gamma1(int N, int M, int t): r""" Let `N` be a positive integer and `M` a divisor of `N`. Let `t` be a @@ -204,29 +205,28 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t): sage: len(degeneracy_coset_representatives_gamma1(13, 1, 13)) 168 """ - if N % M != 0: - raise ArithmeticError("M (=%s) must be a divisor of N (=%s)" % (M,N)) + raise ArithmeticError(f"M (={M}) must be a divisor of N (={N})") - if (N/M) % t != 0: - raise ArithmeticError("t (=%s) must be a divisor of N/M (=%s)"%(t,N/M)) + if (N // M) % t != 0: + raise ArithmeticError("t (={t}) must be a divisor of N/M (={N//M})") cdef int d, g, i, j, k, n, aa, bb, cc, dd, Ndivt, halfmax, is_new cdef int* R # total number of coset representatives that we'll find n = Gamma1(N).index() / Gamma1(M).index() - d = arith_int.c_gcd_int(t, N/t) + d = arith_int.c_gcd_int(t, N // t) n = n / d k = 0 # number found so far - Ndivt = N / t + Ndivt = N // t R = check_allocarray(4 * n, sizeof(int)) halfmax = 2*(n+10) while k < n: # try to find another coset representative. - cc = M*random.randrange(-halfmax, halfmax+1) - dd = 1 + M*random.randrange(-halfmax, halfmax+1) - g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa) + cc = M * random.randrange(-halfmax, halfmax + 1) + dd = 1 + M * random.randrange(-halfmax, halfmax + 1) + g = arith_int.c_xgcd_int(-cc, dd, &bb, &aa) if g == 0: continue cc = cc / g @@ -239,10 +239,10 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t): is_new = 1 for i from 0 <= i < k: j = 4*i - if (R[j] - aa)%t == 0 and \ - (R[j+1] - bb)%t == 0 and \ - (R[j+2] - cc)%(Ndivt) == 0 and \ - (R[j+3] - dd)%(Ndivt) == 0: + if (R[j] - aa) % t == 0 and \ + (R[j+1] - bb) % t == 0 and \ + (R[j+2] - cc) % Ndivt == 0 and \ + (R[j+3] - dd) % Ndivt == 0: is_new = 0 break # If our matrix is new add it to the list. @@ -264,6 +264,7 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t): sig_free(R) return S + def generators_helper(coset_reps, level): r""" Helper function for generators of Gamma0, Gamma1 and GammaH. diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index 07d5c839dad..34b4ebae3f4 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -39,8 +39,6 @@ from .congroup_sl2z import SL2Z from sage.modular.cusps import Cusp from sage.misc.decorators import options, rename_keyword -from sage.misc.latex import latex -from sage.misc.lazy_attribute import lazy_attribute from sage.misc.cachefunc import cached_method from sage.structure.richcmp cimport richcmp_not_equal @@ -338,12 +336,12 @@ cdef class Farey: for i,g in enumerate(self.generators()): m = g.matrix() if (-m).is_one(): - return [i+1] + return [i + 1] t = m.trace() - if t == 0: # order = 4 - return 2 * [i+1] - elif t == 1: # order = 6 - return 3 * [i+1] + if t == 0: # order = 4 + return 2 * [i + 1] + elif t == 1: # order = 6 + return 3 * [i + 1] return [] def word_problem(self, M, output = 'standard', check = True): @@ -443,13 +441,12 @@ cdef class Farey: raise ValueError('Unrecognized output format') if check: if M not in self.group: - raise ValueError("Matrix ( %s ) is not in group ( %s )"%(M,self.group)) + raise ValueError("Matrix ( %s ) is not in group ( %s )" % (M, self.group)) cdef Integer a = M.d() cdef Integer b = -M.b() cdef Integer c = -M.c() cdef Integer d = M.a() - cdef cpp_SL2Z *cpp_beta = new cpp_SL2Z(1,0,0,1) - E = SL2Z([-1,0,0,-1]) + cdef cpp_SL2Z *cpp_beta = new cpp_SL2Z(1, 0, 0, 1) sig_on() result = self.this_ptr.word_problem(a.value, b.value, c.value, d.value, cpp_beta) sig_off() @@ -505,13 +502,13 @@ cdef class Farey: for i in range(len(tietze)): t = tietze[i] tmp = tmp * gens[t-1] if t > 0 else tmp * gens[-t-1]**-1 - assert tmp.matrix() == M.matrix(),'%s %s %s'%(tietze, tmp.matrix(),M.matrix()) + assert tmp.matrix() == M.matrix(),'%s %s %s' % (tietze, tmp.matrix(),M.matrix()) if output == 'standard': return tuple(tietze) if output == 'syllables': return tuple((a-1,len(list(g))) if a > 0 else (-a-1,-len(list(g))) for a,g in groupby(tietze)) - else: # output == 'gens' - return tuple((gens[a-1],len(list(g))) if a > 0 else (gens[-a-1],-len(list(g))) for a,g in groupby(tietze)) + else: # output == 'gens' + return tuple((gens[a-1],len(list(g))) if a > 0 else (gens[-a-1],-len(list(g))) for a, g in groupby(tietze)) def __contains__(self, M): r""" @@ -957,17 +954,16 @@ cdef class Farey: sage: FareySymbol(Gamma0(23)).fundamental_domain(tesselation='coset', linestyle=':', thickness='2') Graphics object consisting of 58 graphics primitives - """ from sage.plot.all import Graphics - from sage.plot.colors import rainbow, to_mpl_color - from sage.plot.all import hyperbolic_arc, hyperbolic_triangle, text + from sage.plot.colors import rainbow + from sage.plot.all import hyperbolic_arc, hyperbolic_triangle I = CC(0, 1) w = RR(3).sqrt() L = 1000 g = Graphics() - ## show coset + # show coset for x in self.coset_reps(): a, b, c, d = x[1, 1], -x[0, 1], -x[1, 0], x[0, 0] A, B = CC(0, L), CC(0, L) diff --git a/src/sage/modular/hypergeometric_misc.pxd b/src/sage/modular/hypergeometric_misc.pxd index d031601666f..00bf9a97e9a 100644 --- a/src/sage/modular/hypergeometric_misc.pxd +++ b/src/sage/modular/hypergeometric_misc.pxd @@ -1,3 +1,2 @@ cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D, gtable, int gtable_prec, bint use_longs) - diff --git a/src/sage/modular/hypergeometric_misc.pyx b/src/sage/modular/hypergeometric_misc.pyx index 4b68e85e618..af2c4f74e15 100644 --- a/src/sage/modular/hypergeometric_misc.pyx +++ b/src/sage/modular/hypergeometric_misc.pyx @@ -31,14 +31,13 @@ cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D, sage: H = Hyp(cyclotomic=[[10,2],[1,1,1,1,1]]) sage: u = H.euler_factor(2,79) # indirect doctest sage: u.reverse().is_weil_polynomial() - True - + True """ from sage.rings.padics.factory import Zp cdef int gl, j, k, l, v, gv cdef long long i, q1, w, w1, w2, q2, r, r1 - cdef bint flip, need_lift + cdef bint flip q1 = p ** f - 1 gl = len(gamma) @@ -118,7 +117,7 @@ cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D, gv = -gv if use_longs: w2 = gtab2[r1] # cast to long long to avoid overflow - if gv > 0: + if gv > 0: for j in range(gv): w = w * w2 % q2 else: diff --git a/src/sage/modular/modform/eis_series_cython.pyx b/src/sage/modular/modform/eis_series_cython.pyx index c22f2296eed..dfcc8a123ff 100644 --- a/src/sage/modular/modform/eis_series_cython.pyx +++ b/src/sage/modular/modform/eis_series_cython.pyx @@ -6,8 +6,6 @@ from cysignals.memory cimport check_allocarray, sig_free from cysignals.signals cimport sig_check from sage.arith.misc import primes, bernoulli -from sage.rings.rational_field import QQ -from sage.rings.power_series_ring import PowerSeriesRing from sage.rings.integer cimport Integer from sage.rings.fast_arith cimport prime_range @@ -165,7 +163,7 @@ cpdef eisenstein_series_poly(int k, int prec = 10) : cdef int i cdef Fmpz_poly res = Fmpz_poly.__new__(Fmpz_poly) - if k%2 or k < 2: + if k % 2 or k < 2: raise ValueError("k (=%s) must be an even positive integer" % k) if prec < 0: raise ValueError("prec (=%s) must be an even nonnegative integer" % prec) diff --git a/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx b/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx index 3246146c9a0..87caa9ff8ab 100644 --- a/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx +++ b/src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx @@ -74,7 +74,6 @@ def bqf_theta_series(Q, long bound, var=None): cdef long* bqf_theta_series_c(long* terms, long bound, long a, long b, long c) except NULL: - cdef long i cdef long x, y, yD cdef long xmax, ymin, ymax cdef double sqrt_yD diff --git a/src/sage/modular/modsym/apply.pyx b/src/sage/modular/modsym/apply.pyx index ff22f208c00..4d1b093ee61 100644 --- a/src/sage/modular/modsym/apply.pyx +++ b/src/sage/modular/modsym/apply.pyx @@ -43,7 +43,7 @@ cdef class Apply: cdef int apply_to_monomial_flint(self, fmpz_poly_t ans, int i, int j, int a, int b, int c, int d) except -1: if i < 0 or j - i < 0: - raise ValueError("i (=%s) and j-i (=%s) must both be nonnegative."%(i,j-i)) + raise ValueError("i (=%s) and j-i (=%s) must both be nonnegative." % (i, j - i)) # f = b+a*x, g = d+c*x fmpz_poly_set_coeff_si(self.f, 0, b) @@ -61,6 +61,7 @@ cdef class Apply: cdef Apply A = Apply() + def apply_to_monomial(int i, int j, int a, int b, int c, int d): r""" Return a list of the coefficients of diff --git a/src/sage/modular/modsym/heilbronn.pyx b/src/sage/modular/modsym/heilbronn.pyx index 81833bbe3b2..e6e63f1bbcb 100644 --- a/src/sage/modular/modsym/heilbronn.pyx +++ b/src/sage/modular/modsym/heilbronn.pyx @@ -41,7 +41,6 @@ export = p1list.export() from .apply cimport Apply cdef Apply PolyApply= Apply() -from sage.rings.integer cimport Integer from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense from sage.matrix.matrix_cyclo_dense cimport Matrix_cyclo_dense @@ -49,7 +48,7 @@ ctypedef long long llong cdef int llong_prod_mod(int a, int b, int N): cdef int c - c = ( (( a) * ( b)) % ( N) ) + c = ((( a) * ( b)) % ( N)) if c < 0: c = c + N return c @@ -198,12 +197,12 @@ cdef class Heilbronn: a[i] = b[i] = 0 if N < 32768: # use ints with no reduction modulo N for i in range(self.length): - a[i] = u*self.list.v[4*i] + v*self.list.v[4*i+2] - b[i] = u*self.list.v[4*i+1] + v*self.list.v[4*i+3] + a[i] = u * self.list.v[4*i] + v * self.list.v[4*i+2] + b[i] = u * self.list.v[4*i+1] + v * self.list.v[4*i+3] elif N < 46340: # use ints but reduce mod N so can add two for i in range(self.length): - a[i] = (u * self.list.v[4*i])%N + (v * self.list.v[4*i+2])%N - b[i] = (u * self.list.v[4*i+1])%N + (v * self.list.v[4*i+3])%N + a[i] = (u * self.list.v[4*i]) % N + (v * self.list.v[4*i+2]) % N + b[i] = (u * self.list.v[4*i+1]) % N + (v * self.list.v[4*i+3]) % N else: for i in range(self.length): a[i] = llong_prod_mod(u,self.list.v[4*i],N) + llong_prod_mod(v,self.list.v[4*i+2], N) @@ -221,11 +220,13 @@ cdef class Heilbronn: OUTPUT: sets entries of ans """ - cdef int j, m = k-2 + cdef int j, m = k - 2 for j in range(self.length): PolyApply.apply_to_monomial_flint(ans[j], i, m, - self.list.v[4*j], self.list.v[4*j+1], - self.list.v[4*j+2], self.list.v[4*j+3]) + self.list.v[4 * j], + self.list.v[4 * j + 1], + self.list.v[4 * j + 2], + self.list.v[4 * j + 3]) def apply(self, int u, int v, int N): """ @@ -332,7 +333,7 @@ cdef class HeilbronnCremona(Heilbronn): sage: HeilbronnCremona(691).__repr__() 'The Cremona-Heilbronn matrices of determinant 691' """ - return "The Cremona-Heilbronn matrices of determinant %s"%self.p + return f"The Cremona-Heilbronn matrices of determinant {self.p}" def _initialize_list(self): """ @@ -363,7 +364,7 @@ cdef class HeilbronnCremona(Heilbronn): [-2, 1, 1, -3], [1, 0, -3, 5]] """ - cdef int r, x1, x2, y1, y2, a, b, c, x3, y3, q, n, p + cdef int r, x1, x2, y1, y2, a, b, c, x3, y3, q, p cdef list *L list_init(&self.list) L = &self.list @@ -799,8 +800,8 @@ def hecke_images_quad_character_weight2(int u, int v, int N, indices, chi, R): cdef int k, scalar cdef Heilbronn H - t = verbose("computing non-reduced images of symbol under Hecke operators", - level=1, caller_name='hecke_images_quad_character_weight2') + _ = verbose("computing non-reduced images of symbol under Hecke operators", + level=1, caller_name='hecke_images_quad_character_weight2') # Make a matrix over the rational numbers each of whose columns # are the values of the character chi. @@ -839,13 +840,11 @@ def hecke_images_quad_character_weight2(int u, int v, int N, indices, chi, R): return T * R - - -############################################################################ +# ########################################################################## # Fast application of Heilbronn operators to computation of # systems of Hecke eigenvalues. # Trivial character and weight > 2. -############################################################################ +# ########################################################################## def hecke_images_gamma0_weight_k(int u, int v, int i, int N, int k, indices, R): """ @@ -897,7 +896,6 @@ def hecke_images_gamma0_weight_k(int u, int v, int i, int N, int k, indices, R): cdef Heilbronn H cdef fmpz_poly_t* poly - cdef Integer coeff = Integer() for z, m in enumerate(indices): H = HeilbronnCremona(m) if is_prime(m) else HeilbronnMerel(m) diff --git a/src/sage/modular/modsym/manin_symbol.pyx b/src/sage/modular/modsym/manin_symbol.pyx index 5d6df57c47d..c02c1f26dbf 100644 --- a/src/sage/modular/modsym/manin_symbol.pyx +++ b/src/sage/modular/modsym/manin_symbol.pyx @@ -181,9 +181,8 @@ cdef class ManinSymbol(Element): """ if self.weight() > 2: polypart = _print_polypart(self.i, self.weight()-2-self.i) - return "[%s,(%s,%s)]"%\ - (polypart, self.u, self.v) - return "(%s,%s)"%(self.u, self.v) + return "[%s,(%s,%s)]" % (polypart, self.u, self.v) + return "(%s,%s)" % (self.u, self.v) def _latex_(self): """ diff --git a/src/sage/modular/modsym/p1list.pxd b/src/sage/modular/modsym/p1list.pxd index 1a78ab5923c..cc24a33139b 100644 --- a/src/sage/modular/modsym/p1list.pxd +++ b/src/sage/modular/modsym/p1list.pxd @@ -21,9 +21,8 @@ cdef class P1List: # Here we use a pointer to a function, so the if logic # for normalizing an element does not need to be used # every time the user calls the normalize function. - cdef int (*__normalize)(int N, int u, int v,\ + cdef int (*__normalize)(int N, int u, int v, int* uu, int* vv, int* ss, int compute_s) except -1 cpdef index(self, int u, int v) cdef index_and_scalar(self, int u, int v, int* i, int* s) - diff --git a/src/sage/modular/modsym/p1list.pyx b/src/sage/modular/modsym/p1list.pyx index 68c6df4dadd..78f1c6d647c 100644 --- a/src/sage/modular/modsym/p1list.pyx +++ b/src/sage/modular/modsym/p1list.pyx @@ -15,7 +15,7 @@ cimport sage.rings.fast_arith import sage.rings.fast_arith cdef sage.rings.fast_arith.arith_int arith_int cdef sage.rings.fast_arith.arith_llong arith_llong -arith_int = sage.rings.fast_arith.arith_int() +arith_int = sage.rings.fast_arith.arith_int() arith_llong = sage.rings.fast_arith.arith_llong() ctypedef long long llong @@ -166,8 +166,9 @@ def p1_normalize_int(N, u, v): 78 """ cdef int uu, vv, ss - c_p1_normalize_int(N, u%N, v%N, &uu, &vv, &ss, 1) - return (uu,vv,ss) + c_p1_normalize_int(N, u % N, v % N, &uu, &vv, &ss, 1) + return (uu, vv, ss) + def p1list_int(int N): r""" @@ -222,22 +223,22 @@ def p1list_int(int N): for d from 0 <= d < N: lst.append((c,d)) - cmax = N/2 - if N%2: # N odd, max divisor is <= N/3 - if N%3: # N not a multiple of 3 either, max is N/5 - cmax = N/5 + cmax = N // 2 + if N % 2: # N odd, max divisor is <= N/3 + if N % 3: # N not a multiple of 3 either, max is N/5 + cmax = N // 5 else: - cmax = N/3 + cmax = N // 3 for c from 2 <= c <= cmax: - if N%c == 0: # c is a proper divisor - h = N/c - g = arith_int.c_gcd_int(c,h) + if N % c == 0: # c is a proper divisor + h = N // c + g = arith_int.c_gcd_int(c, h) for d from 1 <= d <= h: sig_check() - if arith_int.c_gcd_int(d,g)==1: + if arith_int.c_gcd_int(d, g) == 1: d1 = d - while arith_int.c_gcd_int(d1,c)!=1: + while arith_int.c_gcd_int(d1, c) != 1: d1 += h c_p1_normalize_int(N, c, d1, &u, &v, &s, 0) lst.append((u,v)) @@ -364,7 +365,7 @@ cdef int c_p1_normalize_llong(int N, int u, int v, # Multiply [u,v] by s; then [s*u,s*v] = [g,s*v] (mod N) u = g # v = (s*v) % N - v = ( ((s) * (v)) % ll_N ) + v = (((s) * (v)) % ll_N) min_v = v min_t = 1 @@ -430,8 +431,9 @@ def p1_normalize_llong(N, u, v): 78 """ cdef int uu, vv, ss - c_p1_normalize_llong(N, u%N, v%N, &uu, &vv, &ss, 1) - return (uu,vv,ss) + c_p1_normalize_llong(N, u % N, v % N, &uu, &vv, &ss, 1) + return (uu, vv, ss) + def p1list_llong(int N): r""" @@ -473,22 +475,22 @@ def p1list_llong(int N): for d from 0 <= d < N: lst.append((c,d)) - cmax = N/2 - if N%2: # N odd, max divisor is <= N/3 - if N%3: # N not a multiple of 3 either, max is N/5 - cmax = N/5 + cmax = N // 2 + if N % 2: # N odd, max divisor is <= N/3 + if N % 3: # N not a multiple of 3 either, max is N/5 + cmax = N // 5 else: - cmax = N/3 + cmax = N // 3 for c from 2 <= c <= cmax: - if N%c == 0: # c is a proper divisor - h = N/c - g = arith_int.c_gcd_int(c,h) + if N % c == 0: # c is a proper divisor + h = N // c + g = arith_int.c_gcd_int(c, h) for d from 1 <= d <= h: - if arith_int.c_gcd_int(d,g)==1: + if arith_int.c_gcd_int(d, g) == 1: sig_check() d1 = d - while arith_int.c_gcd_int(d1,c)!=1: + while arith_int.c_gcd_int(d1, c) != 1: d1 += h c_p1_normalize_llong(N, c, d1, &u, &v, &s, 0) lst.append((u,v)) @@ -586,6 +588,7 @@ def p1_normalize(int N, int u, int v): else: raise OverflowError + cdef int p1_normalize_xgcdtable(int N, int u, int v, int compute_s, int *t_g, int *t_a, int *t_b, @@ -623,7 +626,7 @@ cdef int p1_normalize_xgcdtable(int N, int u, int v, v += N if u == 0: uu[0] = 0 - if t_g[v] == 1: # "if arith_int.c_gcd_int(v,N) == 1" + if t_g[v] == 1: # "if arith_int.c_gcd_int(v,N) == 1" vv[0] = 1 else: vv[0] = 0 @@ -663,7 +666,7 @@ cdef int p1_normalize_xgcdtable(int N, int u, int v, for k from 2 <= k <= g: v = (v + vNg) % N t = (t + Ng) % N - if v right.ordp: shift = p ** (left.ordp - right.ordp) @@ -1473,7 +1465,6 @@ cdef class WeightKAction_vector(WeightKAction): g.set_immutable() except AttributeError: pass - coeffmodule = v._moments.parent() v_moments = v._moments ans._moments = v_moments * self.acting_matrix(g, len(v_moments)) ans.ordp = v.ordp From ea356998ddc7f3087e0559c6c4ca89fb86bbce9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 24 Apr 2023 19:50:38 +0200 Subject: [PATCH 2/2] adding one forgotten f --- src/sage/modular/arithgroup/congroup.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/modular/arithgroup/congroup.pyx b/src/sage/modular/arithgroup/congroup.pyx index a14e7eac0a1..318996805ca 100644 --- a/src/sage/modular/arithgroup/congroup.pyx +++ b/src/sage/modular/arithgroup/congroup.pyx @@ -209,7 +209,7 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t): raise ArithmeticError(f"M (={M}) must be a divisor of N (={N})") if (N // M) % t != 0: - raise ArithmeticError("t (={t}) must be a divisor of N/M (={N//M})") + raise ArithmeticError(f"t (={t}) must be a divisor of N/M (={N//M})") cdef int d, g, i, j, k, n, aa, bb, cc, dd, Ndivt, halfmax, is_new cdef int* R