Skip to content

Commit

Permalink
drop numpy 1.12 compat code that can hide other errors
Browse files Browse the repository at this point in the history
  • Loading branch information
toddrjen committed Mar 26, 2020
1 parent 6378a71 commit 14fb9d7
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions xarray/core/duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,15 @@ def f(values, axis=None, skipna=None, **kwargs):
try:
return func(values, axis=axis, **kwargs)
except AttributeError:
if isinstance(values, dask_array_type):
try: # dask/dask#3133 dask sometimes needs dtype argument
# if func does not accept dtype, then raises TypeError
return func(values, axis=axis, dtype=values.dtype, **kwargs)
except (AttributeError, TypeError):
msg = "%s is not yet implemented on dask arrays" % name
else:
msg = (
"%s is not available with skipna=False with the "
"installed version of numpy; upgrade to numpy 1.12 "
"or newer to use skipna=True or skipna=None" % name
if not isinstance(values, dask_array_type):
raise
try: # dask/dask#3133 dask sometimes needs dtype argument
# if func does not accept dtype, then raises TypeError
return func(values, axis=axis, dtype=values.dtype, **kwargs)
except (AttributeError, TypeError):
raise NotImplementedError(
f"{name} is not yet implemented on dask arrays"
)
raise NotImplementedError(msg)

f.__name__ = name
return f
Expand Down

0 comments on commit 14fb9d7

Please sign in to comment.