This repository was archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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 | ||
|
@@ -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): | ||
""" | ||
|
@@ -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:: | ||
|
@@ -255,7 +255,7 @@ def zero(self): | |
|
||
def identity_element(self): | ||
""" | ||
Returns the one power series. | ||
Return the one power series. | ||
EXAMPLES:: | ||
|
@@ -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: | ||
|
@@ -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 | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -952,7 +952,7 @@ def get_aorder(self): | |
|
||
def get_order(self): | ||
""" | ||
Returns the order of self. | ||
Return the order of self. | ||
EXAMPLES:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -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:: | ||
|
@@ -1601,7 +1599,7 @@ def exponential(self): | |
|
||
def __getitem__(self, i): | ||
""" | ||
Returns the ith coefficient of self. | ||
Return the ith coefficient of self. | ||
EXAMPLES:: | ||
|
@@ -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:: | ||
|
@@ -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) | ||
|
||
|