Skip to content

Commit

Permalink
Return -1 for _nan_argminmax_object if all NaNs along dim
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed May 9, 2020
1 parent 43384c3 commit 58901b9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions xarray/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,12 @@ def _maybe_null_out(result, axis, mask, min_count=1):

def _nan_argminmax_object(func, fill_value, value, axis=None, **kwargs):
""" In house nanargmin, nanargmax for object arrays. Always return integer
type
type. Returns -1 for all NaN values along axis.
"""
valid_count = count(value, axis=axis)
value = fillna(value, fill_value)
data = _dask_or_eager_func(func)(value, axis=axis, **kwargs)

# TODO This will evaluate dask arrays and might be costly.
if (valid_count == 0).any():
raise ValueError("All-NaN slice encountered")

return data
return where_method(data, valid_count > 0, -1)


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

0 comments on commit 58901b9

Please sign in to comment.