[Numpy-discussion] API: make numpy.lib._arraysetops.intersect1d work on multiple arrays #25688

2024-02-02 Thread Stephan Kuschel via NumPy-Discussion
Dear Community, For my own work, I required the intersect1d function to work on multiple arrays while returning the indices (using `return_indizes=True`). Consequently I changed the function in numpy and now I am seeking feedback from the community. This is the corresponding PR: https://gith

[Numpy-discussion] Re: API: make numpy.lib._arraysetops.intersect1d work on multiple arrays #25688

2024-02-06 Thread Stephan Kuschel via NumPy-Discussion
Dear Dom, thanks for bringing up the possible constriction. I agree that this would be serious argument against the change. However, as you said the overlapping/non-overlapping indices would become ambiguous with more than two arrays. And calling the fucntion with only two arrays at a time w

[Numpy-discussion] Re: API: make numpy.lib._arraysetops.intersect1d work on multiple arrays #25688

2024-02-06 Thread Stephan Kuschel via NumPy-Discussion
Dear Dom, just check, and on my computer the new version is ~factor 2 faster compared to the reduce approach if arrays are shuffled. For sorted arrays, the the new version is factor 3.4. faster: from functools import reduce idss = [np.random.permutation(np.arange(a*100, int(1e5)+a*100, 1)) f