@@ -9,7 +9,6 @@ include("imports.jl")
99 normdict = Dict (:col1 => (col1_mean, col1_std), :col3 => (col3_mean, col3_std))
1010
1111 tfm = NormalizeRow (normdict, cols_to_normalize)
12- # @test_nowarn apply(tfm, item)
1312 testapply (tfm, item)
1413 titem = apply (tfm, item)
1514 @test titem. data[:col1 ] == (item. data[:col1 ] - col1_mean)/ col1_std
1817
1918@testset ExtendedTestSet " `FillMissing`" begin
2019 cols = [:col1 , :col2 , :col3 ]
21- item = TabularItem ((; zip (cols, [1 , missing , missing ])... ), cols)
20+ item = TabularItem (NamedTuple ( zip (cols, [1 , missing , missing ])), cols)
2221 cols_to_fill = [:col1 , :col3 ]
2322 col1_fmval = 1000.
23+ col2_fmval = " d"
2424 col3_fmval = 1000.
25- fmdict = Dict (:col1 => col1_fmval, :col3 => col3_fmval)
25+ fmdict = Dict (:col1 => col1_fmval, :col2 => col2_fmval, : col3 => col3_fmval)
2626
2727 tfm1 = FillMissing (fmdict, cols_to_fill)
2828 @test_nowarn apply (tfm1, item)
2929 titem = apply (tfm1, item)
3030 @test titem. data[:col1 ] == coalesce (item. data[:col1 ], col1_fmval)
31- @test titem. data[:col3 ] == ( ismissing ( item. data[:col3 ]) ? col3_fmval : item . data[ :col3 ] )
31+ @test titem. data[:col3 ] == coalesce ( item. data[:col3 ], col3_fmval)
3232 @test ismissing (titem. data[:col2 ])
3333
34- fmdict[ :col2 ] = " d "
35- tfm2 = FillMissing (fmdict, [ :col1 , :col2 , :col3 ] )
34+ push! (cols_to_fill, :col2 )
35+ tfm2 = FillMissing (fmdict, cols_to_fill )
3636 testapply (tfm2, item)
3737 titem2 = apply (tfm2, item)
38- @test titem2. data[:col2 ] == ( ismissing ( item. data[:col2 ]) ? " d" : item . data[ :col2 ] )
38+ @test titem2. data[:col2 ] == coalesce ( item. data[:col2 ], " d" )
3939end
4040
4141@testset ExtendedTestSet " `Categorify`" begin
4242 cols = [:col1 , :col2 , :col3 , :col4 ]
43- item = TabularItem ((; zip (cols, [1 , " a" , " A" , missing ])... ), cols)
43+ item = TabularItem (NamedTuple ( zip (cols, [1 , " a" , " A" , missing ])), cols)
4444 cols_to_categorify = [:col2 , :col3 , :col4 ]
4545
4646 categorydict = Dict (:col2 => [" a" , " b" , " c" ], :col3 => [" C" , " B" , " A" ], :col4 => [missing , 10 , 20 ])
0 commit comments