[Numpy-discussion] Where's that function?
Wed Feb 6 13:32:29 CST 2013
On Wed, Feb 6, 2013 at 2:17 PM, Sebastian Berg
> On Wed, 2013-02-06 at 13:08 -0500, firstname.lastname@example.org 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
>> 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 : a = np.arange(10)
> In : a[2:5].sum(), a[5:9].sum(), a[9:].sum()
> Out: (9, 26, 9)
> In : np.add.reduceat(a, [2, 5, 9])
> Out: array([ 9, 26, 9])
That's what I remembered seeing, but obviously I didn't remember it correctly.
Not useful for my current case, but I will keep it in mind to clean up
some other code.
I will need a python loop after all to take a list of (unequal length)
slices out of an array.
>> NumPy-Discussion mailing list
> NumPy-Discussion mailing list
More information about the NumPy-Discussion