Support init keyword in sum/prod/maximum/minimum#36188
Support init keyword in sum/prod/maximum/minimum#36188tkf merged 26 commits intoJuliaLang:masterfrom
init keyword in sum/prod/maximum/minimum#36188Conversation
timholy
left a comment
There was a problem hiding this comment.
Very nice, thanks so much for picking this up and getting it across the finish line!
@nalimilan I believe we should keep these caveats. It is highly beneficial that Consider x = reduce(op, [a, b]; init = x0) # in thread 1
y = reduce(op, [c, d]; init = x0) # in thread 2
ans = op(x, y)However, it's not always possible to guarantee that split collections are non-empty. For example, xs = (x for x in [bad, bad, bad, bad, a, b, c, d] if x !== bad)then the collection-splitting routine might produce left = (x for x in [bad, bad, bad, bad] if x !== bad)
right = (x for x in [a, b, c, d] if x !== bad)(That's how SplittablesBase.jl supports Then, we'd have x = reduce(op, []; init = x0) # in thread 1
y = reduce(op, [a, b, c, d]; init = x0) # in thread 2
@assert x == x0
ans = op(x, y)As you can see, Of course, the parallel implementation of |
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr> Co-authored-by: Tim Holy <tim.holy@gmail.com>
|
OK, I was just curious whether we currently make use of that possibility. But for "neutral", IMHO the docstring should either mention that the behavior is unspecified (like for other docstrings), or the word should be removed. |
It's possible but I'm not sure. I just think it's a reasonable API to keep it as-is. |
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
|
@nalimilan @timholy Thanks a lot for your detailed review! |
This PR extends/finalizes @timholy's #35839. It adds
initkwarg also tosumandprod.close #35839