diff --git a/pkg/caret/tests/testthat/test_Dummies.R b/pkg/caret/tests/testthat/test_Dummies.R index 77d608d3..81535a6a 100644 --- a/pkg/caret/tests/testthat/test_Dummies.R +++ b/pkg/caret/tests/testthat/test_Dummies.R @@ -108,9 +108,9 @@ check_dummies <- function(x, expected = NULL) { expect_equal(exp_names, res_names) foosbarsbars <- dummies <- dummyVars(formula = id ~., - data = test_data, - sep = '-', - levelsOnly = TRUE) + data = test_data, + sep = '-', + levelsOnly = TRUE) exp_names_lvls <- paste(1:9) res_names_lvls <- colnames(predict(foosbarsbars, test_data)) @@ -120,10 +120,12 @@ check_dummies <- function(x, expected = NULL) { test_that("Good names for dummies with reocurring patterns", { + set.seed(1) + # 200 all but guarantees (99.999% chance) 1:15 all represented, #1350 data = data.frame( matrix( rep( - as.factor(sample.int(15, size = 100, replace = TRUE, prob = rep(1 / 15, 15)) + as.factor(sample.int(15, size = 200, replace = TRUE, prob = rep(1 / 15, 15)) ), 15 ), @@ -137,4 +139,3 @@ test_that("Good names for dummies with reocurring patterns", { res_names_lvls <- colnames(predict(essai_dummyVars, data)) expect_true(all(exp_names_lvls %in% res_names_lvls)) }) -