From 181bd92e9553d2fa94ec23bb7f8bfeee193d22bd Mon Sep 17 00:00:00 2001 From: Kkkakania <200867803+Kkkakania@users.noreply.github.com> Date: Sun, 9 Aug 2026 18:04:09 +0800 Subject: [PATCH] Test lazy execution across deterministic metrics --- xskillscore/tests/test_skipna_functionality.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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.