[Numpy-discussion] bincount() optional length argument

Robert Kern robert.kern@gmail....
Fri Aug 27 16:15:12 CDT 2010


On Fri, Aug 27, 2010 at 16:13, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> I've been using bincount() in situations where I always want the count vector to be a certain fixed length, even if the upper bins are 0. e.g. I want the counts of 0 through 9, and if there are no 9's in the vector I'm counting, I'd still like it to be at least length 10. It's kind of a pain to have to check for this case and concatenate 0's, nevermind an extra array allocation.
>
> How would people feel about an optional argument to support this behaviour? I'd be happy with either a "minlength" or an "exactly this length" with values above this range being ignored, but it seems like the latter might be useful in more cases.

minlength works for me.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list