[SciPy-User] Return type of scipy.interpolate.splev for input array of length 1
Tue Jan 19 03:41:23 CST 2010
Mon, 18 Jan 2010 10:59:46 -0500, josef.pktd wrote:
> On Sun, Jan 17, 2010 at 5:25 AM, Yves Frederix <firstname.lastname@example.org>
>> It was rather unexpected that the type of input and output data are
>> different. After checking interpolate/fitpack.py it seems that this
>> behavior results from the fact that the length-1 case is explicitly
>> treated differently (probably to be able to deal with the case of
>> scalar input, for which scalar output is expected):
>> 434 def splev(x,tck,der=0):
>> 487 if ier: raise TypeError,"An error occurred" 488
>> if len(y)>1: return y 489 return y
>> Wouldn't it be less confusing to have the return value always have the
>> same type as the input data?
> I don't know of any "official" policy.
I think (unstructured) interpolation should respect
input.shape == output.shape
also for 0-d. So yes, it's a wart, IMHO.
Another question is: how many people actually have code that depends on
this wart, and can it be fixed? I'd guess there's not much problem: (1,)
arrays function nicely as scalars, but not vice versa because of
More information about the SciPy-User