Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splint returns incorrect results (Trac #1393) #1918

Closed
scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Closed

splint returns incorrect results (Trac #1393) #1918

scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.interpolate
Milestone

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/1393 on 2011-02-24 by trac user Dave Hirschfeld, assigned to unknown.

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]"
#
@scipy-gitbot
Copy link
Author

Attachment added by trac user Dave Hirschfeld on 2011-02-24: test_splint.py

@scipy-gitbot
Copy link
Author

@WarrenWeckesser wrote on 2011-02-24

Wrapped code sample in triple curly brackets.

@scipy-gitbot
Copy link
Author

@pv wrote on 2011-02-25

splint assumes the function is zero outside the data interval.

This is probably not a documentation issue only, as the zero assumption is not what is typically wanted.

@scipy-gitbot
Copy link
Author

Milestone changed to Unscheduled by @rgommers on 2011-08-27

@andreas-h
Copy link
Contributor

I think there shouldn't be done anything else here. With the added note in the docstring,splint works as advertised. While this might not be what users want sometimes, it seems this is impossible to fix within the frame of the current FITPACK implementation.

@pv
Copy link
Member

pv commented Feb 18, 2014

Agreed, I don't think this is easily fixed in any other way.

We'll do it in a better way without breaking backward compat, when the new B-spline stuff gets done.

@pv pv closed this as completed Feb 18, 2014
@pv pv added this to the 0.14.0 milestone Feb 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.interpolate
Projects
None yet
Development

No branches or pull requests

3 participants