-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Introduce keyword argument reset
for sum!
etc.
#36332
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
base: master
Are you sure you want to change the base?
Conversation
if haskey(kw, :init) # backward compatibility | ||
_kw_reset(kw) && !isempty(A) && fill!(rval, first(A)) | ||
fill!(rind, zero(eltype(keys(A)))) | ||
elseif _kw_reset(kw) | ||
!isempty(A) && fill!(rval, first(A)) | ||
fill!(rind, zero(eltype(keys(A)))) | ||
end |
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.
The behavior init=false
was not consistent with other multi-dimensional reducers. So I suggest to fix it.
It was added in #6894 by @timholy but it looks like it was an internal function back then. So, probably the consistency with other reducers and the usability for end-users were not the biggest concern.
Also, I'm not sure if we should keep the backward compatibility branch. But it's rather cheap so why not?
_kw_reset(kw::Iterators.Pairs) = _kw_reset(kw.data) | ||
_kw_reset(::NamedTuple{(), Tuple{}}) = true | ||
_kw_reset(kw::NamedTuple{(:reset,), Tuple{Bool}}) = kw.reset | ||
_kw_reset(kw::NamedTuple{(:init,), Tuple{Bool}}) = kw.init |
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.
Should we depwarn
when init
is passed?
See #36266 for the discussion. The name of the argument is still discussed in #36266 (
reset
is a placeholder ATM).close #36266