Skip to content

Commit 58901b9

Browse files
committed
Return -1 for _nan_argminmax_object if all NaNs along dim
1 parent 43384c3 commit 58901b9

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

xarray/core/nanops.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,12 @@ def _maybe_null_out(result, axis, mask, min_count=1):
4747

4848
def _nan_argminmax_object(func, fill_value, value, axis=None, **kwargs):
4949
""" In house nanargmin, nanargmax for object arrays. Always return integer
50-
type
50+
type. Returns -1 for all NaN values along axis.
5151
"""
5252
valid_count = count(value, axis=axis)
5353
value = fillna(value, fill_value)
5454
data = _dask_or_eager_func(func)(value, axis=axis, **kwargs)
55-
56-
# TODO This will evaluate dask arrays and might be costly.
57-
if (valid_count == 0).any():
58-
raise ValueError("All-NaN slice encountered")
59-
60-
return data
55+
return where_method(data, valid_count > 0, -1)
6156

6257

6358
def _nan_minmax_object(func, fill_value, value, axis=None, **kwargs):

0 commit comments

Comments
 (0)