[Numpy-discussion] Re: np.where and ZeroDivisionError: float division by zero

2024-04-26 Thread Lucas Colley
> What you are hoping for here is known as "short circuit" or "lazy" evaluation. In SciPy, we have the private utility function `_lazywhere`[1] for this. Cheers, Lucas [1] https://github.com/scipy/scipy/blob/f44326023dc51758495491fc9f06858fd38358a0/scipy/_lib/_util.py#L88-L156 > On 26 Apr 2024

[Numpy-discussion] Re: np.where and ZeroDivisionError: float division by zero

2024-04-26 Thread rosko37
What you are hoping for here is known as "short circuit" or "lazy" evaluation. Namely, this would work if np.where(cond, x, y) only evaluates x if cond is true and only evaluates y if cond is false. In this case, not only can it handle situations where one of the true/false cases "breaks" one of th