Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Oct 15, 2024
1 parent 9851148 commit 42fc75d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ abstract type AbstractMutable end

function Base.sum(
a::AbstractArray{T};
dims = missing,
dims = :,
init = zero(promote_operation(+, T, T)),
) where {T<:AbstractMutable}
if !ismissing(dims)
# We cannot use `mapreduce` with `add!!` instead of `Base.add_mul` like
# `operate(sum, ...)` because the same instance given at `init` is used
# at several places.
return mapreduce(identity, Base.add_sum, a; dims, init)
end
return operate(sum, a; init)
Expand Down

0 comments on commit 42fc75d

Please sign in to comment.