From 83d2e0a6dc09efeb723b276c6766f93ca10eb57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Fri, 5 Nov 2021 18:12:25 -0300 Subject: [PATCH] Fix reapply output --- src/transforms.jl | 5 +---- src/transforms/eigenanalysis.jl | 4 +--- src/transforms/parallel.jl | 10 ++++------ src/transforms/sequential.jl | 2 +- test/transforms.jl | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/transforms.jl b/src/transforms.jl index d00e2bb0..be69e364 100644 --- a/src/transforms.jl +++ b/src/transforms.jl @@ -204,10 +204,7 @@ function reapply(transform::Colwise, table, cache) vals = tcollect(colfunc(i) for i in 1:length(names)) # new table with transformed columns - newtable = (; vals...) |> Tables.materializer(table) - - # return new table and cache - newtable, cache + (; vals...) |> Tables.materializer(table) end # ---------------- diff --git a/src/transforms/eigenanalysis.jl b/src/transforms/eigenanalysis.jl index 73a756ca..4d761986 100644 --- a/src/transforms/eigenanalysis.jl +++ b/src/transforms/eigenanalysis.jl @@ -111,9 +111,7 @@ function reapply(transform::EigenAnalysis, table, cache) # table with transformed columns 𝒯 = (; zip(names, eachcol(Z))...) - newtable = 𝒯 |> Tables.materializer(table) - - newtable, cache + 𝒯 |> Tables.materializer(table) end function eigenmatrices(transform, Y) diff --git a/src/transforms/parallel.jl b/src/transforms/parallel.jl index 464a2824..5cfca2dd 100644 --- a/src/transforms/parallel.jl +++ b/src/transforms/parallel.jl @@ -78,14 +78,12 @@ function reapply(p::Parallel, table, cache) caches = cache[2] # reapply transforms in parallel - f(t, c) = reapply(t, table, c) |> first - itr = zip(p.transforms, caches) - tables = tcollect(f(t, c) for (t, c) in itr) + f(t, c) = reapply(t, table, c) + itr = zip(p.transforms, caches) + tables = tcollect(f(t, c) for (t, c) in itr) # table with concatenated columns - newtable = tablehcat(tables) - - newtable, cache + tablehcat(tables) end function tablehcat(tables) diff --git a/src/transforms/sequential.jl b/src/transforms/sequential.jl index 68bfdec4..435d8b12 100644 --- a/src/transforms/sequential.jl +++ b/src/transforms/sequential.jl @@ -42,7 +42,7 @@ function reapply(s::Sequential, table, cache) for (ctransform, ccache) in zip(s.transforms, cache) current, _ = reapply(ctransform, current, ccache) end - current, cache + current end """ diff --git a/test/transforms.jl b/test/transforms.jl index 4ccc6ede..6dce3e5e 100644 --- a/test/transforms.jl +++ b/test/transforms.jl @@ -411,8 +411,7 @@ t = Table(x=rand(1000)) T = ZScore() ⊔ Quantile() n1, c1 = apply(T, t) - n2, c2 = reapply(T, t, c1) + n2 = reapply(T, t, c1) @test n1 == n2 - @test c1 == c2 end end \ No newline at end of file