-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Our upstream tests fail due to a change in dask. The likely culprit is dask/dask#6680 - dask.array.zeros_like does now take the meta keyword and thus it tries to coerce str to a bool which fails (and it didn't do before). The following should trigger the error:
import xarray as xr
import dask
da = xr.DataArray(dask.array.array(""))
xr.zeros_like(da, dtype=bool)Note that zeros_like is called in isnull (which triggered the test failures):
xarray/xarray/core/duck_array_ops.py
Lines 100 to 102 in 080caf4
| elif issubclass(scalar_type, (np.bool_, np.integer, np.character, np.void)): | |
| # these types cannot represent missing values | |
| return zeros_like(data, dtype=bool) |
What happened:
/home/vsts/work/1/s/xarray/tests/test_duck_array_ops.py:499:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/vsts/work/1/s/xarray/testing.py:139: in compat_variable
return a.dims == b.dims and (a._data is b._data or equiv(a.data, b.data))
/home/vsts/work/1/s/xarray/testing.py:36: in _data_allclose_or_equiv
return duck_array_ops.array_equiv(arr1, arr2)
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:246: in array_equiv
flag_array = (arr1 == arr2) | (isnull(arr1) & isnull(arr2))
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:104: in isnull
return zeros_like(data, dtype=bool)
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:56: in f
return wrapped(*args, **kwargs)
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/creation.py:174: in zeros_like
return zeros(
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/wrap.py:78: in wrap_func_shape_as_first_arg
return Array(dsk, name, chunks, dtype=dtype, meta=kwargs.get("meta", None))
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/core.py:1083: in __new__
meta = meta_from_array(meta, dtype=dtype)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array('', dtype='<U1'), ndim = 0, dtype = dtype('bool')
def meta_from_array(x, ndim=None, dtype=None):
"""Normalize an array to appropriate meta object
Parameters
----------
x: array-like, callable
Either an object that looks sufficiently like a Numpy array,
or a callable that accepts shape and dtype keywords
if dtype and meta.dtype != dtype:
> meta = meta.astype(dtype)
E ValueError: invalid literal for int() with base 10: ''