[SciPy-Dev] UnivariateSpline evaluated on a ND array

Andreas Hilboll lists@hilboll...
Tue Jun 26 13:52:10 CDT 2012


> Hi,
>
> While playing a bit with UnivariateSpline...
>  >>> from scipy.interpolate import UnivariateSpline
>
>  >>> s = UnivariateSpline([0,1], [0,1],k=1)
>
>
> ...I noticed that the evaluation fails if the input is not flat:
>
>
> Fine with 1D input :
>
>  >>> s(np.linspace(0,1,100))
> array([ 0.        ,  0.11111111,  0.22222222,  0.33333333, 0.44444444,
>          0.55555556,  0.66666667,  0.77777778,  0.88888889, 1.        ])
>
>
> but fails with 2D input :
>  >>> s(np.linspace(0,1,10).reshape(5,2))
> [...]
> /usr/lib/python2.7/dist-packages/scipy/interpolate/fitpack.pyc in
> splev(x, tck, der, ext)
> [...]
> --> 548         y, ier =_fitpack._spl_(x, der, t, c, k, ext)
> [...]
> ValueError: object too deep for desired array
>
>
> Do you think it would be a good move to add *inside* the
> UnivariateSpline.__call__ method a small machinery which performs the
> "flatten -> spline eval -> unflatten" operation ?

+1


More information about the SciPy-Dev mailing list