Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pycodestyle E115 and activate this check in the linter #39340

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions src/sage/categories/modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
26 changes: 13 additions & 13 deletions src/sage/coding/self_dual_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,19 +612,19 @@
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],

Check warning on line 618 in src/sage/coding/self_dual_codes.py

View check run for this annotation

Codecov / codecov/patch

src/sage/coding/self_dual_codes.py#L618

Added line #L618 was not covered by tests
[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)",\
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
43 changes: 23 additions & 20 deletions src/sage/manifolds/differentiable/integrated_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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):
fchapoton marked this conversation as resolved.
Show resolved Hide resolved
# 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

Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions src/sage/manifolds/differentiable/manifold_homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/sage/manifolds/differentiable/tensorfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand All @@ -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 + " "
Expand Down
10 changes: 5 additions & 5 deletions src/sage/modular/pollack_stevens/fund_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/sage/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/hom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/sage/schemes/generic/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,20 +584,20 @@ 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():
if all(g in source.defining_ideal()
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()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/tensor/modules/format_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading