@@ -37,56 +37,20 @@ test_that("Unsupported interface", {
3737})
3838
3939
40- # Randomness --------------------------------------------------------------
41-
42- test_that(" Setting seed in R works" , {
43- set.seed(13 )
44- rpf_fit1 <- rpf(mpg ~ wt + cyl , data = mtcars )
45- pred1 <- predict(rpf_fit1 , mtcars [1 : 5 , ])
46-
47- set.seed(13 )
48- rpf_fit2 <- rpf(mpg ~ wt + cyl , data = mtcars )
49- pred2 <- predict(rpf_fit2 , mtcars [1 : 5 , ])
50-
51- # No seed set, so should be different
52- rpf_fit3 <- rpf(mpg ~ wt + cyl , data = mtcars )
53- pred3 <- predict(rpf_fit3 , mtcars [1 : 5 , ])
54-
55- expect_equal(pred1 , pred2 )
56- expect_failure(expect_equal(pred1 , pred3 ))
57- })
58-
59- test_that(" Rcpp RNG/R RNG interference" , {
60- set.seed(1 )
61- r11 <- runif(1 )
62- r12 <- runif(1 )
63-
64- set.seed(1 )
65- r21 <- runif(1 )
66- rpf_fit <- rpf(mpg ~ wt + cyl , data = mtcars )
67- r22 <- runif(1 )
68-
69- # If this fails R is broken
70- expect_equal(r11 , r21 )
71- # If this fails Rcpp does not properly affect R's RNG
72- expect_failure(expect_equal(r12 , r22 ))
73- })
74-
75-
7640# Parameter sets/combinations ---------------------------------------------
7741
7842test_that(" Setting max_interaction = 0 works" , {
7943 set.seed(100 )
80- rpf_fit0 <- rpf(mpg ~ . , data = mtcars [1 : 20 ,], max_interaction = 0 )
81- pred0 <- predict(rpf_fit0 , new_data = mtcars [21 : 32 ,])
44+ rpf_fit0 <- rpf(mpg ~ . , data = mtcars [1 : 20 , ], max_interaction = 0 )
45+ pred0 <- predict(rpf_fit0 , new_data = mtcars [21 : 32 , ])
8246
8347 set.seed(100 )
84- rpf_fit10 <- rpf(mpg ~ . , data = mtcars [1 : 20 ,], max_interaction = 10 )
85- pred10 <- predict(rpf_fit10 , new_data = mtcars [21 : 32 ,])
48+ rpf_fit10 <- rpf(mpg ~ . , data = mtcars [1 : 20 , ], max_interaction = 10 )
49+ pred10 <- predict(rpf_fit10 , new_data = mtcars [21 : 32 , ])
8650
8751 set.seed(100 )
88- rpf_fit_default <- rpf(mpg ~ . , data = mtcars [1 : 20 ,])
89- pred_default <- predict(rpf_fit_default , new_data = mtcars [21 : 32 ,])
52+ rpf_fit_default <- rpf(mpg ~ . , data = mtcars [1 : 20 , ])
53+ pred_default <- predict(rpf_fit_default , new_data = mtcars [21 : 32 , ])
9054
9155 # Sanity: pred of default (max_interaction = 1) should be different
9256 expect_failure(expect_equal(pred_default , pred0 ))
0 commit comments