Skip to content

Commit 14d7322

Browse files
author
Release Manager
committed
gh-39229: fixing pycodestyle E222 in many cython files about E222 multiple spaces after operator ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39229 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Frédéric Chapoton
2 parents 751bf5a + f04f625 commit 14d7322

38 files changed

+269
-231
lines changed

src/sage/coding/binary_code.pyx

Lines changed: 119 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ cdef inline int min(int a, int b) noexcept:
6262
else:
6363
return a
6464

65-
## NOTE - Since most of the functions are used from within the module, cdef'd
66-
## functions come without an underscore, and the def'd equivalents, which are
67-
## essentially only for doctesting and debugging, have underscores.
65+
# NOTE - Since most of the functions are used from within the module, cdef'd
66+
# functions come without an underscore, and the def'd equivalents, which are
67+
# essentially only for doctesting and debugging, have underscores.
6868

6969
cdef int *hamming_weights() noexcept:
7070
cdef int *ham_wts
@@ -1279,25 +1279,34 @@ cdef class OrbitPartition:
12791279
nwords = (1 << nrows)
12801280
self.nwords = nwords
12811281
self.ncols = ncols
1282-
self.wd_parent = <int *> sig_malloc( nwords * sizeof(int) )
1283-
self.wd_rank = <int *> sig_malloc( nwords * sizeof(int) )
1284-
self.wd_min_cell_rep = <int *> sig_malloc( nwords * sizeof(int) )
1285-
self.wd_size = <int *> sig_malloc( nwords * sizeof(int) )
1286-
self.col_parent = <int *> sig_malloc( ncols * sizeof(int) )
1287-
self.col_rank = <int *> sig_malloc( ncols * sizeof(int) )
1288-
self.col_min_cell_rep = <int *> sig_malloc( ncols * sizeof(int) )
1289-
self.col_size = <int *> sig_malloc( ncols * sizeof(int) )
1290-
if self.wd_parent is NULL or self.wd_rank is NULL or self.wd_min_cell_rep is NULL \
1291-
or self.wd_size is NULL or self.col_parent is NULL or self.col_rank is NULL \
1292-
or self.col_min_cell_rep is NULL or self.col_size is NULL:
1293-
if self.wd_parent is not NULL: sig_free(self.wd_parent)
1294-
if self.wd_rank is not NULL: sig_free(self.wd_rank)
1295-
if self.wd_min_cell_rep is not NULL: sig_free(self.wd_min_cell_rep)
1296-
if self.wd_size is not NULL: sig_free(self.wd_size)
1297-
if self.col_parent is not NULL: sig_free(self.col_parent)
1298-
if self.col_rank is not NULL: sig_free(self.col_rank)
1299-
if self.col_min_cell_rep is not NULL: sig_free(self.col_min_cell_rep)
1300-
if self.col_size is not NULL: sig_free(self.col_size)
1282+
self.wd_parent = <int *> sig_malloc(nwords * sizeof(int))
1283+
self.wd_rank = <int *> sig_malloc(nwords * sizeof(int))
1284+
self.wd_min_cell_rep = <int *> sig_malloc(nwords * sizeof(int))
1285+
self.wd_size = <int *> sig_malloc(nwords * sizeof(int))
1286+
self.col_parent = <int *> sig_malloc(ncols * sizeof(int))
1287+
self.col_rank = <int *> sig_malloc(ncols * sizeof(int))
1288+
self.col_min_cell_rep = <int *> sig_malloc(ncols * sizeof(int))
1289+
self.col_size = <int *> sig_malloc(ncols * sizeof(int))
1290+
if (self.wd_parent is NULL or self.wd_rank is NULL
1291+
or self.wd_min_cell_rep is NULL or self.wd_size is NULL
1292+
or self.col_parent is NULL or self.col_rank is NULL
1293+
or self.col_min_cell_rep is NULL or self.col_size is NULL):
1294+
if self.wd_parent is not NULL:
1295+
sig_free(self.wd_parent)
1296+
if self.wd_rank is not NULL:
1297+
sig_free(self.wd_rank)
1298+
if self.wd_min_cell_rep is not NULL:
1299+
sig_free(self.wd_min_cell_rep)
1300+
if self.wd_size is not NULL:
1301+
sig_free(self.wd_size)
1302+
if self.col_parent is not NULL:
1303+
sig_free(self.col_parent)
1304+
if self.col_rank is not NULL:
1305+
sig_free(self.col_rank)
1306+
if self.col_min_cell_rep is not NULL:
1307+
sig_free(self.col_min_cell_rep)
1308+
if self.col_size is not NULL:
1309+
sig_free(self.col_size)
13011310
raise MemoryError("Memory.")
13021311
for word from 0 <= word < nwords:
13031312
self.wd_parent[word] = word
@@ -1605,33 +1614,43 @@ cdef class PartitionStack:
16051614
self.flag = (1 << (self.radix-1))
16061615

16071616
# data
1608-
self.wd_ents = <int *> sig_malloc( self.nwords * sizeof_int )
1609-
self.wd_lvls = <int *> sig_malloc( self.nwords * sizeof_int )
1610-
self.col_ents = <int *> sig_malloc( self.ncols * sizeof_int )
1611-
self.col_lvls = <int *> sig_malloc( self.ncols * sizeof_int )
1617+
self.wd_ents = <int *> sig_malloc(self.nwords * sizeof_int)
1618+
self.wd_lvls = <int *> sig_malloc(self.nwords * sizeof_int)
1619+
self.col_ents = <int *> sig_malloc(self.ncols * sizeof_int)
1620+
self.col_lvls = <int *> sig_malloc(self.ncols * sizeof_int)
16121621

16131622
# scratch space
1614-
self.col_degs = <int *> sig_malloc( self.ncols * sizeof_int )
1623+
self.col_degs = <int *> sig_malloc( self.ncols * sizeof_int )
16151624
self.col_counts = <int *> sig_malloc( self.nwords * sizeof_int )
16161625
self.col_output = <int *> sig_malloc( self.ncols * sizeof_int )
1617-
self.wd_degs = <int *> sig_malloc( self.nwords * sizeof_int )
1618-
self.wd_counts = <int *> sig_malloc( (self.ncols+1) * sizeof_int )
1619-
self.wd_output = <int *> sig_malloc( self.nwords * sizeof_int )
1626+
self.wd_degs = <int *> sig_malloc( self.nwords * sizeof_int )
1627+
self.wd_counts = <int *> sig_malloc( (self.ncols+1) * sizeof_int )
1628+
self.wd_output = <int *> sig_malloc( self.nwords * sizeof_int )
16201629

16211630
if self.wd_ents is NULL or self.wd_lvls is NULL or self.col_ents is NULL \
16221631
or self.col_lvls is NULL or self.col_degs is NULL or self.col_counts is NULL \
16231632
or self.col_output is NULL or self.wd_degs is NULL or self.wd_counts is NULL \
16241633
or self.wd_output is NULL:
1625-
if self.wd_ents is not NULL: sig_free(self.wd_ents)
1626-
if self.wd_lvls is not NULL: sig_free(self.wd_lvls)
1627-
if self.col_ents is not NULL: sig_free(self.col_ents)
1628-
if self.col_lvls is not NULL: sig_free(self.col_lvls)
1629-
if self.col_degs is not NULL: sig_free(self.col_degs)
1630-
if self.col_counts is not NULL: sig_free(self.col_counts)
1631-
if self.col_output is not NULL: sig_free(self.col_output)
1632-
if self.wd_degs is not NULL: sig_free(self.wd_degs)
1633-
if self.wd_counts is not NULL: sig_free(self.wd_counts)
1634-
if self.wd_output is not NULL: sig_free(self.wd_output)
1634+
if self.wd_ents is not NULL:
1635+
sig_free(self.wd_ents)
1636+
if self.wd_lvls is not NULL:
1637+
sig_free(self.wd_lvls)
1638+
if self.col_ents is not NULL:
1639+
sig_free(self.col_ents)
1640+
if self.col_lvls is not NULL:
1641+
sig_free(self.col_lvls)
1642+
if self.col_degs is not NULL:
1643+
sig_free(self.col_degs)
1644+
if self.col_counts is not NULL:
1645+
sig_free(self.col_counts)
1646+
if self.col_output is not NULL:
1647+
sig_free(self.col_output)
1648+
if self.wd_degs is not NULL:
1649+
sig_free(self.wd_degs)
1650+
if self.wd_counts is not NULL:
1651+
sig_free(self.wd_counts)
1652+
if self.wd_output is not NULL:
1653+
sig_free(self.wd_output)
16351654
raise MemoryError("Memory.")
16361655

16371656
nwords = self.nwords
@@ -3073,40 +3092,54 @@ cdef class BinaryCodeClassifier:
30733092
self.alpha_size = self.w_gamma_size + self.radix
30743093
self.Phi_size = self.w_gamma_size/self.radix + 1
30753094

3076-
self.w_gamma = <int *> sig_malloc( self.w_gamma_size * sizeof(int) )
3077-
self.alpha = <int *> sig_malloc( self.alpha_size * sizeof(int) )
3078-
self.Phi = <unsigned int *> sig_malloc( self.Phi_size * (self.L+1) * sizeof(unsigned int) )
3079-
self.Omega = <unsigned int *> sig_malloc( self.Phi_size * self.L * sizeof(unsigned int) )
3080-
self.W = <unsigned int *> sig_malloc( self.Phi_size * self.radix * 2 * sizeof(unsigned int) )
3095+
self.w_gamma = <int *> sig_malloc( self.w_gamma_size * sizeof(int) )
3096+
self.alpha = <int *> sig_malloc( self.alpha_size * sizeof(int) )
3097+
self.Phi = <unsigned int *> sig_malloc( self.Phi_size * (self.L+1) * sizeof(unsigned int) )
3098+
self.Omega = <unsigned int *> sig_malloc( self.Phi_size * self.L * sizeof(unsigned int) )
3099+
self.W = <unsigned int *> sig_malloc( self.Phi_size * self.radix * 2 * sizeof(unsigned int) )
30813100

3082-
self.base = <int *> sig_malloc( self.radix * sizeof(int) )
3101+
self.base = <int *> sig_malloc( self.radix * sizeof(int) )
30833102
self.aut_gp_gens = <int *> sig_malloc( self.aut_gens_size * sizeof(int) )
3084-
self.c_gamma = <int *> sig_malloc( self.radix * sizeof(int) )
3085-
self.labeling = <int *> sig_malloc( self.radix * 3 * sizeof(int) )
3086-
self.Lambda1 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3087-
self.Lambda2 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3088-
self.Lambda3 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3089-
self.v = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3090-
self.e = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3103+
self.c_gamma = <int *> sig_malloc( self.radix * sizeof(int) )
3104+
self.labeling = <int *> sig_malloc( self.radix * 3 * sizeof(int) )
3105+
self.Lambda1 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3106+
self.Lambda2 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3107+
self.Lambda3 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3108+
self.v = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3109+
self.e = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
30913110

30923111
if self.Phi is NULL or self.Omega is NULL or self.W is NULL or self.Lambda1 is NULL \
30933112
or self.Lambda2 is NULL or self.Lambda3 is NULL or self.w_gamma is NULL \
30943113
or self.c_gamma is NULL or self.alpha is NULL or self.v is NULL or self.e is NULL \
30953114
or self.aut_gp_gens is NULL or self.labeling is NULL or self.base is NULL:
3096-
if self.Phi is not NULL: sig_free(self.Phi)
3097-
if self.Omega is not NULL: sig_free(self.Omega)
3098-
if self.W is not NULL: sig_free(self.W)
3099-
if self.Lambda1 is not NULL: sig_free(self.Lambda1)
3100-
if self.Lambda2 is not NULL: sig_free(self.Lambda2)
3101-
if self.Lambda3 is not NULL: sig_free(self.Lambda3)
3102-
if self.w_gamma is not NULL: sig_free(self.w_gamma)
3103-
if self.c_gamma is not NULL: sig_free(self.c_gamma)
3104-
if self.alpha is not NULL: sig_free(self.alpha)
3105-
if self.v is not NULL: sig_free(self.v)
3106-
if self.e is not NULL: sig_free(self.e)
3107-
if self.aut_gp_gens is not NULL: sig_free(self.aut_gp_gens)
3108-
if self.labeling is not NULL: sig_free(self.labeling)
3109-
if self.base is not NULL: sig_free(self.base)
3115+
if self.Phi is not NULL:
3116+
sig_free(self.Phi)
3117+
if self.Omega is not NULL:
3118+
sig_free(self.Omega)
3119+
if self.W is not NULL:
3120+
sig_free(self.W)
3121+
if self.Lambda1 is not NULL:
3122+
sig_free(self.Lambda1)
3123+
if self.Lambda2 is not NULL:
3124+
sig_free(self.Lambda2)
3125+
if self.Lambda3 is not NULL:
3126+
sig_free(self.Lambda3)
3127+
if self.w_gamma is not NULL:
3128+
sig_free(self.w_gamma)
3129+
if self.c_gamma is not NULL:
3130+
sig_free(self.c_gamma)
3131+
if self.alpha is not NULL:
3132+
sig_free(self.alpha)
3133+
if self.v is not NULL:
3134+
sig_free(self.v)
3135+
if self.e is not NULL:
3136+
sig_free(self.e)
3137+
if self.aut_gp_gens is not NULL:
3138+
sig_free(self.aut_gp_gens)
3139+
if self.labeling is not NULL:
3140+
sig_free(self.labeling)
3141+
if self.base is not NULL:
3142+
sig_free(self.base)
31103143
raise MemoryError("Memory.")
31113144

31123145
def __dealloc__(self):
@@ -3371,27 +3404,32 @@ cdef class BinaryCodeClassifier:
33713404
self.w_gamma_size *= 2
33723405
self.alpha_size = self.w_gamma_size + self.radix
33733406
self.Phi_size = self.w_gamma_size/self.radix + 1
3374-
self.w_gamma = <int *> sig_realloc(self.w_gamma, self.w_gamma_size * sizeof(int) )
3375-
self.alpha = <int *> sig_realloc(self.alpha, self.alpha_size * sizeof(int) )
3376-
self.Phi = <unsigned int *> sig_realloc(self.Phi, self.Phi_size * self.L * sizeof(int) )
3377-
self.Omega = <unsigned int *> sig_realloc(self.Omega, self.Phi_size * self.L * sizeof(int) )
3378-
self.W = <unsigned int *> sig_realloc(self.W, self.Phi_size * self.radix * 2 * sizeof(int) )
3407+
self.w_gamma = <int *> sig_realloc(self.w_gamma, self.w_gamma_size * sizeof(int))
3408+
self.alpha = <int *> sig_realloc(self.alpha, self.alpha_size * sizeof(int))
3409+
self.Phi = <unsigned int *> sig_realloc(self.Phi, self.Phi_size * self.L * sizeof(int))
3410+
self.Omega = <unsigned int *> sig_realloc(self.Omega, self.Phi_size * self.L * sizeof(int))
3411+
self.W = <unsigned int *> sig_realloc(self.W, self.Phi_size * self.radix * 2 * sizeof(int))
33793412
if self.w_gamma is NULL or self.alpha is NULL or self.Phi is NULL or self.Omega is NULL or self.W is NULL:
3380-
if self.w_gamma is not NULL: sig_free(self.w_gamma)
3381-
if self.alpha is not NULL: sig_free(self.alpha)
3382-
if self.Phi is not NULL: sig_free(self.Phi)
3383-
if self.Omega is not NULL: sig_free(self.Omega)
3384-
if self.W is not NULL: sig_free(self.W)
3413+
if self.w_gamma is not NULL:
3414+
sig_free(self.w_gamma)
3415+
if self.alpha is not NULL:
3416+
sig_free(self.alpha)
3417+
if self.Phi is not NULL:
3418+
sig_free(self.Phi)
3419+
if self.Omega is not NULL:
3420+
sig_free(self.Omega)
3421+
if self.W is not NULL:
3422+
sig_free(self.W)
33853423
raise MemoryError("Memory.")
33863424
for i from 0 <= i < self.Phi_size * self.L:
33873425
self.Omega[i] = 0
33883426
word_gamma = self.w_gamma
33893427
alpha = self.alpha # think of alpha as of length exactly nwords + ncols
3390-
Phi = self.Phi
3428+
Phi = self.Phi
33913429
Omega = self.Omega
3392-
W = self.W
3393-
e = self.e
3394-
nu = PartitionStack(nrows, ncols)
3430+
W = self.W
3431+
e = self.e
3432+
nu = PartitionStack(nrows, ncols)
33953433
Theta = OrbitPartition(nrows, ncols)
33963434

33973435
# trivial case

src/sage/combinat/designs/designs_pyx.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,9 @@ def is_quasi_difference_matrix(M, G, int k, int lmbda, int mu, int u, verbose=Fa
822822

823823
# Width of the matrix
824824
for R in M:
825-
if len(R)!=k:
825+
if len(R) != k:
826826
if verbose:
827-
print("The matrix has {} columns but k={}".format(len(R),k))
827+
print("The matrix has {} columns but k={}".format(len(R), k))
828828
return False
829829

830830
# When |G|=0
@@ -836,10 +836,10 @@ def is_quasi_difference_matrix(M, G, int k, int lmbda, int mu, int u, verbose=Fa
836836
cdef dict group_to_int = {v:i for i,v in enumerate(int_to_group)}
837837

838838
# Allocations
839-
cdef int ** x_minus_y = <int **> sig_malloc((n+1)*sizeof(int *))
840-
cdef int * x_minus_y_data = <int *> sig_malloc((n+1)*(n+1)*sizeof(int))
841-
cdef int * M_c = <int *> sig_malloc(k*M_nrows*sizeof(int))
842-
cdef int * G_seen = <int *> sig_malloc((n+1)*sizeof(int))
839+
cdef int ** x_minus_y = <int **> sig_malloc((n+1)*sizeof(int *))
840+
cdef int * x_minus_y_data = <int *> sig_malloc((n+1)*(n+1)*sizeof(int))
841+
cdef int * M_c = <int *> sig_malloc(k*M_nrows*sizeof(int))
842+
cdef int * G_seen = <int *> sig_malloc((n+1)*sizeof(int))
843843
if (x_minus_y == NULL or x_minus_y_data == NULL or M_c == NULL or G_seen == NULL):
844844
sig_free(x_minus_y)
845845
sig_free(x_minus_y_data)

src/sage/combinat/designs/evenly_distributed_sets.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,20 @@ cdef class EvenlyDistributedSetsBacktracker:
228228
self.m = (q - 1) // e
229229
self.K = K
230230

231-
self.diff = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
232-
self.diff[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
231+
self.diff = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
232+
self.diff[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
233233
for i in range(1, self.q):
234234
self.diff[i] = self.diff[i-1] + q
235235

236-
self.ratio = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
237-
self.ratio[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
236+
self.ratio = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
237+
self.ratio[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
238238
for i in range(1, self.q):
239239
self.ratio[i] = self.ratio[i-1] + q
240240

241-
self.B = <unsigned int *> check_malloc(k*sizeof(unsigned int))
241+
self.B = <unsigned int *> check_malloc(k*sizeof(unsigned int))
242242
self.min_orb = <unsigned int *> check_malloc(q*sizeof(unsigned int))
243-
self.cosets = <unsigned int *> check_malloc(e*sizeof(unsigned int))
244-
self.t = <unsigned int *> check_malloc(e*sizeof(unsigned int))
243+
self.cosets = <unsigned int *> check_malloc(e*sizeof(unsigned int))
244+
self.t = <unsigned int *> check_malloc(e*sizeof(unsigned int))
245245

246246
x = K.multiplicative_generator()
247247
list_K = []

src/sage/combinat/designs/subhypergraph_search.pyx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,21 @@ cdef hypergraph h_init(int n, list H) noexcept:
178178
"""
179179
cdef int x,i
180180
cdef hypergraph h
181-
h.n = n
182-
h.m = len(H)
183-
h.limbs = (n+63) // 64 # =ceil(n/64)
184-
h.names = <int *> sig_malloc(sizeof(int)*n)
185-
h.sets = <uint64_t **> sig_malloc(h.m*sizeof(uint64_t *))
186-
h.set_space = <uint64_t *> sig_calloc(h.m*(h.limbs+1),sizeof(uint64_t))
181+
h.n = n
182+
h.m = len(H)
183+
h.limbs = (n+63) // 64 # =ceil(n/64)
184+
h.names = <int *> sig_malloc(sizeof(int)*n)
185+
h.sets = <uint64_t **> sig_malloc(h.m*sizeof(uint64_t *))
186+
h.set_space = <uint64_t *> sig_calloc(h.m*(h.limbs+1),sizeof(uint64_t))
187187

188188
# Consistency check
189189
for S in H:
190190
for x in S:
191-
if x<0 or x>=n:
191+
if x < 0 or x >= n:
192192
h.n = -1
193193

194-
if (h.names == NULL or
195-
h.sets == NULL or
194+
if (h.names == NULL or
195+
h.sets == NULL or
196196
h.set_space == NULL or
197197
h.n == -1):
198198
h.n = -1

src/sage/combinat/integer_lists/base.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ cdef class IntegerListsBackend():
8383
self.max_length = Integer(max_length) if max_length != Infinity else Infinity
8484

8585
self.min_slope = Integer(min_slope) if min_slope != -Infinity else -Infinity
86-
self.max_slope = Integer(max_slope) if max_slope != Infinity else Infinity
86+
self.max_slope = Integer(max_slope) if max_slope != Infinity else Infinity
8787

8888
self.min_part = Integer(min_part) if min_part != -Infinity else -Infinity
8989
self.max_part = Integer(max_part) if max_part != Infinity else Infinity

src/sage/games/sudoku_backtrack.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def backtrack_all(n, puzzle):
7171
# location as row and column in square
7272
# grids are numbered similarly, in row-major order
7373
row = level // nsquare
74-
col = level % nsquare
74+
col = level % nsquare
7575
grid_corner = (row - (row % n))*nsquare + (col - (col % n))
7676
grid_row = row // n
7777
grid_col = col // n
@@ -141,7 +141,7 @@ def backtrack_all(n, puzzle):
141141
if available[abox][asymbol] == 0:
142142
card[abox] += 1
143143
# move sideways in search tree to next available symbol
144-
symbol += 1
144+
symbol += 1
145145
while (symbol < nsquare) and (available[level][symbol] != 0):
146146
symbol += 1
147147
if symbol == nsquare:

0 commit comments

Comments
 (0)