diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index 5b3064688b0..7ff9dc9d452 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -1002,7 +1002,6 @@ cdef class ComplexIntervalFieldElement(FieldElement): """ raise TypeError - def _sage_input_(self, sib, coerce): r""" Produce an expression which will reproduce this value when evaluated. diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index 18b0db173b5..7d98b99b95f 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -24,6 +24,7 @@ from sage.rings.integer_ring import ZZ from sage.rings.integer import Integer from sage.misc.superseded import deprecated_function_alias + def is_FiniteFieldElement(x): """ Return ``True`` if ``x`` is a finite field element. diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx index 401f398ddee..2ef19972fb0 100644 --- a/src/sage/rings/finite_rings/element_givaro.pyx +++ b/src/sage/rings/finite_rings/element_givaro.pyx @@ -1729,6 +1729,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): """ return unpickle_FiniteField_givaroElement,(self.parent(),self.element) + def unpickle_FiniteField_givaroElement(parent, int x): """ TESTS:: diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index 32ffd192353..f8272336c8a 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -1021,7 +1021,6 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): cdef int pow = n/d return f if pow == 1 else f**pow - def minpoly(self, var='x'): r""" Return the minimal polynomial of ``self``, which is the smallest @@ -1302,6 +1301,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement): x = pari.fflog(self, base, (base_order, fac)) return Integer(x) + def unpickleFiniteField_ntl_gf2eElement(parent, elem): """ EXAMPLES:: diff --git a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx index bf3e69f56a7..81b7045b8f6 100644 --- a/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx +++ b/src/sage/rings/finite_rings/hom_finite_field_givaro.pyx @@ -99,7 +99,6 @@ cdef class SectionFiniteFieldHomomorphism_givaro(SectionFiniteFieldHomomorphism_ self._codomain_cache = ((self._codomain.gen()))._cache - cpdef Element _call_(self, x): """ TESTS:: @@ -181,7 +180,6 @@ cdef class FiniteFieldHomomorphism_givaro(FiniteFieldHomomorphism_generic): self._order_domain = domain.cardinality() - 1 self._order_codomain = codomain.cardinality() - 1 - cpdef Element _call_(self, x): """ TESTS:: @@ -228,7 +226,6 @@ cdef class FrobeniusEndomorphism_givaro(FrobeniusEndomorphism_finite_field): raise TypeError("The domain is not an instance of FiniteField_givaro") FrobeniusEndomorphism_finite_field.__init__(self, domain, power) - def fixed_field(self): """ Return the fixed field of ``self``. diff --git a/src/sage/rings/fraction_field_element.pyx b/src/sage/rings/fraction_field_element.pyx index e651a0bf560..38abe60b094 100644 --- a/src/sage/rings/fraction_field_element.pyx +++ b/src/sage/rings/fraction_field_element.pyx @@ -264,7 +264,6 @@ cdef class FractionFieldElement(FieldElement): """ return self._denominator - def is_square(self,root=False): """ Return whether or not ``self`` is a perfect square. @@ -1286,6 +1285,7 @@ cdef class FractionFieldElement_1poly_field(FractionFieldElement): super(self.__class__, self).reduce() self.normalize_leading_coefficients() + def make_element(parent, numerator, denominator): """ Used for unpickling :class:`FractionFieldElement` objects (and subclasses). diff --git a/src/sage/rings/laurent_series_ring_element.pyx b/src/sage/rings/laurent_series_ring_element.pyx index 62c244d1669..f03ad5a3fd5 100644 --- a/src/sage/rings/laurent_series_ring_element.pyx +++ b/src/sage/rings/laurent_series_ring_element.pyx @@ -149,7 +149,6 @@ cdef class LaurentSeries(AlgebraElement): elif parent is not f.parent(): f = parent._power_series_ring(f) - # self is that t^n * u: if not f: if n is infinity: @@ -822,7 +821,6 @@ cdef class LaurentSeries(AlgebraElement): # 3. Subtract return type(self)(self._parent, f1 - f2, m) - def add_bigoh(self, prec): """ Return the truncated series at chosen precision ``prec``. @@ -1564,7 +1562,6 @@ cdef class LaurentSeries(AlgebraElement): """ return multi_derivative(self, args) - def _derivative(self, var=None): """ The formal derivative of this Laurent series with respect to var. @@ -1624,7 +1621,6 @@ cdef class LaurentSeries(AlgebraElement): u = self._parent._power_series_ring(v, self.__u.prec()) return type(self)(self._parent, u, n-1) - def integral(self): r""" The formal integral of this Laurent series with 0 constant term. @@ -1682,7 +1678,6 @@ cdef class LaurentSeries(AlgebraElement): raise ArithmeticError("Coefficients of integral cannot be coerced into the base ring") return type(self)(self._parent, u, n+1) - def nth_root(self, long n, prec=None): r""" Return the ``n``-th root of this Laurent power series. diff --git a/src/sage/rings/polynomial/cyclotomic.pyx b/src/sage/rings/polynomial/cyclotomic.pyx index 84f85104cc3..4d1c44c5ec0 100644 --- a/src/sage/rings/polynomial/cyclotomic.pyx +++ b/src/sage/rings/polynomial/cyclotomic.pyx @@ -40,6 +40,7 @@ try: except ImportError: pass + def cyclotomic_coeffs(nn, sparse=None): """ Return the coefficients of the `n`-th cyclotomic polynomial diff --git a/src/sage/rings/polynomial/hilbert.pyx b/src/sage/rings/polynomial/hilbert.pyx index 198a0940b95..59ba9bc1304 100644 --- a/src/sage/rings/polynomial/hilbert.pyx +++ b/src/sage/rings/polynomial/hilbert.pyx @@ -421,6 +421,7 @@ cdef make_children(Node D, tuple w): # It may be a good idea to form the product of some of the most # frequent variables. But this isn't implemented yet. TODO? + def first_hilbert_series(I, grading=None, return_grading=False): """ Return the first Hilbert series of the given monomial ideal. @@ -550,6 +551,7 @@ def first_hilbert_series(I, grading=None, return_grading=False): fmpz_poly_add(fhs._poly, AN.LMult, AN.RMult) got_result = True + def hilbert_poincare_series(I, grading=None): r""" Return the Hilbert Poincaré series of the given monomial ideal. diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx index 14820418454..e01f181be1d 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx @@ -145,6 +145,7 @@ cdef ideal *sage_ideal_to_singular_ideal(I) except NULL: raise TypeError("All generators must be of type MPolynomial_libsingular.") return i + def kbase_libsingular(I, degree=None): """ SINGULAR's ``kbase()`` algorithm. @@ -201,6 +202,7 @@ def kbase_libsingular(I, degree=None): return res + def std_libsingular(I): """ SINGULAR's ``std()`` algorithm. @@ -224,7 +226,6 @@ def std_libsingular(I): idSkipZeroes(result) - id_Delete(&i,r) res = singular_ideal_to_sage_sequence(result,r,I.ring()) @@ -272,6 +273,7 @@ def slimgb_libsingular(I): id_Delete(&result,r) return res + def interred_libsingular(I): """ SINGULAR's ``interred()`` command. @@ -318,7 +320,6 @@ def interred_libsingular(I): sig_off() singular_options = bck - # divide head by coefficients if r.cf.type != n_Z and r.cf.type != n_Znm and r.cf.type != n_Zn and r.cf.type != n_Z2m : for j from 0 <= j < IDELEMS(result): diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 6b838190c52..ce239335523 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -1877,6 +1877,7 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base): M.append(new_MP(self, p_Copy(tempvector, _ring))) return M + def unpickle_MPolynomialRing_libsingular(base_ring, names, term_order): """ inverse function for ``MPolynomialRing_libsingular.__reduce__`` diff --git a/src/sage/rings/polynomial/polynomial_compiled.pyx b/src/sage/rings/polynomial/polynomial_compiled.pyx index 01fac1e932f..f17122814de 100644 --- a/src/sage/rings/polynomial/polynomial_compiled.pyx +++ b/src/sage/rings/polynomial/polynomial_compiled.pyx @@ -232,8 +232,6 @@ cdef class CompiledPolynomialFunction: The r == 0 case in step 3 is equivalent to binary exponentiation. """ - - cdef int m,n,k,r,half cdef generic_pd T,N,H cdef dummy_pd M diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index dcf2af7cdf2..5d2fc9df65f 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -11554,7 +11554,6 @@ cdef class Polynomial(CommutativePolynomial): phi = SpecializationMorphism(self._parent,D) return phi(self) - def _log_series(self, long n): r""" Return the power series expansion of logarithm of this polynomial, @@ -11711,6 +11710,7 @@ cdef class Polynomial(CommutativePolynomial): """ raise NotImplementedError + # ----------------- inner functions ------------- # Cython can't handle function definitions inside other function @@ -11766,6 +11766,7 @@ cdef list do_schoolbook_product(list x, list y, Py_ssize_t deg): coeffs[k] = sum return coeffs + @cython.boundscheck(False) @cython.wraparound(False) @cython.overflowcheck(False) @@ -11848,6 +11849,7 @@ cdef list do_karatsuba_different_size(list left, list right, Py_ssize_t K_thresh output.extend(carry[n-1:]) return output + @cython.boundscheck(False) @cython.wraparound(False) @cython.overflowcheck(False) @@ -12581,6 +12583,7 @@ cdef class Polynomial_generic_dense(Polynomial): self._coeffs = self._coeffs[:n] return self + def make_generic_polynomial(parent, coeffs): return parent(coeffs) diff --git a/src/sage/rings/polynomial/polynomial_gf2x.pyx b/src/sage/rings/polynomial/polynomial_gf2x.pyx index c3bafe951ca..fceadf66d6b 100644 --- a/src/sage/rings/polynomial/polynomial_gf2x.pyx +++ b/src/sage/rings/polynomial/polynomial_gf2x.pyx @@ -310,6 +310,7 @@ def GF2X_BuildIrred_list(n): GF2X_BuildIrred(f, int(n)) return [GF2(not GF2_IsZero(GF2X_coeff(f, i))) for i in range(n + 1)] + def GF2X_BuildSparseIrred_list(n): """ Return the list of coefficients of an irreducible polynomial of @@ -330,6 +331,7 @@ def GF2X_BuildSparseIrred_list(n): GF2X_BuildSparseIrred(f, int(n)) return [GF2(not GF2_IsZero(GF2X_coeff(f, i))) for i in range(n + 1)] + def GF2X_BuildRandomIrred_list(n): """ Return the list of coefficients of an irreducible polynomial of diff --git a/src/sage/rings/polynomial/polynomial_number_field.pyx b/src/sage/rings/polynomial/polynomial_number_field.pyx index 80d7af0e4b1..54bddc4e203 100644 --- a/src/sage/rings/polynomial/polynomial_number_field.pyx +++ b/src/sage/rings/polynomial/polynomial_number_field.pyx @@ -63,20 +63,21 @@ We can also construct polynomials over relative number fields:: 1 """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2014 Luis Felipe Tabera Alonso # # Distributed under the terms of the GNU General Public License (GPL) # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.rings.polynomial.polynomial_element_generic import Polynomial_generic_dense_field from sage.rings.rational_field import QQ from sage.structure.element import coerce_binop from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing + class Polynomial_absolute_number_field_dense(Polynomial_generic_dense_field): """ Class of dense univariate polynomials over an absolute number field. diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index a43e34a3fc9..84d6ed56596 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -165,7 +165,6 @@ cdef class Polynomial_rational_flint(Polynomial): fmpq_poly_set_si(res._poly, int(x)) return res - def __cinit__(self): """ Initialises the underlying data structure. diff --git a/src/sage/rings/polynomial/weil/weil_polynomials.pyx b/src/sage/rings/polynomial/weil/weil_polynomials.pyx index f9d61a2a352..ca5288a963f 100755 --- a/src/sage/rings/polynomial/weil/weil_polynomials.pyx +++ b/src/sage/rings/polynomial/weil/weil_polynomials.pyx @@ -231,6 +231,7 @@ cdef class dfs_manager: raise RuntimeError("Node limit ({0:%d}) exceeded".format(self.node_limit)) return ans + class WeilPolynomials_iter(): r""" Iterator created by WeilPolynomials. diff --git a/src/sage/rings/power_series_mpoly.pyx b/src/sage/rings/power_series_mpoly.pyx index 714d939c30b..f7a298e8410 100644 --- a/src/sage/rings/power_series_mpoly.pyx +++ b/src/sage/rings/power_series_mpoly.pyx @@ -116,7 +116,6 @@ cdef class PowerSeries_mpoly(PowerSeries): prec = prec, check =True) - def __iter__(self): """ Return an iterator over the coefficients of this power series. diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index 8e1b76a7cc9..30055b75453 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -794,7 +794,6 @@ cdef class PowerSeries(AlgebraElement): s += " + %s"%bigoh return s.lstrip(" ") - def truncate(self, prec=infinity): """ The polynomial obtained from power series by truncation. @@ -2725,7 +2724,6 @@ cdef class PowerSeries(AlgebraElement): """ return multi_derivative(self, args) - def __setitem__(self, n, value): """ Called when an attempt is made to change a power series. diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 819a85dbc35..8a591520d98 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -82,6 +82,7 @@ from sage.structure.richcmp cimport rich_to_bool_sgn RealNumber_classes = () + def _register_real_number_class(cls): r""" Register ``cls``. @@ -1580,7 +1581,6 @@ cdef class Rational(sage.structure.element.FieldElement): a, b = K.pari_bnf(proof=proof).bnfisnorm(self, flag=extra_primes) return K(a), Rational(b) - def is_perfect_power(self, expected_value=False): r""" Return ``True`` if ``self`` is a perfect power. @@ -3560,7 +3560,6 @@ cdef class Rational(sage.structure.element.FieldElement): else: return sage.rings.infinity.infinity - def multiplicative_order(self): """ Return the multiplicative order of ``self``. @@ -3633,10 +3632,9 @@ cdef class Rational(sage.structure.element.FieldElement): """ return True - #Function alias for checking if the number is a integer. Added to solve issue 15500 + # Function alias for checking if the number is a integer. Added to solve issue 15500 is_integer = is_integral - def is_S_integral(self, S=[]): r""" Determine if the rational number is ``S``-integral. diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index 5cd916690de..a1f06964719 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -130,6 +130,7 @@ cdef int three_squares_c(uint_fast32_t n, uint_fast32_t res[3]) noexcept: return 1 + def two_squares_pyx(uint32_t n): r""" Return a pair of non-negative integers ``(i,j)`` such that `i^2 + j^2 = n`. @@ -184,7 +185,8 @@ def two_squares_pyx(uint32_t n): return (integer.smallInteger(i[0]), integer.smallInteger(i[1])) sig_off() - raise ValueError("%d is not a sum of 2 squares"%n) + raise ValueError("%d is not a sum of 2 squares" % n) + def is_sum_of_two_squares_pyx(uint32_t n): r""" @@ -214,6 +216,7 @@ def is_sum_of_two_squares_pyx(uint32_t n): sig_off() return False + def three_squares_pyx(uint32_t n): r""" If ``n`` is a sum of three squares return a 3-tuple ``(i,j,k)`` of Sage integers @@ -266,7 +269,8 @@ def three_squares_pyx(uint32_t n): return (integer.smallInteger(i[0]), integer.smallInteger(i[1]), integer.smallInteger(i[2])) sig_off() - raise ValueError("%d is not a sum of 3 squares"%n) + raise ValueError("%d is not a sum of 3 squares" % n) + def four_squares_pyx(uint32_t n): r""" diff --git a/src/sage/rings/tate_algebra_element.pyx b/src/sage/rings/tate_algebra_element.pyx index 86b0a4dba52..6b606881399 100644 --- a/src/sage/rings/tate_algebra_element.pyx +++ b/src/sage/rings/tate_algebra_element.pyx @@ -1013,7 +1013,6 @@ cdef class TateAlgebraTerm(MonoidElement): raise ValueError("the division is not exact") return (self)._floordiv_c(other) - cdef TateAlgebraTerm _floordiv_c(self, TateAlgebraTerm other): r""" Return the result of the exact division of this term by ``other``. @@ -1664,7 +1663,6 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): """ return self.nth_root(2, prec) - def sqrt(self, prec=None): r""" Return the square root of this series. @@ -1705,7 +1703,6 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): """ return self.nth_root(2, prec) - def nth_root(self, n=2, prec=None): r""" Return the ``n``-th root of this series. @@ -1791,7 +1788,6 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): root += scalar * root * (1 - a * root**n) return root - cpdef _richcmp_(self, other, int op): r""" Compare this series with ``other`` according to @@ -2801,7 +2797,6 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): series += nfactorial return series / nfactorial - def leading_term(self, secure=False): r""" Return the leading term of this series. @@ -2885,7 +2880,6 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): else: raise ValueError("zero has no leading term") - def leading_coefficient(self, secure=False): """ Return the leading coefficient of this series. @@ -3026,15 +3020,11 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement): ...00000000010 + ...0000000001*x*y sage: g.is_monic() False - """ if self.valuation() != 0: return False c = self.leading_coefficient() - if c != 0 and c.unit_part() == 1: - return True - return False - + return c != 0 and c.unit_part() == 1 def weierstrass_degree(self): r""" diff --git a/src/sage/rings/tate_algebra_ideal.pyx b/src/sage/rings/tate_algebra_ideal.pyx index acad1be5fd3..5d72155f97c 100644 --- a/src/sage/rings/tate_algebra_ideal.pyx +++ b/src/sage/rings/tate_algebra_ideal.pyx @@ -35,6 +35,7 @@ from heapq import heappush, heappop from cysignals.signals cimport sig_check + class TateAlgebraIdeal(Ideal_generic): r""" Initialize a class for ideals in a Tate series algebra @@ -785,6 +786,7 @@ def print_pair(p, verbose): s, v = p return "(sign = %s, series = %s + ...)" % (s, v.leading_term()) + def groebner_basis_pote(I, prec, verbose=0): r""" Run the PoTe algorithm to compute the Groebner basis of ``I`` diff --git a/src/tox.ini b/src/tox.ini index c270270ff52..dd8b51409ef 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -181,7 +181,7 @@ description = # 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,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} - pycodestyle --select E111,E271,E301,E305,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} + pycodestyle --select E111,E271,E301,E302,E305,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} [pycodestyle] max-line-length = 160