Skip to content

LSQUnivariateSpline fitting failed with knots generated from UnivariateSpline #5916

@Fmajor

Description

@Fmajor

scipy.__version__='0.17.0'

I tried to use the knots generated from UnivariateSpline to do a LSQUnivariateSpline fitting like this

fit = scipy.interpolate.UnivariateSpline( x, y, w=w, s=s)
knots = fit.get_knots()
newFit = scipy.interpolate.LSQUnivariateSpline(x, y, knots, w=w)

and got error


/usr/local/lib/python2.7/site-packages/scipy/interpolate/fitpack2.pyc in __init__(self, x, y, t, w, bbox, k, ext, check_finite)
    726         n = len(t)
    727         if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0, axis=0):
--> 728             raise ValueError('Interior knots t must satisfy '
    729                              'Schoenberg-Whitney conditions')
    730         if not dfitpack.fpchec(x, t, k) == 0:

ValueError: Interior knots t must satisfy Schoenberg-Whitney conditions

i have checked the knots=fit.get_knots(), the first and last value is the first and last value of x, but
line 727 means that the first and last knot CAN NOT be the first and last x data in LSQUnivariateSpline.

change
727 if not alltrue(t[k+1:n-k]-t[k:n-k-1] > 0, axis=0):
to
727 if not alltrue(t[k+1:n-k]-t[k:n-k-1] >= 0, axis=0):

will solve this issue, but i'm not sure if this could cause other problems.

Any way, you can not init another fitting with the parameters got from a successful fitting, that's unreasonable...

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.orgdefectA clear bug or issue that prevents SciPy from being installed or used as expectedqueryA question or suggestion that requires further informationscipy.interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions