Skip to content

Commit

Permalink
switch eval_monad_expand_where to use np.repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 8, 2024
1 parent 6710bbf commit 0fad0ea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion klongpy/monads.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def eval_monad_expand_where(a):
&[0 1 0 1 0] --> [1 3]
"""
return np.concatenate([np.zeros(x, dtype=int) + i for i,x in enumerate(a if is_list(a) else [a])])
arr = a if is_list(a) else [a]
return np.repeat(np.arange(len(arr)), arr)


def eval_monad_first(a):
Expand Down

0 comments on commit 0fad0ea

Please sign in to comment.