From 7653f2c5f66015b0e9ffedc27e7f58538384332a Mon Sep 17 00:00:00 2001 From: Debartha Paul Date: Wed, 23 Aug 2023 07:20:23 +0530 Subject: [PATCH] Corrections --- src/weights.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/weights.jl b/src/weights.jl index 274213dd..20175ea9 100644 --- a/src/weights.jl +++ b/src/weights.jl @@ -698,13 +698,13 @@ w = rand(n) mean(√, x, weights(w)) ``` """ -mean(f, A::AbstractArray, w::AbstractWeights; kwargs...) = - mean(collect(Iterators.map(f, A)), w; kwargs...) +mean(f, A, w::AbstractWeights; kwargs...) = + mean(broadcast(f, A), w; kwargs...) function mean(f, A::AbstractArray, w::UnitWeights; dims::Union{Colon,Int}=:) a = (dims === :) ? length(A) : size(A, dims) a != length(w) && throw(DimensionMismatch("Inconsistent array dimension.")) - return mean(collect(Iterators.map(f, A)), dims=dims) + return mean(broadcast(f, A), dims=dims) end ##### Weighted quantile #####