From ad59ad06e810171e8803d4d69a3cd2de76c2e923 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:19:35 -0400 Subject: [PATCH 1/5] address scalar/dimension concatenation error --- tests/test_partitioning.py | 10 ---------- xclim/ensembles/_filters.py | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) 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] From 0c58369ec2382bd1e36d39d0f1cd7cdb653c1f92 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:26:01 -0400 Subject: [PATCH 2/5] update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 154df7cde..26e964c11 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -36,6 +36,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) -------------------- From 94d7971a614f12ebafc077306c9e52c9acdf2128 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:32:55 -0400 Subject: [PATCH 3/5] pin numpy below v2.0.0 --- CHANGES.rst | 1 + environment.yml | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 154df7cde..4cdcb4c1f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -24,6 +24,7 @@ Breaking changes - ``interp_calendar`` : Use ``Dataset.interp_calendar`` or ``xarray.coding.calendar_ops.interp_calendar`` instead. - ``days_in_year`` : Use ``xarray.coding.calendar_ops._days_in_year`` instead. - ``datetime_to_decimal_year`` : Use ``xarray.coding.calendar_ops._datetime_to_decimal_year`` instead. +* `numpy` has been pinned below v2.0.0 until `xclim` can be updated to support the latest version. Internal changes ^^^^^^^^^^^^^^^^ diff --git a/environment.yml b/environment.yml index cd1ee94b1..d98429aed 100644 --- a/environment.yml +++ b/environment.yml @@ -13,7 +13,7 @@ dependencies: - dask >=2.6.0 - jsonpickle - numba - - numpy >=1.20.0 + - numpy >=1.20.0,<2.0.0 - pandas >=2.2.0 - pint >=0.10,<0.24 - poppler >=0.67 diff --git a/pyproject.toml b/pyproject.toml index 21ec74787..061768fa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "dask[array]>=2.6", "jsonpickle", "numba", - "numpy>=1.20.0", + "numpy>=1.20.0,<2.0.0", "pandas>=2.2", "pint>=0.10,<0.24", "pyarrow", # Strongly encouraged for pandas v2.2.0+ From fcbcae320a93e6f10ac0dd4dd56b1f45e9d1c24e Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:35:10 -0400 Subject: [PATCH 4/5] add numpy main dev branch to upstream --- requirements_upstream.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_upstream.txt b/requirements_upstream.txt index 71145c0ce..c5ebda67e 100644 --- a/requirements_upstream.txt +++ b/requirements_upstream.txt @@ -2,4 +2,5 @@ bottleneck @ git+https://github.com/pydata/bottleneck.git@master cftime @ git+https://github.com/Unidata/cftime.git@master flox @ git+https://github.com/xarray-contrib/flox.git@main numba @ git+https://github.com/numba/numba.git@main +numpy @ git+https://github.com/numpy/numpy.git@main xarray @ git+https://github.com/pydata/xarray.git@main From 030547821ba5bd1adaf9f480e7adc69317375689 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:42:40 -0400 Subject: [PATCH 5/5] update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4cdcb4c1f..412af0296 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -24,7 +24,7 @@ Breaking changes - ``interp_calendar`` : Use ``Dataset.interp_calendar`` or ``xarray.coding.calendar_ops.interp_calendar`` instead. - ``days_in_year`` : Use ``xarray.coding.calendar_ops._days_in_year`` instead. - ``datetime_to_decimal_year`` : Use ``xarray.coding.calendar_ops._datetime_to_decimal_year`` instead. -* `numpy` has been pinned below v2.0.0 until `xclim` can be updated to support the latest version. +* `numpy` has been pinned below v2.0.0 until `xclim` can be updated to support the latest version. (:pull:`1783`). Internal changes ^^^^^^^^^^^^^^^^