Skip to content

Commit d6b00a2

Browse files
authored
Merge pull request #305 from FluxML/add-types-test-embedder
Add a test on the consistency of types before and after encoding.
2 parents 22c2e33 + c7735ce commit d6b00a2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/encoders.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Column3 = categorical(["b", "c", "d"]),
88
Column4 = [1.0, 2.0, 3.0, 4.0, 5.0],
99
)
10+
# Test Encoding Functionality
1011
map = MLJFlux.ordinal_encoder_fit(X; featinds = [2, 3])
1112
Xenc = MLJFlux.ordinal_encoder_transform(X, map)
1213
@test map[2] == Dict('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5)
@@ -21,6 +22,16 @@
2122
@test !haskey(map, 1) # already encoded
2223

2324
@test Xenc == MLJFlux.ordinal_encoder_fit_transform(X; featinds = [2, 3])[1]
25+
26+
# Test Consistency with Types
27+
scs = schema(Xenc).scitypes
28+
ts = schema(Xenc).types
29+
30+
# 1) all scitypes must be exactly Continuous
31+
@test all(scs .== Continuous)
32+
33+
# 2) all types must be a concrete subtype of AbstractFloat (i.e. <: AbstractFloat, but ≠ AbstractFloat itself)
34+
@test all(t -> t <: AbstractFloat && isconcretetype(t), ts)
2435
end
2536

2637
@testset "Generate New feature names Function Tests" begin

0 commit comments

Comments
 (0)