Skip to content

Commit 302ca3e

Browse files
committed
some care for pep8 code E241 in some pyx files
1 parent b002b63 commit 302ca3e

File tree

19 files changed

+93
-95
lines changed

19 files changed

+93
-95
lines changed

src/sage/coding/codecan/codecan.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,8 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic):
920920
if self._inner_group.rank < 2:
921921
return True
922922
923-
lower = iter(self._matrix[ : self._inner_group.rank ].columns())
924-
upper = iter(self._matrix[ self._inner_group.rank : ].columns())
923+
lower = iter(self._matrix[ : self._inner_group.rank].columns())
924+
upper = iter(self._matrix[self._inner_group.rank : ].columns())
925925
926926
for i in range(self._n):
927927
l = next(lower)

src/sage/combinat/crystals/tensor_product_element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,4 +1867,4 @@ cdef Py_ssize_t count_leading(list row, letter) noexcept:
18671867

18681868
# for unpickling
18691869
from sage.misc.persist import register_unpickle_override
1870-
register_unpickle_override('sage.combinat.crystals.tensor_product', 'ImmutableListWithParent', ImmutableListWithParent)
1870+
register_unpickle_override('sage.combinat.crystals.tensor_product', 'ImmutableListWithParent', ImmutableListWithParent)

src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -755,46 +755,45 @@ cpdef find_brouwer_separable_design(int k,int n) noexcept:
755755

756756
# i)
757757
if (x == 0 and
758-
is_available(k, t) and
759-
is_available(k,t+q)):
760-
return brouwer_separable_design, (k,t,q,x)
758+
is_available(k, t) and is_available(k, t+q)):
759+
return brouwer_separable_design, (k, t, q, x)
761760

762761
# ii)
763762
elif (x == t+q and
764-
is_available(k+e3, t ) and
765-
is_available( k , t+q ) and
763+
is_available(k+e3, t) and
764+
is_available(k, t+q) and
766765
is_available(k+1 ,t+q+1)):
767-
return brouwer_separable_design, (k,t,q,x)
766+
return brouwer_separable_design, (k, t, q, x)
768767

769768
# iii)
770769
elif (x == q**2-q+1-t and
771-
is_available( k , x ) and
772-
is_available( k+e2, t+1 ) and
773-
is_available( k+1 , t+q )):
774-
return brouwer_separable_design, (k,t,q,x)
770+
is_available(k, x) and
771+
is_available(k+e2, t+1)
772+
and is_available(k+1, t+q)):
773+
return brouwer_separable_design, (k, t, q, x)
775774

776775
# iv)
777776
elif (x == q**2+1 and
778-
is_available( k , x ) and
779-
is_available( k+e4, t+1 ) and
780-
is_available( k+1 ,t+q+1)):
781-
return brouwer_separable_design, (k,t,q,x)
777+
is_available(k, x) and
778+
is_available(k+e4, t+1) and
779+
is_available(k+1 ,t+q+1)):
780+
return brouwer_separable_design, (k, t, q, x)
782781

783782
# v)
784783
elif (0<x and x<q**2-q+1-t and (e1 or e2) and
785-
is_available( k , x ) and
786-
is_available( k+e1, t ) and
787-
is_available( k+e2, t+1 ) and
788-
is_available( k+1 , t+q )):
789-
return brouwer_separable_design, (k,t,q,x)
784+
is_available(k, x) and
785+
is_available(k+e1, t) and
786+
is_available(k+e2, t+1) and
787+
is_available(k+1, t+q)):
788+
return brouwer_separable_design, (k, t, q, x)
790789

791790
# vi)
792791
elif (t+q<x and x<q**2+1 and (e3 or e4) and
793-
is_available( k , x ) and
794-
is_available( k+e3, t ) and
795-
is_available( k+e4, t+1 ) and
796-
is_available( k+1 ,t+q+1)):
797-
return brouwer_separable_design, (k,t,q,x)
792+
is_available(k, x) and
793+
is_available(k+e3, t) and
794+
is_available(k+e4, t+1) and
795+
is_available(k+1, t+q+1)):
796+
return brouwer_separable_design, (k, t, q, x)
798797

799798
return False
800799

@@ -808,7 +807,7 @@ for x in _QDM.itervalues():
808807
if u>1:
809808
if n not in ioa_indexed_by_n_minus_x:
810809
ioa_indexed_by_n_minus_x[n] = []
811-
ioa_indexed_by_n_minus_x[n].append((k,u))
810+
ioa_indexed_by_n_minus_x[n].append((k, u))
812811

813812

814813
def int_as_sum(int value, list S, int k_max):

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,12 @@ cdef inline int SC_realloc_gens(StabilizerChain *SC, int level, int size) noexce
629629
cdef int *temp
630630
cdef int n = SC.degree
631631

632-
temp = <int *> sig_realloc( SC.generators[level], n * size * sizeof(int) )
632+
temp = <int *> sig_realloc(SC.generators[level], n * size * sizeof(int))
633633
if temp is NULL:
634634
return 1
635635
SC.generators[level] = temp
636636

637-
temp = <int *> sig_realloc( SC.gen_inverses[level], n * size * sizeof(int) )
637+
temp = <int *> sig_realloc(SC.gen_inverses[level], n * size * sizeof(int))
638638
if temp is NULL:
639639
return 1
640640
SC.gen_inverses[level] = temp

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@ cdef int double_coset(void *S1, void *S2, PartitionStack *partition1, int *order
400400
cdef bint unknown = 1
401401

402402
# set up the identity permutation
403-
for i from 0 <= i < n:
403+
for i in range(n):
404404
id_perm[i] = i
405405
if ordering2 is NULL:
406406
ordering2 = id_perm
407407

408408
# Copy reordering of left_ps coming from ordering2 to current_ps.
409-
memcpy(current_ps.entries, ordering2, n*sizeof(int))
410-
memcpy(current_ps.levels, left_ps.levels, n*sizeof(int))
409+
memcpy(current_ps.entries, ordering2, n * sizeof(int))
410+
memcpy(current_ps.levels, left_ps.levels, n * sizeof(int))
411411
current_ps.depth = left_ps.depth
412412

413413
# default values of "infinity"

src/sage/matrix/action.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,10 @@ cdef class MatrixMatrixAction(MatrixMulAction):
195195
Nonetheless, there is no guarantee that the set that is acted upon
196196
will always be cached in such a way, so that following the above
197197
example is good practice.
198-
199198
"""
200199
if self.G.ncols() != self.underlying_set().nrows():
201200
raise TypeError("incompatible dimensions %s, %s" %
202-
(self.G.ncols(), self.underlying_set().nrows()))
201+
(self.G.ncols(), self.underlying_set().nrows()))
203202
return MatrixSpace(base, self.G.nrows(), self.underlying_set().ncols(),
204203
sparse = self.G.is_sparse() and self.underlying_set().is_sparse())
205204

src/sage/matrix/matrix0.pyx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ cdef class Matrix(sage.structure.element.Matrix):
23502350
for i from 0 <= i < n:
23512351
tmp = []
23522352
for j from 0 <= j < n:
2353-
tmp.append(self.get_unsafe(i,j)*vars[j])
2353+
tmp.append(self.get_unsafe(i, j)*vars[j])
23542354
ans.append( sum(tmp) )
23552355
return f(tuple(ans))
23562356

@@ -2912,7 +2912,7 @@ cdef class Matrix(sage.structure.element.Matrix):
29122912
"""
29132913
return self.with_permuted_rows(row_permutation).with_permuted_columns(column_permutation)
29142914

2915-
def add_multiple_of_row(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col=0):
2915+
def add_multiple_of_row(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col=0):
29162916
"""
29172917
Add s times row j to row i.
29182918
@@ -2943,19 +2943,19 @@ cdef class Matrix(sage.structure.element.Matrix):
29432943
TypeError: Multiplying row by Symbolic Ring element cannot be done over
29442944
Rational Field, use change_ring or with_added_multiple_of_row instead.
29452945
"""
2946-
self.check_row_bounds_and_mutability(i,j)
2946+
self.check_row_bounds_and_mutability(i, j)
29472947
try:
29482948
s = self._coerce_element(s)
29492949
self.add_multiple_of_row_c(i, j, s, start_col)
29502950
except TypeError:
29512951
raise TypeError('Multiplying row by %s element cannot be done over %s, use change_ring or with_added_multiple_of_row instead.' % (s.parent(), self.base_ring()))
29522952

2953-
cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col) noexcept:
2953+
cdef add_multiple_of_row_c(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col) noexcept:
29542954
cdef Py_ssize_t c
29552955
for c from start_col <= c < self._ncols:
29562956
self.set_unsafe(i, c, self.get_unsafe(i, c) + s*self.get_unsafe(j, c))
29572957

2958-
def with_added_multiple_of_row(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col=0):
2958+
def with_added_multiple_of_row(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_col=0):
29592959
"""
29602960
Add s times row j to row i, returning new matrix.
29612961
@@ -2983,7 +2983,7 @@ cdef class Matrix(sage.structure.element.Matrix):
29832983
[ 3 4 5]
29842984
"""
29852985
cdef Matrix temp
2986-
self.check_row_bounds_and_mutability(i,j)
2986+
self.check_row_bounds_and_mutability(i, j)
29872987
try:
29882988
s = self._coerce_element(s)
29892989
temp = self.__copy__()
@@ -3028,7 +3028,7 @@ cdef class Matrix(sage.structure.element.Matrix):
30283028
TypeError: Multiplying column by Symbolic Ring element cannot be done over
30293029
Rational Field, use change_ring or with_added_multiple_of_column instead.
30303030
"""
3031-
self.check_column_bounds_and_mutability(i,j)
3031+
self.check_column_bounds_and_mutability(i, j)
30323032
try:
30333033
s = self._coerce_element(s)
30343034
self.add_multiple_of_column_c(i, j, s, start_row)
@@ -3040,7 +3040,7 @@ cdef class Matrix(sage.structure.element.Matrix):
30403040
for r from start_row <= r < self._nrows:
30413041
self.set_unsafe(r, i, self.get_unsafe(r, i) + s*self.get_unsafe(r, j))
30423042

3043-
def with_added_multiple_of_column(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_row=0):
3043+
def with_added_multiple_of_column(self, Py_ssize_t i, Py_ssize_t j, s, Py_ssize_t start_row=0):
30443044
"""
30453045
Add s times column j to column i, returning new matrix.
30463046
@@ -3068,7 +3068,7 @@ cdef class Matrix(sage.structure.element.Matrix):
30683068
[13/3 4 5]
30693069
"""
30703070
cdef Matrix temp
3071-
self.check_column_bounds_and_mutability(i,j)
3071+
self.check_column_bounds_and_mutability(i, j)
30723072
try:
30733073
s = self._coerce_element(s)
30743074
temp = self.__copy__()
@@ -3335,7 +3335,7 @@ cdef class Matrix(sage.structure.element.Matrix):
33353335
...
33363336
TypeError: Multiplying row by Rational Field element cannot be done over Integer Ring, use change_ring or with_row_set_to_multiple_of_row instead.
33373337
"""
3338-
self.check_row_bounds_and_mutability(i,j)
3338+
self.check_row_bounds_and_mutability(i, j)
33393339
cdef Py_ssize_t n
33403340
try:
33413341
s = self._coerce_element(s)
@@ -3370,7 +3370,7 @@ cdef class Matrix(sage.structure.element.Matrix):
33703370
[ 0 1 2]
33713371
[ 0 1/2 1]
33723372
"""
3373-
self.check_row_bounds_and_mutability(i,j)
3373+
self.check_row_bounds_and_mutability(i, j)
33743374
cdef Matrix temp
33753375
cdef Py_ssize_t n
33763376
try:
@@ -3413,7 +3413,7 @@ cdef class Matrix(sage.structure.element.Matrix):
34133413
...
34143414
TypeError: Multiplying column by Rational Field element cannot be done over Integer Ring, use change_ring or with_col_set_to_multiple_of_col instead.
34153415
"""
3416-
self.check_column_bounds_and_mutability(i,j)
3416+
self.check_column_bounds_and_mutability(i, j)
34173417
cdef Py_ssize_t n
34183418
try:
34193419
s = self._coerce_element(s)
@@ -3453,7 +3453,7 @@ cdef class Matrix(sage.structure.element.Matrix):
34533453
[ 0 0 2]
34543454
[ 3 3/2 5]
34553455
"""
3456-
self.check_column_bounds_and_mutability(i,j)
3456+
self.check_column_bounds_and_mutability(i, j)
34573457
cdef Py_ssize_t n
34583458
cdef Matrix temp
34593459
try:
@@ -3706,7 +3706,7 @@ cdef class Matrix(sage.structure.element.Matrix):
37063706
if positive and not d[i] > 0:
37073707
return False
37083708
for j in d:
3709-
if d[i] * self.get_unsafe(i,j) != sign * d[j] * self.get_unsafe(j,i):
3709+
if d[i] * self.get_unsafe(i, j) != sign * d[j] * self.get_unsafe(j,i):
37103710
return False
37113711
return L
37123712

@@ -3959,11 +3959,11 @@ cdef class Matrix(sage.structure.element.Matrix):
39593959
if self._ncols != self._nrows: return False
39603960
# could be bigger than an int on a 64-bit platform, this
39613961
# is the type used for indexing.
3962-
cdef Py_ssize_t i,j
3962+
cdef Py_ssize_t i, j
39633963

39643964
for i from 0 <= i < self._nrows:
39653965
for j from 0 <= j < i:
3966-
if self.get_unsafe(i,j) != self.get_unsafe(j,i):
3966+
if self.get_unsafe(i, j) != self.get_unsafe(j, i):
39673967
return False
39683968
return True
39693969

@@ -4072,7 +4072,7 @@ cdef class Matrix(sage.structure.element.Matrix):
40724072

40734073
tolerance = self.base_ring()(tolerance)
40744074
cdef bint tolerance_is_zero = tolerance.is_zero()
4075-
cdef Py_ssize_t i,j
4075+
cdef Py_ssize_t i, j
40764076

40774077
if self.is_sparse_c():
40784078
# The dense algorithm checks all of the on-or-below-diagonal
@@ -4086,12 +4086,12 @@ cdef class Matrix(sage.structure.element.Matrix):
40864086
# copy, so it's important that we don't modify it.
40874087
entries = self._nonzero_positions_by_row(copy=False)
40884088
else:
4089-
entries = ( (i,j) for i in range(self._nrows)
4090-
for j in range(i+1) )
4089+
entries = ((i, j) for i in range(self._nrows)
4090+
for j in range(i + 1))
40914091

4092-
for (i,j) in entries:
4093-
entry_a = self.get_unsafe(i,j)
4094-
entry_b = s*self.get_unsafe(j,i).conjugate()
4092+
for (i, j) in entries:
4093+
entry_a = self.get_unsafe(i, j)
4094+
entry_b = s*self.get_unsafe(j, i).conjugate()
40954095

40964096
if tolerance_is_zero:
40974097
# When the tolerance is exactly zero, as will
@@ -4293,11 +4293,11 @@ cdef class Matrix(sage.structure.element.Matrix):
42934293
if self._ncols != self._nrows: return False
42944294
# could be bigger than an int on a 64-bit platform, this
42954295
# is the type used for indexing.
4296-
cdef Py_ssize_t i,j
4296+
cdef Py_ssize_t i, j
42974297

42984298
for i from 0 <= i < self._nrows:
42994299
for j from 0 <= j <= i:
4300-
if self.get_unsafe(i,j) != -self.get_unsafe(j,i):
4300+
if self.get_unsafe(i, j) != -self.get_unsafe(j,i):
43014301
return False
43024302
return True
43034303

@@ -4336,14 +4336,14 @@ cdef class Matrix(sage.structure.element.Matrix):
43364336
if self._ncols != self._nrows: return False
43374337
# could be bigger than an int on a 64-bit platform, this
43384338
# is the type used for indexing.
4339-
cdef Py_ssize_t i,j
4339+
cdef Py_ssize_t i, j
43404340

43414341
zero = self._base_ring.zero()
43424342
for i from 0 <= i < self._nrows:
43434343
for j from 0 <= j < i:
4344-
if self.get_unsafe(i,j) != -self.get_unsafe(j,i):
4344+
if self.get_unsafe(i, j) != -self.get_unsafe(j, i):
43454345
return False
4346-
if not self.get_unsafe(i,i) == zero:
4346+
if not self.get_unsafe(i, i) == zero:
43474347
return False
43484348
return True
43494349

@@ -4803,8 +4803,8 @@ cdef class Matrix(sage.structure.element.Matrix):
48034803
nzp = []
48044804
for j from 0 <= j < self._ncols:
48054805
for i from 0 <= i < self._nrows:
4806-
if not self.get_is_zero_unsafe(i,j):
4807-
nzp.append((i,j))
4806+
if not self.get_is_zero_unsafe(i, j):
4807+
nzp.append((i, j))
48084808
self.cache('nonzero_positions_by_column', nzp)
48094809
if copy:
48104810
return list(nzp)
@@ -4882,7 +4882,7 @@ cdef class Matrix(sage.structure.element.Matrix):
48824882
tmp = []
48834883

48844884
for j from 0 <= j < self._ncols:
4885-
if not self.get_is_zero_unsafe(i,j):
4885+
if not self.get_is_zero_unsafe(i, j):
48864886
tmp.append(j)
48874887
return tmp
48884888

@@ -5227,7 +5227,7 @@ cdef class Matrix(sage.structure.element.Matrix):
52275227
A = self.new_matrix()
52285228
for i in range(self._nrows):
52295229
for j in range(self._ncols):
5230-
A.set_unsafe(i,j,self.get_unsafe(i,j)._add_(right.get_unsafe(i,j)))
5230+
A.set_unsafe(i, j, self.get_unsafe(i,j)._add_(right.get_unsafe(i,j)))
52315231
return A
52325232

52335233
cpdef _sub_(self, _right) noexcept:

src/sage/matrix/matrix_cyclo_dense.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
661661
prod *= p
662662
Amodp, _ = self._reductions(p)
663663
Bmodp, _ = right._reductions(p)
664-
_, S = self._reduction_matrix(p)
664+
_, S = self._reduction_matrix(p)
665665
X = Amodp[0]._matrix_from_rows_of_matrices([Amodp[i] * Bmodp[i] for i in range(len(Amodp))])
666666
v.append(S*X)
667667
p = previous_prime(p)

src/sage/matrix/matrix_gf2e_dense.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
10331033
cdef m4ri_word x = poly_to_word(multiple)
10341034
mzed_rescale_row(self._entries, row, start_col, x)
10351035

1036-
1037-
cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept:
1036+
cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept:
10381037
"""
10391038
Compute ``self[row_to][start_col:] += multiple * self[row_from][start_col:]``.
10401039

src/sage/matrix/matrix_gfpn_dense.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ cdef class Matrix_gfpn_dense(Matrix_dense):
10421042
FfSetNoc(noc)
10431043
FfMulRow(row_head, c)
10441044

1045-
cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept:
1045+
cdef add_multiple_of_row_c(self, Py_ssize_t row_to, Py_ssize_t row_from, multiple, Py_ssize_t start_col) noexcept:
10461046
"""
10471047
Add the ``multiple``-fold of row ``row_from`` in-place to row ``row_to``, beginning with ``start_col``
10481048

0 commit comments

Comments
 (0)