Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Thu, Sep 30, 2010 at 12:07 AM, wrote: > On Wed, Sep 29, 2010 at 11:24 PM, Damien Morton > wrote: >> On Thu, Sep 30, 2010 at 11:11 AM,   wrote: bincount only works for gathering/accumulating scalars. Even the 'weights' parameter is limited to scalars. >>> >>> Do you mean that bincou

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 11:24 PM, Damien Morton wrote: > On Thu, Sep 30, 2010 at 11:11 AM,   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 >> th

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
>>> 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 operati

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
On Thu, Sep 30, 2010 at 11:11 AM, 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

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 20:11, wrote: > On Wed, Sep 29, 2010 at 9:03 PM, Damien Morton wrote: >> On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: >>> On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: [clip: inplace addition wi

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread josef . pktd
On Wed, Sep 29, 2010 at 9:03 PM, Damien Morton wrote: > On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: >> On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: >>> Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: >>> [clip: inplace addition with duplicates] Use numpy.bincount() inste

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Damien Morton
On Thu, Sep 30, 2010 at 3:28 AM, Robert Kern wrote: > On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: >> Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: >> [clip: inplace addition with duplicates] >>> Use numpy.bincount() instead. >> >> It might be worthwhile to add a separate helper fun

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 12:00, Pauli Virtanen wrote: > Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: > [clip: inplace addition with duplicates] >> Use numpy.bincount() instead. > > It might be worthwhile to add a separate helper function for this > purpose. Bincount makes a copy that could b

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Pauli Virtanen
Wed, 29 Sep 2010 11:15:08 -0500, Robert Kern wrote: [clip: inplace addition with duplicates] > Use numpy.bincount() instead. It might be worthwhile to add a separate helper function for this purpose. Bincount makes a copy that could be avoided, and it is difficult to find if you don't know about

Re: [Numpy-discussion] indexed arrays ignoring duplicates

2010-09-29 Thread Robert Kern
On Wed, Sep 29, 2010 at 01:01, Damien Morton wrote: > lets say i have arrays: > > a = array((1,2,3,4,5)) > indices = array((1,1,1,1)) > > and i perform operation: > > a[indices] += 1 > > the result is > > array([1, 3, 3, 4, 5]) > > in other words, the duplicates in indices are ignored > > if I wan

[Numpy-discussion] indexed arrays ignoring duplicates

2010-09-28 Thread Damien Morton
lets say i have arrays: a = array((1,2,3,4,5)) indices = array((1,1,1,1)) and i perform operation: a[indices] += 1 the result is array([1, 3, 3, 4, 5]) in other words, the duplicates in indices are ignored if I wanted the duplicates not to be ignored, resulting in: array([1, 6, 3, 4, 5]) h