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

Charles R Harris charlesr.harris at gmail.com
Mon Feb 1 23:45:50 EST 2010


On Mon, Feb 1, 2010 at 9:36 PM, David Cournapeau <cournape at gmail.com> wrote:

> On Tue, Feb 2, 2010 at 1:05 PM,  <josef.pktd at 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.
>
>
In this case I would expect an empty input to be a programming error and
raising an error to be the right thing.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100201/e547451f/attachment.html>


More information about the NumPy-Discussion mailing list