From 3e83bb9e2da00512ad14f72c6bff49dc73f8f436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Tue, 11 Jun 2024 11:26:54 -0400 Subject: [PATCH 1/3] fix {hot|cold}_spell_max_length --- CHANGES.rst | 6 +++++- tests/test_indices.py | 2 +- xclim/indices/_threshold.py | 10 ++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 6eafde626..96b48b4cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,12 +4,16 @@ Changelog v0.50.0 (unreleased) -------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`). +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Éric Dupuis (:user:`coxipi`). Internal changes ^^^^^^^^^^^^^^^^ * Synchronized tooling versions across ``pyproject.toml`` and ``tox.ini`` and pinned them to the latest stable releases in GitHub Workflows. (:pull:`1744`). +Bug fixes +^^^^^^^^^ +* ``xclim.indices.{cold|hot}_spell_total_length`` now properly use the argument `window` to only count spells with at least `window` time steps . (:issue:`1765`). + v0.49.0 (2024-05-02) -------------------- Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Juliette Lavoie (:user:`juliettelavoie`), David Huard (:user:`huard`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Javier Diez-Sierra (:user:`JavierDiezSierra`), Sarah Gammon (:user:`SarahG-579462`), Éric Dupuis (:user:`coxipi`). diff --git a/tests/test_indices.py b/tests/test_indices.py index e2a8ccc47..0f50b60a0 100644 --- a/tests/test_indices.py +++ b/tests/test_indices.py @@ -1421,7 +1421,7 @@ class TestHotSpellTotalLength: ("29 C", 3, ">", 8), # Two HS ("29 C", 3, ">=", 9), # One long HS, minus a day ("40 C", 3, ">", 0), # No HS - ("30 C", 5, ">", 8), # Windowed + ("30 C", 5, ">", 5), # Windowed ], ) def test_1d(self, tasmax_series, thresh, window, op, expected): diff --git a/xclim/indices/_threshold.py b/xclim/indices/_threshold.py index 150c55b04..604fad520 100644 --- a/xclim/indices/_threshold.py +++ b/xclim/indices/_threshold.py @@ -336,14 +336,13 @@ def cold_spell_total_length( thresh = convert_units_to(thresh, tas) cond = compare(tas, op, thresh, constrain=("<", "<=")) - max_l = rl.resample_and_rl( + out = rl.resample_and_rl( cond, resample_before_rl, rl.windowed_run_count, - window=1, + window=window, freq=freq, ) - out = max_l.where(max_l >= window, 0) return to_agg_units(out, tas, "count") @@ -2112,14 +2111,13 @@ def hot_spell_total_length( thresh = convert_units_to(thresh, tasmax) cond = compare(tasmax, op, thresh, constrain=(">", ">=")) - max_l = rl.resample_and_rl( + out = rl.resample_and_rl( cond, resample_before_rl, rl.windowed_run_count, - window=1, + window=window, freq=freq, ) - out = max_l.where(max_l >= window, 0) return to_agg_units(out, tasmax, "count") From e0f062a2fcc4dbe3350f19eb6d21206b01c19a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Tue, 11 Jun 2024 11:29:48 -0400 Subject: [PATCH 2/3] add pull number --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 96b48b4cc..80e09b850 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ Internal changes Bug fixes ^^^^^^^^^ -* ``xclim.indices.{cold|hot}_spell_total_length`` now properly use the argument `window` to only count spells with at least `window` time steps . (:issue:`1765`). +* ``xclim.indices.{cold|hot}_spell_total_length`` now properly use the argument `window` to only count spells with at least `window` time steps . (:issue:`1765`, :pull:`1777`). v0.49.0 (2024-05-02) -------------------- From e3f04cd4f9158a969c69d9f0aeae545b94fd36b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= <71575674+coxipi@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:57:15 -0400 Subject: [PATCH 3/3] spelling sugg. Co-authored-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 096f33def..cb5c5d985 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,7 +20,7 @@ Internal changes Bug fixes ^^^^^^^^^ -* ``xclim.indices.{cold|hot}_spell_total_length`` now properly use the argument `window` to only count spells with at least `window` time steps . (:issue:`1765`, :pull:`1777`). +* ``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`). v0.49.0 (2024-05-02) --------------------