[SciPy-Dev] UnivariateSpline evaluated on a ND array

Pierre Haessig pierre.haessig@crans....
Tue Jun 26 10:00:45 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 ?

On the other hand, the Docstring of scipy.interpolate.splev which called
within UnivariateSpline states explicately that input should be 1D. If
this limitation should be propagated to UnivariateSpline, then it should
be clarified in the Docstring of UnivariateSpline.__call__
(https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack2.py#L215
if I'm right)

What do you think is the best solution ?

Best,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20120626/283c1a69/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
Url : http://mail.scipy.org/pipermail/scipy-dev/attachments/20120626/283c1a69/attachment.bin 


More information about the SciPy-Dev mailing list