Skip to content

Commit

Permalink
Fix reapply output
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Nov 5, 2021
1 parent 4df9cf1 commit 83d2e0a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ----------------
Expand Down
4 changes: 1 addition & 3 deletions src/transforms/eigenanalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions src/transforms/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/sequential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
3 changes: 1 addition & 2 deletions test/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 83d2e0a

Please sign in to comment.