Skip to content

Commit 2d47da7

Browse files
committed
fix and activate pycodestyle E301 in pyx files
1 parent 0fd5967 commit 2d47da7

30 files changed

+142
-137
lines changed

src/sage/graphs/edge_connectivity.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,6 @@ cdef class GabowEdgeConnectivity:
11971197
raise ValueError("the value of the edge connectivity has not been "
11981198
"properly computed. This may result from an interruption")
11991199

1200-
12011200
#
12021201
# Packing arborescences
12031202
#

src/sage/libs/giac/giac.pyx

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,11 +1266,10 @@ cdef class Pygen(GiacMethods_base):
12661266
GIAC_archive( <string>encstring23(filename), (<Pygen>self).gptr[0], context_ptr)
12671267
sig_off()
12681268
1269-
1270-
12711269
# NB: with giac <= 1.2.3-57 redim doesn't have a non evaluated for so Pygen('redim') fails.
12721270
# hence replacement for redim:
1273-
def redim(self,a,b=None):
1271+
1272+
def redim(self, a, b=None):
12741273
"""
12751274
Increase the size of a matrix when possible, otherwise return self.
12761275
@@ -1677,11 +1676,11 @@ cdef class Pygen(GiacMethods_base):
16771676
xyplot=[[(u.real())._double,(u.im())._double] for u in l]
16781677
16791678
1680-
if (xyscat != []):
1681-
result=scatter_plot(xyscat)
1679+
if xyscat:
1680+
result = scatter_plot(xyscat)
16821681
16831682
else:
1684-
result=line(xyplot)
1683+
result = line(xyplot)
16851684
sig_off()
16861685
16871686
return result
@@ -1695,11 +1694,11 @@ cdef class Pygen(GiacMethods_base):
16951694
#
16961695
# # # # # # # # # # # # # # # # # # # # # # # # #
16971696
1698-
def __richcmp__( self, other,op):
1697+
def __richcmp__(self, other, op):
16991698
if not isinstance(other, Pygen):
1700-
other=Pygen(other)
1699+
other = Pygen(other)
17011700
if not isinstance(self, Pygen):
1702-
self=Pygen(self)
1701+
self = Pygen(self)
17031702
sig_on()
17041703
result= giacgenrichcmp((<Pygen>self).gptr[0],(<Pygen>other).gptr[0], op, context_ptr )
17051704
sig_off()
@@ -1708,10 +1707,11 @@ cdef class Pygen(GiacMethods_base):
17081707
#
17091708
# Some attributes of the gen class:
17101709
#
1710+
17111711
property _type:
17121712
def __get__(self):
17131713
sig_on()
1714-
result=self.gptr.type
1714+
result = self.gptr.type
17151715
sig_off()
17161716
return result
17171717
@@ -1723,30 +1723,27 @@ cdef class Pygen(GiacMethods_base):
17231723
sig_off()
17241724
return result
17251725
1726-
1727-
17281726
property _val: # immediate int (type _INT_)
17291727
"""
17301728
immediate int value of an _INT_ type gen.
17311729
"""
17321730
def __get__(self):
1733-
if(self._type == 0):
1731+
if self._type == 0:
17341732
sig_on()
1735-
result=self.gptr.val
1733+
result = self.gptr.val
17361734
sig_off()
17371735
return result
17381736
else:
17391737
raise TypeError("cannot convert non _INT_ giac gen")
17401738
1741-
17421739
property _double: # immediate double (type _DOUBLE_)
17431740
"""
17441741
immediate conversion to float for a gen of _DOUBLE_ type.
17451742
"""
17461743
def __get__(self):
1747-
if(self._type == 1):
1744+
if self._type == 1:
17481745
sig_on()
1749-
result=self.gptr._DOUBLE_val
1746+
result = self.gptr._DOUBLE_val
17501747
sig_off()
17511748
return result
17521749
else:
@@ -1756,8 +1753,6 @@ cdef class Pygen(GiacMethods_base):
17561753
def __get__(self):
17571754
return self._help()
17581755
1759-
1760-
17611756
###################################################
17621757
# Add the others methods
17631758
###################################################
@@ -1767,30 +1762,22 @@ cdef class Pygen(GiacMethods_base):
17671762
#
17681763
# def __getattr__(self, name):
17691764
# return GiacMethods[str(name)](self)
1770-
##
17711765
1766+
# test
17721767
1773-
#test
17741768
def giacAiry_Ai(self, *args):
1775-
cdef gen result=GIAC_Airy_Ai(self.gptr[0], context_ptr)
1769+
cdef gen result = GIAC_Airy_Ai(self.gptr[0], context_ptr)
17761770
return _wrap_gen(result)
17771771
17781772
def giacifactor(self, *args):
17791773
cdef gen result
17801774
sig_on()
1781-
result=GIAC_eval(self.gptr[0], <int>1, context_ptr)
1782-
result=GIAC_ifactor(result, context_ptr)
1775+
result = GIAC_eval(self.gptr[0], <int>1, context_ptr)
1776+
result = GIAC_ifactor(result, context_ptr)
17831777
sig_off()
17841778
return _wrap_gen(result)
17851779
17861780
1787-
1788-
1789-
1790-
1791-
1792-
1793-
##
17941781
################################################################
17951782
# A wrapper from a cpp element of type giac gen to create #
17961783
# the Python object #

src/sage/matrix/constructor.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,13 @@ def matrix(*args, **kwds):
645645
M.set_immutable()
646646
return M
647647

648+
648649
Matrix = matrix
649650

651+
650652
from .special import *
651653

654+
652655
@matrix_method
653656
class options(GlobalOptions):
654657
r"""

src/sage/matrix/matrix0.pyx

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -581,26 +581,25 @@ cdef class Matrix(sage.structure.element.Matrix):
581581

582582
self.set_unsafe(i, j, elt + self.get_unsafe(i, j))
583583

584-
585-
## def _get_very_unsafe(self, i, j):
586-
## r"""
587-
## Entry access, but potentially fast since it might be without
588-
## bounds checking. (I know of no cases where this is actually
589-
## faster.)
590-
591-
## This function it can very easily !! SEG FAULT !! if you call
592-
## it with invalid input. Use with *extreme* caution.
593-
594-
## EXAMPLES::
595-
##
596-
## sage: a = matrix(ZZ,2,range(4))
597-
## sage: a._get_very_unsafe(0,1)
598-
## 1
599-
600-
## If you do \code{a.\_get\_very\_unsafe(0,10)} you'll very likely crash Sage
601-
## completely.
602-
## """
603-
## return self.get_unsafe(i, j)
584+
## def _get_very_unsafe(self, i, j):
585+
## r"""
586+
## Entry access, but potentially fast since it might be without
587+
## bounds checking. (I know of no cases where this is actually
588+
## faster.)
589+
590+
## This function it can very easily !! SEG FAULT !! if you call
591+
## it with invalid input. Use with *extreme* caution.
592+
593+
## EXAMPLES::
594+
##
595+
## sage: a = matrix(ZZ,2,range(4))
596+
## sage: a._get_very_unsafe(0,1)
597+
## 1
598+
599+
## If you do \code{a.\_get\_very\_unsafe(0,10)} you'll very likely crash Sage
600+
## completely.
601+
## """
602+
## return self.get_unsafe(i, j)
604603

605604
def __iter__(self):
606605
"""
@@ -2239,11 +2238,10 @@ cdef class Matrix(sage.structure.element.Matrix):
22392238

22402239
return "\\left" + matrix_delimiters[0] + "\\begin{array}{%s}\n"%format + s + "\n\\end{array}\\right" + matrix_delimiters[1]
22412240

2242-
2243-
22442241
###################################################
22452242
## Basic Properties
22462243
###################################################
2244+
22472245
def ncols(self):
22482246
"""
22492247
Return the number of columns of this matrix.
@@ -2311,22 +2309,20 @@ cdef class Matrix(sage.structure.element.Matrix):
23112309
"""
23122310
return (self._nrows,self._ncols)
23132311

2314-
23152312
###################################################
23162313
# Functions
23172314
###################################################
2315+
23182316
def act_on_polynomial(self, f):
23192317
r"""
23202318
Return the polynomial f(self\*x).
23212319
23222320
INPUT:
23232321
2324-
23252322
- ``self`` - an nxn matrix
23262323
23272324
- ``f`` - a polynomial in n variables x=(x1,...,xn)
23282325
2329-
23302326
OUTPUT: The polynomial f(self\*x).
23312327
23322328
EXAMPLES::

src/sage/matrix/matrix1.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,10 +1461,10 @@ cdef class Matrix(Matrix0):
14611461
tmp = [self.get_unsafe(i,j) for j in range(self._ncols)]
14621462
return V(tmp, coerce=False, copy=False, check=False)
14631463

1464-
14651464
###########################################################################
14661465
# Building matrices out of other matrices, rows, or columns
14671466
###########################################################################
1467+
14681468
def stack(self, bottom, subdivide=False):
14691469
r"""
14701470
Return a new matrix formed by appending the matrix (or vector)
@@ -2521,10 +2521,9 @@ cdef class Matrix(Matrix0):
25212521
M.set_unsafe(i, j, one)
25222522
return M
25232523

2524-
2525-
####################################################################################
2524+
######################################################################
25262525
# Change of representation between dense and sparse.
2527-
####################################################################################
2526+
######################################################################
25282527

25292528
def dense_matrix(self):
25302529
"""

src/sage/matrix/matrix2.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def ideal_or_fractional(R, *args):
112112
R = R.number_field()
113113
return R.ideal(*args)
114114

115+
115116
_Fields = Fields()
116117

118+
117119
cdef class Matrix(Matrix1):
118120
"""
119121
Base class for matrices, part 2

src/sage/matrix/matrix_cyclo_dense.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,6 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
814814
A._matrix = -self._matrix
815815
return A
816816

817-
818817
########################################################################
819818
# LEVEL 3 functionality (Optional)
820819
# * __deepcopy__
@@ -824,6 +823,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
824823
# * Specialized echelon form
825824
# * tensor product
826825
########################################################################
826+
827827
def set_immutable(self):
828828
"""
829829
Change this matrix so that it is immutable.

src/sage/matrix/matrix_integer_dense.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,6 @@ cdef class Matrix_integer_dense(Matrix_dense):
10941094
sig_off()
10951095
return ans
10961096

1097-
10981097
########################################################################
10991098
# LEVEL 3 functionality (Optional)
11001099
# * __deepcopy__
@@ -2743,10 +2742,9 @@ cdef class Matrix_integer_dense(Matrix_dense):
27432742
import sage.libs.ntl.ntl_mat_ZZ
27442743
return sage.libs.ntl.ntl_mat_ZZ.ntl_mat_ZZ(self._nrows,self._ncols, self.list())
27452744

2746-
2747-
####################################################################################
2745+
#######################################################################
27482746
# LLL
2749-
####################################################################################
2747+
#######################################################################
27502748

27512749
def BKZ(self, delta=None, algorithm="fpLLL", fp=None, block_size=10, prune=0,
27522750
use_givens=False, precision=0, proof=None, **kwds):
@@ -5165,7 +5163,6 @@ cdef class Matrix_integer_dense(Matrix_dense):
51655163
sig_free(T_rows)
51665164
return res
51675165

5168-
51695166
#################################################################
51705167
# operations with matrices
51715168
#################################################################

src/sage/matrix/matrix_mod2_dense.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,11 +2057,13 @@ def unpickle_matrix_mod2_dense_v2(r, c, data, size, immutable=False):
20572057

20582058
return A
20592059

2060+
20602061
from sage.misc.persist import register_unpickle_override
20612062
register_unpickle_override('sage.matrix.matrix_mod2_dense',
20622063
'unpickle_matrix_mod2_dense_v1',
20632064
unpickle_matrix_mod2_dense_v2)
20642065

2066+
20652067
def from_png(filename):
20662068
"""
20672069
Returns a dense matrix over GF(2) from a 1-bit PNG image read from

src/sage/matrix/matrix_rational_sparse.pyx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
268268
mpq_clear(s)
269269
return ans
270270

271-
272271
########################################################################
273272
# def _pickle(self):
274273
# def _unpickle(self, data, int version): # use version >= 0
@@ -281,20 +280,21 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
281280
# def _multiply_classical(left, matrix.Matrix _right):
282281
# def _list(self):
283282

284-
# TODO
285-
## cpdef _lmul_(self, Element right):
286-
## """
287-
## EXAMPLES::
288-
##
289-
## sage: a = matrix(QQ,2,range(6))
290-
## sage: (3/4) * a
291-
## [ 0 3/4 3/2]
292-
## [ 9/4 3 15/4]
293-
## """
283+
# TODO
284+
## cpdef _lmul_(self, Element right):
285+
## """
286+
## EXAMPLES::
287+
##
288+
## sage: a = matrix(QQ,2,range(6))
289+
## sage: (3/4) * a
290+
## [ 0 3/4 3/2]
291+
## [ 9/4 3 15/4]
292+
## """
294293

295294
def _dict(self):
296295
"""
297296
Unsafe version of the dict method, mainly for internal use.
297+
298298
This may return the dict of elements, but as an *unsafe*
299299
reference to the underlying dict of the object. It might
300300
be dangerous if you change entries of the returned dict.
@@ -313,7 +313,6 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
313313
self.cache('dict', d)
314314
return d
315315

316-
317316
########################################################################
318317
# LEVEL 3 functionality (Optional)
319318
# * cdef _sub_
@@ -325,7 +324,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
325324

326325
def _nonzero_positions_by_row(self, copy=True):
327326
"""
328-
Returns the list of pairs (i,j) such that self[i,j] != 0.
327+
Return the list of pairs (i,j) such that self[i,j] != 0.
329328
330329
It is safe to change the resulting list (unless you give the option copy=False).
331330

0 commit comments

Comments
 (0)