We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e812e7d commit 2108ae0Copy full SHA for 2108ae0
src/InMemoryDatasets.jl
@@ -85,8 +85,6 @@ export
85
# from stat
86
stdze,
87
rescale,
88
- wsum,
89
- wmean,
90
topk,
91
cummax,
92
cummax!,
src/stat/non_hp_stat.jl
@@ -197,11 +197,11 @@ stat_mean(x::AbstractArray{T,1}) where T = stat_mean(identity, x)
197
198
function stat_wmean(f, x::AbstractVector{T}, w::AbstractArray{S,1}) where T where S
199
all(ismissing, x) && return missing
200
- _dmiss(y)::T = ismissing(y[1])||ismissing(y[2]) ? zero(T) : (f(y[1])*y[2])::T
201
- _dmiss2(y)::S = ismissing(y[1])||ismissing(y[2]) ? zero(S) : y[2]
202
- _op(y1,y2)::Tuple{T,S} = _stat_add_sum.(y1, y2)
203
- _f(y)::Tuple{T,S} = (_dmiss(y), _dmiss2(y))
204
- sval, n = mapreduce(_f, _op, zip(x,w))::Tuple{T,S}
+ _dmiss(y) = ismissing(y[1])||ismissing(y[2]) ? zero(T) : (f(y[1])*y[2])
+ _dmiss2(y) = ismissing(y[1])||ismissing(y[2]) ? zero(S) : y[2]
+ _op(y1,y2) = _stat_add_sum.(y1, y2)
+ _f(y) = (_dmiss(y), _dmiss2(y))
+ sval, n = mapreduce(_f, _op, zip(x,w))
205
n == 0 ? missing : sval / n
206
end
207
stat_wmean(x::AbstractVector{T}, w::AbstractArray{S,1}) where T where S = stat_wmean(identity, x, w)
0 commit comments