Skip to content

Commit

Permalink
make dict an alias to avoid duplicating docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Oct 5, 2024
1 parent 92c4646 commit 81f9a96
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/laurent_polynomial.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement):
cpdef _mul_(self, other)
cpdef _floordiv_(self, other)
cpdef long number_of_terms(self) except -1
cpdef dict dict(self)
cpdef dict monomial_coefficients(self)


cdef class LaurentPolynomial_univariate(LaurentPolynomial):
cdef ModuleElement __u
cdef long __n
Expand Down
10 changes: 4 additions & 6 deletions src/sage/rings/polynomial/laurent_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,22 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement):
"""
return self.number_of_terms()

cpdef dict dict(self):
cpdef dict monomial_coefficients(self):
"""
Abstract ``dict`` method.
EXAMPLES::
sage: R.<x> = LaurentPolynomialRing(ZZ)
sage: from sage.rings.polynomial.laurent_polynomial import LaurentPolynomial
sage: LaurentPolynomial.dict(x)
sage: LaurentPolynomial.monomial_coefficients(x)
Traceback (most recent call last):
...
NotImplementedError
"""
raise NotImplementedError

cpdef dict monomial_coefficients(self):
raise NotImplementedError
dict = monomial_coefficients

def map_coefficients(self, f, new_base_ring=None):
"""
Expand Down Expand Up @@ -863,8 +862,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial):
cdef dict d = self.__u.monomial_coefficients()
return {k + self.__n: d[k] for k in d}

cpdef dict dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def coefficients(self):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/polynomial/laurent_polynomial_mpair.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ cdef class LaurentPolynomial_mpair(LaurentPolynomial):
self._compute_polydict()
return < dict > self._prod.dict()

cpdef dict dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def _fraction_pair(self):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3022,8 +3022,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
p = pNext(p)
return pd

def dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def iterator_exp_coeff(self, as_ETuples=True):
"""
Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/polynomial/ore_polynomial_element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ cdef class OrePolynomial_generic_dense(OrePolynomial):
cdef list _mul_list(self, list A)
cpdef _mul_(self, other)

cpdef dict dict(self)
cpdef dict monomial_coefficients(self)
cpdef list list(self, bint copy=*)

Expand Down
9 changes: 5 additions & 4 deletions src/sage/rings/polynomial/ore_polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2491,10 +2491,12 @@ cdef class OrePolynomial_generic_dense(OrePolynomial):
sage: sigma = R.hom([t+1])
sage: S.<x> = R['x',sigma]
sage: a = x^2012 + t*x^1006 + t^3 + 2*t
sage: a.dict()
sage: a.monomial_coefficients()
{0: t^3 + 2*t, 1006: t, 2012: 1}
sage: a.monomial_coefficients()
``dict`` is an alias::
sage: a.dict()
{0: t^3 + 2*t, 1006: t, 2012: 1}
"""
cdef dict X = {}
Expand All @@ -2506,8 +2508,7 @@ cdef class OrePolynomial_generic_dense(OrePolynomial):
X[i] = c
return X

cpdef dict dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

cpdef Integer degree(self):
r"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4487,8 +4487,7 @@ cdef class Polynomial(CommutativePolynomial):
X[i] = c
return X

def dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def factor(self, **kwargs):
r"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/power_series_pari.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,7 @@ cdef class PowerSeries_pari(PowerSeries):
"""
return self.polynomial().monomial_coefficients()

def dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def _derivative(self, var=None):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/power_series_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ cdef class PowerSeries_poly(PowerSeries):
"""
return self.__f.monomial_coefficients()

def dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def _derivative(self, var=None):
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/tate_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2213,8 +2213,7 @@ cdef class TateAlgebraElement(CommutativeAlgebraElement):
self._normalize()
return dict(self._poly.__repn)

def dict(self):
return self.monomial_coefficients()
dict = monomial_coefficients

def coefficient(self, exponent):
r"""
Expand Down

0 comments on commit 81f9a96

Please sign in to comment.