[Scipy-tickets] [SciPy] #1393: splint returns incorrect results

SciPy Trac scipy-tickets@scipy....
Thu Feb 24 03:57:17 CST 2011


#1393: splint returns incorrect results
-----------------------------+----------------------------------------------
 Reporter:  Dave Hirschfeld  |       Owner:  somebody
     Type:  defect           |      Status:  new     
 Priority:  normal           |   Milestone:  0.10.0  
Component:  Other            |     Version:  0.8.0   
 Keywords:                   |  
-----------------------------+----------------------------------------------
 This was originally reported on the list -
 http://article.gmane.org/gmane.comp.python.scientific.user/28000

 A self-contained example is given below and attached in case the line-
 endings get mangled...


 def test_splint():
     from scipy.interpolate import splev, splint, splrep
     from scipy.integrate import quad
     from numpy import allclose
     y = array([ 0.38608245,  0.33937334,  0.30557594,  0.29031793,
 0.27597413,
                 0.26680583,  0.25012443,  0.24310048,  0.23825924,
 0.23260759,
                 0.22179233,  0.21821583,  0.2164903 ,  0.21275566,
 0.20813042,
                 0.20404953,  0.19703265,  0.19649831,  0.19548709,
 0.1922062 ,
                 0.18623453])
     #
     x = ones(y.size)/4
     x[0] /= 2
     x = x.cumsum()
     tck = splrep(x, y, s=0.0001)
     #
     lhs = splint(0.2, 0.3, tck)
     rhs = quad(lambda v: splev(v, tck, der=0), 0.2, 0.3)[0]
     assert allclose(lhs, rhs, 1e-6, 1e-12), "splint != quad. region =
 [0.2, 0.3]"
     lhs = splint(0, 0.1, tck)
     rhs = quad(lambda v: splev(v, tck, der=0), 0, 0.1)[0]
     assert allclose(lhs, rhs, 1e-6, 1e-12), "splint != quad. region = [0,
 0.1]"
     lhs = splint(0.1, 0.2, tck)
     rhs = quad(lambda v: splev(v, tck, der=0), 0.1, 0.2)[0]
     assert allclose(lhs, rhs, 1e-6, 1e-12), "splint != quad. region =
 [0.1, 0.2]"
 #

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1393>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list