Skip to content

Commit 1a22791

Browse files
updated tests
Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
1 parent e90dc4b commit 1a22791

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/rowtransforms.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include("imports.jl")
22

33
@testset ExtendedTestSet "`NormalizeRow`" begin
44
cols = [:col1, :col2, :col3]
5-
item = TabularItem((; zip(cols, [1, "a", 10])...), cols)
5+
item = TabularItem(NamedTuple(zip(cols, [1, "a", 10])), cols)
66
cols_to_normalize = [:col1, :col3]
77
col1_mean, col1_std = 10, 100
88
col3_mean, col3_std = 100, 10
@@ -22,13 +22,12 @@ end
2222
cols_to_fill = [:col1, :col3]
2323
col1_fmval = 1000.
2424
col3_fmval = 1000.
25-
fmdict = Dict()
26-
fmdict[:col1], fmdict[:col3] = col1_fmval, col3_fmval
25+
fmdict = Dict(:col1 => col1_fmval, :col3 => col3_fmval)
2726

2827
tfm1 = FillMissing(fmdict, cols_to_fill)
2928
@test_nowarn apply(tfm1, item)
3029
titem = apply(tfm1, item)
31-
@test titem.data[:col1] == (ismissing(item.data[:col1]) ? col1_fmval : item.data[:col1])
30+
@test titem.data[:col1] == coalesce(item.data[:col1], col1_fmval)
3231
@test titem.data[:col3] == (ismissing(item.data[:col3]) ? col3_fmval : item.data[:col3])
3332
@test ismissing(titem.data[:col2])
3433

@@ -46,11 +45,11 @@ end
4645

4746
categorydict = Dict(:col2 => ["a", "b", "c"], :col3 => ["C", "B", "A"], :col4 => [missing, 10, 20])
4847
tfm = Categorify(categorydict, cols_to_categorify)
49-
@test !any(ismissing.(tfm.dict[:col4]))
48+
@test !any(ismissing, tfm.dict[:col4])
5049
@test_nowarn apply(tfm, item)
5150
testapply(tfm, item)
5251
titem = apply(tfm, item)
5352
@test titem.data[:col2] == 2
5453
@test titem.data[:col3] == 4
5554
@test titem.data[:col4] == 1
56-
end
55+
end

0 commit comments

Comments
 (0)