On Fri, 2023-12-22 at 18:01 -0500, Marten van Kerkwijk wrote:
> Hi Martin,
> 
> I agree it is a long-standing issue, and I was reminded of it by your
> comment.  I have a draft PR at 
> https://github.com/numpy/numpy/pull/25476
> that does not change the old behaviour, but allows you to pass in a
> start-stop array which behaves more sensibly (exact API TBD).
> 
> Please have a look!


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.
Of course if go with your `slice(start, stop)` idea that also works,
although passing as separate parameters seems nice too.

Adding another name (if we can think of one at least) seems pretty good
to me, since I suspect we would add docs to suggest not using
`reduceat`.


One small thing about the PR: I would like to distinct `default` and
`initial`.  I.e. the default value is used only for empty reductions,
while the initial value should be always used (unless you would pass
both, which we don't for normal reductions though).
I suppose the machinery isn't quite set up to do both side-by-side.

- Sebastian



> 
> Marten
> 
> Martin Ling <martin-nu...@earth.li> writes:
> 
> > Hi folks,
> > 
> > I don't follow numpy development in much detail these days but I
> > see
> > that there is a 2.0 release planned soon.
> > 
> > Would this be an opportunity to change the behaviour of 'reduceat'?
> > 
> > This issue has been open in some form since 2006!
> > https://github.com/numpy/numpy/issues/834
> > 
> > The current behaviour was originally inherited from Numeric, and
> > makes
> > reduceat often unusable in practice, even where it should be the
> > perfect, concise, efficient solution. But it has been impossible to
> > change it without breaking compatibіlity with existing code.
> > 
> > As a result, horrible hacks are needed instead, e.g. my answer
> > here:
> > https://stackoverflow.com/questions/57694003
> > 
> > Is this something that could finally be fixed in 2.0?
> > 
> > 
> > Martin
> > _______________________________________________
> > 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: m...@astro.utoronto.ca
> _______________________________________________
> 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