Skip to content

Commit

Permalink
Fix sum(::AbstractArray{Bool}; dims)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 8, 2020
1 parent b8a686b commit be78f8b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/reduce.jl
Expand Up @@ -523,9 +523,8 @@ julia> sum(1:20)
```
"""
sum(a; kw...) = sum(identity, a; kw...)
sum(a::AbstractArray{Bool}; kw...) = count(a)
# Note: It is OK to ignore `init` to `sum(::AbstractArray{Bool})`
# because it is unspecified if the value of `init` is used or not.
sum(a::AbstractArray{Bool}; init = nothing, kw...) =
init === nothing ? count(a; kw...) : reduce(add_sum, a; init = init, kw...)

## prod
"""
Expand Down

0 comments on commit be78f8b

Please sign in to comment.