summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-05-05 02:50:00 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-05-05 02:50:00 +0000
commit632623d6a9ca99c34dc412ca676e4d2c59e2b297 (patch)
tree8dba4bb24ec4c76a9a233e8f811f06ece129af22 /numpy/lib
parente014ff75420eeb809699935433ab4c61bd7f6f8b (diff)
downloadnumpy-632623d6a9ca99c34dc412ca676e4d2c59e2b297.tar.gz
BUG: Make polyder return a poly1d for the zeroeth order derivative when
the input is a poly1d. Fixes ticket #1249.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/polynomial.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 66982186a..603655ec2 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -378,19 +378,20 @@ def polyder(p, m=1):
"""
m = int(m)
+ if m < 0:
+ raise ValueError, "Order of derivative must be positive (see polyint)"
+
truepoly = isinstance(p, poly1d)
p = NX.asarray(p)
- n = len(p)-1
+ n = len(p) - 1
y = p[:-1] * NX.arange(n, 0, -1)
- if m < 0:
- raise ValueError, "Order of derivative must be positive (see polyint)"
if m == 0:
- return p
+ val = p
else:
- val = polyder(y, m-1)
- if truepoly:
- val = poly1d(val)
- return val
+ val = polyder(y, m - 1)
+ if truepoly:
+ val = poly1d(val)
+ return val
def polyfit(x, y, deg, rcond=None, full=False):
"""