[Numpy-discussion] searchsorted bug

Charles R Harris charlesr.harris@gmail....
Thu Jan 31 11:38:01 CST 2008


On Jan 31, 2008 9:17 AM, lorenzo bolla <lbolla@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://projects.scipy.org/pipermail/numpy-discussion/attachments/20080131/dc9365d7/attachment.html 


More information about the Numpy-discussion mailing list