Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 7d3fd94

Browse files
committedApr 10, 2022
fix and activate pycodestyle E703 in pyx files
1 parent 78bfb6c commit 7d3fd94

10 files changed

+40
-27
lines changed
 

‎src/sage/combinat/combinat_cython.pyx

+14-7
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,14 @@ cdef void _linear_extension_switch(list _le, list _a, list _b, list _is_plus, Py
481481
if i == -1:
482482
_is_plus[0] = not _is_plus[0]
483483
else:
484-
a = _a[i]; b = _b[i]
484+
a = _a[i]
485+
b = _b[i]
485486
a_index = _le.index(a)
486487
b_index = _le.index(b)
487488
_le[a_index] = b
488489
_le[b_index] = a
489-
_b[i] = a; _a[i] = b
490+
_b[i] = a
491+
_a[i] = b
490492

491493
@cython.wraparound(False)
492494
@cython.boundscheck(False)
@@ -572,7 +574,8 @@ def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssiz
572574
while _linear_extension_right_b(_D, _le, _a, _b, i):
573575
mrb += 1
574576
# move_right
575-
index = _le.index(_b[i]); index1 = index + 1
577+
index = _le.index(_b[i])
578+
index1 = index + 1
576579
_le[index] = _le[index1]
577580
_le[index1] = _b[i]
578581
if _is_plus[0]:
@@ -585,7 +588,8 @@ def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssiz
585588
typical = True
586589
mra += 1
587590
# move_right
588-
index = _le.index(_a[i]); index1 = index+1
591+
index = _le.index(_a[i])
592+
index1 = index+1
589593
_le[index] = _le[index1]
590594
_le[index1] = _a[i]
591595
if _is_plus[0]:
@@ -607,7 +611,8 @@ def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssiz
607611
mla = mra + 1
608612
for _ in range(mla):
609613
# move_left
610-
index = _le.index(_a[i]); index1 = index-1
614+
index = _le.index(_a[i])
615+
index1 = index-1
611616
_le[index] = _le[index1]
612617
_le[index1] = _a[i]
613618
if _is_plus[0]:
@@ -618,7 +623,8 @@ def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssiz
618623

619624
if typical and (mrb % 2 == 1):
620625
# move_left
621-
index = _le.index(_a[i]); index1 = index-1
626+
index = _le.index(_a[i])
627+
index1 = index-1
622628
_le[index] = _le[index1]
623629
_le[index1] = _a[i]
624630
if _is_plus[0]:
@@ -631,7 +637,8 @@ def _linear_extension_gen(_D, list _le, list _a, list _b, list _is_plus, Py_ssiz
631637
yield e
632638
for _ in range(mrb):
633639
# move_left
634-
index = _le.index(_b[i]); index1 = index-1
640+
index = _le.index(_b[i])
641+
index1 = index-1
635642
_le[index] = _le[index1]
636643
_le[index1] = _b[i]
637644
if _is_plus[0]:

‎src/sage/combinat/debruijn_sequence.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ cdef gen(int t, int p, k, n):
101101
cdef int j
102102
if t > n:
103103
if n % p == 0:
104-
for j in range(1, p + 1): sequence.append(a[j])
104+
for j in range(1, p + 1):
105+
sequence.append(a[j])
105106
else:
106107
a[t] = a[t - p]
107108
gen(t + 1, p, k, n)
108109
for j in range((a[t - p] + 1), (k)):
109110
a[t] = j
110111
gen(t + 1, t, k, n)
111112

113+
112114
def is_debruijn_sequence(seq, k, n):
113115
r"""
114116
Given a sequence of integer elements in `0..k-1`, tests whether it

‎src/sage/combinat/designs/gen_quadrangles_with_spread.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def generalised_quadrangle_with_spread(const int s, const int t,
103103
raise RuntimeError(f"No GQ of order ({s}, {t}) exists")
104104

105105
if s == 1 and t == 1: # we have a square
106-
if existence: return True
106+
if existence:
107+
return True
107108
D = IncidenceStructure([[0, 1], [1, 2], [2, 3], [3, 0]])
108109
return (D, [[0, 1], [2, 3]])
109110

‎src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,11 @@ cdef dict ioa_indexed_by_n_minus_x = {}
801801
for x in _QDM.itervalues():
802802
for (n,_,_,u),(k,_) in x.items():
803803
if u>1:
804-
if not n in ioa_indexed_by_n_minus_x:
804+
if n not in ioa_indexed_by_n_minus_x:
805805
ioa_indexed_by_n_minus_x[n] = []
806806
ioa_indexed_by_n_minus_x[n].append((k,u))
807807

808+
808809
def int_as_sum(int value, list S, int k_max):
809810
r"""
810811
Return a tuple `(s_1, s_2, \ldots, s_k)` of less then `k_max` elements of `S` such

‎src/sage/combinat/matrices/dancing_links.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ cdef class dancing_linksWrapper:
674674
else:
675675
return None
676676

677-
indices = [i for (i,row) in enumerate(self._rows) if column in row]
677+
indices = [i for (i, row) in enumerate(self._rows) if column in row]
678678
for (args_kwds, val) in first_solution(indices):
679-
if not val is None:
679+
if val is not None:
680680
return val
681681

682682
def all_solutions(self, ncpus=None, column=None):

‎src/sage/combinat/words/word_char.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ cdef class WordDatatype_char(WordDatatype):
534534

535535
if exp == float('inf'):
536536
from sage.rings.infinity import Infinity
537-
fcn = lambda n: self[n % self.length()]
537+
538+
def fcn(n):
539+
return self[n % self.length()]
538540
return self._parent.shift()(fcn, datatype='callable')
539541

540542
if exp < 0:

‎src/sage/libs/giac/giac.pyx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1926,8 +1926,7 @@ cdef gen pylongtogen(a) except +:
19261926
# when cythonizing with cython 0.24:
19271927
# g=-g gives an Invalid operand type for '-' (gen)
19281928
g=GIAC_neg(g)
1929-
return g;
1930-
1929+
return g
19311930

19321931

19331932
#############################################################
@@ -2033,8 +2032,8 @@ class GiacFunctionNoEV(Pygen):
20332032
#############################################################
20342033
# Some convenient settings
20352034
############################################################
2036-
Pygen('printpow(1)').eval() ; # default power is ^
2037-
Pygen('add_language(1)').eval(); # Add the french keywords in the giac library language.
2035+
Pygen('printpow(1)').eval() # default power is ^
2036+
Pygen('add_language(1)').eval() # Add the french keywords in the giac library language.
20382037
# FIXME: print I for sqrt(-1) instead of i
20392038
# GIAC_try_parse_i(False,context_ptr); (does not work??)
20402039

‎src/sage/libs/singular/singular.pyx

+8-8
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring):
783783
apow2 = _ring.cf.cfMult(coeff, apow1,_ring.cf)
784784
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
785785
_ring.cf.cfDelete(&apow2, _ring.cf)
786-
_ring.cf.cfDelete(&n1, _ring.cf);
786+
_ring.cf.cfDelete(&n1, _ring.cf)
787787
n1 = n2
788788

789789
apow2 = _ring.cf.cfMult(apow1, a,_ring.cf)
@@ -849,7 +849,7 @@ cdef number *sa2si_GFq_generic(object elem, ring *_ring):
849849
apow2 = _ring.cf.cfMult(coeff, apow1,_ring.cf)
850850
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
851851
_ring.cf.cfDelete(&apow2, _ring.cf)
852-
_ring.cf.cfDelete(&n1, _ring.cf);
852+
_ring.cf.cfDelete(&n1, _ring.cf)
853853
n1 = n2
854854

855855
apow2 = _ring.cf.cfMult(apow1, a,_ring.cf)
@@ -938,7 +938,7 @@ cdef number *sa2si_transext_QQ(object elem, ring *_ring):
938938
cdef number *power
939939
cdef int ngens
940940
cdef int ex
941-
cdef nMapFunc nMapFuncPtr = NULL;
941+
cdef nMapFunc nMapFuncPtr = NULL
942942

943943
if _ring != currRing:
944944
rChangeCurrRing(_ring)
@@ -1057,7 +1057,7 @@ cdef number *sa2si_transext_FF(object elem, ring *_ring):
10571057
cdef number *aux2
10581058
cdef int ngens
10591059
cdef int ex
1060-
cdef nMapFunc nMapFuncPtr = NULL;
1060+
cdef nMapFunc nMapFuncPtr = NULL
10611061

10621062
if _ring != currRing:
10631063
rChangeCurrRing(_ring)
@@ -1163,7 +1163,7 @@ cdef number *sa2si_NF(object elem, ring *_ring):
11631163
cdef number *apow1
11641164
cdef number *apow2
11651165

1166-
cdef nMapFunc nMapFuncPtr = NULL;
1166+
cdef nMapFunc nMapFuncPtr = NULL
11671167

11681168
nMapFuncPtr = naSetMap(_ring.cf, currRing.cf) # choose correct mapping function
11691169

@@ -1188,7 +1188,7 @@ cdef number *sa2si_NF(object elem, ring *_ring):
11881188
cdef char **_ext_names
11891189
_ext_names = <char**>omAlloc0(sizeof(char*))
11901190
_ext_names[0] = omStrDup(_name)
1191-
qqr = rDefault( 0, 1, _ext_names);
1191+
qqr = rDefault( 0, 1, _ext_names)
11921192
rComplete(qqr,1)
11931193
qqr.ShortOut = 0
11941194

@@ -1203,7 +1203,7 @@ cdef number *sa2si_NF(object elem, ring *_ring):
12031203
apow2 = _ring.cf.cfMult(naCoeff, apow1,_ring.cf)
12041204
n2 = _ring.cf.cfAdd(apow2, n1,_ring.cf)
12051205
_ring.cf.cfDelete(&apow2, _ring.cf)
1206-
_ring.cf.cfDelete(&n1, _ring.cf);
1206+
_ring.cf.cfDelete(&n1, _ring.cf)
12071207
_ring.cf.cfDelete(&naCoeff, _ring.cf)
12081208
n1 = n2
12091209

@@ -1302,7 +1302,7 @@ cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring):
13021302
cdef char *_name
13031303
cdef char **_ext_names
13041304

1305-
cdef nMapFunc nMapFuncPtr = NULL;
1305+
cdef nMapFunc nMapFuncPtr = NULL
13061306

13071307
if _ring.cf.type == n_Z2m:
13081308
_d = long(d)

‎src/sage/rings/finite_rings/integer_mod.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract):
21742174
mpz_add(x.value, self.value, (<IntegerMod_gmp>right).value)
21752175
if mpz_cmp(x.value, self.__modulus.sageInteger.value) >= 0:
21762176
mpz_sub(x.value, x.value, self.__modulus.sageInteger.value)
2177-
return x;
2177+
return x
21782178

21792179
cpdef _sub_(self, right):
21802180
"""
@@ -2189,7 +2189,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract):
21892189
mpz_sub(x.value, self.value, (<IntegerMod_gmp>right).value)
21902190
if mpz_sgn(x.value) == -1:
21912191
mpz_add(x.value, x.value, self.__modulus.sageInteger.value)
2192-
return x;
2192+
return x
21932193

21942194
cpdef _neg_(self):
21952195
"""

‎src/tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ description =
9090
# See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
9191
deps = pycodestyle
9292
commands = pycodestyle --select E111,E401,E701,E702,E703,W605,E711,E712,E713,E721,E722 {posargs:{toxinidir}/sage/}
93+
pycodestyle --select E703 --filename *.pyx {posargs:{toxinidir}/sage/}
9394

9495
[pycodestyle]
9596
max-line-length = 160

0 commit comments

Comments
 (0)
This repository has been archived.