[SciPy-User] Return type of scipy.interpolate.splev for input array of length 1

Yves Frederix yves.frederix at gmail.com
Tue Jan 19 04:45:11 EST 2010


Hi,

In fact, I totally agree with you. Full matching of output to the type
of the input does not make sense. But one could expect that array_like
input results in ndarray output and scalar input in scalar output. As
far as I can see, scipy.stats behaves exactly in this way.

Anyway, I checked some other files and, e.g., in
scipy/interpolate/polyint.py the input is explicitly tested to be
scalar. In attachment you can find a patch for
scipy/interpolate/fitpack.py so that it behaves 'correctly'.

Regards,
YVES

> scipy.stats has switched for the most part to the same behavior. I
> think, mainly it is just a convention to have a nicer output when the
> return value is a scalar.
>
> One problem with making the output depend on the input type or shape
> is that in most functions I know, this information is not kept inside
> the function. Usually the input of array_like (arrays, lists, tuples,
> scalar numbers) is converted to an ndarray with np.asarray or
> np.array.
> The output then is independent of the input type (which hurts also if
> a user wants to work with matrices or other subclasses of ndarrays).
>
> On the other hand, if I want to use a list as input for convenience, I
> don't really want a list as output, I want an ndarray.
>
> That's my view, I don't really care in which direction the convention
> goes, but I like the consistency.
>
> Josef
>
>> Cheers,
>> YVES
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: splev_patch.diff
Type: application/octet-stream
Size: 1112 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100119/f10b0f49/attachment.obj>


More information about the SciPy-User mailing list