From 2237dda8a642bdd0a1bb48a75ca7b2ef51235fe9 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 17 Oct 2024 14:17:52 -0400 Subject: [PATCH 1/3] Update stats.py to avoid FutureWarning --- xclim/indices/stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xclim/indices/stats.py b/xclim/indices/stats.py index f6becdc63..474973c5f 100644 --- a/xclim/indices/stats.py +++ b/xclim/indices/stats.py @@ -933,7 +933,7 @@ def reindex_time(da, da_ref, group): da = da.rename(month="time").reindex(time=da_ref.time.dt.month) da["time"] = da_ref.time elif group == "time.week": - da = da.rename(week="time").reindex(time=da_ref.time.dt.week) + da = da.rename(week="time").reindex(time=da_ref.time.dt.isocalendar().week) da["time"] = da_ref.time # I don't think rechunking is necessary here, need to check return da if not uses_dask(da) else da.chunk({"time": -1}) From b7e8716f68b89afe5b292bbccc1ce832becb96bb Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 17 Oct 2024 14:23:03 -0400 Subject: [PATCH 2/3] Remove uneeded (?) warning filter --- tests/test_sdba/test_base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_sdba/test_base.py b/tests/test_sdba/test_base.py index 31d63d307..255ea061e 100644 --- a/tests/test_sdba/test_base.py +++ b/tests/test_sdba/test_base.py @@ -63,7 +63,6 @@ def test_grouper_get_index(tas_series, group, interp, val90): # xarray does not yet access "week" or "weekofyear" with groupby in a pandas-compatible way for cftime objects. # See: https://github.com/pydata/xarray/discussions/6375 -@pytest.mark.filterwarnings("ignore:dt.weekofyear and dt.week have been deprecated") @pytest.mark.slow @pytest.mark.parametrize( "group,n", From 6f92c8271c20f9aeb251d567d12d37c082de251f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:40:52 -0400 Subject: [PATCH 3/3] remove filterwarning --- tests/test_indices.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_indices.py b/tests/test_indices.py index 28f5032a5..3fcd31319 100644 --- a/tests/test_indices.py +++ b/tests/test_indices.py @@ -494,12 +494,12 @@ def test_effective_growing_degree_days( class TestStandardizedIndices: # gamma/APP reference results: Obtained with `monocongo/climate_indices` library # MS/fisk/ML reference results: Obtained with R package `SPEI` - # Using the method `APP` in XClim matches the method from monocongo, hence the very low - # tolerance possible. + # Using the method `APP` in XClim matches the method from monocongo, hence the very low tolerance possible. # Repeated tests with lower tolerance means we want a more precise comparison, so we compare - # the current version of XClim with the version where the test was implemented + # the current version of XClim with the version where the test was implemented. + # Additionally, xarray does not yet access "week" or "weekofyear" with groupby in a pandas-compatible way for cftime objects. + # See: https://github.com/pydata/xarray/discussions/6375 @pytest.mark.slow - @pytest.mark.filterwarnings("ignore:dt.weekofyear and dt.week have been deprecated") @pytest.mark.parametrize( "freq, window, dist, method, values, diff_tol", [