[Scipy-svn] r4170 - in trunk/scipy/interpolate: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Apr 23 21:20:15 EDT 2008
Author: peridot
Date: 2008-04-23 20:19:57 -0500 (Wed, 23 Apr 2008)
New Revision: 4170
Modified:
trunk/scipy/interpolate/info.py
trunk/scipy/interpolate/interpolate.py
trunk/scipy/interpolate/tests/test_interpolate.py
Log:
Fix, test, and publicize polynomial interpolation code
Modified: trunk/scipy/interpolate/info.py
===================================================================
--- trunk/scipy/interpolate/info.py 2008-04-24 00:31:58 UTC (rev 4169)
+++ trunk/scipy/interpolate/info.py 2008-04-24 01:19:57 UTC (rev 4170)
@@ -31,6 +31,11 @@
interp2d -- Create a class whose instances can interpolate
to compute unknown values of a bivariate function.
Rbf -- Apply Radial Basis Functions to interpolate scattered N-D data.
+
+Additional tools
+
+ lagrange -- Compute the Lagrange interpolating polynomial
+
"""
postpone_import = 1
Modified: trunk/scipy/interpolate/interpolate.py
===================================================================
--- trunk/scipy/interpolate/interpolate.py 2008-04-24 00:31:58 UTC (rev 4169)
+++ trunk/scipy/interpolate/interpolate.py 2008-04-24 01:19:57 UTC (rev 4170)
@@ -8,7 +8,7 @@
from numpy import shape, sometrue, rank, array, transpose, \
swapaxes, searchsorted, clip, take, ones, putmask, less, greater, \
- logical_or, atleast_1d, atleast_2d, meshgrid, ravel, dot
+ logical_or, atleast_1d, atleast_2d, meshgrid, ravel, dot, poly1d
import numpy as np
import scipy.linalg as slin
import scipy.special as spec
Modified: trunk/scipy/interpolate/tests/test_interpolate.py
===================================================================
--- trunk/scipy/interpolate/tests/test_interpolate.py 2008-04-24 00:31:58 UTC (rev 4169)
+++ trunk/scipy/interpolate/tests/test_interpolate.py 2008-04-24 01:19:57 UTC (rev 4170)
@@ -1,8 +1,8 @@
from scipy.testing import *
-from numpy import mgrid, pi, sin, ogrid
+from numpy import mgrid, pi, sin, ogrid, poly1d
import numpy as np
-from scipy.interpolate import interp1d, interp2d
+from scipy.interpolate import interp1d, interp2d, lagrange
class TestInterp2D(TestCase):
@@ -198,6 +198,14 @@
[[4.8, 5.8], [15.6, 16.6]]]),
)
+class TestLagrange(TestCase):
+ def test_lagrange(self):
+ p = poly1d([5,2,1,4,3])
+ xs = np.arange(len(p.coeffs))
+ ys = p(xs)
+ pl = lagrange(xs,ys)
+ assert_array_almost_equal(p.coeffs,pl.coeffs)
+
if __name__ == "__main__":
nose.run(argv=['', __file__])
More information about the Scipy-svn
mailing list