diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 637ed9192bd..2b8c5d1d6de 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1457,11 +1457,11 @@ def random_prime(n, proof=None, lbound=2): lbound = max(2, lbound) if lbound > 2: if lbound == 3 or n <= 2*lbound - 2: - # check for Betrand's postulate (proved by Chebyshev) + # check for Betrand's postulate (proved by Chebyshev) if lbound < 25 or n <= 6*lbound/5: - # see J. Nagura, Proc. Japan Acad. 28, (1952). 177-181. + # see J. Nagura, Proc. Japan Acad. 28, (1952). 177-181 if lbound < 2010760 or n <= 16598*lbound/16597: - # see L. Schoenfeld, Math. Comp. 30 (1976), no. 134, 337-360. + # see L. Schoenfeld, Math. Comp. 30 (1976), no 134, 337-360 if proof: smallest_prime = ZZ(lbound-1).next_prime() else: diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py index cda4ecdca68..8993d020e37 100644 --- a/src/sage/categories/modules_with_basis.py +++ b/src/sage/categories/modules_with_basis.py @@ -1419,12 +1419,12 @@ class ElementMethods: # subclasses). These methods should be consistent with those on # polynomials. -# def _neg_(self): -# """ -# Default implementation of negation by trying to multiply by -1. -# TODO: doctest -# """ -# return self._lmul_(-self.parent().base_ring().one(), self) + # def _neg_(self): + # """ + # Default implementation of negation by trying to multiply by -1. + # TODO: doctest + # """ + # return self._lmul_(-self.parent().base_ring().one(), self) @abstract_method def monomial_coefficients(self, copy=True): diff --git a/src/sage/coding/self_dual_codes.py b/src/sage/coding/self_dual_codes.py index 10565d9e1a0..53d892a640d 100644 --- a/src/sage/coding/self_dual_codes.py +++ b/src/sage/coding/self_dual_codes.py @@ -612,19 +612,19 @@ def self_dual_binary_codes(n): return self_dual_codes if n == 20: - # all of these of these are Type I; 2 of these codes - # are formally equivalent but with different automorphism groups; - # one of these has a unique codeword of lowest weight - A10 = MatrixSpace(_F,10,10)([[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], - [1, 1, 1, 0, 1, 0, 1, 0, 1, 1], - [1, 0, 0, 1, 0, 1, 0, 1, 0, 1], - [0, 0, 0, 1, 1, 1, 0, 1, 0, 1], - [0, 0, 1, 1, 0, 1, 0, 1, 0, 1], - [0, 0, 0, 1, 0, 1, 1, 1, 0, 1], - [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], - [0, 0, 0, 1, 0, 0, 0, 0, 1, 1], - [0, 0, 0, 0, 0, 1, 0, 0, 1, 1], - [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]]) + # all of these of these are Type I; 2 of these codes + # are formally equivalent but with different automorphism groups; + # one of these has a unique codeword of lowest weight + A10 = MatrixSpace(_F, 10, 10)([[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 0, 1, 0, 1, 0, 1, 1], + [1, 0, 0, 1, 0, 1, 0, 1, 0, 1], + [0, 0, 0, 1, 1, 1, 0, 1, 0, 1], + [0, 0, 1, 1, 0, 1, 0, 1, 0, 1], + [0, 0, 0, 1, 0, 1, 1, 1, 0, 1], + [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], + [0, 0, 0, 1, 0, 0, 0, 0, 1, 1], + [0, 0, 0, 0, 0, 1, 0, 0, 1, 1], + [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]]) # [20,0]: genmat = _I2(n).augment(_I2(n)) # G = PermutationGroup( ["(10,20)", "(9,10)(19,20)", "(8,9)(18,19)", "(7,8)(17,18)", "(6,7)(16,17)",\ diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py b/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py index 1e2c7270b39..1b6a89714fc 100644 --- a/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py +++ b/src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py @@ -186,7 +186,7 @@ def image_isometry_matrix(self, x): [0 1] """ if x.det() < 0: -# x = I * x + # x = I * x return matrix([[1,-I],[-I,1]]) * x * matrix([[1,I],[I,1]]).conjugate()/Integer(2) return matrix([[1,-I],[-I,1]]) * x * matrix([[1,I],[I,1]])/Integer(2) diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py index 8b2d1f0251c..2d07ad8f50a 100644 --- a/src/sage/manifolds/differentiable/integrated_curve.py +++ b/src/sage/manifolds/differentiable/integrated_curve.py @@ -504,10 +504,11 @@ def __init__(self, parent, equations_rhs, velocities, parameters = set() # extract all the variables appearing in the equations: for eqn in equations_rhs: - if isinstance(eqn, Expression): # some right hand sides - # might merely be real numbers and not expressions, so that - # they do not contain any variable, and method 'variables' - # could not be called on them + if isinstance(eqn, Expression): + # some right hand sides + # might merely be real numbers and not expressions, so that + # they do not contain any variable, and method 'variables' + # could not be called on them parameters = parameters.union(eqn.variables()) # remove the Expressions that should not be treated as # parameters (i.e. the coordinate functions, the velocities and @@ -521,7 +522,7 @@ def __init__(self, parent, equations_rhs, velocities, # extract all the variables appearing in the initial point # coordinates: for coord in initial_pt_coords: - if isinstance(coord,Expression): + if isinstance(coord, Expression): parameters = parameters.union(coord.variables()) # extract all the variables appearing in the initial tangent # vector components: @@ -548,9 +549,9 @@ def __init__(self, parent, equations_rhs, velocities, # define all attributes if not isinstance(equations_rhs, dict): - self._equations_rhs = list(equations_rhs) # converts to list + self._equations_rhs = list(equations_rhs) # converts to list # since might not already be a list (which is later required) - else: # case multi charts + else: # case multi charts self._equations_rhs = equations_rhs self._across_charts = across_charts @@ -565,14 +566,15 @@ def __init__(self, parent, equations_rhs, velocities, M = M.numpy() for i in range(dim): for j in range(dim): - M[i,j] = fast_callable(SR(M[i, j]), vars=list(CoF[1]._chart[:]), domain=float) + M[i, j] = fast_callable(SR(M[i, j]), vars=list(CoF[1]._chart[:]), domain=float) import numpy as np + def fast_CoF(pos, vel, M=M): - # using default arguments for binding (ugly python) - #print(det(*pos)) - return list(np.dot( [[M[j, i](*pos) for i in range(dim)] - for j in range(dim)], vel)) + # using default arguments for binding (ugly python) + # print(det(*pos)) + return list(np.dot([[M[j, i](*pos) for i in range(dim)] + for j in range(dim)], vel)) self._fast_changes_of_frame[CoF] = fast_CoF @@ -582,7 +584,7 @@ def fast_CoF(pos, vel, M=M): for f in transf] self._fast_changes_of_chart[CoC] = fast_transf - self._velocities = list(velocities) # converts to list + self._velocities = list(velocities) # converts to list # since might not already be a list (which is later required) self._curve_parameter = curve_parameter self._initial_tangent_vector = initial_tangent_vector @@ -1126,9 +1128,9 @@ def solve(self, step=None, method='odeint', solution_key=None, for i in range(dim): if isinstance(eqns_num[i], Expression): # some right - # hand sides might merely be real numbers and not - # expressions, so that they do not contain any variable, - # and hence no substitution is required + # hand sides might merely be real numbers and not + # expressions, so that they do not contain any variable, + # and hence no substitution is required eqns_num[i] = eqns_num[i].substitute(parameters_values) for i in range(dim): @@ -1147,10 +1149,11 @@ def solve(self, step=None, method='odeint', solution_key=None, t_max = numerical_approx(t_max) for i in range(dim): - if not isinstance(eqns_num[i], Expression): # in case of a - # right hand side that is not an Expression (and then is a - # number), it is needed to be converted to an Expression - # since some solvers called below require only expressions + if not isinstance(eqns_num[i], Expression): + # in case of a + # right hand side that is not an Expression (and then is a + # number), it is needed to be converted to an Expression + # since some solvers called below require only expressions eqns_num[i] = SR(eqns_num[i]) if step is None: diff --git a/src/sage/manifolds/differentiable/manifold_homset.py b/src/sage/manifolds/differentiable/manifold_homset.py index 98fdf8998f5..1ce82e51ae1 100644 --- a/src/sage/manifolds/differentiable/manifold_homset.py +++ b/src/sage/manifolds/differentiable/manifold_homset.py @@ -892,9 +892,10 @@ def _an_element_(self): # chart used on the codomain. if dom == codom: param = var('s') - if t == param: # the canonical coordinate of the domain - # might be the expression 's' even though it was affected - # above to the variable 't' + if t == param: + # the canonical coordinate of the domain + # might be the expression 's' even though it was affected + # above to the variable 't' param = var('u') else: param = t @@ -903,8 +904,8 @@ def _an_element_(self): # where a certain integrated curve may be defined: H = Hom(dom, codom) c = H.an_element() - x0_A = c.expr()[0].substitute({t:1}) - x0_B = c.expr()[0].substitute({t:0}) # necessarily, x0_A < x0_B + x0_A = c.expr()[0].substitute({t: 1}) + x0_B = c.expr()[0].substitute({t: 0}) # necessarily, x0_A < x0_B p_coords = [x0_A] + list(c.expr()[1:dim]) p = codom.point(p_coords) diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py index 50ed9fe7a80..5e6c5438914 100644 --- a/src/sage/manifolds/differentiable/tensorfield.py +++ b/src/sage/manifolds/differentiable/tensorfield.py @@ -547,7 +547,7 @@ def __bool__(self): # #### End of required methods for ModuleElement (beside arithmetic) ##### - def _repr_(self): + def _repr_(self) -> str: r""" String representation of ``self``. @@ -564,7 +564,7 @@ def _repr_(self): if self._name is not None: description += self._name + " " else: - # Generic case + # Generic case description = "Tensor field " if self._name is not None: description += self._name + " " diff --git a/src/sage/modular/pollack_stevens/fund_domain.py b/src/sage/modular/pollack_stevens/fund_domain.py index c9b61b36546..99a8a772743 100644 --- a/src/sage/modular/pollack_stevens/fund_domain.py +++ b/src/sage/modular/pollack_stevens/fund_domain.py @@ -812,7 +812,7 @@ def __init__(self, N): # interior path on either of the last two cusps for s in range(r + 2, len(cusps)): - # s is in the index of the cusp on the right of the path + # s is in the index of the cusp on the right of the path cusp1 = cusps[r] cusp2 = cusps[s] if self.is_unimodular_path(cusp1, cusp2): @@ -1213,10 +1213,10 @@ def form_list_of_cusps(self): if (b1 ** 2 + b2 ** 2 + b1 * b2) % N != 0: - # this congruence is exactly equivalent to - # gam * [0 -1; 1 -1] * gam^(-1) is in Gamma_0(N) - # where gam is the matrix corresponding to the - # unimodular path connecting cusp1 to cusp2 + # this congruence is exactly equivalent to + # gam * [0 -1; 1 -1] * gam^(-1) is in Gamma_0(N) + # where gam is the matrix corresponding to the + # unimodular path connecting cusp1 to cusp2 C[s] = "i" # The '?' is changed to an 'i' # indicating that a new cusp needs to diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py index c8f5a0fca96..c5ab3b74aed 100644 --- a/src/sage/plot/plot.py +++ b/src/sage/plot/plot.py @@ -2051,13 +2051,15 @@ def f(x): return (floor(x)+0.5) / (1-(x-0.5)**2) elif n == 1: G = _plot(funcs, *args, **kwds) elif n == 2: - # if there are two extra args, then pull them out and pass them as a tuple + # if there are two extra args, then pull them out + # and pass them as a tuple xmin = args[0] xmax = args[1] args = args[2:] G = _plot(funcs, (xmin, xmax), *args, **kwds) elif n == 3: - # if there are three extra args, then pull them out and pass them as a tuple + # if there are three extra args, then pull them out + # and pass them as a tuple var = args[0] xmin = args[1] xmax = args[2] diff --git a/src/sage/schemes/elliptic_curves/hom.py b/src/sage/schemes/elliptic_curves/hom.py index 01112bc8bb2..96700fa254d 100644 --- a/src/sage/schemes/elliptic_curves/hom.py +++ b/src/sage/schemes/elliptic_curves/hom.py @@ -1197,7 +1197,7 @@ def compare_via_evaluation(left, right): for _ in range(100): P = E.lift_x(F.random_element(), extend=True) if P._has_order_at_least(4*d + 1, attempts=50): - # if P.height(precision=250) == 0: # slow sometimes + # if P.height(precision=250) == 0: # slow sometimes return left._eval(P) == right._eval(P) else: assert False, "couldn't find a point of large enough order" diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 370049d2238..b6c59d7090a 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -584,10 +584,10 @@ def _coerce_map_from_(self, other): except AttributeError: # no .ambient_space return False elif isinstance(other, SchemeHomset_points): - #we are converting between scheme points + # we are converting between scheme points source = other.codomain() if isinstance(target, AlgebraicScheme_subscheme): - #subscheme coerce when there is containment + # subscheme coerce when there is containment if not isinstance(source, AlgebraicScheme_subscheme): return False if target.ambient_space() == source.ambient_space(): @@ -595,9 +595,9 @@ def _coerce_map_from_(self, other): for g in target.defining_polynomials()): return self.domain().coordinate_ring().has_coerce_map_from(other.domain().coordinate_ring()) else: - #if the target is an ambient space, we can coerce if the base rings coerce - #and they are the same type: affine, projective, etc and have the same - #variable names + # if the target is an ambient space, we can coerce if the base rings coerce + # and they are the same type: affine, projective, etc and have the same + # variable names try: ta = target.ambient_space() sa = source.ambient_space() diff --git a/src/sage/tensor/modules/format_utilities.py b/src/sage/tensor/modules/format_utilities.py index d00e00f8071..293ab146942 100644 --- a/src/sage/tensor/modules/format_utilities.py +++ b/src/sage/tensor/modules/format_utilities.py @@ -247,7 +247,7 @@ def format_unop_txt(operator, name): if name is None: return None if not is_atomic(name) or not is_atomic_wedge_txt(name): - #!# is_atomic_otimes_txt should be added + # ! is_atomic_otimes_txt should be added name = '(' + name + ')' return operator + name @@ -270,7 +270,7 @@ def format_unop_latex(operator, name): if name is None: return None if not is_atomic(name) or not is_atomic_wedge_latex(name): - #!# is_atomic_otimes_latex should be added + # ! is_atomic_otimes_latex should be added name = r'\left(' + name + r'\right)' return operator + name diff --git a/src/tox.ini b/src/tox.ini index 29dd3fcaa15..67656775581 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -180,7 +180,7 @@ description = # W605: invalid escape sequence ‘x’ # See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes deps = pycodestyle -commands = pycodestyle --select E111,E21,E221,E222,E225,E227,E228,E25,E271,E275,E302,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} +commands = pycodestyle --select E111,E115,E21,E221,E222,E225,E227,E228,E25,E271,E275,E302,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} pycodestyle --select E111,E271,E301,E302,E303,E305,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} [pycodestyle]