On Tue, Jan 17, 2012 at 8:57 AM, Adam Klein <a...@lambdafoundry.com> wrote:

> Hello,
>
> I get a segfault here:
>
> In [1]: x = np.array([1,2,3], dtype='M')
> In [2]: x.searchsorted(2, side='left')
>
> But it's fine here:
>
> In [1]: x = np.array([1,2,3], dtype='M')
> In [2]: x.view('i8').searchsorted(2, side='left')
> Out[2]: 1
>
> This segfaults again:
>
> x.view('i8').searchsorted(np.datetime64(2), side='left')
>
> GDB gets me this far:
>
> Program received signal SIGSEGV, Segmentation fault.
> PyArray_SearchSorted (op1=0x1b8dd70, op2=0x17dfac0, side=NPY_SEARCHLEFT)
> at numpy/core/src/multiarray/item_selection.c:1463
> 1463        Py_INCREF(dtype);
>
>
>
Confirmed in current development. Note that things have changed and the
initial array creation will fail (no unit). The searchsorted will work if
searching for a datetime:

In [10]: x = np.array([1,2,3], 'datetime64[D]')

In [11]: x.searchsorted(datetime64(2,'D'))
Out[11]: 1

So the failure is one of raising an appropriate error message.

Please open a ticket.

Chuck
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to