diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5573a3c3e..b5930a36f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,14 @@ Changelog ========= +v0.53.0 +-------------------- +Contributors to this version: Adrien Lamarche (:user:`LamAdr`). + +Bug fixes +^^^^^^^^^ +* Fixed a small inefficiency in ``_otc_adjust`` (:pull:`1890`). + v0.52.0 (2024-08-08) -------------------- Contributors to this version: David Huard (:user:`huard`), Trevor James Smith (:user:`Zeitsperre`), Hui-Min Wang (:user:`Hem-W`), Éric Dupuis (:user:`coxipi`), Sarah Gammon (:user:`SarahG-579462`), Pascal Bourgault (:user:`aulemahal`), Juliette Lavoie (:user:`juliettelavoie`), Adrien Lamarche (:user:`LamAdr`). diff --git a/xclim/sdba/_adjustment.py b/xclim/sdba/_adjustment.py index 303d4a3e3..8bc9dcd62 100644 --- a/xclim/sdba/_adjustment.py +++ b/xclim/sdba/_adjustment.py @@ -1031,10 +1031,8 @@ def _otc_adjust( rng = np.random.default_rng() # The plan row corresponding to a source bin indicates its probabilities to be transported to every target bin for i, binX_group in enumerate(binX_groups): - # Get the plan row of this bin - pi = np.where((binX[binX_group[0]] == gridX).all(1))[0][0] # Pick as much target bins for this source bin as there are points in the source bin - choice = rng.choice(range(muY.size), p=plan[pi, :], size=binX_count[i]) + choice = rng.choice(range(muY.size), p=plan[i, :], size=binX_count[i]) out[binX_group] = (gridY[choice] + 1 / 2) * bin_width + bin_origin if jitter_inside_bins: