Skip to content

Commit 88f81cf

Browse files
committed
Fix reapply for Stateless
1 parent 654a7d0 commit 88f81cf

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/transforms.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ isrevertible(::Type{<:Transform}) = false
117117
# STATELESS FALLBACKS
118118
# --------------------
119119

120-
reapply(transform::Stateless, table, cache) = apply(transform, table)
120+
reapply(transform::Stateless, table, cache) = apply(transform, table) |> first
121121

122122
# ------------------
123123
# COLWISE FALLBACKS

test/transforms.jl

+26-14
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
@test (Select(:a) == Select("a") ==
5858
Select((:a,)) == Select(("a",)) ==
5959
Select([:a]) == Select(["a"]))
60+
61+
# reapply test
62+
T = Select(:b, :c, :d)
63+
n1, c1 = apply(T, t)
64+
n2 = reapply(T, t, c1)
65+
@test n1 == n2
6066
end
6167

6268
@testset "Reject" begin
@@ -117,6 +123,12 @@
117123
@test (Reject(:a) == Reject("a") ==
118124
Reject((:a,)) == Reject(("a",)) ==
119125
Reject([:a]) == Reject(["a"]))
126+
127+
# reapply test
128+
T = Reject(:b, :c, :d)
129+
n1, c1 = apply(T, t)
130+
n2 = reapply(T, t, c1)
131+
@test n1 == n2
120132
end
121133

122134
@testset "Identity" begin
@@ -360,6 +372,13 @@
360372
n, c = apply(T, t)
361373
tₒ = revert(T, n, c)
362374
@test Tables.matrix(t) Tables.matrix(tₒ)
375+
376+
# reapply with Sequential transform
377+
t = Table(x=rand(1000))
378+
T = ZScore() Quantile()
379+
n1, c1 = apply(T, t)
380+
n2 = reapply(T, t, c1)
381+
@test n1 == n2
363382
end
364383

365384
@testset "Parallel" begin
@@ -394,6 +413,13 @@
394413
n₁ = P₁(t)
395414
n₂ = P₂(t)
396415
@test Tables.matrix(n₁) Tables.matrix(n₂)
416+
417+
# reapply with Parallel transform
418+
t = Table(x=rand(1000))
419+
T = ZScore() Quantile()
420+
n1, c1 = apply(T, t)
421+
n2 = reapply(T, t, c1)
422+
@test n1 == n2
397423
end
398424

399425
@testset "Miscellaneous" begin
@@ -406,19 +432,5 @@
406432
@test isapprox(std(n.x), 1.0, atol=1e-8)
407433
@test isapprox(mean(r.x), mean(t.x), atol=1e-8)
408434
@test isapprox(std(r.x), std(t.x), atol=1e-8)
409-
410-
# reapply with Sequential transform
411-
t = Table(x=rand(1000))
412-
T = ZScore() Quantile()
413-
n1, c1 = apply(T, t)
414-
n2 = reapply(T, t, c1)
415-
@test n1 == n2
416-
417-
# reapply with Parallel transform
418-
t = Table(x=rand(1000))
419-
T = ZScore() Quantile()
420-
n1, c1 = apply(T, t)
421-
n2 = reapply(T, t, c1)
422-
@test n1 == n2
423435
end
424436
end

0 commit comments

Comments
 (0)