[Numpy-discussion] searchsorted bug

Charles R Harris charlesr.harris at gmail.com
Thu Jan 31 12:38:01 EST 2008


On Jan 31, 2008 9:17 AM, lorenzo bolla <lbolla at gmail.com> wrote:

> 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. <-----
>
>

Heh. I knew there was a reason I documented that subroutine, I had forgotten
about that. Anyway, I think an exception should be thrown in the higher
level routine that sets up the call when there is a type mismatch. Some
typecasting might also be appropriate.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080131/dc9365d7/attachment.html>


More information about the NumPy-Discussion mailing list