[Numpy-discussion] np.bincount raises MemoryError when given an empty array

Keith Goodman kwgoodman@gmail....
Mon Feb 1 11:09:20 CST 2010


2010/2/1 Ernest Adrogué <eadrogue@gmx.net>:
> Hello,
>
> Consider the following code:
>
> for j in range(5):
>        f = np.bincount(x[y == j])
>
> It fails with MemoryError whenever y == j is all False element-wise.
>
>
> In [96]: np.bincount([])
> ---------------------------------------------------------------------------
> MemoryError                               Traceback (most recent call last)
>
> /home/ernest/<ipython console> in <module>()
>
> MemoryError:
>
> In [97]: np.__version__
> Out[97]: '1.3.0'
>
> Is this a bug?
>
> Bye.

I get it to work sometimes:

$ ipython
>> import numpy as np
>> np.bincount([])
---------------------------------------------------------------------------
MemoryError:
>> np.bincount(())
   array([0])
>> np.bincount([])
   array([0])
>> np.bincount([])
---------------------------------------------------------------------------
MemoryError:
>> np.__version__
   '1.4.0rc2'


More information about the NumPy-Discussion mailing list