[Numpy-discussion] "arg" searchsorted
Bryan Van de Ven
bryanv at continuum.io
Mon Mar 26 18:32:26 EDT 2012
On 3/26/12 4:57 PM, Charles R Harris wrote:
>
> On Mon, Mar 26, 2012 at 3:34 PM, Bryan Van de Ven <bryanv at continuum.io
> <mailto:bryanv at continuum.io>> wrote:
>
> I recently got asked about an "arg" version of searchsorted,
> basically a
> version that could take a sorter as an additional argument. For
> instance:
>
> In [13]: a = np.array([5,6,8,1,6,9,0])
>
> In [14]: s = np.argsort(a)
>
> In [17]: s
> Out[17]: array([6, 3, 0, 1, 4, 2, 5])
>
> In [18]: np.searchsorted(a, [1.5, 7.2], sorter=sorter)
> Out[18]: array([2, 5])
>
>
> An alternate API would be to pass a pair (a, sorter) as the first
> argument.
>
> Chuck
Sure, that would be easy enough to implement. I don't really have a
preference, is there a reason you would prefer that API?
Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120326/ab2df228/attachment.html>
More information about the NumPy-Discussion
mailing list