Skip to content

Commit a216ed3

Browse files
author
Release Manager
committed
gh-36420: fix for E702 in pyx outside rings This fixes pycodestyle warning E702 in pyx files outside of rings ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #36420 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Kwankyu Lee
2 parents ef7bd8d + d223040 commit a216ed3

File tree

4 files changed

+121
-54
lines changed

4 files changed

+121
-54
lines changed

src/sage/coding/binary_code.pyx

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,6 @@ cdef class BinaryCode:
12061206
combination ^= (1 << j)
12071207
word ^= self.basis[j]
12081208

1209-
12101209
cpdef int put_in_std_form(self):
12111210
"""
12121211
Put the code in binary form, which is defined by an identity matrix on
@@ -1225,7 +1224,6 @@ cdef class BinaryCode:
12251224
Binary [6,2] linear code, generator matrix
12261225
[101011]
12271226
[010111]
1228-
12291227
"""
12301228
cdef codeword swap, current = 1, pivots = 0
12311229
cdef int i, j, k, row = 0
@@ -1261,6 +1259,7 @@ cdef class BinaryCode:
12611259
self._apply_permutation_to_basis(perm)
12621260
self._update_words_from_basis()
12631261

1262+
12641263
cdef class OrbitPartition:
12651264
"""
12661265
Structure which keeps track of which vertices are equivalent
@@ -2770,7 +2769,8 @@ cdef class PartitionStack:
27702769
j = 0
27712770
if alpha[m] & flag:
27722771
while j < self_ncols:
2773-
i = j; s = 0
2772+
i = j
2773+
s = 0
27742774
invariant += 8
27752775
while True:
27762776
self_col_degs[i-j] = self.col_degree(CG, self_col_ents[i], alpha[m]^flag, k)
@@ -2800,7 +2800,8 @@ cdef class PartitionStack:
28002800
j = i
28012801
else:
28022802
while j < self.nwords:
2803-
i = j; s = 0
2803+
i = j
2804+
s = 0
28042805
invariant += 64
28052806
while True:
28062807
self_wd_degs[i-j] = self.wd_degree(CG, self_wd_ents[i], alpha[m], k, ham_wts)
@@ -3430,7 +3431,9 @@ cdef class BinaryCodeClassifier:
34303431
alpha[1] = nu.flag
34313432
nu.refine(k, alpha, 2, C, ham_wts)
34323433
if nu.sat_225(k): hh = k
3433-
if nu.is_discrete(k): state = 18; continue
3434+
if nu.is_discrete(k):
3435+
state = 18
3436+
continue
34343437

34353438
# store the first smallest nontrivial cell in W[k], and set v[k]
34363439
# equal to its minimum element
@@ -3448,7 +3451,9 @@ cdef class BinaryCodeClassifier:
34483451
alpha[0] = nu.split_vertex(v[k-1], k)
34493452
Lambda[k] = nu.refine(k, alpha, 1, C, ham_wts) # store the invariant to Lambda[k]
34503453
# only if this is the first time moving down the search tree:
3451-
if h == -1: state = 5; continue
3454+
if h == -1:
3455+
state = 5
3456+
continue
34523457

34533458
# update hzf__h_zeta
34543459
if hzf__h_zeta == k-1 and Lambda[k] == zf__Lambda_zeta[k]: hzf__h_zeta = k
@@ -3478,7 +3483,9 @@ cdef class BinaryCodeClassifier:
34783483
else: state = 6
34793484

34803485
elif state == 4: # at this point we have -not- ruled out the presence of automorphisms
3481-
if nu.is_discrete(k): state = 7; continue # we have a terminal node, so process it
3486+
if nu.is_discrete(k):
3487+
state = 7
3488+
continue # we have a terminal node, so process it
34823489

34833490
# otherwise, prepare to split out another column:
34843491
# store the first smallest nontrivial cell in W[k], and set v[k]
@@ -3521,7 +3528,9 @@ cdef class BinaryCodeClassifier:
35213528
if hb > k:# update hb since we are backtracking
35223529
hb = k
35233530
# if j == hh, then all nodes lower than our current position are equivalent, so bail out
3524-
if j == hh: state = 13; continue
3531+
if j == hh:
3532+
state = 13
3533+
continue
35253534

35263535
# recall hh: the height of the oldest ancestor of zeta for which Lemma 2.25 is
35273536
# satisfied, which implies that all terminal nodes descended from there are equivalent.
@@ -3536,11 +3545,15 @@ cdef class BinaryCodeClassifier:
35363545
elif state == 7: # we have just arrived at a terminal node of the search tree T(G, Pi)
35373546
# if this is the first terminal node, go directly to 18, to
35383547
# process zeta
3539-
if h == -1: state = 18; continue
3548+
if h == -1:
3549+
state = 18
3550+
continue
35403551

35413552
# hzf is the extremal height of ancestors of both nu and zeta, so if k < hzf, nu is not
35423553
# equivalent to zeta, i.e. there is no automorphism to discover.
3543-
if k < hzf__h_zeta: state = 8; continue
3554+
if k < hzf__h_zeta:
3555+
state = 8
3556+
continue
35443557

35453558
nu.get_permutation(zeta, word_gamma, col_gamma)
35463559

@@ -3553,18 +3566,26 @@ cdef class BinaryCodeClassifier:
35533566
elif state == 8: # we have just ruled out the presence of automorphism and have not yet
35543567
# considered whether nu improves on rho
35553568
# if qzb < 0, then rho already has larger indicator tuple
3556-
if qzb < 0: state = 6; continue
3569+
if qzb < 0:
3570+
state = 6
3571+
continue
35573572

35583573
# if Lambda[k] > zb[k] or nu is shorter than rho, then we have an improvement for rho
3559-
if (qzb > 0) or (k < k_rho): state = 9; continue
3574+
if (qzb > 0) or (k < k_rho):
3575+
state = 9
3576+
continue
35603577

35613578
# now Lambda[k] == zb[k] and k == k_rho, so we appeal to an enumeration:
35623579
j = nu.cmp(rho, C)
35633580
# if C(nu) > C(rho), we have a new label, goto 9
3564-
if j > 0: state = 9; continue
3581+
if j > 0:
3582+
state = 9
3583+
continue
35653584

35663585
# if C(nu) < C(rho), no new label, goto 6
3567-
if j < 0: state = 6; continue
3586+
if j < 0:
3587+
state = 6
3588+
continue
35683589

35693590
# if C(nu) == C(rho), get the automorphism and goto 10
35703591
rho.get_permutation(nu, word_gamma, col_gamma)
@@ -3627,7 +3648,9 @@ cdef class BinaryCodeClassifier:
36273648

36283649
# j stores whether anything happened or not- if not, then the automorphism we have
36293650
# discovered is already in the subgroup spanned by the generators we have output
3630-
if not j: state = 11; continue
3651+
if not j:
3652+
state = 11
3653+
continue
36313654

36323655
# otherwise, we have a new generator, so record it:
36333656
self.record_automorphism(col_gamma, ncols)
@@ -3641,10 +3664,11 @@ cdef class BinaryCodeClassifier:
36413664
if tvc & nu.flag:
36423665
i = tvc^nu.flag
36433666
if Theta.wd_min_cell_rep[Theta.wd_find(i)] == i:
3644-
state = 11; continue
3645-
else:
3646-
if Theta.col_min_cell_rep[Theta.col_find(tvc)] == tvc:
3647-
state = 11; continue
3667+
state = 11
3668+
continue
3669+
elif Theta.col_min_cell_rep[Theta.col_find(tvc)] == tvc:
3670+
state = 11
3671+
continue
36483672

36493673
# Otherwise, proceed to where zeta meets nu:
36503674
k = h
@@ -3675,11 +3699,17 @@ cdef class BinaryCodeClassifier:
36753699
state = 13
36763700

36773701
elif state == 13: # hub state
3678-
if k == -1: state = -1; continue # exit point
3702+
if k == -1:
3703+
state = -1
3704+
continue # exit point
36793705

3680-
if k > h: state = 17; continue # we are still on the same principal branch from zeta
3706+
if k > h:
3707+
state = 17
3708+
continue # we are still on the same principal branch from zeta
36813709

3682-
if k == h: state = 14; continue # update the stabilizer index and check for new splits,
3710+
if k == h:
3711+
state = 14
3712+
continue # update the stabilizer index and check for new splits,
36833713
# since we have returned to a partition of zeta
36843714
# otherwise k < h, hence we have just backtracked up zeta, and are one level closer to done
36853715
h = k
@@ -3719,7 +3749,8 @@ cdef class BinaryCodeClassifier:
37193749
v[k] = i^nu.flag
37203750
else:
37213751
# there is no new split at this level
3722-
state = 16; continue
3752+
state = 16
3753+
continue
37233754
# new split column better be a minimal representative in Theta, or wasted effort
37243755
if Theta.wd_min_cell_rep[Theta.wd_find(i)] == i:
37253756
state = 15
@@ -3733,7 +3764,8 @@ cdef class BinaryCodeClassifier:
37333764
v[k] = i
37343765
else:
37353766
# there is no new split at this level
3736-
state = 16; continue
3767+
state = 16
3768+
continue
37373769
# new split column better be a minimal representative in Theta, or wasted effort
37383770
if Theta.col_min_cell_rep[Theta.col_find(v[k])] == v[k]:
37393771
state = 15
@@ -3760,7 +3792,8 @@ cdef class BinaryCodeClassifier:
37603792
i = W[jj]
37613793
j = ham_wts[i & 65535] + ham_wts[(i >> 16) & 65535]
37623794
else:
3763-
i = 0; j = 0
3795+
i = 0
3796+
j = 0
37643797
ii = self.radix
37653798
while i*ii < nwords:
37663799
iii = W[jj+1+i]
@@ -3812,15 +3845,17 @@ cdef class BinaryCodeClassifier:
38123845
if (1 << i%self.radix) & W[jjj+1+i/self.radix]: break
38133846
if i < nwords:
38143847
v[k] = i^nu.flag
3815-
state = 15; continue
3848+
state = 15
3849+
continue
38163850
else:
38173851
i = v[k]
38183852
while i < ncols:
38193853
i += 1
38203854
if (1 << i) & W[jjj]: break
38213855
if i < ncols:
38223856
v[k] = i
3823-
state = 15; continue
3857+
state = 15
3858+
continue
38243859

38253860
k -= 1
38263861
state = 13

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

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ cdef class LinearBinaryCodeStruct(BinaryCodeStruct):
9393
bitset_free(&self.basis[j])
9494
memerr = 1
9595
if memerr:
96-
sig_free(self.basis); sig_free(self.scratch_bitsets)
97-
sig_free(self.alpha_is_wd); PS_dealloc(self.word_ps)
98-
sig_free(self.alpha); sig_free(self.scratch)
96+
sig_free(self.basis)
97+
sig_free(self.scratch_bitsets)
98+
sig_free(self.alpha_is_wd)
99+
PS_dealloc(self.word_ps)
100+
sig_free(self.alpha)
101+
sig_free(self.scratch)
99102
raise MemoryError
100103
else:
101104
bitset_zero(self.alpha_is_wd)
@@ -349,9 +352,12 @@ cdef class LinearBinaryCodeStruct(BinaryCodeStruct):
349352
bitset_free(&self.scratch_bitsets[j])
350353
for j from 0 <= j < self.dimension:
351354
bitset_free(&self.basis[j])
352-
sig_free(self.basis); sig_free(self.scratch_bitsets)
353-
sig_free(self.alpha_is_wd); PS_dealloc(self.word_ps)
354-
sig_free(self.alpha); sig_free(self.scratch)
355+
sig_free(self.basis)
356+
sig_free(self.scratch_bitsets)
357+
sig_free(self.alpha_is_wd)
358+
PS_dealloc(self.word_ps)
359+
sig_free(self.alpha)
360+
sig_free(self.scratch)
355361
if self.output is not NULL:
356362
deallocate_agcl_output(self.output)
357363

@@ -433,9 +439,12 @@ cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct):
433439
bitset_free(&self.words[j])
434440
memerr = 1
435441
if memerr:
436-
sig_free(self.words); sig_free(self.scratch_bitsets)
437-
sig_free(self.alpha_is_wd); PS_dealloc(self.word_ps)
438-
sig_free(self.alpha); sig_free(self.scratch)
442+
sig_free(self.words)
443+
sig_free(self.scratch_bitsets)
444+
sig_free(self.alpha_is_wd)
445+
PS_dealloc(self.word_ps)
446+
sig_free(self.alpha)
447+
sig_free(self.scratch)
439448
raise MemoryError
440449
else:
441450
bitset_zero(self.alpha_is_wd)
@@ -456,20 +465,24 @@ cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct):
456465
bitset_free(&self.scratch_bitsets[j])
457466
for j from 0 <= j < self.nwords:
458467
bitset_free(&self.words[j])
459-
sig_free(self.words); sig_free(self.scratch_bitsets)
460-
sig_free(self.alpha_is_wd); PS_dealloc(self.word_ps)
461-
sig_free(self.alpha); sig_free(self.scratch)
468+
sig_free(self.words)
469+
sig_free(self.scratch_bitsets)
470+
sig_free(self.alpha_is_wd)
471+
PS_dealloc(self.word_ps)
472+
sig_free(self.alpha)
473+
sig_free(self.scratch)
462474
if self.output is not NULL:
463475
deallocate_agcl_output(self.output)
464476

465477
def run(self, partition=None):
466478
"""
467479
Perform the canonical labeling and automorphism group computation,
468-
storing results to self.
480+
storing results to ``self``.
469481
470482
INPUT:
471-
partition -- an optional list of lists partition of the columns.
472-
default is the unit partition.
483+
484+
- ``partition`` -- an optional list of lists partition of the columns.
485+
default is the unit partition.
473486
474487
EXAMPLES::
475488

src/sage/matrix/matrix2.pyx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,8 @@ cdef class Matrix(Matrix1):
36493649
for i from 0 <= i <= n:
36503650
# Finally, set v[i] = c[n,i]
36513651
o = c.get_unsafe(n,i)
3652-
Py_INCREF(o); PyList_SET_ITEM(v, i, o)
3652+
Py_INCREF(o)
3653+
PyList_SET_ITEM(v, i, o)
36533654

36543655
R = self._base_ring[var] # polynomial ring over the base ring
36553656
return R(v)
@@ -4561,7 +4562,8 @@ cdef class Matrix(Matrix1):
45614562
# Third: generic first, if requested explicitly
45624563
# then try specialized class methods, and finally
45634564
# delegate to ad-hoc methods in greater generality
4564-
M = None; format = ''
4565+
M = None
4566+
format = ''
45654567

45664568
if algorithm == 'generic':
45674569
format, M = self._right_kernel_matrix_over_field()
@@ -6025,7 +6027,8 @@ cdef class Matrix(Matrix1):
60256027
sage: t.charpoly() # needs sage.libs.pari
60266028
x^3 - 12*x^2 - 18*x
60276029
"""
6028-
i = int(i); t=int(t)
6030+
i = int(i)
6031+
t = int(t)
60296032
if self.nrows() != self.ncols():
60306033
raise ArithmeticError("self must be a square matrix")
60316034
n = self.nrows()
@@ -11035,7 +11038,8 @@ cdef class Matrix(Matrix1):
1103511038
R = self.base_ring()
1103611039
if isinstance(R, (sage.rings.abc.RealDoubleField, sage.rings.abc.ComplexDoubleField)):
1103711040
Q, R = self.transpose().QR()
11038-
m = R.nrows(); n = R.ncols()
11041+
m = R.nrows()
11042+
n = R.ncols()
1103911043
if m > n:
1104011044
Q = Q[0:m, 0:n]
1104111045
R = R[0:n, 0:n]
@@ -14250,8 +14254,11 @@ cdef class Matrix(Matrix1):
1425014254
# a 1x1 pivot, but this time we need to swap
1425114255
# rows/columns k and r.
1425214256
d.append( one_by_one_space(A_rr) )
14253-
A.swap_columns_c(k,r); A.swap_rows_c(k,r)
14254-
p_k = p[k]; p[k] = p[r]; p[r] = p_k
14257+
A.swap_columns_c(k, r)
14258+
A.swap_rows_c(k, r)
14259+
p_k = p[k]
14260+
p[k] = p[r]
14261+
p[r] = p_k
1425514262
_block_ldlt_pivot1x1(A,k)
1425614263
k += 1
1425714264
continue
@@ -14260,8 +14267,11 @@ cdef class Matrix(Matrix1):
1426014267
# or Step (6) in B&K, where we perform a 2x2 pivot. See
1426114268
# pivot1x1() for an explanation of why it's OK to permute
1426214269
# the entries of "L" here as well.
14263-
A.swap_columns_c(k+1,r); A.swap_rows_c(k+1,r)
14264-
p_k = p[k+1]; p[k+1] = p[r]; p[r] = p_k
14270+
A.swap_columns_c(k+1, r)
14271+
A.swap_rows_c(k+1, r)
14272+
p_k = p[k+1]
14273+
p[k+1] = p[r]
14274+
p[r] = p_k
1426514275

1426614276
# The top-left 2x2 submatrix (starting at position k,k) is
1426714277
# now our pivot.

0 commit comments

Comments
 (0)