(Sorry if this is a duplicate; I think sent this from the wrong email
the first time)
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)
I hesitate to call this behavior a bug (when I've done this in the
past, I find out I'm just doing something wrong), but I find the error
unnecessary (and the error output a bit obscure).
Below is a (poorly tested) fix, which seems to work for me. (Sorry I'm
not on svn, so it isn't a proper diff)
Cheers,
-Tony
Python 2.5.1
numpy 1.3.0
numpy/lib/function_base.py: line 1144
=============================
if isinstance(x, (float, int, number)):
return compiled_interp([x], xp, fp, left, right).item()
+ elif isinstance(x, np.ndarray) and x.ndim == 0:
+ return compiled_interp(x[np.newaxis], xp, fp, left, right)[0]
else:
return compiled_interp(x, xp, fp, left, right)
=============================
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion