Hi All,

This discussion about updating reduceat went silent, but recently I came
back to my PR to allow `indices` to be a 2-dimensional array of start
and stop values (or a tuple of separate start and stop arrays).  I
thought a bit more about it and think it is the easiest way to extend
the present definition.  So, I have added some tests and documentation
and would now like to open it for proper discussion.  See

https://github.com/numpy/numpy/pull/25476

>From the examples there:
```
a = np.arange(12)
np.add.reduceat(a, ([1, 3, 5], [2, -1, 0]))
# array([ 1, 52,  0])
np.minimum.reduceat(a, ([1, 3, 5], [2, -1, 0]), initial=10)
# array([ 1,  3, 10])
np.minimum.reduceat(a, ([1, 3, 5], [2, -1, 0]))
# ValueError: empty slice encountered with reduceat operation for 'minimum', 
which does not have an identity. Specify 'initial'.
```
Let me know what you all think,

Marten

p.s.  Rereading the thread, I see we discussed initial vs default values
in some detail. This is interesting, but somewhat orthogonal to the PR,
since it just copies behaviour already present for reduce.
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to