Skip to content

Commit e7b3a0d

Browse files
committed
Correct bug in step function
1 parent 0e96706 commit e7b3a0d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

validphys2/src/validphys/theorycovariance/higher_twist_functions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ def step_function(a: npt.ArrayLike, y_shift: npt.ArrayLike, bin_edges: npt.Array
7070
A one-dimensional array containing the function values evaluated at the points
7171
specified in `a`.
7272
"""
73-
res = []
73+
res = np.zeros_like(a)
7474
for shift_pos, shift in enumerate(y_shift):
7575
bin_low = bin_edges[shift_pos]
7676
bin_high = bin_edges[shift_pos + 1]
7777
condition = np.multiply(
7878
a >= bin_low, a < bin_high if shift_pos != len(y_shift) - 1 else a <= bin_high
7979
)
80-
res.append([shift for cond in condition if cond])
81-
res = np.concatenate(res)
80+
res = np.add(res, [shift if cond else 0.0 for cond in condition])
8281
return res
8382

8483

0 commit comments

Comments
 (0)