Skip to content

Commit 9cff81c

Browse files
author
Release Manager
committed
Trac #34921: fix E714 in pyx files inside matrix/
about using "is not" following #34895 URL: https://trac.sagemath.org/34921 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents e52e968 + c621882 commit 9cff81c

12 files changed

+62
-57
lines changed

src/sage/matrix/matrix0.pyx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ cdef class Matrix(sage.structure.element.Matrix):
204204
cdef Py_ssize_t i, j
205205

206206
x = self.fetch('list')
207-
if not x is None:
207+
if x is not None:
208208
return x
209209
x = []
210210
for i from 0 <= i < self._nrows:
@@ -309,7 +309,7 @@ cdef class Matrix(sage.structure.element.Matrix):
309309
[ 3 4 10]
310310
"""
311311
d = self.fetch('dict')
312-
if not d is None:
312+
if d is not None:
313313
return d
314314

315315
cdef Py_ssize_t i, j
@@ -4612,7 +4612,8 @@ cdef class Matrix(sage.structure.element.Matrix):
46124612
(0, 1)
46134613
"""
46144614
x = self.fetch('pivots')
4615-
if not x is None: return tuple(x)
4615+
if x is not None:
4616+
return tuple(x)
46164617
self.echelon_form()
46174618
x = self.fetch('pivots')
46184619
if x is None:
@@ -4650,10 +4651,10 @@ cdef class Matrix(sage.structure.element.Matrix):
46504651
....: [8*x^2 + 12*x + 15, 8*x^2 + 9*x + 16] ])
46514652
sage: m.rank()
46524653
2
4653-
46544654
"""
46554655
x = self.fetch('rank')
4656-
if not x is None: return x
4656+
if x is not None:
4657+
return x
46574658
if self._nrows == 0 or self._ncols == 0:
46584659
return 0
46594660
r = len(self.pivots())
@@ -4681,12 +4682,13 @@ cdef class Matrix(sage.structure.element.Matrix):
46814682
(2,)
46824683
"""
46834684
x = self.fetch('nonpivots')
4684-
if not x is None: return tuple(x)
4685+
if x is not None:
4686+
return tuple(x)
46854687

46864688
X = set(self.pivots())
46874689
np = []
46884690
for j in xrange(self.ncols()):
4689-
if not (j in X):
4691+
if j not in X:
46904692
np.append(j)
46914693
np = tuple(np)
46924694
self.cache('nonpivots',np)
@@ -4777,7 +4779,7 @@ cdef class Matrix(sage.structure.element.Matrix):
47774779
[(0, 0), (1, 0), (1, 1), (0, 2)]
47784780
"""
47794781
x = self.fetch('nonzero_positions_by_column')
4780-
if not x is None:
4782+
if x is not None:
47814783
if copy:
47824784
return list(x)
47834785
return x

src/sage/matrix/matrix2.pyx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ cdef class Matrix(Matrix1):
27982798
(y + 1) * (y + 2)^2
27992799
"""
28002800
f = self.fetch('minpoly')
2801-
if not f is None:
2801+
if f is not None:
28022802
return f.change_variable_name(var)
28032803
f = self.charpoly(var=var, **kwds)
28042804
try:
@@ -3418,7 +3418,7 @@ cdef class Matrix(Matrix1):
34183418
TypeError: Hessenbergize only possible for matrices over a field
34193419
"""
34203420
X = self.fetch('hessenberg_form')
3421-
if not X is None:
3421+
if X is not None:
34223422
return X
34233423
R = self._base_ring
34243424
if R not in _Fields:
@@ -4440,7 +4440,7 @@ cdef class Matrix(Matrix1):
44404440

44414441
# Determine proof keyword for integer matrices
44424442
proof = kwds.pop('proof', None)
4443-
if not (proof in [None, True, False]):
4443+
if proof not in [None, True, False]:
44444444
raise ValueError("'proof' must be one of True, False or None, not %s" % proof)
44454445
if not (proof is None or is_IntegerRing(R)):
44464446
raise ValueError("'proof' flag only valid for matrices over the integers")
@@ -4851,7 +4851,7 @@ cdef class Matrix(Matrix1):
48514851
True
48524852
"""
48534853
K = self.fetch('right_kernel')
4854-
if not K is None:
4854+
if K is not None:
48554855
verbose("retrieving cached right kernel for %sx%s matrix" % (self.nrows(), self.ncols()),level=1)
48564856
return K
48574857

@@ -5027,7 +5027,7 @@ cdef class Matrix(Matrix1):
50275027
True
50285028
"""
50295029
K = self.fetch('left_kernel')
5030-
if not K is None:
5030+
if K is not None:
50315031
verbose("retrieving cached left kernel for %sx%s matrix" % (self.nrows(), self.ncols()),level=1)
50325032
return K
50335033

@@ -5124,7 +5124,7 @@ cdef class Matrix(Matrix1):
51245124
True
51255125
"""
51265126
A = self.restrict(V, check=check)
5127-
if not poly is None:
5127+
if poly is not None:
51285128
A = poly(A)
51295129
W = A.kernel()
51305130
if V.is_ambient():
@@ -6266,7 +6266,7 @@ cdef class Matrix(Matrix1):
62666266

62676267
key = 'eigenspaces_left_' + format + '{0}'.format(var)
62686268
x = self.fetch(key)
6269-
if not x is None:
6269+
if x is not None:
62706270
if algebraic_multiplicity:
62716271
return x
62726272
else:
@@ -6508,7 +6508,7 @@ cdef class Matrix(Matrix1):
65086508

65096509
key = 'eigenspaces_right_' + format + '{0}'.format(var)
65106510
x = self.fetch(key)
6511-
if not x is None:
6511+
if x is not None:
65126512
if algebraic_multiplicity:
65136513
return x
65146514
else:
@@ -6746,7 +6746,7 @@ cdef class Matrix(Matrix1):
67466746
% self.base_ring())
67476747

67486748
x = self.fetch('eigenvectors_left')
6749-
if not x is None:
6749+
if x is not None:
67506750
return x
67516751

67526752
if not self.base_ring().is_exact():
@@ -7805,7 +7805,7 @@ cdef class Matrix(Matrix1):
78057805
[0.000 1.00 1.00]
78067806
"""
78077807
E = self.fetch('echelon_' + algorithm)
7808-
if not E is None:
7808+
if E is not None:
78097809
return E
78107810
E = self.__copy__()
78117811
E._echelon_in_place(algorithm)
@@ -8591,7 +8591,7 @@ cdef class Matrix(Matrix1):
85918591
"""
85928592
if self._ncols != right._nrows:
85938593
raise ArithmeticError("Number of columns of self must equal number of rows of right.")
8594-
if not self._base_ring is right.base_ring():
8594+
if self._base_ring is not right.base_ring():
85958595
raise TypeError("Base rings must be the same.")
85968596

85978597
if cutoff == 0:
@@ -9643,7 +9643,7 @@ cdef class Matrix(Matrix1):
96439643
"""
96449644
key = 'normal'
96459645
n = self.fetch(key)
9646-
if not n is None:
9646+
if n is not None:
96479647
return n
96489648
if not self.is_square():
96499649
self.cache(key, False)
@@ -9951,12 +9951,11 @@ cdef class Matrix(Matrix1):
99519951

99529952
The result is cached.
99539953
"""
9954-
99559954
if self._nrows != self._ncols:
99569955
raise ValueError("must be a square matrix")
99579956

99589957
X = self.fetch('adjugate')
9959-
if not X is None:
9958+
if X is not None:
99609959
return X
99619960

99629961
X = self._adjugate()
@@ -12402,7 +12401,7 @@ cdef class Matrix(Matrix1):
1240212401

1240312402
iterates, poly, augmented, pivots = self._cyclic_subspace(v)
1240412403
k = len(pivots)
12405-
polynomial = not var is None
12404+
polynomial = (var is not None)
1240612405
if polynomial:
1240712406
x = sage.rings.polynomial.polynomial_ring.polygen(R, var)
1240812407
poly = sum([poly[i] * x**i for i in range(len(poly))])

src/sage/matrix/matrix_double_dense.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
10311031
return P, L, U
10321032

10331033
PLU = self.fetch('PLU_factors')
1034-
if not PLU is None:
1034+
if PLU is not None:
10351035
return PLU
10361036
if scipy is None:
10371037
import scipy
@@ -2351,7 +2351,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
23512351
raise ValueError("algorithm must be 'naive' or 'orthonormal', not {0}".format(algorithm))
23522352
key = 'unitary_{0}_{1}'.format(algorithm, tol)
23532353
b = self.fetch(key)
2354-
if not b is None:
2354+
if b is not None:
23552355
return b
23562356
if not self.is_square():
23572357
self.cache(key, False)
@@ -2479,7 +2479,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
24792479

24802480
key = ("_is_hermitian_orthonormal", tol, skew)
24812481
h = self.fetch(key)
2482-
if not h is None:
2482+
if h is not None:
24832483
return h
24842484
if not self.is_square():
24852485
self.cache(key, False)
@@ -2910,7 +2910,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
29102910

29112911
key = 'normal_{0}_{1}'.format(algorithm, tol)
29122912
b = self.fetch(key)
2913-
if not b is None:
2913+
if b is not None:
29142914
return b
29152915
if not self.is_square():
29162916
self.cache(key, False)
@@ -3214,7 +3214,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense):
32143214
format = 'real'
32153215

32163216
schur = self.fetch('schur_factors_' + format)
3217-
if not schur is None:
3217+
if schur is not None:
32183218
return schur
32193219
if scipy is None:
32203220
import scipy

src/sage/matrix/matrix_gf2e_dense.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
903903
full = int(reduced)
904904

905905
x = self.fetch('in_echelon_form')
906-
if not x is None: return # already known to be in echelon form
906+
if x is not None:
907+
return # already known to be in echelon form
907908

908909
self.check_mutability()
909910
self.clear_cache()
@@ -1335,7 +1336,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
13351336
0
13361337
"""
13371338
x = self.fetch('rank')
1338-
if not x is None:
1339+
if x is not None:
13391340
return x
13401341
if self._nrows == 0 or self._ncols == 0:
13411342
return 0
@@ -1517,6 +1518,7 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
15171518
mzed_cling(self._entries, v)
15181519
mzd_slice_free(v)
15191520

1521+
15201522
def unpickle_matrix_gf2e_dense_v0(Matrix_mod2_dense a, base_ring, nrows, ncols):
15211523
r"""
15221524
EXAMPLES::

src/sage/matrix/matrix_integer_dense.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
22692269
[ 0 0 0]
22702270
"""
22712271
p = self.fetch('pivots')
2272-
if not p is None:
2272+
if p is not None:
22732273
return tuple(p)
22742274

22752275
cdef Matrix_integer_dense E
@@ -3582,7 +3582,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
35823582
"or 'linbox'")
35833583

35843584
r = self.fetch('rank')
3585-
if not r is None:
3585+
if r is not None:
35863586
return r
35873587

35883588
if algorithm == 'flint' or (self._nrows <= 6 and self._ncols <= 6

src/sage/matrix/matrix_integer_sparse.pyx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
219219
be dangerous if you change entries of the returned dict.
220220
"""
221221
d = self.fetch('dict')
222-
if not d is None:
222+
if d is not None:
223223
return d
224224

225225
cdef Py_ssize_t i, j, k
@@ -311,10 +311,9 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
311311
[0 1 0 0 0 0 1 0]
312312
sage: M._nonzero_positions_by_row()
313313
[(0, 3), (1, 1), (1, 6)]
314-
315314
"""
316315
x = self.fetch('nonzero_positions')
317-
if not x is None:
316+
if x is not None:
318317
if copy:
319318
return list(x)
320319
return x
@@ -343,10 +342,9 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
343342
[0 1 0 0 0 0 1 0]
344343
sage: M._nonzero_positions_by_column()
345344
[(1, 1), (0, 3), (1, 6)]
346-
347345
"""
348346
x = self.fetch('nonzero_positions_by_column')
349-
if not x is None:
347+
if x is not None:
350348
if copy:
351349
return list(x)
352350
return x

src/sage/matrix/matrix_mod2_dense.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,8 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
10401040
full = int(reduced)
10411041

10421042
x = self.fetch('in_echelon_form')
1043-
if not x is None: return # already known to be in echelon form
1043+
if x is not None:
1044+
return # already known to be in echelon form
10441045

10451046
if algorithm == 'heuristic':
10461047

@@ -1839,7 +1840,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
18391840
0
18401841
"""
18411842
x = self.fetch('rank')
1842-
if not x is None:
1843+
if x is not None:
18431844
return x
18441845
if self._nrows == 0 or self._ncols == 0:
18451846
return 0

src/sage/matrix/matrix_modn_sparse.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
231231
Finite Field of size 13
232232
"""
233233
d = self.fetch('dict')
234-
if not d is None:
234+
if d is not None:
235235
return d
236236

237237
cdef Py_ssize_t i, j, k
@@ -427,7 +427,8 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
427427
"""
428428
from sage.misc.verbose import verbose, get_verbose
429429
x = self.fetch('in_echelon_form')
430-
if not x is None and x: return # already known to be in echelon form
430+
if x is not None and x:
431+
return # already known to be in echelon form
431432
self.check_mutability()
432433

433434
cdef Py_ssize_t i, r, c, min, min_row, start_row
@@ -501,7 +502,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
501502
[(0, 3), (1, 1), (1, 6)]
502503
"""
503504
x = self.fetch('nonzero_positions')
504-
if not x is None:
505+
if x is not None:
505506
if copy:
506507
return list(x)
507508
return x

0 commit comments

Comments
 (0)