[Numpy-discussion] searchsorted bug

lorenzo bolla lbolla at gmail.com
Thu Jan 31 11:17:56 EST 2008


from docstring in multiarraymodule.c

/** @brief Use bisection of sorted array to find first entries >= keys.
 *
 * For each key use bisection to find the first index i s.t. key <= arr[i].
 * When there is no such index i, set i = len(arr). Return the results in
ret.
 * All arrays are assumed contiguous on entry and both arr and key must be
of    <-----
 * the same comparable type. <-----
 *
 * @param arr contiguous sorted array to be searched.
 * @param key contiguous array of keys.
 * @param ret contiguous array of intp for returned indices.
 * @return void
 */
static void
local_search_left(PyArrayObject *arr, PyArrayObject *key, PyArrayObject
*ret)

In particular:

 * All arrays are assumed contiguous on entry and both arr and key must be
of    <-----
 * the same comparable type. <-----

A and B are not of the same type ('|S2' is not '|S1').
This should be mentioned somewhere more accessible.

L.


On 1/31/08, Alan G Isaac <aisaac at american.edu> wrote:
>
> Problem also with Windows P3 binaries.
> fwiw,
> Alan Isaac
>
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310
> 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> numpy.__version__
> '1.0.4'
> >>> A = numpy.array(['a','aa','b'])
> >>> B = numpy.array(['d','e'])
> >>> A.searchsorted(B)
> array([3, 0])
> >>>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Lorenzo Bolla
lbolla at gmail.com
http://lorenzobolla.emurse.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080131/e0820fa3/attachment.html>


More information about the NumPy-Discussion mailing list