Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid FutureWarning for dt.week #1964

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions tests/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down
1 change: 0 additions & 1 deletion tests/test_sdba/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion xclim/indices/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Loading