Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #29029: some cleaning in power series pyx files
Browse files Browse the repository at this point in the history
some doc details

and removing unused imports

URL: https://trac.sagemath.org/29029
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Jori Mäntysalo
  • Loading branch information
Release Manager committed Jan 20, 2020
2 parents 4cb8a7b + da67634 commit 4fd5d56
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 54 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=fef64fcd9915ea4f881bc5cfeecb8b3864bc555f
md5=0b23947f22228ef6d5d1143a906cd4a6
cksum=844195685
sha1=3506adf8c82496e255cfdbbdcf29834dfe304972
md5=5025184149d48727710a67a8cff91387
cksum=914476400
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7140d0e7bb897e008d315fdcd371c11528aa70d3
c17110f970d3b0d8b0857cd02edd96b8f03430ef
8 changes: 3 additions & 5 deletions src/sage/rings/power_series_pari.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,21 @@ AUTHORS:
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2013-2017 Peter Bruin <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License 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 cypari2.gen cimport Gen as pari_gen
from cypari2.pari_instance cimport get_var
from cypari2.paridecl cimport gel, typ, lg, valp, varn, t_POL, t_SER, t_RFRAC, t_VEC
from sage.libs.pari.all import pari

from sage.misc.superseded import deprecated_function_alias

from sage.rings.polynomial.polynomial_element cimport Polynomial
from sage.rings.power_series_ring_element cimport PowerSeries
from sage.structure.element cimport Element, RingElement
Expand Down
89 changes: 44 additions & 45 deletions src/sage/rings/power_series_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ from .power_series_ring_element cimport PowerSeries
from sage.structure.element cimport Element, ModuleElement, RingElement
from .infinity import infinity, is_Infinite
from sage.libs.all import pari_gen, PariError
from sage.misc.superseded import deprecated_function_alias


cdef class PowerSeries_poly(PowerSeries):
Expand Down Expand Up @@ -103,7 +102,7 @@ cdef class PowerSeries_poly(PowerSeries):

def polynomial(self):
"""
Return the underlying polynomial of self.
Return the underlying polynomial of ``self``.
EXAMPLES::
Expand All @@ -116,7 +115,7 @@ cdef class PowerSeries_poly(PowerSeries):

def valuation(self):
"""
Return the valuation of self.
Return the valuation of ``self``.
EXAMPLES::
Expand All @@ -137,10 +136,11 @@ cdef class PowerSeries_poly(PowerSeries):

def degree(self):
"""
Return the degree of the underlying polynomial of self. That
is, if self is of the form f(x) + O(x^n), we return the degree
of f(x). Note that if f(x) is 0, we return -1, just as with
polynomials.
Return the degree of the underlying polynomial of ``self``.
That is, if ``self`` is of the form `f(x) + O(x^n)`, we return
the degree of `f(x)`. Note that if `f(x)` is `0`, we return `-1`,
just as with polynomials.
EXAMPLES::
Expand All @@ -156,7 +156,7 @@ cdef class PowerSeries_poly(PowerSeries):

def __nonzero__(self):
"""
Return True if self is nonzero, and False otherwise.
Return ``True`` if ``self`` is nonzero, and ``False`` otherwise.
EXAMPLES::
Expand All @@ -179,14 +179,14 @@ cdef class PowerSeries_poly(PowerSeries):
- ``x``:
- a tuple of elements the first of which can be meaningfully
substituted in self, with the remainder used for substitution
in the coefficients of self.
substituted in ``self``, with the remainder used for substitution
in the coefficients of ``self``.
- a dictionary for kwds:value pairs. If the variable name of
self is a keyword it is substituted for. Other keywords
are used for substitution in the coefficients of self.
OUTPUT: the value of self after substitution.
OUTPUT: the value of ``self`` after substitution.
EXAMPLES::
Expand Down Expand Up @@ -404,14 +404,14 @@ cdef class PowerSeries_poly(PowerSeries):

def __getitem__(self, n):
"""
Return the nth coefficient of self.
Return the ``n``-th coefficient of ``self``.
If n is a slice object, this will return a power series of the
same precision, whose coefficients are the same as self for
If ``n`` is a slice object, this will return a power series of the
same precision, whose coefficients are the same as ``self`` for
those indices in the slice, and 0 otherwise.
Returns 0 for negative coefficients. Raises an IndexError if
try to access beyond known coefficients.
This returns 0 for negative coefficients and raises an
``IndexError`` if trying to access beyond known coefficients.
EXAMPLES::
Expand Down Expand Up @@ -545,7 +545,7 @@ cdef class PowerSeries_poly(PowerSeries):

cpdef _rmul_(self, Element c):
"""
Multiply self on the right by a scalar.
Multiply ``self`` on the right by a scalar.
EXAMPLES::
Expand All @@ -558,7 +558,7 @@ cdef class PowerSeries_poly(PowerSeries):

cpdef _lmul_(self, Element c):
"""
Multiply self on the left by a scalar.
Multiply ``self`` on the left by a scalar.
EXAMPLES::
Expand All @@ -571,7 +571,7 @@ cdef class PowerSeries_poly(PowerSeries):

def __lshift__(PowerSeries_poly self, n):
"""
Shift self to the left by n, i.e. multiply by x^n.
Shift ``self`` to the left by ``n``, i.e. multiply by `x^n`.
EXAMPLES::
Expand All @@ -587,7 +587,7 @@ cdef class PowerSeries_poly(PowerSeries):

def __rshift__(PowerSeries_poly self, n):
"""
Shift self to the right by n, i.e. multiply by x^-n and
Shift ``self`` to the right by ``n``, i.e. multiply by `x^{-n}` and
remove any terms of negative exponent.
EXAMPLES::
Expand Down Expand Up @@ -720,9 +720,9 @@ cdef class PowerSeries_poly(PowerSeries):

cdef _inplace_truncate(self, long prec):
"""
Truncate self to precision ``prec`` in place.
Truncate ``self`` to precision ``prec`` in place.
NOTE::
.. NOTE::
This is very unsafe, since power series are supposed to
be immutable in Sage. Use at your own risk!
Expand All @@ -749,9 +749,11 @@ cdef class PowerSeries_poly(PowerSeries):

def list(self):
"""
Return the list of known coefficients for self. This is just
the list of coefficients of the underlying polynomial, so in
particular, need not have length equal to self.prec().
Return the list of known coefficients for ``self``.
This is just the list of coefficients of the underlying
polynomial, so in particular, need not have length equal to
``self.prec()``.
EXAMPLES::
Expand All @@ -764,9 +766,11 @@ cdef class PowerSeries_poly(PowerSeries):

def dict(self):
"""
Return a dictionary of coefficients for self. This is simply a
dict for the underlying polynomial, so need not have keys
corresponding to every number smaller than self.prec().
Return a dictionary of coefficients for ``self``.
This is simply a dict for the underlying polynomial, so need
not have keys corresponding to every number smaller than
``self.prec()``.
EXAMPLES::
Expand All @@ -780,17 +784,17 @@ cdef class PowerSeries_poly(PowerSeries):
def _derivative(self, var=None):
"""
Return the derivative of this power series with respect
to the variable var.
to the variable ``var``.
If var is None or is the generator of this ring, we take the derivative
with respect to the generator.
If ``var`` is ``None`` or is the generator of this ring, we
take the derivative with respect to the generator.
Otherwise, we call _derivative(var) on each coefficient of
Otherwise, we call ``_derivative(var)`` on each coefficient of
the series.
SEEALSO::
.. SEEALSO::
self.derivative()
``self.derivative()``
EXAMPLES::
Expand Down Expand Up @@ -836,7 +840,7 @@ cdef class PowerSeries_poly(PowerSeries):

def integral(self,var=None):
"""
The integral of this power series
Return the integral of this power series.
By default, the integration variable is the variable of the
power series.
Expand Down Expand Up @@ -880,6 +884,7 @@ cdef class PowerSeries_poly(PowerSeries):
def reverse(self, precision=None):
"""
Return the reverse of f, i.e., the series g such that g(f(x)) = x.
Given an optional argument ``precision``, return the reverse with given
precision (note that the reverse can have precision at most
``f.prec()``). If ``f`` has infinite precision, and the argument
Expand Down Expand Up @@ -991,7 +996,6 @@ cdef class PowerSeries_poly(PowerSeries):
sage: (x - x^2).reverse(precision=3)
x + x^2 + O(x^3)
TESTS::
sage: R.<x> = PowerSeriesRing(QQ)
Expand All @@ -1000,9 +1004,6 @@ cdef class PowerSeries_poly(PowerSeries):
Traceback (most recent call last):
...
ValueError: Series must have valuation one for reversion.
"""
if self.valuation() != 1:
raise ValueError("Series must have valuation one for reversion.")
Expand Down Expand Up @@ -1038,8 +1039,7 @@ cdef class PowerSeries_poly(PowerSeries):
from sage.misc.all import verbose
verbose("passing to pari failed; trying Lagrange inversion")


if f.parent().characteristic() > 0:
if f.parent().characteristic():
# over a ring of positive characteristic, attempt lifting to
# characteristic zero ring
verbose("parent ring has positive characteristic; attempting lift to characteristic zero")
Expand All @@ -1064,7 +1064,7 @@ cdef class PowerSeries_poly(PowerSeries):

def pade(self, m, n):
r"""
Returns the Padé approximant of ``self`` of index `(m, n)`.
Return the Padé approximant of ``self`` of index `(m, n)`.
The Padé approximant of index `(m, n)` of a formal power
series `f` is the quotient `Q/P` of two polynomials `Q` and `P`
Expand Down Expand Up @@ -1149,7 +1149,6 @@ cdef class PowerSeries_poly(PowerSeries):
u, v = c.rational_reconstruct(z**(n + m + 1), m, n);
return u/v


def _symbolic_(self, ring):
"""
Conversion to symbolic series.
Expand Down Expand Up @@ -1188,9 +1187,9 @@ cdef class PowerSeries_poly(PowerSeries):
return pex.series(var, self.prec())


def make_powerseries_poly_v0(parent, f, prec, is_gen):
def make_powerseries_poly_v0(parent, f, prec, is_gen):
"""
Return the power series specified by f, prec, and is_gen.
Return the power series specified by ``f``, ``prec``, and ``is_gen``.
This function exists for the purposes of pickling. Do not delete
this function -- if you change the internal representation,
Expand Down

0 comments on commit 4fd5d56

Please sign in to comment.