On Sat, 2023-12-23 at 09:56 -0500, Marten van Kerkwijk wrote:
> Hi Sebastian,
> 
> > That looks nice, I don't have a clear feeling on the order of
> > items, if
> > we think of it in terms of `(start, stop)` there was also the idea
> > voiced to simply add another name in which case you would allow
> > start
> > and stop to be separate arrays.
> 
> Yes, one could add another method.  Or perhaps even add a new
> argument
> to `.reduce` instead (say `slices`).  But this seemed the simplest
> route...

Yeah, I don't mind this, doesn't stop us from a better idea either.
Adding to `.reduce` could be fine, but overall I actually think a new
name or using `reduceat` is nicer than overloading it more, even
`reduce_slices()`.

> > 
<snip>

> > 
> > I suppose the machinery isn't quite set up to do both side-by-side.
> 
> I just followed what is done for reduce, where a default could also
> have
> made sense given that `where` can exclude all inputs along a given
> row.
> I'm not convinced it would be necessary to have both, though it would
> not be hard to add.

Sorry, I misread the code: You do use initial the same way as in
reductions, I thought it wasn't used when there were multiple elements.
I.e. it is used for non-empty slices also.

There is still a little annoyance when `initial=` isn't passed, since
default/initial can be different (this is the case for object add for
example: the default is `0`, but it is not used as initial for non
empty reductions).
Anyway, its a small details to some degree even if it may be finicky to
get right.  At the moment it seems passing `dtype=object` somehow
changes the result also.

- Sebastian


> 
> All the best,
> 
> Marten
> _______________________________________________
> 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: sebast...@sipsolutions.net
> 


_______________________________________________
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