From d1f1f3ba8c160f3ab0c9f6f6f460baa84170d8d5 Mon Sep 17 00:00:00 2001 From: joshday Date: Fri, 24 Apr 2020 11:12:32 -0400 Subject: [PATCH] cleanup --- src/part.jl | 4 +++- test/test_stats.jl | 12 +++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/part.jl b/src/part.jl index c328e22..a07151c 100644 --- a/src/part.jl +++ b/src/part.jl @@ -1,8 +1,10 @@ #-----------------------------------------------------------------------------# Part struct Part{D, O<:OnlineStat} <: OnlineStat{TwoThings} - stat::O domain::D + stat::O end +Part(stat::OnlineStat, domain) = Part(domain, stat) + value(o::Part) = (domain=o.domain, stat=o.stat) Base.in(x, o::Part) = x ∈ o.domain Base.isless(a::Part, b::Part) = isless(a.domain, b.domain) diff --git a/test/test_stats.jl b/test/test_stats.jl index efb23ce..bd049a1 100644 --- a/test/test_stats.jl +++ b/test/test_stats.jl @@ -81,10 +81,10 @@ println(" > CovMatrix") @test all(x -> ≈(x...), zip(std(o), std(ymat; dims=1))) @test all(x -> ≈(x...), zip(mean(o), mean(ymat; dims=1))) - @test ≈(mergevals(CovMatrix(), O.eachrow(ymat), O.eachrow(ymat2))...) + @test ≈(mergevals(CovMatrix(), eachrow(ymat), eachrow(ymat2))...) @test ≈(mergevals(CovMatrix(), O.eachcol(ymat'), O.eachcol(ymat2'))...) - @test ≈(mergevals(CovMatrix(Complex{Float64}), O.eachrow(ymat * im), O.eachrow(ymat2))...) - @test ≈(mergevals(CovMatrix(Complex{Float64}), O.eachrow(ymat * im), O.eachrow(ymat2 * im))...) + @test ≈(mergevals(CovMatrix(Complex{Float64}), eachrow(ymat * im), eachrow(ymat2))...) + @test ≈(mergevals(CovMatrix(Complex{Float64}), eachrow(ymat * im), eachrow(ymat2 * im))...) end #-----------------------------------------------------------------------# Extrema println(" > Extrema") @@ -122,7 +122,7 @@ end #-----------------------------------------------------------------------# Group println(" > Group") @testset "Group" begin - o = fit!(5Mean(), O.eachrow(ymat)) + o = fit!(5Mean(), eachrow(ymat)) @test o[1] == first(o) @test o[end] == last(o) @test 5Mean() == 5Mean() @@ -134,9 +134,7 @@ println(" > Group") @test length(o2) == 5 a, b = mergevals( - Group(Mean(), Variance(), Sum(), Moments(), Mean()), - O.eachrow(ymat), - O.eachrow(ymat2) + Group(Mean(), Variance(), Sum(), Moments(), Mean()), eachrow(ymat), eachrow(ymat2) ) for (ai, bi) in zip(a, b) @test value(ai) ≈ value(bi)