Skip to content

Commit

Permalink
fix E306 outside of combinat,graphs,rings,categories,schemes,algebras
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jun 2, 2022
1 parent 5fb2a6e commit a642e3a
Show file tree
Hide file tree
Showing 43 changed files with 78 additions and 22 deletions.
16 changes: 9 additions & 7 deletions src/sage/calculus/desolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ def desolve(de, dvar, ics=None, ivar=None, show_method=False, contrib_ode=False,
dvar_str=P(dvar.operator()).str()
ivar_str=P(ivar).str()
de00 = de00.str()

def sanitize_var(exprs):
return exprs.replace("'"+dvar_str+"("+ivar_str+")",dvar_str)
de0 = sanitize_var(de00)
Expand Down Expand Up @@ -811,6 +812,7 @@ def desolve_laplace(de, dvar, ics=None, ivar=None):
## verbatim copy from desolve - end

dvar_str = str(dvar)

def sanitize_var(exprs): # 'y(x) -> y(x)
return exprs.replace("'"+dvar_str,dvar_str)
de0=de._maxima_()
Expand Down Expand Up @@ -1680,25 +1682,25 @@ def Dfun(y, t):
variabs = dvars[:]
variabs.append(ivar)
for de in des:
desc.append(fast_float(de,*variabs))
desc.append(fast_float(de, *variabs))

def func(y,t):
def func(y, t):
v = list(y[:])
v.append(t)
return [dec(*v) for dec in desc]

if not compute_jac:
Dfun=None
Dfun = None
else:
J = jacobian(des,dvars)
J = jacobian(des, dvars)
J = [list(v) for v in J]
J = fast_float(J,*variabs)
def Dfun(y,t):
J = fast_float(J, *variabs)

def Dfun(y, t):
v = list(y[:])
v.append(t)
return [[element(*v) for element in row] for row in J]


sol=odeint(func, ics, times, args=args, Dfun=Dfun, rtol=rtol, atol=atol,
tcrit=tcrit, h0=h0, hmax=hmax, hmin=hmin, ixpr=ixpr, mxstep=mxstep,
mxhnil=mxhnil, mxordn=mxordn, mxords=mxords, printmessg=printmessg)
Expand Down
4 changes: 3 additions & 1 deletion src/sage/categories/finite_posets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,14 +1901,16 @@ def order_ideals_lattice(self, as_ideals=True, facade=None):
else:
from sage.misc.cachefunc import cached_function
antichains = [tuple(a) for a in self.antichains()]

@cached_function
def is_above(a, xb):
return any(self.is_lequal(xa, xb) for xa in a)

def compare(a, b):
return all(is_above(a, xb) for xb in b)
return LatticePoset((antichains, compare), facade=facade)

@abstract_method(optional = True)
@abstract_method(optional=True)
def antichains(self):
r"""
Return all antichains of ``self``.
Expand Down
1 change: 1 addition & 0 deletions src/sage/coding/guruswami_sudan/gs_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def guruswami_sudan_decoding_radius(C = None, n_k = None, l = None, s = None):
(92, (2, 6))
"""
n,k = n_k_params(C, n_k)

def get_tau(s,l):
"Return the decoding radius given this s and l"
if s<=0 or l<=0:
Expand Down
2 changes: 2 additions & 0 deletions src/sage/coding/guruswami_sudan/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,13 @@ def lee_osullivan_module(points, parameters, wy):
y = PFy.gens()[0]
ybasis = [(y-R)**i * G**(s-i) for i in range(0, s+1)] \
+ [y**(i-s) * (y-R)**s for i in range(s+1, l+1)]

def pad(lst):
return lst + [0]*(l+1-len(lst))
modbasis = [pad(yb.coefficients(sparse=False)) for yb in ybasis]
return matrix(PF, modbasis)


def gs_interpolation_lee_osullivan(points, tau, parameters, wy):
r"""
Returns an interpolation polynomial Q(x,y) for the given input using the
Expand Down
2 changes: 2 additions & 0 deletions src/sage/coding/information_set_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def calibrate(self):
F = C.base_ring()
q = F.cardinality()
Fstar = F.list()[1:]

def time_information_set_steps():
before = process_time()
while True:
Expand All @@ -565,6 +566,7 @@ def time_information_set_steps():
except ZeroDivisionError:
continue
return process_time() - before

def time_search_loop(p):
y = random_vector(F, n)
g = random_matrix(F, p, n).rows()
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/cluster_algebra_quiver/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def plot(self, circular=True, center=(0, 0), directed=True, mark=None,
from sage.all import e, pi, I
graphs = GraphGenerators()
# returns positions for graph vertices on two concentric cycles with radius 1 and 2

def _graphs_concentric_circles(n, m):
g1 = graphs.CycleGraph(n).get_pos()
g2 = graphs.CycleGraph(m).get_pos()
Expand Down
1 change: 1 addition & 0 deletions src/sage/crypto/sboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def bf(x):

elif isinstance(bf, (BooleanFunction,)):
bf_f2 = bf

def bf(x):
xprime = map(int, x.polynomial().list())
xprime += [0]*(n-1 - len(xprime))
Expand Down
3 changes: 3 additions & 0 deletions src/sage/databases/findstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def _data_from_iterable(iterable, mapping=False, domain=None,
codomain = FindStatCollection(vals)

all_elements = set()

def sanitize_pair(elts, vals):
if domain.is_element(elts):
elts = [elts]
Expand Down Expand Up @@ -1050,6 +1051,7 @@ def findstat(query=None, values=None, distribution=None, domain=None,
raise ValueError("the maximal number of values for a FindStat query must be a non-negative integer less than or equal to %i" % FINDSTAT_MAX_VALUES)

check_collection = True

def get_values(raw, domain=None):
if callable(raw):
known_terms = _data_from_function(raw, domain)
Expand Down Expand Up @@ -1272,6 +1274,7 @@ def findmap(*args, **kwargs):
raise ValueError("the maximal number of values for a FindStat query must be a non-negative integer less than or equal to %i" % FINDSTAT_MAX_VALUES)

check_collection = True

def get_values(raw, domain=None, codomain=None):
if callable(raw):
known_terms = _data_from_function(raw, domain)
Expand Down
1 change: 1 addition & 0 deletions src/sage/databases/sql_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def _create_print_table(cur, col_titles, **kwds):
continue
global p
p = 0

def row_str(row, html):
f = 0
global p
Expand Down
2 changes: 2 additions & 0 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ def filter_sources(self):
# Filter the sources to only include those with failing doctests if the --failed option is passed
if self.options.failed:
self.log("Only doctesting files that failed last test.")

def is_failure(source):
basename = source.basename
return basename not in self.stats or self.stats[basename].get('failed')
Expand Down Expand Up @@ -989,6 +990,7 @@ def sort_sources(self):
if self.options.nthreads > 1 and len(self.sources) > self.options.nthreads:
self.log("Sorting sources by runtime so that slower doctests are run first....")
default = dict(walltime=0)

def sort_key(source):
basename = source.basename
return -self.stats.get(basename, default).get('walltime'), basename
Expand Down
1 change: 1 addition & 0 deletions src/sage/doctest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def trace_method(obj, meth, **kwds):
from sage.cpython.getattr import raw_getattr
f = raw_getattr(obj, meth)
t = AttributeAccessTracerProxy(obj, **kwds)

@wraps(f)
def g(*args, **kwds):
arglst = [reproducible_repr(arg) for arg in args]
Expand Down
1 change: 1 addition & 0 deletions src/sage/functions/orthogonal_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2793,6 +2793,7 @@ def eval_formula(self, n, x, b, c):
+ (3*b^2 + 6*b - 3*b^2/c - 3*b/c - 3*b/c^2 - 2/c^3 + 2)*x + 2*b
"""
from sage.misc.misc_c import prod

def P(val, k):
return prod(val + j for j in range(k))
return sum((-1)**k * binomial(n, k) * binomial(x, k) * factorial(k)
Expand Down
1 change: 1 addition & 0 deletions src/sage/geometry/triangulation/point_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,7 @@ def placing_triangulation(self, point_order=None):
(<0,2,4>, <0,3,4>, <1,2,4>, <1,3,4>)
"""
facet_normals = dict()

def facets_of_simplex(simplex):
"""
Return the facets of the simplex and store the normals in facet_normals
Expand Down
1 change: 1 addition & 0 deletions src/sage/groups/braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,7 @@ def reduced_word(self):
in parallel.
"""
M = self._algebra._indices

def tuple_to_word(q_tuple):
return M.prod(self._gens[i] ** exp
for i, exp in enumerate(q_tuple))
Expand Down
2 changes: 2 additions & 0 deletions src/sage/groups/cubic_braid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ def create_sympl_realization(self, m):
# matrix.
# -----------------------------------------------------------
from sage.matrix.constructor import matrix

def transvec2mat(v, bas=bas, bform=bform, fact=1):
t = [x + fact*(x * bform * v) * v for x in bas]
return matrix(bform.base_ring(), t)
Expand Down Expand Up @@ -1295,6 +1296,7 @@ def create_unitary_realization(self, m):
# matrix.
# -----------------------------------------------------------
from sage.matrix.constructor import matrix

def transvec2mat(v, bas=bas, bform=bform, fact=a):
# note x does not change under conjugation, since it belongs to standard basis
t = [x + fact *(x * bform * v.conjugate()) * v for x in bas]
Expand Down
1 change: 1 addition & 0 deletions src/sage/homology/chain_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ def _homology_in_degree(self, deg, base_ring, verbose, generators, algorithm):
print('Computing homology of the chain complex in dimension %s...' % deg)

fraction_field = base_ring.fraction_field()

def change_ring(X):
if X.base_ring() is base_ring:
return X
Expand Down
1 change: 1 addition & 0 deletions src/sage/homology/hochschild_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def boundary(self, d):
Fd = self.module(d-1)
Fd1 = self.module(d)
mone = -one

def on_basis(k):
p = self._M.monomial(k[0]) * self._A.monomial(k[1])
ret = Fd._from_dict({(m,) + k[2:]: c for m,c in p}, remove_zeros=False)
Expand Down
4 changes: 3 additions & 1 deletion src/sage/interfaces/frobby.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def associated_primes(self, monomial_ideal):
if lines[-1]=='':
lines.pop(-1)
lists = [[int(_) for _ in a.split()] for a in lines]

def to_monomial(exps):
return [v ** e for v, e in zip(monomial_ideal.ring().gens(), exps) if e != 0]
return [monomial_ideal.ring().ideal(to_monomial(a)) for a in lists]
Expand Down Expand Up @@ -338,8 +339,9 @@ def _parse_ideals(self, string, ring):
for i in range(nrows):
nmatrix+=lines.pop(0)+'\n'
matrices.append(nmatrix)

def to_ideal(exps):
if len(exps)==0:
if len(exps) == 0:
return ring.zero_ideal()
gens = [prod([v ** e for v, e in zip(ring.gens(), expo) if e != 0]) for expo in exps]
return ring.ideal(gens or ring(1))
Expand Down
1 change: 1 addition & 0 deletions src/sage/knots/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -3918,6 +3918,7 @@ def get_knotinfo(self, mirror_version=True, unique=True):
# over :class:`KnotInfo` should be returned

non_unique_hint = '\nuse keyword argument `unique` to obtain more details'

def answer(L):
r"""
Return a single item of the KnotInfo database according to the keyword
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/singular/standard_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def libsingular_gb_standard_options(func):
does not need to use it manually.
"""
from sage.misc.decorators import sage_wraps

@sage_wraps(func)
def wrapper(*args, **kwds):
"""
Expand Down
1 change: 0 additions & 1 deletion src/sage/manifolds/differentiable/vectorfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ def plot(self, chart=None, ambient_coords=None, mapping=None,
extra_options)
for ind_part in local_list]


# definition of the parallel function
@parallel(p_iter='multiprocessing', ncpus=nproc)
def add_point_plot(vector, dom, xx_list, chart_domain, chart,
Expand Down
3 changes: 3 additions & 0 deletions src/sage/manifolds/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ def vertex_family(subset):
def vertex_family(subset):
return ManifoldSubsetFiniteFamily([subset])
subset_to_vertex = {}

def vertex(subset):
try:
return subset_to_vertex[subset]
Expand Down Expand Up @@ -2307,6 +2308,7 @@ def _reduce_intersection_members(subsets):
subsets = set(subsets)
if not subsets:
raise TypeError('input set must be nonempty')

def reduce():
# Greedily replace inclusion chains by their minimal element
# and pairs with declared intersections by their intersection
Expand Down Expand Up @@ -2531,6 +2533,7 @@ def _reduce_union_members(subsets):
"""
subsets = set(subsets)

def reduce():
# Greedily replace inclusion chains by their maximal element
# and pairs with declared unions by their union
Expand Down
1 change: 1 addition & 0 deletions src/sage/misc/explain_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,7 @@ def unpickle_newobj(klass, args):
pickle = b"P0\nP1\n\x81."

pers = [klass, args]

def pers_load(id):
return pers[int(id)]

Expand Down
1 change: 1 addition & 0 deletions src/sage/misc/superseded.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def __call__(self, func):
(3,) {'what': 'Hello'}
"""
from sage.misc.decorators import sage_wraps

@sage_wraps(func)
def wrapper(*args, **kwds):
if not wrapper._already_issued:
Expand Down
2 changes: 2 additions & 0 deletions src/sage/modular/modform/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def _eigendata(self):
x = self._easy_vector()

B = self._eigenvectors()

def phi(y):
"""
Take coefficients and a basis, and return that
Expand Down Expand Up @@ -416,6 +417,7 @@ def eigenvalues(self, primes):
raise ValueError('each element of primes must be prime.')
phi_x, phi_x_inv, nzp, x_nzp = self._eigendata()
B = self._eigenvectors()

def phi(y):
"""
Take coefficients and a basis, and return that
Expand Down
3 changes: 2 additions & 1 deletion src/sage/modular/modsym/ambient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ def _pari_pairing(self):
m = Integer(self.weight() - 2)
R = PolynomialRing(QQ, 'x')
x = R.gen()

def ev(s):
# The Manin symbol s = X^i (c, d) corresponds to the
# modular symbol (dX - bY)^i (-cX + aY)^(m - i) {b/d, a/c}.
Expand All @@ -2481,7 +2482,7 @@ def ev(s):
i = s.i
a, b, c, d = s.lift_to_sl2z()
e = [R(p) for p in P.mseval(I, matrix(2, 2, [b, a, d, c]))]
g = (d*x - b)**i * (-c*x + a)**(m - i)
g = (d * x - b)**i * (-c * x + a)**(m - i)
return [sum(f[j] * g[m - j] / m.binomial(j) for j in range(m + 1))
for f in e]
return matrix([ev(s) for s in self.manin_symbols_basis()])
Expand Down
1 change: 1 addition & 0 deletions src/sage/modules/filtered_vector_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def direct_sum(self, other):
generators = \
[ list(v) + [base_ring.zero()]*other.dimension() for v in self_gens ] + \
[ [base_ring.zero()]*self.dimension() + list(v) for v in other_gens ]

# construct the filtration dictionary
def join_indices(self_indices, other_indices):
self_indices = tuple(self_indices)
Expand Down
1 change: 1 addition & 0 deletions src/sage/modules/with_basis/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ def section(self):
retract_dom = None
else:
on_basis = self.on_basis()

def retract_dom(i):
self._dominant_item(on_basis(i))[0]

Expand Down
1 change: 1 addition & 0 deletions src/sage/monoids/indexed_free_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _ascii_art_(self):
ascii_art_gen = lambda m: P._ascii_art_generator(m[0])
else:
pref = AsciiArt([P.prefix()])

def ascii_art_gen(m):
if m[1] != 1:
r = (AsciiArt([" " * len(pref)]) + ascii_art(m[1]))
Expand Down
2 changes: 2 additions & 0 deletions src/sage/parallel/decorate.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,12 @@ def __call__(self, f):
P = Parallel(p_iter='fork', ncpus=1, timeout=self.timeout,
verbose=self.verbose)
g = P(f)

def h(*args, **kwds):
return list(g([(args, kwds)]))[0][1]
return h


def fork(f=None, timeout=0, verbose=False):
"""
Decorate a function so that when called it runs in a forked
Expand Down
1 change: 1 addition & 0 deletions src/sage/plot/hyperbolic_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def hyperbolic_polygon(pts, model="UHP", resolution=200, **options):
xlist = [p[0] for p in pts]
ylist = [p[1] for p in pts]
zlist = [p[2] for p in pts]

def region(x, y, z):
return _winding_number(arc_points, (x, y, z)) != 0
g = g + implicit_plot3d(x**2 + y**2 - z**2 == -1,
Expand Down
Loading

0 comments on commit a642e3a

Please sign in to comment.