I don’t think that np.search is really solving the same problem as find_first would.
IMO, we should solve that problem with an argfirst(bool_array, axis=0, keepdims=False) -> intp function, with almost the same semantics as argmax, but special-casing an array of Falses, to return bool_array.shape[axis]. Eric On Tue, 9 May 2017 at 18:39 Stephan Hoyer <sho...@gmail.com> wrote: > On Tue, May 9, 2017 at 9:46 AM, Martin Spacek <nu...@mspacek.mm.st> wrote: > >> Looking at my own habits and uses, it seems to me that finding the >> indices of matching values of one array in another is a more common use >> case than finding insertion indices of one array into another sorted array. >> So, I propose that np.search(), or something like it, could be even more >> useful than np.searchsorted(). >> > > The current version of this PR only returns the indices of the *first* > match (rather than all matches), which is an important detail. I would > strongly consider including that detail in the name (e.g., by calling this > "find_first" rather than "search"), because my naive expectation for a > method called "search" is to find all matches. > > In any case, I agree that this functionality would be welcome. Getting the > details right for a high performance solution is tricky, and there is > strong evidence of interest given the 200+ upvotes on this StackOverflow > question: > > http://stackoverflow.com/questions/432112/is-there-a-numpy-function-to-return-the-first-index-of-something-in-an-array > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion