The following snippet was broken by commit 8362e08:
import numpy as np
np.nanargmin(np.array([['nan', 'nan'], [1, 2]], dtype=np.float), axis=1)
Before the change this would yield
Now this raises a ValueError:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/foo/.local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 1564, in nanargmin
return _nanop(np.argmin, np.inf, a, axis)
File "/home/foo/.local/lib/python2.7/site-packages/numpy/lib/function_base.py", line 1400, in _nanop
res[mask_all_along_axis] = np.nan
ValueError: cannot convert float NaN to integer
This is very likely a re-incarnation of bug #643 in some form, but I'm opening separately since this was working up until a month ago.
The problem is that the functions return nan for an all nan row (or column or ...) and argmin etc return integers, and nans can't be cast to integers. What should we do in this case? Using nan as an integer type didn't make sense in the first place (what were they thinking?), but if you raise this issue on the list perhaps folks can agree on a solution.
This now raises ValueError: All-NaN slice encountered. Folks didn't like the idea of returning the minimum possible (negative) index value as an error, which was the other possibility. Returning something like -1 was not acceptable as -1 is a valid index in most cases.
ValueError: All-NaN slice encountered