Skip to content

Commit 7501d93

Browse files
committed
fixing pycodestyle E222 in many cython files
1 parent c9dd1e8 commit 7501d93

38 files changed

+262
-225
lines changed

src/sage/coding/binary_code.pyx

Lines changed: 112 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,25 +1279,33 @@ 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) )
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))
12901290
if self.wd_parent is NULL or self.wd_rank is NULL or self.wd_min_cell_rep is NULL \
12911291
or self.wd_size is NULL or self.col_parent is NULL or self.col_rank is NULL \
12921292
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)
1293+
if self.wd_parent is not NULL:
1294+
sig_free(self.wd_parent)
1295+
if self.wd_rank is not NULL:
1296+
sig_free(self.wd_rank)
1297+
if self.wd_min_cell_rep is not NULL:
1298+
sig_free(self.wd_min_cell_rep)
1299+
if self.wd_size is not NULL:
1300+
sig_free(self.wd_size)
1301+
if self.col_parent is not NULL:
1302+
sig_free(self.col_parent)
1303+
if self.col_rank is not NULL:
1304+
sig_free(self.col_rank)
1305+
if self.col_min_cell_rep is not NULL:
1306+
sig_free(self.col_min_cell_rep)
1307+
if self.col_size is not NULL:
1308+
sig_free(self.col_size)
13011309
raise MemoryError("Memory.")
13021310
for word from 0 <= word < nwords:
13031311
self.wd_parent[word] = word
@@ -1605,33 +1613,43 @@ cdef class PartitionStack:
16051613
self.flag = (1 << (self.radix-1))
16061614

16071615
# 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 )
1616+
self.wd_ents = <int *> sig_malloc( self.nwords * sizeof_int )
1617+
self.wd_lvls = <int *> sig_malloc( self.nwords * sizeof_int )
1618+
self.col_ents = <int *> sig_malloc( self.ncols * sizeof_int )
1619+
self.col_lvls = <int *> sig_malloc( self.ncols * sizeof_int )
16121620

16131621
# scratch space
1614-
self.col_degs = <int *> sig_malloc( self.ncols * sizeof_int )
1622+
self.col_degs = <int *> sig_malloc( self.ncols * sizeof_int )
16151623
self.col_counts = <int *> sig_malloc( self.nwords * sizeof_int )
16161624
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 )
1625+
self.wd_degs = <int *> sig_malloc( self.nwords * sizeof_int )
1626+
self.wd_counts = <int *> sig_malloc( (self.ncols+1) * sizeof_int )
1627+
self.wd_output = <int *> sig_malloc( self.nwords * sizeof_int )
16201628

16211629
if self.wd_ents is NULL or self.wd_lvls is NULL or self.col_ents is NULL \
16221630
or self.col_lvls is NULL or self.col_degs is NULL or self.col_counts is NULL \
16231631
or self.col_output is NULL or self.wd_degs is NULL or self.wd_counts is NULL \
16241632
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)
1633+
if self.wd_ents is not NULL:
1634+
sig_free(self.wd_ents)
1635+
if self.wd_lvls is not NULL:
1636+
sig_free(self.wd_lvls)
1637+
if self.col_ents is not NULL:
1638+
sig_free(self.col_ents)
1639+
if self.col_lvls is not NULL:
1640+
sig_free(self.col_lvls)
1641+
if self.col_degs is not NULL:
1642+
sig_free(self.col_degs)
1643+
if self.col_counts is not NULL:
1644+
sig_free(self.col_counts)
1645+
if self.col_output is not NULL:
1646+
sig_free(self.col_output)
1647+
if self.wd_degs is not NULL:
1648+
sig_free(self.wd_degs)
1649+
if self.wd_counts is not NULL:
1650+
sig_free(self.wd_counts)
1651+
if self.wd_output is not NULL:
1652+
sig_free(self.wd_output)
16351653
raise MemoryError("Memory.")
16361654

16371655
nwords = self.nwords
@@ -3073,40 +3091,54 @@ cdef class BinaryCodeClassifier:
30733091
self.alpha_size = self.w_gamma_size + self.radix
30743092
self.Phi_size = self.w_gamma_size/self.radix + 1
30753093

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) )
3094+
self.w_gamma = <int *> sig_malloc( self.w_gamma_size * sizeof(int) )
3095+
self.alpha = <int *> sig_malloc( self.alpha_size * sizeof(int) )
3096+
self.Phi = <unsigned int *> sig_malloc( self.Phi_size * (self.L+1) * sizeof(unsigned int) )
3097+
self.Omega = <unsigned int *> sig_malloc( self.Phi_size * self.L * sizeof(unsigned int) )
3098+
self.W = <unsigned int *> sig_malloc( self.Phi_size * self.radix * 2 * sizeof(unsigned int) )
30813099

3082-
self.base = <int *> sig_malloc( self.radix * sizeof(int) )
3100+
self.base = <int *> sig_malloc( self.radix * sizeof(int) )
30833101
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) )
3102+
self.c_gamma = <int *> sig_malloc( self.radix * sizeof(int) )
3103+
self.labeling = <int *> sig_malloc( self.radix * 3 * sizeof(int) )
3104+
self.Lambda1 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3105+
self.Lambda2 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3106+
self.Lambda3 = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3107+
self.v = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
3108+
self.e = <int *> sig_malloc( self.radix * 2 * sizeof(int) )
30913109

30923110
if self.Phi is NULL or self.Omega is NULL or self.W is NULL or self.Lambda1 is NULL \
30933111
or self.Lambda2 is NULL or self.Lambda3 is NULL or self.w_gamma is NULL \
30943112
or self.c_gamma is NULL or self.alpha is NULL or self.v is NULL or self.e is NULL \
30953113
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)
3114+
if self.Phi is not NULL:
3115+
sig_free(self.Phi)
3116+
if self.Omega is not NULL:
3117+
sig_free(self.Omega)
3118+
if self.W is not NULL:
3119+
sig_free(self.W)
3120+
if self.Lambda1 is not NULL:
3121+
sig_free(self.Lambda1)
3122+
if self.Lambda2 is not NULL:
3123+
sig_free(self.Lambda2)
3124+
if self.Lambda3 is not NULL:
3125+
sig_free(self.Lambda3)
3126+
if self.w_gamma is not NULL:
3127+
sig_free(self.w_gamma)
3128+
if self.c_gamma is not NULL:
3129+
sig_free(self.c_gamma)
3130+
if self.alpha is not NULL:
3131+
sig_free(self.alpha)
3132+
if self.v is not NULL:
3133+
sig_free(self.v)
3134+
if self.e is not NULL:
3135+
sig_free(self.e)
3136+
if self.aut_gp_gens is not NULL:
3137+
sig_free(self.aut_gp_gens)
3138+
if self.labeling is not NULL:
3139+
sig_free(self.labeling)
3140+
if self.base is not NULL:
3141+
sig_free(self.base)
31103142
raise MemoryError("Memory.")
31113143

31123144
def __dealloc__(self):
@@ -3371,27 +3403,32 @@ cdef class BinaryCodeClassifier:
33713403
self.w_gamma_size *= 2
33723404
self.alpha_size = self.w_gamma_size + self.radix
33733405
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) )
3406+
self.w_gamma = <int *> sig_realloc(self.w_gamma, self.w_gamma_size * sizeof(int))
3407+
self.alpha = <int *> sig_realloc(self.alpha, self.alpha_size * sizeof(int))
3408+
self.Phi = <unsigned int *> sig_realloc(self.Phi, self.Phi_size * self.L * sizeof(int))
3409+
self.Omega = <unsigned int *> sig_realloc(self.Omega, self.Phi_size * self.L * sizeof(int))
3410+
self.W = <unsigned int *> sig_realloc(self.W, self.Phi_size * self.radix * 2 * sizeof(int))
33793411
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)
3412+
if self.w_gamma is not NULL:
3413+
sig_free(self.w_gamma)
3414+
if self.alpha is not NULL:
3415+
sig_free(self.alpha)
3416+
if self.Phi is not NULL:
3417+
sig_free(self.Phi)
3418+
if self.Omega is not NULL:
3419+
sig_free(self.Omega)
3420+
if self.W is not NULL:
3421+
sig_free(self.W)
33853422
raise MemoryError("Memory.")
33863423
for i from 0 <= i < self.Phi_size * self.L:
33873424
self.Omega[i] = 0
33883425
word_gamma = self.w_gamma
33893426
alpha = self.alpha # think of alpha as of length exactly nwords + ncols
3390-
Phi = self.Phi
3427+
Phi = self.Phi
33913428
Omega = self.Omega
3392-
W = self.W
3393-
e = self.e
3394-
nu = PartitionStack(nrows, ncols)
3429+
W = self.W
3430+
e = self.e
3431+
nu = PartitionStack(nrows, ncols)
33953432
Theta = OrbitPartition(nrows, ncols)
33963433

33973434
# 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:

src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ cdef aut_gp_and_can_lab *get_aut_gp_and_can_lab(void *S,
529529
orbits_of_permutation = work_space.orbits_of_permutation
530530

531531
current_indicators = work_space.int_array
532-
first_indicators = work_space.int_array + n
533-
permutation = work_space.int_array + 2*n
534-
id_perm = work_space.int_array + 3*n
535-
cells_to_refine_by = work_space.int_array + 4*n
536-
vertices_determining_current_stack = work_space.int_array + 5*n
537-
label_perm = work_space.int_array + 6*n
532+
first_indicators = work_space.int_array + n
533+
permutation = work_space.int_array + 2 * n
534+
id_perm = work_space.int_array + 3 * n
535+
cells_to_refine_by = work_space.int_array + 4 * n
536+
vertices_determining_current_stack = work_space.int_array + 5 * n
537+
label_perm = work_space.int_array + 6 * n
538538

539539
fixed_points_of_generators = work_space.bitset_array
540540
minimal_cell_reps_of_generators = work_space.bitset_array + len_of_fp_and_mcr

0 commit comments

Comments
 (0)