Skip to content

Commit

Permalink
Address scalar/dimension concatenation error (#1780)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Fixes a previously uncaught error where remnants of a scenario
selection were not being dropped properly.

### Does this PR introduce a breaking change?

No.
  • Loading branch information
Zeitsperre authored Jun 17, 2024
2 parents 0305478 + 2b275ae commit 61ca7a8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------------
Expand Down
10 changes: 0 additions & 10 deletions tests/test_partitioning.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion xclim/ensembles/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 61ca7a8

Please sign in to comment.