[Numpy-svn] r8382 - trunk/numpy/lib
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue May 4 22:50:00 EDT 2010
Author: charris
Date: 2010-05-04 21:50:00 -0500 (Tue, 04 May 2010)
New Revision: 8382
Modified:
trunk/numpy/lib/polynomial.py
Log:
BUG: Make polyder return a poly1d for the zeroeth order derivative when
the input is a poly1d. Fixes ticket #1249.
Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py 2010-05-04 06:24:07 UTC (rev 8381)
+++ trunk/numpy/lib/polynomial.py 2010-05-05 02:50:00 UTC (rev 8382)
@@ -378,19 +378,20 @@
"""
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):
"""
More information about the Numpy-svn
mailing list