Skip to content

Commit

Permalink
Trac #34753: fix all W391 in pyx files
Browse files Browse the repository at this point in the history
namely, no empty final lines

already done for py files, and will be added to the linter later

URL: https://trac.sagemath.org/34753
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager committed Nov 21, 2022
2 parents 7503e42 + cd0e58d commit 513a7bc
Show file tree
Hide file tree
Showing 55 changed files with 9 additions and 71 deletions.
1 change: 0 additions & 1 deletion src/sage/coding/ag_code_decoders.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2636,4 +2636,3 @@ cdef class DifferentialAGCodeDecoder_K_extension(Decoder_K_extension):
sage: TestSuite(circuit).run(skip='_test_pickling') # long time
"""
super().__init__(pls, G, Q, DifferentialAGCodeDecoder_K, verbose=verbose)

3 changes: 0 additions & 3 deletions src/sage/coding/binary_code.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4182,6 +4182,3 @@ cdef class BinaryCodeClassifier:
sig_free(ortho_basis)
sig_free(temp_basis)
return output



1 change: 0 additions & 1 deletion src/sage/geometry/integral_points.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1450,4 +1450,3 @@ cpdef print_cache(InequalityCollection inequality_collection):
print('Cached next-to-inner loop: ' +
str(ieq.coeff) + ' * x_0 + ' +
str(ieq.coeff_next) + ' * x_1 + ' + str(ieq.cache_next) + ' >= 0')
2 changes: 1 addition & 1 deletion src/sage/libs/arb/arith.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def bernoulli(n):
fmpq_clear(x)
return q


def hilbert_class_polynomial(D):
"""
Return the Hilbert class polynomial for discriminant ``D`` using ``arb``.
Expand All @@ -82,4 +83,3 @@ def hilbert_class_polynomial(D):
poly = PolynomialRing(ZZ, "x", implementation="FLINT")()
acb_modular_hilbert_class_poly(poly.__poly, n)
return poly

2 changes: 0 additions & 2 deletions src/sage/libs/braiding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,10 @@ def sliding_circuits(braid):
[[[0], [2, 1], [1, 2], [2]]],
[[[0], [1, 2], [2], [2, 1]]],
[[[0], [2, 1], [1], [1, 2]]]]
"""
nstrands = braid.parent().strands()
l = braid.Tietze()
sig_on()
cdef list[list[list[list[int]]]] rop = SlidingCircuits(nstrands, l)
sig_off()
return rop

4 changes: 1 addition & 3 deletions src/sage/libs/eclib/homspace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,4 @@ cdef class ModularSymbols:
inc(iter)
MS = MatrixSpace(base_ring, n, sparse=True)
# The next step is the bottleneck.
ans = MS(d)
return ans

return MS(d)
2 changes: 0 additions & 2 deletions src/sage/libs/flint/fmpz_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ cdef class Fmpz_poly(SageObject):
cdef long nn = n
fmpz_poly_truncate(self.poly, nn) # mutating!


def _sage_(self, var='x'):
"""
Return self as an element of the sage ZZ[var].
Expand All @@ -456,4 +455,3 @@ cdef class Fmpz_poly(SageObject):
"""
from sage.rings.integer_ring import ZZ
return ZZ[var](self.list())

3 changes: 1 addition & 2 deletions src/sage/libs/homfly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ def homfly_polynomial_dict(link):
cdef Poly* c_output = homfly(link)
sig_off()
cdef int l = c_output.len
d = dict()
d = {}
for i in range(l):
ter = c_output.term[i]
d[(int(ter.l), int(ter.m))] = int(ter.coef)
return d

2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_GF2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def unpickle_class_value(cls, x):
"""
return cls(x)


def unpickle_class_args(cls, x):
"""
Here for unpickling.
Expand All @@ -278,4 +279,3 @@ def unpickle_class_args(cls, x):
<class 'sage.libs.ntl.ntl_GF2.ntl_GF2'>
"""
return cls(*x)

1 change: 0 additions & 1 deletion src/sage/libs/sirocco.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,3 @@ cpdef list[list] contpath_comps(int deg, list values, double y0r, double y0i, li
free(c_otherdegrees)
free(c_othercoefs)
return l

1 change: 0 additions & 1 deletion src/sage/matrix/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,3 @@ cdef class MatrixSchemePointAction(MatrixMulAction):
(2 : 1)
"""
return P._matrix_times_point_(mat, self._codomain)

5 changes: 1 addition & 4 deletions src/sage/matrix/change_ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,5 @@ def integer_to_real_double_dense(Matrix_integer_dense A):
S, None, None, None)
for i from 0 <= i < A._nrows:
for j from 0 <= j < A._ncols:
M.set_unsafe_double(i,j,A.get_unsafe_double(i,j))
M.set_unsafe_double(i, j, A.get_unsafe_double(i, j))
return M



1 change: 0 additions & 1 deletion src/sage/matrix/echelon_matrix.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,3 @@ def reduced_echelon_matrix_iterator(K, k, n, bint sparse=False, bint copy=True,
yield m
del v # hack: Python itertools reuses the tuple if nobody else uses it
del pivots # hack: Python itertools reuses the tuple if nobody else uses it

1 change: 0 additions & 1 deletion src/sage/matrix/matrix_cyclo_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1961,4 +1961,3 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
if subdivide:
M.subdivide([Anr*i for i in range(1,nr)], [Anc*i for i in range(1,nc)])
return M

1 change: 0 additions & 1 deletion src/sage/matrix/matrix_rational_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -805,4 +805,3 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
cdef mpq_t minus_one
mpq_init(minus_one)
mpq_set_si(minus_one, -1,1)

1 change: 0 additions & 1 deletion src/sage/matrix/strassen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,3 @@ def test(n, m, R, c=2):

## sage: C == D
## True

1 change: 0 additions & 1 deletion src/sage/misc/derivative.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,3 @@ def multi_derivative(F, args):
for arg in derivative_parse(args):
F = F._derivative(arg)
return F

1 change: 0 additions & 1 deletion src/sage/misc/instancedoc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,3 @@ def instancedoc(cls):
tp.tp_doc = NULL
PyType_Modified(tp)
return cls

4 changes: 2 additions & 2 deletions src/sage/misc/lazy_attribute.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ class lazy_attribute(_lazy_attribute):
if hasattr(f, "__module__"):
self.__module__ = f.__module__


class lazy_class_attribute(lazy_attribute):
"""
A lazy class attribute for an class is like a usual class attribute,
Expand Down Expand Up @@ -601,7 +602,6 @@ class lazy_class_attribute(lazy_attribute):
"""
result = self.f(cls)
if result is NotImplemented:
return getattr(super(cls, cls),self.__name__)
return getattr(super(cls, cls), self.__name__)
setattr(cls, self.__name__, result)
return result

1 change: 0 additions & 1 deletion src/sage/misc/nested_class.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,3 @@ class A1:
class A2:
class A3:
pass

1 change: 0 additions & 1 deletion src/sage/misc/parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,4 +1098,3 @@ cdef class LookupNameMaker:
if self.fallback is not None:
return self.fallback(name)
raise NameError("Unknown variable: '{}'".format(name))

1 change: 0 additions & 1 deletion src/sage/monoids/free_abelian_monoid_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,3 @@ cdef class FreeAbelianMonoidElement(MonoidElement):
"""
cdef Py_ssize_t i
return [_Integer_from_mpz(self._element_vector[i]) for i in range(self._n)]

1 change: 0 additions & 1 deletion src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1002,4 +1002,3 @@ cdef class CVXOPTBackend(GenericBackend):
return self.param[name]
else:
self.param[name] = value

3 changes: 1 addition & 2 deletions src/sage/numerical/mip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,7 @@ cdef class MIPVariable(SageObject):
"""
Implement the action of a matrix multiplying from the left.
"""
result = dict()
result = {}
for i, col in enumerate(m.columns()):
x = self[i]
x_index, = x.dict().keys()
Expand All @@ -3585,4 +3585,3 @@ cdef class MIPVariable(SageObject):
V = FreeModule(self._p.base_ring(), m.nrows())
T = self._p.linear_functions_parent().tensor(V)
return T(result)

2 changes: 0 additions & 2 deletions src/sage/rings/complex_number.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ TESTS::
DeprecationWarning: the complex_number module is deprecated, please use sage.rings.complex_mpfr
See http://trac.sagemath.org/24483 for details.
"""

from sage.misc.superseded import deprecation
from sage.rings.complex_mpfr import *
deprecation(24483, "the complex_number module is deprecated, please use sage.rings.complex_mpfr")

2 changes: 0 additions & 2 deletions src/sage/rings/finite_rings/residue_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1919,5 +1919,3 @@ class ResidueFiniteField_ntl_gf2e(ResidueField_generic, FiniteField_ntl_gf2e):
return FiniteField_ntl_gf2e._element_constructor_(self, x)
except TypeError:
return ResidueField_generic._element_constructor_(self, x)


1 change: 0 additions & 1 deletion src/sage/rings/function_field/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1578,4 +1578,3 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement):
assert f.denominator() == 1
assert self._x.denominator() == 1
return self.parent()(self._x.numerator().inverse_mod(f.numerator()))

1 change: 0 additions & 1 deletion src/sage/rings/function_field/hermite_form_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@ def reversed_hermite_form(Matrix mat, bint transformation=False):

if transformation:
return U

1 change: 0 additions & 1 deletion src/sage/rings/noncommutative_ideals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,3 @@ class Ideal_nc(Ideal_generic):
return other.ring().ideal(other.gens(), side='twosided')

raise NotImplementedError("cannot multiply non-commutative ideals")

Original file line number Diff line number Diff line change
Expand Up @@ -3074,4 +3074,3 @@ cpdef bint is_sqrt_disc(Rational ad, Rational bd):
mpz_clear(denom)

return ret

1 change: 0 additions & 1 deletion src/sage/rings/number_field/number_field_morphisms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,3 @@ cdef class CyclotomicFieldConversion(Map):
return self.phi.preimage(M(x))
except ValueError:
raise ValueError('Element {} has no image in the codomain'.format(x))

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2351,4 +2351,3 @@ def make_ZZpXCAElement(parent, value, absprec, version):
return ans
else:
raise ValueError("unknown unpickling version")

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3284,4 +3284,3 @@ def make_ZZpXCRElement(parent, unit, ordp, relprec, version):
return ans
else:
raise ValueError("unknown unpickling version")

2 changes: 1 addition & 1 deletion src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement):
"""
return self.ext_p_list_precs(pos, self.prime_pow.ram_prec_cap)


def make_ZZpXFMElement(parent, f):
"""
Create a new ``pAdicZZpXFMElement`` out of an ``ntl_ZZ_pX`` ``f``, with
Expand All @@ -1737,4 +1738,3 @@ def make_ZZpXFMElement(parent, f):
True
"""
return pAdicZZpXFMElement(parent, f)

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_ZZ_pX_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -914,4 +914,3 @@ cdef get_val_prec(PowComputer_ext pp, a):
print(py_tmp)
raise TypeError("modulus must be a positive power of the appropriate prime")
raise TypeError("unsupported type for list element: %s" % type(a))

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_capped_relative_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -610,4 +610,3 @@ def base_p_list(Integer n, bint pos, PowComputer_class prime_pow):
cdef ExpansionIter expansion = ExpansionIter(dummy, n.exact_log(p) + 2, mode)
mpz_set(expansion.curvalue, n.value)
return trim_zeros(list(expansion))

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_ext_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,3 @@ cdef class pAdicExtElement(pAdicGenericElement):
return R.residue_field()(self.expansion(0))
else:
raise NotImplementedError("residue() not implemented in extensions for absprec larger than one")

2 changes: 0 additions & 2 deletions src/sage/rings/padics/padic_fixed_mod_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ cdef class pAdicFixedModElement(FMElement):
return ans



def make_pAdicFixedModElement(parent, value):
"""
Unpickles a fixed modulus element.
Expand All @@ -580,4 +579,3 @@ def make_pAdicFixedModElement(parent, value):
2*5^2 + 3*5^3
"""
return unpickle_fme_v2(pAdicFixedModElement, parent, value)

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_floating_point_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,3 @@ cdef class pAdicFloatingPointElement(FPElement):
sig_off()

return ans

1 change: 0 additions & 1 deletion src/sage/rings/padics/padic_relaxed_errors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ def raise_error(error, permissive=False):
raise PrecisionError("not enough precision")
if error & ERROR_ABANDON:
raise PrecisionError("computation has been abandoned; try to increase precision")

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/hilbert.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -601,4 +601,3 @@ def hilbert_poincare_series(I, grading=None):
if HP.leading_coefficient() >= 0:
return HP / PR.prod([(1-t**d) for d in grading])
return (-HP) / (-PR.prod([(1-t**d) for d in grading]))

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/laurent_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3763,4 +3763,3 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
if new_ring is not None:
return new_ring(ans)
return ans

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/polynomial_compiled.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,3 @@ cdef class abc_pd(binary_pd):
self.value = self.left.value * self.right.value + coeffs[self.index]
pd_clean(self.left)
pd_clean(self.right)

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,3 @@ def make_PolynomialRealDense(parent, data):
3.00000000000000*x^2 + 2.00000000000000*x + 1.00000000000000
"""
return PolynomialRealDense(parent, data)

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/polynomial_zz_pex.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,3 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
x^4 + x^3 + x
"""
return self.shift(-n)

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/skew_polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,3 @@ cdef class SkewPolynomial_generic_dense(OrePolynomial_generic_dense):
q.append(c)
q.reverse()
return (self._new_c(q, parent), self._new_c(a[:db], parent, 1))

2 changes: 0 additions & 2 deletions src/sage/rings/polynomial/skew_polynomial_finite_order.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,6 @@ cdef class SkewPolynomial_finite_order_dense(SkewPolynomial_generic_dense):
self._optbound = [section(x) for x in bound.list()]
return center(self._optbound)


# TODO:
# fast multiplication
# reduced characteristic polynomial

1 change: 0 additions & 1 deletion src/sage/rings/polynomial/weil/weil_polynomials.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,3 @@ class WeilPolynomials():
158
"""
return self.w.node_count()

1 change: 0 additions & 1 deletion src/sage/rings/power_series_pari.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -953,4 +953,3 @@ cdef class PowerSeries_pari(PowerSeries):
precision = self._prec
f = self
return PowerSeries_pari(self._parent, f.g.serreverse(), precision)

1 change: 0 additions & 1 deletion src/sage/rings/power_series_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1293,4 +1293,3 @@ cdef class BaseRingFloorDivAction(Action):
P = self.US()
g = P.base_ring()(g)
return type(x)(P, elt.__f // g, prec=prec, check=False)

1 change: 0 additions & 1 deletion src/sage/rings/puiseux_series_ring_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1052,4 +1052,3 @@ cdef class PuiseuxSeries(AlgebraElement):
25*x^(23/2) + O(x^(27/2))
"""
return self.__invert__()

1 change: 0 additions & 1 deletion src/sage/rings/real_lazy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1748,4 +1748,3 @@ cdef class LazyWrapperMorphism(Morphism):
else:
e._value = x
return e

1 change: 0 additions & 1 deletion src/sage/rings/semirings/tropical_semiring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,3 @@ cdef class TropicalToTropical(Map):
+infinity
"""
return self.codomain()((<TropicalSemiringElement>x)._val)

1 change: 0 additions & 1 deletion src/sage/sat/solvers/satsolver.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,3 @@ def SAT(solver=None, *args, **kwds):
return GlucoseSyrup(*args, **kwds)
else:
raise ValueError("Solver '{}' is not available".format(solver))

1 change: 0 additions & 1 deletion src/sage/stats/hmm/chmm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,4 +1559,3 @@ def unpickle_gaussian_mixture_hmm_v1(A, B, pi, mixture):
m.pi = pi
m.mixture = mixture
return m

0 comments on commit 513a7bc

Please sign in to comment.