forked from pool/python-xarray
- Add xarray-pr5449-dask-meta.patch in order to support updated dask -- gh#pydata/xarray#5449 OBS-URL: https://build.opensuse.org/request/show/906712 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-xarray?expand=0&rev=55
116 lines
3.9 KiB
Diff
116 lines
3.9 KiB
Diff
From 941b8a8286178c13ee057d87a5198f163c174b0e Mon Sep 17 00:00:00 2001
|
|
From: Mathias Hauser <mathias.hauser@env.ethz.ch>
|
|
Date: Mon, 7 Jun 2021 20:21:00 +0200
|
|
Subject: [PATCH 1/3] fix dask meta and output_dtypes error
|
|
|
|
---
|
|
xarray/tests/test_computation.py | 13 ++++++++++---
|
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
|
|
index b7ae1ca982..7759e7d6a8 100644
|
|
--- a/xarray/tests/test_computation.py
|
|
+++ b/xarray/tests/test_computation.py
|
|
@@ -1313,7 +1313,8 @@ def test_vectorize_dask_dtype_meta():
|
|
data_array = xr.DataArray([[0, 1, 2], [1, 2, 3]], dims=("x", "y"))
|
|
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"]],
|
|
@@ -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):
|
|
|
|
From 2e51db563f82657a30a0b3d87f0ddab36a936fe9 Mon Sep 17 00:00:00 2001
|
|
From: Mathias Hauser <mathias.hauser@env.ethz.ch>
|
|
Date: Mon, 7 Jun 2021 21:48:15 +0200
|
|
Subject: [PATCH 2/3] don't test in newer dask versions
|
|
|
|
---
|
|
xarray/tests/test_computation.py | 18 +++++++-----------
|
|
1 file changed, 7 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
|
|
index 7759e7d6a8..92a543e14b 100644
|
|
--- a/xarray/tests/test_computation.py
|
|
+++ b/xarray/tests/test_computation.py
|
|
@@ -1306,15 +1306,17 @@ def test_vectorize_dask_dtype_without_output_dtypes(data_array):
|
|
assert expected.dtype == actual.dtype
|
|
|
|
|
|
-@pytest.mark.xfail(LooseVersion(dask.__version__) < "2.3", reason="dask GH5274")
|
|
+@pytest.mark.skip(
|
|
+ LooseVersion(dask.__version__) > "2021.06",
|
|
+ reason="dask/dask#7669: can no longer pass output_dtypes and meta",
|
|
+)
|
|
@requires_dask
|
|
def test_vectorize_dask_dtype_meta():
|
|
# meta dtype takes precedence
|
|
data_array = xr.DataArray([[0, 1, 2], [1, 2, 3]], dims=("x", "y"))
|
|
expected = xr.DataArray([1, 2], dims=["x"])
|
|
|
|
- func = functools.partial(
|
|
- apply_ufunc,
|
|
+ actual = apply_ufunc(
|
|
pandas_median,
|
|
data_array.chunk({"x": 1}),
|
|
input_core_dims=[["y"]],
|
|
@@ -1324,14 +1326,8 @@ def test_vectorize_dask_dtype_meta():
|
|
dask_gufunc_kwargs=dict(meta=np.ndarray((0, 0), dtype=float)),
|
|
)
|
|
|
|
- # 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
|
|
+ assert_identical(expected, actual)
|
|
+ assert float == actual.dtype
|
|
|
|
|
|
def pandas_median_add(x, y):
|
|
|
|
From a4cef6dac3fa5a84f144e56c63ce4b3b903681b4 Mon Sep 17 00:00:00 2001
|
|
From: Mathias Hauser <mathias.hauser@env.ethz.ch>
|
|
Date: Mon, 7 Jun 2021 21:56:46 +0200
|
|
Subject: [PATCH 3/3] skipIF
|
|
|
|
---
|
|
xarray/tests/test_computation.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
|
|
index 92a543e14b..09bed72496 100644
|
|
--- a/xarray/tests/test_computation.py
|
|
+++ b/xarray/tests/test_computation.py
|
|
@@ -1306,7 +1306,7 @@ def test_vectorize_dask_dtype_without_output_dtypes(data_array):
|
|
assert expected.dtype == actual.dtype
|
|
|
|
|
|
-@pytest.mark.skip(
|
|
+@pytest.mark.skipif(
|
|
LooseVersion(dask.__version__) > "2021.06",
|
|
reason="dask/dask#7669: can no longer pass output_dtypes and meta",
|
|
)
|