From 0dc235c1a5a093f2ba66c32e922f4a7079182785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20S=2E=20Silva?= Date: Fri, 29 Oct 2021 15:49:04 -0300 Subject: [PATCH 1/3] add a few tests --- test/transforms.jl | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/transforms.jl b/test/transforms.jl index 6883cf22..e4c3a830 100644 --- a/test/transforms.jl +++ b/test/transforms.jl @@ -223,10 +223,47 @@ end @testset "Sequential" begin - # TODO + x = rand(Normal(0,10), 1500) + y = x + rand(Normal(0,2), 1500) + z = y + rand(Normal(0,5), 1500) + t = Table(; x, y, z) + S = Scale(low=0.2, high=0.8) → EigenAnalysis(:VDV) + n, c = apply(S, t) + tₒ = revert(S, n, c) + @test Tables.matrix(t) ≈ Tables.matrix(tₒ) + + x = rand(Normal(0,10), 1500) + y = x + rand(Normal(0,2), 1500) + z = y + rand(Normal(0,5), 1500) + t = Table(; x, y, z) + S = Select(:x, :z) → ZScore() → EigenAnalysis(:V) → Scale(low=0, high=1) + n, c = apply(S, t) + tₒ = revert(S, n, c) + @test Tables.matrix(t) ≈ Tables.matrix(tₒ) end @testset "Parallel" begin - # TODO + x = rand(Normal(0,10), 1500) + y = x + rand(Normal(0,2), 1500) + z = y + rand(Normal(0,5), 1500) + t = Table(; x, y, z) + S = Scale(low=0.3, high=0.6) ∥ EigenAnalysis(:VDV) + n, c = apply(S, t) + tₒ = revert(S, n, c) + @test Tables.matrix(t) ≈ Tables.matrix(tₒ) + + # distributivity with respect to Sequential + x = rand(Normal(0,10), 1500) + y = x + rand(Normal(0,2), 1500) + z = y + rand(Normal(0,5), 1500) + t = Table(; x, y, z) + T₁ = Center() + T₂ = Scale(low=0.2, high=0.8) + T₃ = EigenAnalysis(:VD) + S₁ = T₁ → (T₂ ∥ T₃) + S₂ = (T₁ → T₂) ∥ (T₁ →T₃) + n₁, c₁ = apply(S₁, t) + n₂, c₂ = apply(S₂, t) + @test Tables.matrix(n₂) ≈ Tables.matrix(n₂) end end \ No newline at end of file From f2a1903e0fa2139182fd9d72ebc74172200d8f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20S=2E=20Silva?= Date: Fri, 29 Oct 2021 15:54:55 -0300 Subject: [PATCH 2/3] wrong index used --- test/transforms.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/transforms.jl b/test/transforms.jl index e4c3a830..b05b0539 100644 --- a/test/transforms.jl +++ b/test/transforms.jl @@ -264,6 +264,6 @@ S₂ = (T₁ → T₂) ∥ (T₁ →T₃) n₁, c₁ = apply(S₁, t) n₂, c₂ = apply(S₂, t) - @test Tables.matrix(n₂) ≈ Tables.matrix(n₂) + @test Tables.matrix(n₁) ≈ Tables.matrix(n₂) end end \ No newline at end of file From e4c0ad3f808220709989df466471d09eb64a0406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20S=2E=20Silva?= Date: Fri, 29 Oct 2021 16:48:14 -0300 Subject: [PATCH 3/3] change var names and add one more test to parallel --- test/transforms.jl | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/test/transforms.jl b/test/transforms.jl index b05b0539..97bb823a 100644 --- a/test/transforms.jl +++ b/test/transforms.jl @@ -227,18 +227,18 @@ y = x + rand(Normal(0,2), 1500) z = y + rand(Normal(0,5), 1500) t = Table(; x, y, z) - S = Scale(low=0.2, high=0.8) → EigenAnalysis(:VDV) - n, c = apply(S, t) - tₒ = revert(S, n, c) + T = Scale(low=0.2, high=0.8) → EigenAnalysis(:VDV) + n, c = apply(T, t) + tₒ = revert(T, n, c) @test Tables.matrix(t) ≈ Tables.matrix(tₒ) x = rand(Normal(0,10), 1500) y = x + rand(Normal(0,2), 1500) z = y + rand(Normal(0,5), 1500) t = Table(; x, y, z) - S = Select(:x, :z) → ZScore() → EigenAnalysis(:V) → Scale(low=0, high=1) - n, c = apply(S, t) - tₒ = revert(S, n, c) + T = Select(:x, :z) → ZScore() → EigenAnalysis(:V) → Scale(low=0, high=1) + n, c = apply(T, t) + tₒ = revert(T, n, c) @test Tables.matrix(t) ≈ Tables.matrix(tₒ) end @@ -247,11 +247,20 @@ y = x + rand(Normal(0,2), 1500) z = y + rand(Normal(0,5), 1500) t = Table(; x, y, z) - S = Scale(low=0.3, high=0.6) ∥ EigenAnalysis(:VDV) - n, c = apply(S, t) - tₒ = revert(S, n, c) + T = Scale(low=0.3, high=0.6) ∥ EigenAnalysis(:VDV) + n, c = apply(T, t) + tₒ = revert(T, n, c) @test Tables.matrix(t) ≈ Tables.matrix(tₒ) + # check cardinality of Parallel + x = rand(Normal(0,10), 1500) + y = x + rand(Normal(0,2), 1500) + z = y + rand(Normal(0,5), 1500) + t = Table(; x, y, z) + T = ZScore() ∥ EigenAnalysis(:V) + n = T(t) + @test length(Tables.columnnames(n)) == 6 + # distributivity with respect to Sequential x = rand(Normal(0,10), 1500) y = x + rand(Normal(0,2), 1500) @@ -260,10 +269,10 @@ T₁ = Center() T₂ = Scale(low=0.2, high=0.8) T₃ = EigenAnalysis(:VD) - S₁ = T₁ → (T₂ ∥ T₃) - S₂ = (T₁ → T₂) ∥ (T₁ →T₃) - n₁, c₁ = apply(S₁, t) - n₂, c₂ = apply(S₂, t) + P₁ = T₁ → (T₂ ∥ T₃) + P₂ = (T₁ → T₂) ∥ (T₁ →T₃) + n₁ = P₁(t) + n₂ = P₂(t) @test Tables.matrix(n₁) ≈ Tables.matrix(n₂) end end \ No newline at end of file