diff --git a/CHANGES.rst b/CHANGES.rst index 412af0296..13039c828 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -37,6 +37,7 @@ Internal changes Bug fixes ^^^^^^^^^ * ``xclim.indices.{cold|hot}_spell_total_length`` now properly uses the argument `window` to only count spells with at least `window` time steps. (:issue:`1765`, :pull:`1777`). +* Addressed an error in ``xclim.ensembles._filters._concat_hist`` where remnants of a scenario selection were not being dropped properly. (:pull:`1780`). v0.49.0 (2024-05-02) -------------------- diff --git a/tests/test_partitioning.py b/tests/test_partitioning.py index 8afc8f9a1..9862e4e60 100644 --- a/tests/test_partitioning.py +++ b/tests/test_partitioning.py @@ -1,24 +1,14 @@ from __future__ import annotations -import warnings - import numpy as np -import pytest import xarray as xr -from packaging.version import Version from xclim.ensembles import fractional_uncertainty, hawkins_sutton, lafferty_sriver from xclim.ensembles._filters import _concat_hist, _model_in_all_scens, _single_member -# FIXME: Investigate why _concat_hist() fails on xarray 2024.5.0 def test_hawkins_sutton_smoke(open_dataset): """Just a smoke test.""" - if Version(xr.__version__) == Version("2024.5.0"): - pytest.skip("xarray 2024.5.0 does not support `_concat_hist()` here.") - if Version(xr.__version__) > Version("2024.5.0"): - warnings.warn("FIXME: Remove this warning if this test is passing.") - dims = {"run": "member", "scen": "scenario"} da = ( open_dataset("uncertainty_partitioning/cmip5_pr_global_mon.nc") diff --git a/xclim/ensembles/_filters.py b/xclim/ensembles/_filters.py index e800b94e6..39dcd9641 100644 --- a/xclim/ensembles/_filters.py +++ b/xclim/ensembles/_filters.py @@ -50,7 +50,7 @@ def _concat_hist(da: xr.DataArray, **hist) -> xr.DataArray: ((dim, _),) = hist.items() # Select historical scenario and drop it from the data - h = da.sel(**hist).dropna("time", how="all") + h = da.sel(drop=True, **hist).dropna("time", how="all") ens = da.drop_sel(**hist) index = ens[dim]