|
24 | 24 |
|
25 | 25 | from . import has_dask, raise_if_dask_computes, requires_dask
|
26 | 26 |
|
27 |
| -dask = pytest.importorskip("dask") |
28 |
| - |
29 | 27 |
|
30 | 28 | def assert_identical(a, b):
|
31 | 29 | """A version of this function which accepts numpy arrays"""
|
@@ -1420,6 +1418,7 @@ def arrays_w_tuples():
|
1420 | 1418 | ],
|
1421 | 1419 | )
|
1422 | 1420 | @pytest.mark.parametrize("dim", [None, "x", "time"])
|
| 1421 | +@requires_dask |
1423 | 1422 | def test_lazy_corrcov(da_a, da_b, dim, ddof) -> None:
|
1424 | 1423 | # GH 5284
|
1425 | 1424 | from dask import is_dask_collection
|
@@ -1554,6 +1553,28 @@ def test_covcorr_consistency(da_a, da_b, dim) -> None:
|
1554 | 1553 | assert_allclose(actual, expected)
|
1555 | 1554 |
|
1556 | 1555 |
|
| 1556 | +@requires_dask |
| 1557 | +@pytest.mark.parametrize("da_a, da_b", arrays_w_tuples()[1]) |
| 1558 | +@pytest.mark.parametrize("dim", [None, "time", "x"]) |
| 1559 | +def test_corr_lazycorr_consistency(da_a, da_b, dim) -> None: |
| 1560 | + da_al = da_a.chunk() |
| 1561 | + da_bl = da_b.chunk() |
| 1562 | + c_abl = xr.corr(da_al, da_bl, dim=dim) |
| 1563 | + c_ab = xr.corr(da_a, da_b, dim=dim) |
| 1564 | + c_ab_mixed = xr.corr(da_a, da_bl, dim=dim) |
| 1565 | + assert_allclose(c_ab, c_abl) |
| 1566 | + assert_allclose(c_ab, c_ab_mixed) |
| 1567 | + |
| 1568 | + |
| 1569 | +@requires_dask |
| 1570 | +def test_corr_dtype_error(): |
| 1571 | + da_a = xr.DataArray([[1, 2], [2, 1]], dims=["x", "time"]) |
| 1572 | + da_b = xr.DataArray([[1, 2], [1, np.nan]], dims=["x", "time"]) |
| 1573 | + |
| 1574 | + xr.testing.assert_equal(xr.corr(da_a, da_b), xr.corr(da_a.chunk(), da_b.chunk())) |
| 1575 | + xr.testing.assert_equal(xr.corr(da_a, da_b), xr.corr(da_a, da_b.chunk())) |
| 1576 | + |
| 1577 | + |
1557 | 1578 | @pytest.mark.parametrize(
|
1558 | 1579 | "da_a",
|
1559 | 1580 | arrays_w_tuples()[0],
|
|
0 commit comments