From 49c7a0762516f09e09d5282eda0ef85d793b8c0f Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Thu, 9 Jun 2016 20:13:33 -0400 Subject: [PATCH 1/2] Delete varzm now that it has been deleted from Base. There doesn't seem to be a time penalty for using varm with m=0. --- src/moments.jl | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/moments.jl b/src/moments.jl index aa593571e803bc..057f38c4ed4ea1 100644 --- a/src/moments.jl +++ b/src/moments.jl @@ -2,36 +2,23 @@ ## var -function Base.varzm(v::RealArray, wv::WeightVec) - n = length(v) - length(wv) == n || throw(DimensionMismatch("Inconsistent array lengths.")) - w = values(wv) - s = 0.0 - for i = 1:n - @inbounds s += w[i] * abs2(v[i]) - end - return s / sum(wv) -end - Base.varm(v::RealArray, wv::WeightVec, m::Real) = _moment2(v, wv, m) function Base.var(v::RealArray, wv::WeightVec; mean=nothing) - mean == 0 ? Base.varzm(v, wv) : + mean == 0 ? Base.varm(v, wv, 0) : mean == nothing ? varm(v, wv, Base.mean(v, wv)) : varm(v, wv, mean) end ## var along dim -Base.varzm!(R::AbstractArray, A::RealArray, wv::WeightVec, dim::Int) = - scale!(_wsum_general!(R, @functorize(abs2), A, values(wv), dim, true), inv(sum(wv))) - Base.varm!(R::AbstractArray, A::RealArray, wv::WeightVec, M::RealArray, dim::Int) = scale!(_wsum_centralize!(R, @functorize(abs2), A, values(wv), M, dim, true), inv(sum(wv))) function var!(R::AbstractArray, A::RealArray, wv::WeightVec, dim::Int; mean=nothing) if mean == 0 - Base.varzm!(R, A, wv, dim) + Base.varm!(R, A, wv, + Base.reducedim_initarray(A, dim, 0, eltype(R)), dim) elseif mean == nothing Base.varm!(R, A, wv, Base.mean(A, wv, dim), dim) else From c56727c57df2b00a09a3ed6eccc116ebbad351ef Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Thu, 9 Jun 2016 20:17:55 -0400 Subject: [PATCH 2/2] Temporarily comment out statquiz.jl since it depends on DataArrays which is broken until varzm has been fixed/deleted. --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index aa598974be0698..6d593c1f8d9499 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,8 +14,8 @@ tests = ["weights", "misc", "sampling", "wsampling", - "statmodels", - "statquiz"] + "statmodels"] + # ,"statquiz"] println("Running tests:")