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

Commit

Permalink
py3: final fix for species
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jan 29, 2019
1 parent 0cb4942 commit aba9cd9
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/sage/combinat/species/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
In particular, the relevant section for this file can be found at
http://www.risc.uni-linz.ac.at/people/hemmecke/AldorCombinat/combinatse9.html.
"""
#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2008 Mike Hansen <[email protected]>,
#
# Distributed under the terms of the GNU General Public License (GPL)
Expand All @@ -26,8 +26,8 @@
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import absolute_import

from .stream import Stream, Stream_class
Expand Down Expand Up @@ -91,7 +91,7 @@ def __repr__(self):
sage: LazyPowerSeriesRing(QQ)
Lazy Power Series Ring over Rational Field
"""
return "Lazy Power Series Ring over %s"%self.base_ring()
return "Lazy Power Series Ring over %s" % self.base_ring()

def __eq__(self, x):
"""
Expand Down Expand Up @@ -239,11 +239,11 @@ def __call__(self, x=None, order=unk):
x = BR(x)
return self.term(x, 0)

raise TypeError("do not know how to coerce %s into self"%x)
raise TypeError("do not know how to coerce %s into self" % x)

def zero(self):
"""
Returns the zero power series.
Return the zero power series.
EXAMPLES::
Expand All @@ -255,7 +255,7 @@ def zero(self):

def identity_element(self):
"""
Returns the one power series.
Return the one power series.
EXAMPLES::
Expand Down Expand Up @@ -303,13 +303,13 @@ def term(self, r, n):
elif n == 1:
res._name = repr(r) + "*" + self._name
else:
res._name = "%s*%s^%s"%(repr(r), self._name, n)
res._name = "%s*%s^%s" % (repr(r), self._name, n)

return res

def _new_initial(self, order, stream):
"""
Returns a new power series with specified order.
Return a new power series with specified order.
INPUT:
Expand Down Expand Up @@ -596,7 +596,7 @@ def __repr__(self):
else:
l = baserepr + " + " + repr_lincomb([(x+"^"+str(i), self._stream[n-1]) for i in range(n, n+3)]) + " + ..."
else:
l = baserepr + " + O(x^%s)"%n if n > 0 else "O(1)"
l = baserepr + " + O(x^%s)" % n if n > 0 else "O(1)"
else:
l = 'Uninitialized lazy power series'
return l
Expand Down Expand Up @@ -739,7 +739,7 @@ def compute_coefficients(self, i):

def coefficients(self, n):
"""
Returns the first n coefficients of self.
Return the first n coefficients of self.
EXAMPLES::
Expand All @@ -752,7 +752,7 @@ def coefficients(self, n):

def is_zero(self):
"""
Returns True if and only if self is zero.
Return True if and only if self is zero.
EXAMPLES::
Expand Down Expand Up @@ -918,7 +918,7 @@ def define(self, x):

def coefficient(self, n):
"""
Returns the coefficient of xn in self.
Return the coefficient of xn in self.
EXAMPLES::
Expand All @@ -938,7 +938,7 @@ def coefficient(self, n):

def get_aorder(self):
"""
Returns the approximate order of self.
Return the approximate order of self.
EXAMPLES::
Expand All @@ -952,7 +952,7 @@ def get_aorder(self):

def get_order(self):
"""
Returns the order of self.
Return the order of self.
EXAMPLES::
Expand All @@ -966,7 +966,7 @@ def get_order(self):

def get_stream(self):
"""
Returns self's underlying Stream object.
Return self's underlying Stream object.
EXAMPLES::
Expand Down Expand Up @@ -1198,8 +1198,7 @@ def __pow__(self, n):

def __call__(self, y):
"""
Returns the composition of this power series and the power series
y.
Return the composition of this power series and the power series y.
EXAMPLES::
Expand Down Expand Up @@ -1267,7 +1266,7 @@ def _compose_gen(self, y, ao):

def tail(self):
"""
Returns the power series whose coefficients obtained by subtracting
Return the power series whose coefficients obtained by subtracting
the constant term from this series and then dividing by x.
EXAMPLES::
Expand All @@ -1283,7 +1282,7 @@ def tail(self):

def iterator(self, n=0, initial=None):
"""
Returns an iterator for the coefficients of self starting at n.
Return an iterator for the coefficients of self starting at n.
EXAMPLES::
Expand All @@ -1308,7 +1307,7 @@ def iterator(self, n=0, initial=None):

def _power_gen(self):
"""
Returns a generator for all the powers self^k starting with k = 1.
Return a generator for all the powers self^k starting with k = 1.
EXAMPLES::
Expand Down Expand Up @@ -1388,8 +1387,7 @@ def derivative(self):

def _diff_gen(self, ao):
"""
Returns an iterator for the coefficients of the derivative of
self.
Return an iterator for the coefficients of the derivative of self.
EXAMPLES::
Expand Down Expand Up @@ -1601,7 +1599,7 @@ def exponential(self):

def __getitem__(self, i):
"""
Returns the ith coefficient of self.
Return the ith coefficient of self.
EXAMPLES::
Expand All @@ -1618,10 +1616,11 @@ def __getitem__(self, i):
#########################
def restricted(self, min=None, max=None):
"""
Returns the power series restricted to the coefficients starting at
min and going up to, but not including max. If min is not
specified, then it is assumed to be zero. If max is not specified,
then it is assumed to be infinity.
Return the power series restricted to the coefficients starting at
``min`` and going up to, but not including ``max``.
If ``min`` is not specified, then it is assumed to be zero. If
``max`` is not specified, then it is assumed to be infinity.
EXAMPLES::
Expand All @@ -1637,10 +1636,13 @@ def restricted(self, min=None, max=None):
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
"""
from six.moves import builtins

if ((min is None and max is None) or
(max is None and self.get_aorder() >= min)):
return self

if min is None:
min = 0
return self._new(partial(self._restricted_gen, min, max),
lambda ao: builtins.max(ao, min), self)

Expand Down

0 comments on commit aba9cd9

Please sign in to comment.