Skip to content

Commit b416906

Browse files
authored
Force specialization for _mean's dims argument (#38)
Ensures we get the specialization we want when passing `dims=(:)`. Fixes #37.
1 parent 5811fba commit b416906

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Statistics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ mean(A::AbstractArray; dims=:) = _mean(identity, A, dims)
165165

166166
_mean_promote(x::T, y::S) where {T,S} = convert(promote_type(T, S), y)
167167

168-
function _mean(f, A::AbstractArray, dims=:)
168+
# ::Dims is there to force specializing on Colon (as it is a Function)
169+
function _mean(f, A::AbstractArray, dims::Dims=:) where Dims
169170
isempty(A) && return sum(f, A, dims=dims)/0
170171
if dims === (:)
171172
n = length(A)

0 commit comments

Comments
 (0)