[Numpy-discussion] indexed arrays ignoring duplicates
Damien Morton
dmorton@bitfurnace....
Wed Sep 29 22:24:55 CDT 2010
On Thu, Sep 30, 2010 at 11:11 AM, <josef.pktd@gmail.com> wrote:
>> bincount only works for gathering/accumulating scalars. Even the
>> 'weights' parameter is limited to scalars.
>
> Do you mean that bincount only works with 1d arrays? I also think that
> this is a major limitation of it.
>>> from numpy import *
>>> a = array((1,2,2,3,3))
>>> w = array(((1,2),(3,4),(5,6),(7,8),(9,10)))
>>> bincount(a,weights=w)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: object too deep for desired array
>>> w0 = array((1,2,3,4,5))
>>> bincount(a,weights=w0)
array([ 0., 1., 5., 9.])
>> I propose the name 'gather()' for the helper function that does this.
>
> I don't think "gather" is an obvious name to search for.
"gather" is the name that the GPGPU community uses to describe this
kind of operation. Not just for summation but for any kind of indexed
reducing operation.
More information about the NumPy-Discussion
mailing list