From 630b7369333967d0722d8b648aeee6f364fe169a Mon Sep 17 00:00:00 2001 From: Hugo Farajallah Date: Thu, 13 Aug 2026 11:31:24 +0200 Subject: [PATCH] Fix crash in oblique section projection on NumPy 2 RectBivariateSpline.ev returns a shape-(1,) ndarray, not a scalar. Assigning it to a scalar element of out_var was tolerated by NumPy 1.x (DeprecationWarning since 1.25) but is an error on NumPy 2: ValueError: setting an array element with a sequence This makes oblique_proj unusable for both the 3D and 2D paths on any current installation. setup.py requires numpy>=1.26.4 with no upper bound, so a fresh install picks up NumPy 2 and the function raises. Reproduced with Python 3.14.6, NumPy 2.4.6, SciPy 1.18.0. Meso-NH already carries this fix in its in-tree copy of the module (src/LIB/Python/misc_functions.py); this ports it back so the two copies match byte for byte again. --- src/MNHPy/misc_functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MNHPy/misc_functions.py b/src/MNHPy/misc_functions.py index a5d8ec7..d8530de 100644 --- a/src/MNHPy/misc_functions.py +++ b/src/MNHPy/misc_functions.py @@ -125,11 +125,13 @@ def oblique_proj(var, ni, nj, lvl, i_beg, j_beg, i_end, j_end): a = RectBivariateSpline(nj, ni, var[k, :, :], kx=1, ky=1) for m in range(int(dist_seg) + 1): # La fonction ev de RectBivariate retourne la valeur la plus proche du point considéré - out_var[k, m] = a.ev(axe_m_coord[m][1], axe_m_coord[m][0]) + result = a.ev(axe_m_coord[m][1], axe_m_coord[m][0]) + out_var[k, m] = result.item() else: # 2D variables to project a = RectBivariateSpline(nj, ni, var[:, :], kx=1, ky=1) for m in range(int(dist_seg) + 1): - out_var[m] = a.ev(axe_m_coord[m][1], axe_m_coord[m][0]) + result = a.ev(axe_m_coord[m][1], axe_m_coord[m][0]) + out_var[m] = result.item() angle_proj = math.acos((ni[i_end] - ni[i_beg]) / axe_m[-1]) return angle_proj, out_var, axe_m