Skip to content

Commit 8d8c044

Browse files
author
Release Manager
committed
Trac #33691: some care for pep8 in pyx in modular
found using {{{ pycodestyle --select E111,E401,E701,E702,E703,W605,E711,E712,E713,E721,E722 --filename=*.pyx src/sage/modular/ }}} URL: https://trac.sagemath.org/33691 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): David Coudert
2 parents fbf034f + 2c956e2 commit 8d8c044

File tree

6 files changed

+103
-63
lines changed

6 files changed

+103
-63
lines changed

src/sage/modular/arithgroup/arithgroup_element.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement):
194194
return richcmp(self.__x, right.__x, op)
195195

196196
def __bool__(self):
197-
"""
197+
r"""
198198
Return ``True``, since the ``self`` lives in SL(2,\Z), which does not
199199
contain the zero matrix.
200200

src/sage/modular/arithgroup/congroup.pyx

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
"""
1+
r"""
22
Cython helper functions for congruence subgroups
33
44
This file contains optimized Cython implementations of a few functions related
55
to the standard congruence subgroups `\Gamma_0, \Gamma_1, \Gamma_H`. These
66
functions are for internal use by routines elsewhere in the Sage library.
77
"""
88

9-
#*****************************************************************************
9+
# ****************************************************************************
1010
# This program is free software: you can redistribute it and/or modify
1111
# it under the terms of the GNU General Public License as published by
1212
# the Free Software Foundation, either version 2 of the License, or
1313
# (at your option) any later version.
14-
# http://www.gnu.org/licenses/
15-
#*****************************************************************************
14+
# https://www.gnu.org/licenses/
15+
# ****************************************************************************
1616

1717
from cysignals.memory cimport check_allocarray, sig_free
1818

@@ -28,7 +28,7 @@ from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense
2828
from sage.modular.modsym.p1list import lift_to_sl2z
2929
from sage.matrix.matrix_space import MatrixSpace
3030
from sage.rings.integer_ring import ZZ
31-
Mat2Z = MatrixSpace(ZZ,2)
31+
Mat2Z = MatrixSpace(ZZ, 2)
3232

3333
cdef Matrix_integer_dense genS, genT, genI
3434
genS = Matrix_integer_dense(Mat2Z, [0,-1, 1, 0], True, True)
@@ -124,9 +124,11 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t):
124124
cc = M*random.randrange(-halfmax, halfmax+1)
125125
dd = random.randrange(-halfmax, halfmax+1)
126126
g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa)
127-
if g == 0: continue
127+
if g == 0:
128+
continue
128129
cc = cc / g
129-
if cc % M != 0: continue
130+
if cc % M != 0:
131+
continue
130132
dd = dd / g
131133
# Test if we've found a new coset representative.
132134
is_new = 1
@@ -212,7 +214,6 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
212214
cdef int d, g, i, j, k, n, aa, bb, cc, dd, Ndivt, halfmax, is_new
213215
cdef int* R
214216

215-
216217
# total number of coset representatives that we'll find
217218
n = Gamma1(N).index() / Gamma1(M).index()
218219
d = arith_int.c_gcd_int(t, N/t)
@@ -226,11 +227,14 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
226227
cc = M*random.randrange(-halfmax, halfmax+1)
227228
dd = 1 + M*random.randrange(-halfmax, halfmax+1)
228229
g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa)
229-
if g == 0: continue
230+
if g == 0:
231+
continue
230232
cc = cc / g
231-
if cc % M != 0: continue
233+
if cc % M != 0:
234+
continue
232235
dd = dd / g
233-
if M != 1 and dd % M != 1: continue
236+
if M != 1 and dd % M != 1:
237+
continue
234238
# Test if we've found a new coset representative.
235239
is_new = 1
236240
for i from 0 <= i < k:

src/sage/modular/arithgroup/farey_symbol.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ cdef class Farey:
610610
if forced_format == 'plain':
611611
# output not using xymatrix
612612
s = r'\left( -\infty'
613-
a = [x._latex_() for x in self.fractions()] + ['\infty']
613+
a = [x._latex_() for x in self.fractions()] + [r'\infty']
614614
b = self.pairings()
615615
for i in xrange(len(a)):
616616
u = b[i]
@@ -623,7 +623,7 @@ cdef class Farey:
623623
else:
624624
# output using xymatrix
625625
s = r'\begin{xy}\xymatrix{& -\infty '
626-
f = [x._latex_() for x in self.fractions()]+[r'\infty']
626+
f = [x._latex_() for x in self.fractions()] + [r'\infty']
627627
f.reverse()
628628
for p in self.pairings():
629629
if p >= 0:

src/sage/modular/modsym/heilbronn.pyx

+24-11
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ cdef class Heilbronn:
211211
sig_off()
212212

213213
cdef apply_to_polypart(self, fmpz_poly_t* ans, int i, int k):
214-
"""
214+
r"""
215215
INPUT:
216216
217217
- ``ans`` - fmpz_poly_t\*; pre-allocated an
@@ -402,7 +402,11 @@ cdef class HeilbronnCremona(Heilbronn):
402402
a = -b
403403
b = c
404404
x3 = q*x2 - x1
405-
x1 = x2; x2 = x3; y3 = q*y2 - y1; y1 = y2; y2 = y3
405+
x1 = x2
406+
x2 = x3
407+
y3 = q*y2 - y1
408+
y1 = y2
409+
y2 = y3
406410
list_append4(L, x1,x2, y1,y2)
407411
self.length = L.i/4
408412
sig_off()
@@ -573,9 +577,11 @@ def hecke_images_gamma0_weight2(int u, int v, int N, indices, R):
573577

574578
# Allocate memory to hold images of (u,v) under all Heilbronn matrices
575579
a = <int*> sig_malloc(sizeof(int)*H.length)
576-
if not a: raise MemoryError
580+
if not a:
581+
raise MemoryError
577582
b = <int*> sig_malloc(sizeof(int)*H.length)
578-
if not b: raise MemoryError
583+
if not b:
584+
raise MemoryError
579585

580586
# Compute images of (u,v) under all Heilbronn matrices
581587
H.apply_only(u, v, N, a, b)
@@ -708,9 +714,11 @@ def hecke_images_nonquad_character_weight2(int u, int v, int N, indices, chi, R)
708714

709715
# Allocate memory to hold images of (u,v) under all Heilbronn matrices
710716
a = <int*> sig_malloc(sizeof(int)*H.length)
711-
if not a: raise MemoryError
717+
if not a:
718+
raise MemoryError
712719
b = <int*> sig_malloc(sizeof(int)*H.length)
713-
if not b: raise MemoryError
720+
if not b:
721+
raise MemoryError
714722

715723
# Compute images of (u,v) under all Heilbronn matrices
716724
H.apply_only(u, v, N, a, b)
@@ -798,16 +806,19 @@ def hecke_images_quad_character_weight2(int u, int v, int N, indices, chi, R):
798806
# are the values of the character chi.
799807
_chivals = chi.values()
800808
cdef int *chi_vals = <int*>sig_malloc(sizeof(int)*len(_chivals))
801-
if not chi_vals: raise MemoryError
809+
if not chi_vals:
810+
raise MemoryError
802811
for i in range(len(_chivals)):
803812
chi_vals[i] = _chivals[i]
804813

805814
for i, n in enumerate(indices):
806815
H = HeilbronnCremona(n) if is_prime(n) else HeilbronnMerel(n)
807816
a = <int*> sig_malloc(sizeof(int)*H.length)
808-
if not a: raise MemoryError
817+
if not a:
818+
raise MemoryError
809819
b = <int*> sig_malloc(sizeof(int)*H.length)
810-
if not b: raise MemoryError
820+
if not b:
821+
raise MemoryError
811822

812823
H.apply_only(u, v, N, a, b)
813824
for j in range(H.length):
@@ -893,9 +904,11 @@ def hecke_images_gamma0_weight_k(int u, int v, int i, int N, int k, indices, R):
893904

894905
# Allocate memory to hold images of (u,v) under all Heilbronn matrices
895906
a = <int*> sig_malloc(sizeof(int)*H.length)
896-
if not a: raise MemoryError
907+
if not a:
908+
raise MemoryError
897909
b = <int*> sig_malloc(sizeof(int)*H.length)
898-
if not b: raise MemoryError
910+
if not b:
911+
raise MemoryError
899912

900913
# Compute images of (u,v) under all Heilbronn matrices
901914
H.apply_only(u, v, N, a, b)

src/sage/modular/modsym/manin_symbol.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""
2+
r"""
33
Manin symbols
44
55
This module defines the class ManinSymbol. A Manin symbol of
@@ -19,9 +19,7 @@ monomial Manin symbols to monomial Manin symbols, up to a scalar
1919
factor. For general matrices (such as `T=[0,1,-1,-1]` and
2020
`T^2=[-1,-1;0,1]`) the image of a monomial Manin symbol is expressed
2121
as a formal sum of monomial Manin symbols, with integer coefficients.
22-
2322
"""
24-
2523
from sage.modular.cusps import Cusp
2624
from sage.rings.all import Infinity, ZZ
2725
from sage.rings.integer cimport Integer

0 commit comments

Comments
 (0)