[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-26 Thread Dom Grigonis
If such issue is at numpy level, eg xor, which tests for number truth value is equal to n: xor([1, 1, 0], 2) == True xor([1, 0, 0], 2) == False I try to use builtin iterator functions for efficiency, such as combination of filter + next. If, however, the problem is at numpy level, I find `numba

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-26 Thread Ilhan Polat
It's typically called short-circuiting or quick exit when the target condition is met. if you have an array a = np.array([-1, 2, 3, 4, , 1]) and you are looking for a true/false result whether anything is negative or not (a < 0).any() will generate a bool array equal to and then check all

[Numpy-discussion] Re: Function that searches arrays for the first element that satisfies a condition

2023-10-26 Thread Dom Grigonis
Could you please give a concise example? I know you have provided one, but it is engrained deep in verbose text and has some typos in it, which makes hard to understand exactly what inputs should result in what output. Regards, DG > On 25 Oct 2023, at 22:59, rosko37 wrote: > > I know this que

[Numpy-discussion] Function that searches arrays for the first element that satisfies a condition

2023-10-26 Thread rosko37
I know this question has been asked before, both on this list as well as several threads on Stack Overflow, etc. It's a common issue. I'm NOT asking for how to do this using existing Numpy functions (as that information can be found in any of those sources)--what I'm asking is whether Numpy would a