From 7b21216fd6b7240ddc99b325dbd80eae95aedd3e Mon Sep 17 00:00:00 2001 From: achiefa Date: Wed, 29 Jan 2025 19:13:24 +0000 Subject: [PATCH] Correct bug in step function --- .../src/validphys/theorycovariance/higher_twist_functions.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/validphys2/src/validphys/theorycovariance/higher_twist_functions.py b/validphys2/src/validphys/theorycovariance/higher_twist_functions.py index acbb174164..5e494478bf 100644 --- a/validphys2/src/validphys/theorycovariance/higher_twist_functions.py +++ b/validphys2/src/validphys/theorycovariance/higher_twist_functions.py @@ -70,15 +70,14 @@ def step_function(a: npt.ArrayLike, y_shift: npt.ArrayLike, bin_edges: npt.Array A one-dimensional array containing the function values evaluated at the points specified in `a`. """ - res = [] + res = np.zeros_like(a) for shift_pos, shift in enumerate(y_shift): bin_low = bin_edges[shift_pos] bin_high = bin_edges[shift_pos + 1] condition = np.multiply( a >= bin_low, a < bin_high if shift_pos != len(y_shift) - 1 else a <= bin_high ) - res.append([shift for cond in condition if cond]) - res = np.concatenate(res) + res = np.add(res, [shift if cond else 0.0 for cond in condition]) return res