diff --git a/xskillscore/tests/test_skipna_functionality.py b/xskillscore/tests/test_skipna_functionality.py index ad7b83bc..a30d6d87 100644 --- a/xskillscore/tests/test_skipna_functionality.py +++ b/xskillscore/tests/test_skipna_functionality.py @@ -3,6 +3,7 @@ import numpy as np import pytest +from dask import is_dask_collection from xarray.testing import assert_allclose from xskillscore.core.deterministic import ( @@ -73,6 +74,15 @@ def raise_if_dask_computes(max_computes=0): NON_WEIGHTED_METRICS: List[Callable] = [median_absolute_error] +@pytest.mark.parametrize("metric", WEIGHTED_METRICS + NON_WEIGHTED_METRICS) +def test_deterministic_metrics_do_not_compute_chunked_inputs(a_dask, b_dask, metric): + """All deterministic metrics preserve lazy execution for chunked inputs.""" + with raise_if_dask_computes(): + result = metric(a_dask, b_dask, dim="time", skipna=True) + + assert is_dask_collection(result.data) + + def drop_nans(a, b, weights=None, dim="time"): """ Masks a and b where they have pairwise nans.