Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-16 Thread Jaime Fernández del Río
On Tue, May 16, 2017 at 1:25 AM, Stephan Hoyer wrote: > I like the idea of a strategy keyword argument. strategy='auto' leaves the > door open for future improvements, e.g., if we ever add hash tables to > numpy. > > For the algorithm, I think we actually want to sort the needles array as > well

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-15 Thread Peter Creasey
> From: Stephan Hoyer > > I like the idea of a strategy keyword argument. strategy='auto' leaves the > door open for future improvements, e.g., if we ever add hash tables to > numpy. > > For the algorithm, I think we actually want to sort the needles array as > well in most (all?) cases. > > If ha

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-15 Thread Stephan Hoyer
I like the idea of a strategy keyword argument. strategy='auto' leaves the door open for future improvements, e.g., if we ever add hash tables to numpy. For the algorithm, I think we actually want to sort the needles array as well in most (all?) cases. If haystack is also sorted, advancing thorou

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-15 Thread Nathaniel Smith
On May 9, 2017 9:47 AM, "Martin Spacek" wrote: Hello, I've opened up a pull request to add a function called np.search(), or something like it, to complement np.searchsorted(): https://github.com/numpy/numpy/pull/9055 There's also this issue I opened before starting the PR: https://github.com

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-15 Thread Martin Spacek
On 2017-05-09 07:39 PM, Stephan Hoyer wrote: On Tue, May 9, 2017 at 9:46 AM, Martin Spacek mailto: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

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-09 Thread Eric Wieser
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[

Re: [Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-09 Thread Stephan Hoyer
On Tue, May 9, 2017 at 9:46 AM, Martin Spacek 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

[Numpy-discussion] Proposal: np.search() to complement np.searchsorted()

2017-05-09 Thread Martin Spacek
Hello, I've opened up a pull request to add a function called np.search(), or something like it, to complement np.searchsorted(): https://github.com/numpy/numpy/pull/9055 There's also this issue I opened before starting the PR: https://github.com/numpy/numpy/issues/9052 Proposed API changes