[Scipy-svn] r6630 - in trunk/scipy/interpolate: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Jul 18 15:21:57 EDT 2010
Author: charris
Date: 2010-07-18 14:21:56 -0500 (Sun, 18 Jul 2010)
New Revision: 6630
Modified:
trunk/scipy/interpolate/fitpack2.py
trunk/scipy/interpolate/tests/test_fitpack.py
trunk/scipy/interpolate/tests/test_regression.py
Log:
BUG: Fix ticket #600.
Modified: trunk/scipy/interpolate/fitpack2.py
===================================================================
--- trunk/scipy/interpolate/fitpack2.py 2010-07-18 19:21:52 UTC (rev 6629)
+++ trunk/scipy/interpolate/fitpack2.py 2010-07-18 19:21:56 UTC (rev 6630)
@@ -20,6 +20,7 @@
import warnings
from numpy import zeros, concatenate, alltrue, ravel, all, diff
+import fitpack
import dfitpack
################ Univariate spline ####################
@@ -205,15 +206,16 @@
self._data = data
self._reset_class()
- def __call__(self, x, nu=None):
+ def __call__(self, x, nu=0):
""" Evaluate spline (or its nu-th derivative) at positions x.
Note: x can be unordered but the evaluation is more efficient
if x is (partially) ordered.
"""
- if nu is None:
- return dfitpack.splev(*(self._eval_args+(x,)))
- return dfitpack.splder(nu=nu,*(self._eval_args+(x,)))
+# if nu is None:
+# return dfitpack.splev(*(self._eval_args+(x,)))
+# return dfitpack.splder(nu=nu,*(self._eval_args+(x,)))
+ return fitpack.splev(x, self._eval_args, der=nu)
def get_knots(self):
""" Return the positions of (boundary and interior)
Modified: trunk/scipy/interpolate/tests/test_fitpack.py
===================================================================
--- trunk/scipy/interpolate/tests/test_fitpack.py 2010-07-18 19:21:52 UTC (rev 6629)
+++ trunk/scipy/interpolate/tests/test_fitpack.py 2010-07-18 19:21:56 UTC (rev 6630)
@@ -13,7 +13,7 @@
#import libwadpy
from numpy.testing import *
-from numpy import array, diff
+from numpy import array, diff, shape
from scipy.interpolate.fitpack2 import UnivariateSpline, LSQBivariateSpline, \
SmoothBivariateSpline, RectBivariateSpline
@@ -27,6 +27,17 @@
assert_almost_equal(lut.get_residual(),0.0)
assert_array_almost_equal(lut([1,1.5,2]),[3,3,3])
+ def test_preserve_shape(self):
+ x = [1, 2, 3]
+ y = [0, 2, 4]
+ lut = UnivariateSpline(x, y, k=1)
+ arg = 2
+ assert_equal(shape(arg), shape(lut(arg)))
+ assert_equal(shape(arg), shape(lut(arg, nu=1)))
+ arg = [1.5, 2, 2.5]
+ assert_equal(shape(arg), shape(lut(arg)))
+ assert_equal(shape(arg), shape(lut(arg, nu=1)))
+
def test_linear_1d(self):
x = [1,2,3]
y = [0,2,4]
Modified: trunk/scipy/interpolate/tests/test_regression.py
===================================================================
--- trunk/scipy/interpolate/tests/test_regression.py 2010-07-18 19:21:52 UTC (rev 6629)
+++ trunk/scipy/interpolate/tests/test_regression.py 2010-07-18 19:21:56 UTC (rev 6630)
@@ -11,5 +11,3 @@
res = interp.spalde(np.float64(1), tck)
des = np.array([ 1., 3., 6., 6.])
assert_almost_equal(res, des)
-
-
More information about the Scipy-svn
mailing list