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

David Cournapeau cournape@gmail....
Mon Feb 1 22:36:08 CST 2010

On Tue, Feb 2, 2010 at 1:05 PM,  <josef.pktd@gmail.com> wrote:

> I think this could be considered as a correct answer, the count of any
> integer is zero.

Maybe, but this shape is random - it would be different in different
conditions, as the length of the returned array is just some random
memory location.

> Returning an array with one zero, or the empty array or raising an
> exception? I don't see much of a pattern

Since there is no obvious solution, the only rationale for not raising
an exception  I could see is to accommodate often-encountered special
cases. I find returning [0] more confusing than returning empty
arrays, though - maybe there is a usecase I don't know about.



More information about the NumPy-Discussion mailing list