[Numpy-discussion] np.in1d() capacity limit?

Pauli Virtanen pav at iki.fi
Wed Oct 26 06:00:00 EDT 2011


26.10.2011 09:09, Grové kirjoitti:
> I have picked up a strange limit to np.in1d():
> ----------
> 
> b
> Out[100]: 
> array(['2007-01-01T02:30:00+0200', '2007-01-01T03:00:00+0200',
>        '2007-01-01T03:30:00+0200', ..., '2008-01-01T01:00:00+0200',
>        '2008-01-01T01:30:00+0200', '2008-01-01T02:00:00+0200'], 
> dtype='datetime64[s]')
> 
> b.shape
> Out[101]: (17520,)
> 
> a = b[0:42]
> 
> np.in1d(b,a)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
[clip]
> In other words the limit seems to be 41 elements for a.  Is this a bug or am I 
> getting something wrong?

The problem here seems to be that argsort (or only the mergesort?) for
datetime datatypes is not implemented.

There's a faster code path that is triggered for small selection arrays,
and that does not require argsort, and that's why the error occurs in
only some of the cases.

-- 
Pauli Virtanen




More information about the NumPy-Discussion mailing list