Skip to content

Commit

Permalink
Correct bug in step function
Browse files Browse the repository at this point in the history
  • Loading branch information
achiefa committed Jan 29, 2025
1 parent f916a65 commit faad150
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit faad150

Please sign in to comment.