<br><br><div class="gmail_quote">On Tue, Jan 17, 2012 at 8:57 AM, Adam Klein <span dir="ltr"><<a href="mailto:adam@lambdafoundry.com">adam@lambdafoundry.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<div><br></div><div>I get a segfault here:</div><div><br></div><div><div>In [1]: x = np.array([1,2,3], dtype='M')</div><div>In [2]: x.searchsorted(2, side='left')</div></div><div><br></div><div>But it's fine here:</div>

<div><br></div><div><div>In [1]: x = np.array([1,2,3], dtype='M')</div><div>In [2]: x.view('i8').searchsorted(2, side='left')</div></div><div>Out[2]: 1</div><div><br></div><div>This segfaults again:</div>

<div><br></div><div>x.view('i8').searchsorted(np.datetime64(2), side='left')</div><div><br></div><div>GDB gets me this far:</div><div><br></div><div><div>Program received signal SIGSEGV, Segmentation fault.</div>

<div>PyArray_SearchSorted (op1=0x1b8dd70, op2=0x17dfac0, side=NPY_SEARCHLEFT) at numpy/core/src/multiarray/item_selection.c:1463</div><div>1463        Py_INCREF(dtype);</div></div><div><br></div><div><br></div></blockquote>
<div><br>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:<br><br><span style="font-family:courier new,monospace">In [10]: x = np.array([1,2,3], 'datetime64[D]')</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">In [11]: x.searchsorted(datetime64(2,'D'))</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Out[11]: 1</span><br>
 <br>So the failure is one of raising an appropriate error message.<br><br>Please open a ticket.<br><br>Chuck<br></div></div>