Skip to content

Commit 673f9a0

Browse files
author
Release Manager
committed
gh-39393: breaking lines after else: in pyx files as this is already done in all .py files and almost all pyx files ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39393 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Kwankyu Lee
2 parents f04fb1c + 11cba3d commit 673f9a0

File tree

8 files changed

+303
-198
lines changed

8 files changed

+303
-198
lines changed

src/sage/coding/binary_code.pyx

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ cdef codeword *expand_to_ortho_basis(BinaryCode B, int n) noexcept:
617617
i = k
618618
word = <codeword>1 << k
619619
k += 1
620-
else: # NOTE THIS WILL NEVER HAPPEN AS CURRENTLY SET UP!
620+
else: # NOTE THIS WILL NEVER HAPPEN AS CURRENTLY SET UP!
621621
temp = (<codeword>1 << k) - 1
622622
i = k
623623
word = <codeword>1 << k
@@ -813,7 +813,7 @@ cdef class BinaryCode:
813813
combination ^= (1 << j)
814814
word ^= self_basis[j]
815815

816-
else: # isinstance(arg1, BinaryCode)
816+
else: # isinstance(arg1, BinaryCode)
817817
other_basis = other.basis
818818
for i from 0 <= i < nrows-1:
819819
self_basis[i] = other_basis[i]
@@ -2423,9 +2423,12 @@ cdef class PartitionStack:
24232423
cdef int *self_wd_lvls = self.wd_lvls
24242424
cdef int *self_wd_ents = self.wd_ents
24252425
while True:
2426-
if CG.is_one(self_wd_ents[wd_ptr], col): i += 1
2427-
if self_wd_lvls[wd_ptr] > k: wd_ptr += 1
2428-
else: break
2426+
if CG.is_one(self_wd_ents[wd_ptr], col):
2427+
i += 1
2428+
if self_wd_lvls[wd_ptr] > k:
2429+
wd_ptr += 1
2430+
else:
2431+
break
24292432
return i
24302433

24312434
def _wd_degree(self, C, wd, col_ptr, k):
@@ -3347,15 +3350,17 @@ cdef class BinaryCodeClassifier:
33473350
if qzb > 0: zb__Lambda_rho[k] = Lambda[k]
33483351
state = 3
33493352

3350-
elif state == 3: # attempt to rule out automorphisms while moving down the tree
3353+
elif state == 3: # attempt to rule out automorphisms while moving down the tree
33513354
# if k > hzf, then we know that nu currently does not look like zeta, the first
33523355
# terminal node encountered, thus there is no automorphism to discover. If qzb < 0,
33533356
# i.e. Lambda[k] < zb[k], then the indicator is not maximal, and we can't reach a
33543357
# canonical leaf. If neither of these is the case, then proceed to state 4.
3355-
if hzf__h_zeta <= k or qzb >= 0: state = 4
3356-
else: state = 6
3358+
if hzf__h_zeta <= k or qzb >= 0:
3359+
state = 4
3360+
else:
3361+
state = 6
33573362

3358-
elif state == 4: # at this point we have -not- ruled out the presence of automorphisms
3363+
elif state == 4: # at this point we have -not- ruled out the presence of automorphisms
33593364
if nu.is_discrete(k):
33603365
state = 7
33613366
continue # we have a terminal node, so process it
@@ -3365,17 +3370,18 @@ cdef class BinaryCodeClassifier:
33653370
# equal to its minimum element
33663371
v[k] = nu.new_first_smallest_nontrivial(k, W, self.Phi_size * k)
33673372
if not nu.sat_225(k): hh = k + 1
3368-
e[k] = 0 # see state 12 and 17
3369-
state = 2 # continue down the tree
3373+
e[k] = 0 # see state 12 and 17
3374+
state = 2 # continue down the tree
33703375

3371-
elif state == 5: # same as state 3, but in the case where we haven't yet defined zeta
3372-
# i.e. this is our first time down the tree. Once we get to the bottom,
3373-
# we will have zeta = nu = rho, so we do:
3376+
elif state == 5:
3377+
# same as state 3, but in the case where we haven't yet defined zeta
3378+
# i.e. this is our first time down the tree. Once we get to the bottom,
3379+
# we will have zeta = nu = rho, so we do:
33743380
zf__Lambda_zeta[k] = Lambda[k]
33753381
zb__Lambda_rho[k] = Lambda[k]
33763382
state = 4
33773383

3378-
elif state == 6: # at this stage, there is no reason to continue downward, so backtrack
3384+
elif state == 6: # at this stage, there is no reason to continue downward, so backtrack
33793385
j = k
33803386

33813387
# return to the longest ancestor nu[i] of nu that could have a
@@ -3396,9 +3402,10 @@ cdef class BinaryCodeClassifier:
33963402
else:
33973403
k = hh-1
33983404
# TODO: is the following line necessary?
3399-
if k == -1: k = 0
3405+
if k == -1:
3406+
k = 0
34003407

3401-
if hb > k:# update hb since we are backtracking
3408+
if hb > k: # update hb since we are backtracking
34023409
hb = k
34033410
# if j == hh, then all nodes lower than our current position are equivalent, so bail out
34043411
if j == hh:
@@ -3465,7 +3472,7 @@ cdef class BinaryCodeClassifier:
34653472

34663473
state = 10
34673474

3468-
elif state == 9: # nu is a better guess at the canonical label than rho
3475+
elif state == 9: # nu is a better guess at the canonical label than rho
34693476
rho = PartitionStack(nu)
34703477
k_rho = k
34713478
qzb = 0
@@ -3475,7 +3482,7 @@ cdef class BinaryCodeClassifier:
34753482
zb__Lambda_rho[k+1] = -1
34763483
state = 6
34773484

3478-
elif state == 10: # we have an automorphism to process
3485+
elif state == 10: # we have an automorphism to process
34793486
# increment l
34803487
if l < self.L-1: l += 1
34813488
# store information about the automorphism to Omega and Phi
@@ -3496,8 +3503,8 @@ cdef class BinaryCodeClassifier:
34963503
Omega[ii] ^= (1<<j) # so cancel
34973504
j = col_gamma[j] # cellmates
34983505
i += 1
3499-
while i < ncols and not Omega[ii]&(1<<i): # find minimal element
3500-
i += 1 # of next cell
3506+
while i < ncols and not Omega[ii]&(1<<i): # find minimal element
3507+
i += 1 # of next cell
35013508
i = 0
35023509
jj = self.radix
35033510
while i < nwords:

src/sage/libs/mpmath/ext_impl.pyx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,10 +1183,14 @@ cdef MPF_exp(MPF *y, MPF *x, MPopts opts):
11831183
cdef mpz_t t, u
11841184
cdef tuple w
11851185
if x.special:
1186-
if x.special == S_ZERO: MPF_set_si(y, 1)
1187-
elif x.special == S_NINF: MPF_set_zero(y)
1188-
elif x.special == S_INF: MPF_set_inf(y)
1189-
else: MPF_set_nan(y)
1186+
if x.special == S_ZERO:
1187+
MPF_set_si(y, 1)
1188+
elif x.special == S_NINF:
1189+
MPF_set_zero(y)
1190+
elif x.special == S_INF:
1191+
MPF_set_inf(y)
1192+
else:
1193+
MPF_set_nan(y)
11901194
return
11911195
wp = opts.prec + 14
11921196
sign = mpz_sgn(x.man) < 0

src/sage/libs/mpmath/utils.pyx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd):
134134
elif rnd == 'd':
135135
mpz_fdiv_q_2exp(res.value, man.value, shift)
136136
elif rnd == 'f':
137-
if sign: mpz_cdiv_q_2exp(res.value, man.value, shift)
138-
else: mpz_fdiv_q_2exp(res.value, man.value, shift)
137+
if sign:
138+
mpz_cdiv_q_2exp(res.value, man.value, shift)
139+
else:
140+
mpz_fdiv_q_2exp(res.value, man.value, shift)
139141
elif rnd == 'c':
140-
if sign: mpz_fdiv_q_2exp(res.value, man.value, shift)
141-
else: mpz_cdiv_q_2exp(res.value, man.value, shift)
142+
if sign:
143+
mpz_fdiv_q_2exp(res.value, man.value, shift)
144+
else:
145+
mpz_cdiv_q_2exp(res.value, man.value, shift)
142146
elif rnd == 'u':
143147
mpz_cdiv_q_2exp(res.value, man.value, shift)
144148
exp += shift

src/sage/libs/singular/singular.pyx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,18 @@ cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring):
9696

9797
mpq_init(_z)
9898

99-
## Immediate integers handles carry the tag 'SR_INT', i.e. the last bit is 1.
100-
## This distinguishes immediate integers from other handles which point to
101-
## structures aligned on 4 byte boundaries and therefore have last bit zero.
102-
## (The second bit is reserved as tag to allow extensions of this scheme.)
103-
## Using immediates as pointers and dereferencing them gives address errors.
99+
# Immediate integers handles carry the tag 'SR_INT', i.e. the last bit is 1.
100+
# This distinguishes immediate integers from other handles which point to
101+
# structures aligned on 4 byte boundaries and therefore have last bit zero.
102+
# (The second bit is reserved as tag to allow extensions of this scheme.)
103+
# Using immediates as pointers and dereferencing them gives address errors.
104104
nom = nlGetNumerator(n, _ring.cf)
105105
mpz_init(nom_z)
106106

107-
if (SR_HDL(nom) & SR_INT): mpz_set_si(nom_z, SR_TO_INT(nom))
108-
else: mpz_set(nom_z,nom.z)
107+
if SR_HDL(nom) & SR_INT:
108+
mpz_set_si(nom_z, SR_TO_INT(nom))
109+
else:
110+
mpz_set(nom_z,nom.z)
109111

110112
mpq_set_num(_z,nom_z)
111113
nlDelete(&nom,_ring.cf)
@@ -114,8 +116,10 @@ cdef Rational si2sa_QQ(number *n, number **nn, ring *_ring):
114116
denom = nlGetDenom(n, _ring.cf)
115117
mpz_init(denom_z)
116118

117-
if (SR_HDL(denom) & SR_INT): mpz_set_si(denom_z, SR_TO_INT(denom))
118-
else: mpz_set(denom_z,denom.z)
119+
if SR_HDL(denom) & SR_INT:
120+
mpz_set_si(denom_z, SR_TO_INT(denom))
121+
else:
122+
mpz_set(denom_z,denom.z)
119123

120124
mpq_set_den(_z, denom_z)
121125
nlDelete(&denom,_ring.cf)

0 commit comments

Comments
 (0)