@@ -141,7 +141,6 @@ function stat_maximum(f::typeof(identity), x::AbstractArray{T,1}; lo=1, hi=lengt
141141 Base. mapreduce_impl (_dmiss, max, x, lo, hi)
142142end
143143function stat_maximum (f:: F , x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {F,T}
144- all (ismissing, view (x, lo: hi)) && return missing
145144 Base. mapreduce_impl (f, _stat_max_fun, x, lo, hi)
146145end
147146stat_maximum (x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {T} = stat_maximum (identity, x; lo= lo, hi= hi)
@@ -166,7 +165,6 @@ function stat_minimum(f::typeof(identity), x::AbstractArray{T,1}; lo=1, hi=lengt
166165 Base. mapreduce_impl (_dmiss, min, x, lo, hi)
167166end
168167function stat_minimum (f:: F , x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {F,T}
169- all (ismissing, view (x, lo: hi)) && return missing
170168 Base. mapreduce_impl (f, _stat_min_fun, x, lo, hi)
171169end
172170stat_minimum (x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {T} = stat_minimum (identity, x; lo= lo, hi= hi)
@@ -180,9 +178,7 @@ stat_findmin(x::AbstractArray{T,1}) where {T} = stat_findmin(identity, x)
180178
181179
182180function stat_sum (f, x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {T<: Union{Missing,INTEGERS,FLOATS} }
183- all (ismissing, view (x, lo: hi)) && return f (first (x))
184- _dmiss (y) = ifelse (ismissing (f (y)), zero (T), f (y))
185- Base. mapreduce_impl (_dmiss, _stat_add_sum, x, lo, hi)
181+ Base. mapreduce_impl (f, _stat_add_sum, x, lo, hi)
186182end
187183stat_sum (x:: AbstractArray{T,1} ; lo= 1 , hi= length (x)) where {T<: Union{Missing,INTEGERS,FLOATS} } = stat_sum (identity, x; lo= lo, hi= hi)
188184
@@ -300,7 +296,7 @@ stat_wmean(x::AbstractVector{T}, w::AbstractArray{S,1}) where {T} where {S} = st
300296_abs2_var_barrier (x,y,f:: F ) where F = abs2 (f (x)- y)
301297_meanval_var_barrier (n, sval):: Union{Missing, Float64} = n == 0 ? missing : sval / n
302298function stat_var (f, x:: AbstractArray{T,1} , dof= true ):: Union{Float64,Missing} where {T<: Union{Missing,INTEGERS,FLOATS} }
303- all (ismissing, x) && return missing
299+ # all(ismissing, x) && return missing
304300 # any(ISNAN, x) && return convert(eltype(x), NaN)
305301 # meanval = stat_mean(f, x)
306302 # n = mapreduce(!ismissing∘f, +, x)
@@ -345,6 +341,7 @@ function stat_median(v::AbstractArray{T,1}) where {T}
345341 end
346342end
347343
344+ # TODO in julia1.9+ partialsort! allocates, and it is not a good idea if we need to call stat_median! many times
348345function stat_median! (v:: AbstractArray{T,1} ) where {T}
349346 isempty (v) && throw (ArgumentError (" median of an empty array is undefined, $(repr (v)) " ))
350347 all (ismissing, v) && return missing
0 commit comments