@@ -9,7 +9,6 @@ age = [23, 23, 14, 23])
9
9
10
10
11
11
@testset " Contrast Encoder Error Handling" begin
12
-
13
12
# Example definitions to allow the test to run
14
13
function dummy_buildmatrix (colname, k)
15
14
# Simple dummy function to generate a matrix of correct size
@@ -23,21 +22,35 @@ age = [23, 23, 14, 23])
23
22
)
24
23
25
24
# Test IGNORE_MUST_FALSE_VEC_MODE error
26
- @test_throws ArgumentError contrast_encoder_fit (data, [:A ], mode= [:contrast ], ignore= true )
25
+ @test_throws MLJTransforms. IGNORE_MUST_FALSE_VEC_MODE begin
26
+ contrast_encoder_fit (data, [:A ], mode= [:contrast ], ignore= true )
27
+ end
27
28
28
29
# Test LENGTH_MISMATCH_VEC_MODE error
29
- @test_throws ArgumentError contrast_encoder_fit (data, [:A ], mode= [:contrast , :dummy ], buildmatrix= dummy_buildmatrix, ignore= false )
30
+ @test_throws MLJTransforms. LENGTH_MISMATCH_VEC_MODE (2 , 1 ) begin
31
+ contrast_encoder_fit (data, [:A ], mode= [:contrast , :dummy ], buildmatrix= dummy_buildmatrix, ignore= false )
32
+ end
30
33
31
34
# Test BUILDFUNC_MUST_BE_SPECIFIED error
32
- @test_throws ArgumentError contrast_encoder_fit (data, [:A ], mode= :contrast , ignore= false )
35
+ @test_throws MLJTransforms. BUILDFUNC_MUST_BE_SPECIFIED begin
36
+ contrast_encoder_fit (data, [:A ], mode= :contrast , ignore= false )
37
+ end
33
38
34
39
# Test MATRIX_SIZE_ERROR
35
40
wrong_buildmatrix = (levels, k) -> randn (k, k) # Incorrect dimensions
36
- @test_throws ArgumentError contrast_encoder_fit (data, [:A ], mode= :contrast , buildmatrix= wrong_buildmatrix, ignore= false )
41
+ k = 3 # Number of levels in data[:A]
42
+ wrong_size = (k, k)
43
+ @test_throws MLJTransforms. MATRIX_SIZE_ERROR (k, wrong_size, :A ) begin
44
+ contrast_encoder_fit (data, [:A ], mode= :contrast , buildmatrix= wrong_buildmatrix, ignore= false )
45
+ end
37
46
38
47
# Test MATRIX_SIZE_ERROR_HYP
39
48
wrong_buildmatrix_hyp = (levels, k) -> randn (k, k+ 1 ) # Incorrect dimensions for hypothesis matrix
40
- @test_throws ArgumentError contrast_encoder_fit (data, [:A ], mode= :hypothesis , buildmatrix= wrong_buildmatrix_hyp, ignore= false )
49
+ wrong_size_hyp = (k, k+ 1 )
50
+ @test_throws MLJTransforms. MATRIX_SIZE_ERROR_HYP (k, wrong_size_hyp, :A ) begin
51
+ contrast_encoder_fit (data, [:A ], mode= :hypothesis , buildmatrix= wrong_buildmatrix_hyp, ignore= false )
52
+ end
53
+
41
54
end
42
55
43
56
@testset " Dummy Coding Tests" begin
0 commit comments