[Numpy-discussion] Where's that function?
Sebastian Berg
sebastian@sipsolutions....
Wed Feb 6 13:17:25 CST 2013
On Wed, 2013-02-06 at 13:08 -0500, josef.pktd@gmail.com wrote:
> I'm convinced that I saw a while ago a function that uses a list of
> interval boundaries to index into an array, either to iterate or to
> take.
> I thought that's very useful, but didn't make a note.
>
> Now, I have no idea where I saw this (I thought numpy), and I cannot
> find it anywhere.
>
> any clues?
>
It does not quite sound like what you are looking for, but the only
thing I can think of in numpy right now that does something in that
direction is the ufunc.reduceat functionality:
In [1]: a = np.arange(10)
In [2]: a[2:5].sum(), a[5:9].sum(), a[9:].sum()
Out[2]: (9, 26, 9)
In [3]: np.add.reduceat(a, [2, 5, 9])
Out[3]: array([ 9, 26, 9])
Regards,
Sebastian
> Thanks,
>
> Josef
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list