summaryrefslogtreecommitdiff
path: root/numpy/polynomial/chebyshev.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-08-15 00:40:26 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-08-15 00:40:26 +0000
commit6b9762c0a918acb583bee7e387863123e339e46c (patch)
tree383363edd7b3ede838d6c4eba69f514d1dabd878 /numpy/polynomial/chebyshev.py
parent50db7ff052aef5e0399464a6bbaa7540b83247ea (diff)
downloadnumpy-6b9762c0a918acb583bee7e387863123e339e46c.tar.gz
BUG: Fix integration of zero polynomials.
Remove checks that prevent use of foreign scalar types for lower bounds and integration constants. Cleanup code a bit.
Diffstat (limited to 'numpy/polynomial/chebyshev.py')
-rw-r--r--numpy/polynomial/chebyshev.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py
index 99edecca1..533b4c293 100644
--- a/numpy/polynomial/chebyshev.py
+++ b/numpy/polynomial/chebyshev.py
@@ -852,8 +852,6 @@ def chebder(cs, m=1, scl=1) :
raise ValueError, "The order of derivation must be integer"
if cnt < 0 :
raise ValueError, "The order of derivation must be non-negative"
- if not np.isscalar(scl) :
- raise ValueError, "The scl parameter must be a scalar"
# cs is a trimmed copy
[cs] = pu.as_series([cs])
@@ -955,23 +953,24 @@ def chebint(cs, m=1, k=[], lbnd=0, scl=1):
raise ValueError, "The order of integration must be non-negative"
if len(k) > cnt :
raise ValueError, "Too many integration constants"
- if not np.isscalar(lbnd) :
- raise ValueError, "The lbnd parameter must be a scalar"
- if not np.isscalar(scl) :
- raise ValueError, "The scl parameter must be a scalar"
# cs is a trimmed copy
[cs] = pu.as_series([cs])
if cnt == 0:
return cs
- else:
- k = list(k) + [0]*(cnt - len(k))
- for i in range(cnt) :
- zs = _cseries_to_zseries(cs)*scl
+
+ k = list(k) + [0]*(cnt - len(k))
+ for i in range(cnt) :
+ n = len(cs)
+ cs *= scl
+ if n == 1 and cs[0] == 0:
+ cs[0] += k[i]
+ else:
+ zs = _cseries_to_zseries(cs)
zs = _zseries_int(zs)
cs = _zseries_to_cseries(zs)
cs[0] += k[i] - chebval(lbnd, cs)
- return cs
+ return cs
def chebval(x, cs):
"""Evaluate a Chebyshev series.