Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dask meta and output_dtypes error #5449

Merged
merged 3 commits into from
Jun 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,8 @@ def test_vectorize_dask_dtype_meta():
data_array = xr.DataArray([[0, 1, 2], [1, 2, 3]], dims=("x", "y"))
dcherian marked this conversation as resolved.
Show resolved Hide resolved
expected = xr.DataArray([1, 2], dims=["x"])

actual = apply_ufunc(
func = functools.partial(
apply_ufunc,
pandas_median,
data_array.chunk({"x": 1}),
input_core_dims=[["y"]],
Expand All @@ -1323,8 +1324,14 @@ def test_vectorize_dask_dtype_meta():
dask_gufunc_kwargs=dict(meta=np.ndarray((0, 0), dtype=float)),
)

assert_identical(expected, actual)
assert float == actual.dtype
# dask/dask#7669: can no longer pass output_dtypes and meta
if LooseVersion(dask.__version__) >= "2021.06":
with pytest.raises(ValueError):
func()
else:
actual = func()
assert_identical(expected, actual)
assert float == actual.dtype


def pandas_median_add(x, y):
Expand Down