Skip to content
Open
Changes from all commits
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
10 changes: 10 additions & 0 deletions xskillscore/tests/test_skipna_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
Expand Down