[SciPy-User] Return type of scipy.interpolate.splev for input array of length 1
Thu Jan 21 20:56:53 CST 2010
On Tue, Jan 19, 2010 at 4:45 AM, Yves Frederix <email@example.com> wrote:
> 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'.
I also found a related http://projects.scipy.org/scipy/ticket/600
I don't know what the status of it is.
>> 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
>> 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.
More information about the SciPy-User