-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support init
keyword in sum
/prod
/maximum
/minimum
#36188
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> Co-authored-by: Tim Holy <[email protected]>
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 <[email protected]>
Co-authored-by: Milan Bouchet-Valat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@nalimilan @timholy Thanks a lot for your detailed review! |
…#36188) Co-authored-by: Tim Holy <[email protected]> Co-authored-by: Milan Bouchet-Valat <[email protected]>
This PR extends/finalizes @timholy's #35839. It adds
init
kwarg also tosum
andprod
.close #35839