diff --git a/xarray/core/dask_array_compat.py b/xarray/core/dask_array_compat.py index 5e6b81a253d..2196dba7f86 100644 --- a/xarray/core/dask_array_compat.py +++ b/xarray/core/dask_array_compat.py @@ -44,7 +44,13 @@ def isin(element, test_elements, assume_unique=False, invert=False): import math from numbers import Integral, Real - AxisError = np.AxisError + try: + AxisError = np.AxisError + except AttributeError: + try: + np.array([0]).sum(axis=5) + except Exception as e: + AxisError = type(e) def validate_axis(axis, ndim): """ Validate an input to axis= keywords """