<div dir="ltr"><div class="markdown-here-wrapper" style="font-size:1em;font-family:Helvetica,arial,freesans,clean,sans-serif;color:rgb(34,34,34);background-color:rgb(255,255,255);border:none;line-height:1.2"><p style="margin:1em 0px">I don’t think that <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">np.search</code> is really solving the same problem as <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">find_first</code> would.</p>
<p style="margin:1em 0px">IMO, we should solve that problem with an <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">argfirst(bool_array, axis=0, keepdims=False) -> intp</code> function, with almost the same semantics as <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">argmax</code>, but special-casing an array of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">False</code>s, to return <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">bool_array.shape[axis]</code>.</p>
<p style="margin:1em 0px">Eric</p>
<div title="MDH:SSBkb24ndCB0aGluayB0aGF0IGBucC5zZWFyY2hgIGlzIHJlYWxseSBzb2x2aW5nIHRoZSBzYW1l
IHByb2JsZW0gYXMgYGZpbmRfZmlyc3RgIHdvdWxkLjxkaXY+PGJyPjwvZGl2PjxkaXY+SU1PLCB3
ZSBzaG91bGQgc29sdmUgdGhhdCBwcm9ibGVtIHdpdGggYW4gYGFyZ2ZpcnN0KGJvb2xfYXJyYXks
IGF4aXM9MCwga2VlcGRpbXM9RmFsc2UpIC0mZ3Q7IGludHBgIGZ1bmN0aW9uLCB3aXRoIGFsbW9z
dCB0aGUgc2FtZSBzZW1hbnRpY3MgYXMgYGFyZ21heGAsIGJ1dCBzcGVjaWFsLWNhc2luZyBhbiBh
cnJheSBvZiBgRmFsc2VgcywgdG8gcmV0dXJuIGBib29sX2FycmF5LnNoYXBlW2F4aXNdYC48L2Rp
dj48ZGl2Pjxicj48L2Rpdj48ZGl2PkVyaWM8L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 9 May 2017 at 18:39 Stephan Hoyer <<a href="mailto:shoyer@gmail.com">shoyer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 9, 2017 at 9:46 AM, Martin Spacek <span dir="ltr"><<a href="mailto:numpy@mspacek.mm.st" target="_blank">numpy@mspacek.mm.st</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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().<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">The current version of this PR only returns the indices of the <i>first</i> 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.</div><div class="gmail_quote"><br></div><div class="gmail_quote">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:</div><div class="gmail_quote"><a href="http://stackoverflow.com/questions/432112/is-there-a-numpy-function-to-return-the-first-index-of-something-in-an-array" target="_blank">http://stackoverflow.com/questions/432112/is-there-a-numpy-function-to-return-the-first-index-of-something-in-an-array</a><br></div><div class="gmail_quote"><br></div></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>