summaryrefslogtreecommitdiff
path: root/numpy/polynomial/polytemplate.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-05-23 22:02:08 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-05-23 22:02:08 +0000
commit6e77005137eca1e7fdd4ebd3935f7f57d6aba7bd (patch)
treee5845447e506a080d00961f5e0a3dfc3e40d8c8a /numpy/polynomial/polytemplate.py
parent59fd4c37d75895ca09f5ad06571d67084eb34324 (diff)
downloadnumpy-6e77005137eca1e7fdd4ebd3935f7f57d6aba7bd.tar.gz
REV: Revert the changes to the truncate method of Polynomial and Chebyshev.
On second thought it was a bad idea to make such a radical change to existing behaviour. It was also hard to document the variations ;)
Diffstat (limited to 'numpy/polynomial/polytemplate.py')
-rw-r--r--numpy/polynomial/polytemplate.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/numpy/polynomial/polytemplate.py b/numpy/polynomial/polytemplate.py
index 08510c1ff..bf94d28ec 100644
--- a/numpy/polynomial/polytemplate.py
+++ b/numpy/polynomial/polytemplate.py
@@ -391,20 +391,19 @@ class $name(pu.PolyBase) :
"""
return self.__class__(pu.trimcoef(self.coef, tol), self.domain)
- def truncate(self, deg) :
- """Truncate series to degree `deg`.
+ def truncate(self, size) :
+ """Truncate series to length `size`.
- Return a $name series obtained from the current instance by discarding
- all terms of degree greater than `deg`. The value of `deg` must be
- non-negative. This operation is most likely to be useful in least squares
- fits when the high order coefficients are very small.
+ Reduce the $name series to length `size` by discarding the high
+ degree terms. The value of `size` must be a positive integer. This
+ can be useful in least squares where the coefficients of the
+ high degree terms may be very small.
Parameters:
-----------
- deg : non-negative int
- The series is reduced to degree `deg` by discarding the
- coefficients of the higher degree terms. The value of `deg`
- must be non-negative.
+ size : positive int
+ The series is reduced to length `size` by discarding the high
+ degree terms. The value of `size` must be a positive integer.
Returns:
-------
@@ -412,13 +411,13 @@ class $name(pu.PolyBase) :
New instance of $name with truncated coefficients.
"""
- size = int(deg) + 1
- if size != deg + 1 or size < 1 :
- raise ValueError("deg must be a non-negative integer")
- if size >= len(self) :
+ isize = int(size)
+ if isize != size or isize < 1 :
+ raise ValueError("size must be a positive integer")
+ if isize >= len(self.coef) :
return self.__class__(self.coef, self.domain)
else :
- return self.__class__(self.coef[:size], self.domain)
+ return self.__class__(self.coef[:isize], self.domain)
def copy(self) :
"""Return a copy.
@@ -442,7 +441,7 @@ class $name(pu.PolyBase) :
Parameters:
-----------
- m : non-negative integer
+ m : non-negative int
The number of integrations to perform.
k : array_like
Integration constants. The first constant is applied to the
@@ -455,7 +454,7 @@ class $name(pu.PolyBase) :
Returns:
--------
integral : $name
- The integral of the original series with the same domain.
+ The integral of the series using the same domain.
See Also
--------
@@ -479,13 +478,13 @@ class $name(pu.PolyBase) :
Parameters:
-----------
- m : non-negative integer
+ m : non-negative int
The number of integrations to perform.
Returns:
--------
derivative : $name
- The derivative of the original series with the same domain.
+ The derivative of the series using the same domain.
See Also
--------