[Numpy-discussion] Using interpolate with zero-rank array raises error

Tony Yu tsyu80@gmail....
Fri Jul 17 08:51:51 CDT 2009

> Date: Thu, 16 Jul 2009 23:37:58 -0400
> From: Ralf Gommers <ralf.gommers@googlemail.com>
> It seems to me that there are quite a few other functions that will  
> give
> errors with 0-D arrays (apply_along/over_axis are two that come to  
> mind).
> There is nothing to interpolate so I'm not surprised.

Hmm, I don't quite understand. In the example below, the 0-D array  
(`x0`) gives the x-value(s) where you want interpolated values. This  
shouldn't require a non-scalar, and in fact, interp currently accepts  
python scalars (but not Numpy scalars).

If the 0-D array replaced `x` and `y`---the known data points--- then,  
I agree there would be nothing to interpolate. I believe the example  
functions you cite are similar to replacing `x` and `y` below with  
scalar values.

... or am I just missing something?


>>> When using interpolate with a zero-rank array, I get "ValueError:
>>> object of too small depth for desired array". The following code
>>> reproduces this issue
>>>>>> import numpy as np
>>>>>> x0 = np.array(0.1)
>>>>>> x = np.linspace(0, 1)
>>>>>> y = np.linspace(0, 1)
>>>>>> np.interp(x0, x, y)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090717/e6a0ea71/attachment.html 

More information about the NumPy-Discussion mailing list