@@ -3,7 +3,7 @@ test_that("rsample objects", {
3
3
obj_loo <- rsample :: loo_cv(mtcars )
4
4
obj_nst <- rsample :: nested_cv(mtcars , obj_cv , inside = rsample :: bootstraps())
5
5
obj_permut <- rsample :: permutations(mtcars , hp )
6
- expect_error (tune ::: check_rset(obj_cv ), regexp = NA )
6
+ expect_no_error (tune ::: check_rset(obj_cv ))
7
7
expect_snapshot(error = TRUE , tune ::: check_rset(obj_loo ))
8
8
expect_snapshot(error = TRUE , tune ::: check_rset(obj_nst ))
9
9
expect_snapshot(error = TRUE , tune ::: check_rset(obj_permut ))
@@ -69,7 +69,7 @@ test_that("grid objects", {
69
69
add_model(svm_mod ) %> %
70
70
add_recipe(bare_rec )
71
71
72
- expect_error (grid_2 <- tune ::: check_grid(6 , wflow_1 ), NA )
72
+ expect_no_error (grid_2 <- tune ::: check_grid(6 , wflow_1 ))
73
73
expect_equal(nrow(grid_2 ), 6 )
74
74
expect_true(inherits(grid_2 , " data.frame" ))
75
75
@@ -226,17 +226,15 @@ test_that("workflow objects (will not tune, tidymodels/tune#548)", {
226
226
lr_glmnet_2 <- lr_lm_2 %> % parsnip :: set_engine(" glmnet" )
227
227
228
228
# don't error when supplied tune args make sense given engine / steps
229
- expect_error_na <- function (x ) {testthat :: expect_error(x , regexp = NA )}
229
+ expect_no_error(check_workflow(workflow(rec_bare , lr_lm_0 )))
230
+ expect_no_error(check_workflow(workflow(rec_bare , lr_glmnet_0 )))
231
+ expect_no_error(check_workflow(workflow(rec_bare , lr_glmnet_1 )))
232
+ expect_no_error(check_workflow(workflow(rec_bare , lr_glmnet_2 )))
230
233
231
- expect_error_na(check_workflow(workflow(rec_bare , lr_lm_0 )))
232
- expect_error_na(check_workflow(workflow(rec_bare , lr_glmnet_0 )))
233
- expect_error_na(check_workflow(workflow(rec_bare , lr_glmnet_1 )))
234
- expect_error_na(check_workflow(workflow(rec_bare , lr_glmnet_2 )))
235
-
236
- expect_error_na(check_workflow(workflow(rec_tune , lr_lm_0 )))
237
- expect_error_na(check_workflow(workflow(rec_tune , lr_glmnet_0 )))
238
- expect_error_na(check_workflow(workflow(rec_tune , lr_glmnet_1 )))
239
- expect_error_na(check_workflow(workflow(rec_tune , lr_glmnet_2 )))
234
+ expect_no_error(check_workflow(workflow(rec_tune , lr_lm_0 )))
235
+ expect_no_error(check_workflow(workflow(rec_tune , lr_glmnet_0 )))
236
+ expect_no_error(check_workflow(workflow(rec_tune , lr_glmnet_1 )))
237
+ expect_no_error(check_workflow(workflow(rec_tune , lr_glmnet_2 )))
240
238
241
239
# error when supplied tune args don't make sense given engine / steps
242
240
expect_error_nt <- function (x ) {testthat :: expect_error(x , class = " not_tunable_error" )}
@@ -321,7 +319,7 @@ test_that("metrics must match the parsnip engine", {
321
319
# ------------------------------------------------------------------------------
322
320
323
321
test_that(" grid control objects" , {
324
- expect_error (control_grid(), NA )
322
+ expect_no_error (control_grid())
325
323
expect_snapshot(error = TRUE , control_grid(tomato = 1 ))
326
324
expect_snapshot(error = TRUE , control_grid(verbose = 1 ))
327
325
expect_snapshot(error = TRUE , control_grid(verbose = rep(TRUE , 2 )))
@@ -330,18 +328,18 @@ test_that("grid control objects", {
330
328
expect_snapshot(error = TRUE , control_grid(extract = Inf ))
331
329
expect_snapshot(error = TRUE , control_grid(pkgs = Inf ))
332
330
333
- expect_error (control_grid(verbose = TRUE ), NA )
334
- expect_error (control_grid(allow_par = FALSE ), NA )
335
- expect_error (control_grid(save_pred = TRUE ), NA )
336
- expect_error (control_grid(extract = NULL ), NA )
337
- expect_error (control_grid(extract = I ), NA )
338
- expect_error (control_grid(pkgs = NULL ), NA )
339
- expect_error (control_grid(pkgs = letters ), NA )
331
+ expect_no_error (control_grid(verbose = TRUE ))
332
+ expect_no_error (control_grid(allow_par = FALSE ))
333
+ expect_no_error (control_grid(save_pred = TRUE ))
334
+ expect_no_error (control_grid(extract = NULL ))
335
+ expect_no_error (control_grid(extract = I ))
336
+ expect_no_error (control_grid(pkgs = NULL ))
337
+ expect_no_error (control_grid(pkgs = letters ))
340
338
expect_s3_class(control_grid(), c(" control_grid" , " control_resamples" ))
341
339
})
342
340
343
341
test_that(" Bayes control objects" , {
344
- expect_error (control_bayes(), NA )
342
+ expect_no_error (control_bayes())
345
343
expect_snapshot(error = TRUE , control_bayes(tomato = 1 ))
346
344
expect_snapshot(error = TRUE , control_bayes(verbose = 1 ))
347
345
expect_snapshot(error = TRUE , control_bayes(verbose = rep(TRUE , 2 )))
@@ -357,15 +355,15 @@ test_that("Bayes control objects", {
357
355
tmp <- control_bayes(no_improve = 2 , uncertain = 5 )
358
356
)
359
357
360
- expect_error (control_bayes(verbose = TRUE ), NA )
361
- expect_error (control_bayes(no_improve = 2 ), NA )
362
- expect_error (control_bayes(uncertain = 2 ), NA )
363
- expect_error (control_bayes(save_pred = TRUE ), NA )
364
- expect_error (control_bayes(extract = NULL ), NA )
365
- expect_error (control_bayes(extract = I ), NA )
366
- expect_error (control_bayes(pkgs = NULL ), NA )
367
- expect_error (control_bayes(pkgs = letters ), NA )
368
- expect_error (control_bayes(time_limit = 2 ), NA )
358
+ expect_no_error (control_bayes(verbose = TRUE ))
359
+ expect_no_error (control_bayes(no_improve = 2 ))
360
+ expect_no_error (control_bayes(uncertain = 2 ))
361
+ expect_no_error (control_bayes(save_pred = TRUE ))
362
+ expect_no_error (control_bayes(extract = NULL ))
363
+ expect_no_error (control_bayes(extract = I ))
364
+ expect_no_error (control_bayes(pkgs = NULL ))
365
+ expect_no_error (control_bayes(pkgs = letters ))
366
+ expect_no_error (control_bayes(time_limit = 2 ))
369
367
expect_s3_class(control_bayes(), " control_bayes" )
370
368
})
371
369
@@ -448,16 +446,14 @@ test_that("check parameter finalization", {
448
446
add_model(rf1 )
449
447
450
448
expect_snapshot(
451
- expect_error(
452
- p1 <- tune ::: check_parameters(w1 , data = mtcars , grid_names = character (0 )),
453
- regex = NA
449
+ expect_no_error(
450
+ p1 <- tune ::: check_parameters(w1 , data = mtcars , grid_names = character (0 ))
454
451
)
455
452
)
456
453
expect_false(any(dials :: has_unknowns(p1 $ object )))
457
454
458
- expect_error(
459
- p1 <- tune ::: check_parameters(w1 , data = mtcars , grid_names = " mtry" ),
460
- regex = NA
455
+ expect_no_error(
456
+ p1 <- tune ::: check_parameters(w1 , data = mtcars , grid_names = " mtry" )
461
457
)
462
458
463
459
w2 <-
@@ -466,9 +462,8 @@ test_that("check parameter finalization", {
466
462
add_model(rf1 )
467
463
468
464
expect_snapshot(
469
- expect_error(
470
- p2 <- tune ::: check_parameters(w2 , data = mtcars ),
471
- regex = NA
465
+ expect_no_error(
466
+ p2 <- tune ::: check_parameters(w2 , data = mtcars )
472
467
)
473
468
)
474
469
expect_false(any(dials :: has_unknowns(p2 $ object )))
@@ -480,9 +475,8 @@ test_that("check parameter finalization", {
480
475
p3 <- extract_parameter_set_dials(w3 )
481
476
482
477
expect_snapshot(
483
- expect_error(
484
- p3_a <- tune ::: check_parameters(w3 , data = mtcars ),
485
- regex = NA
478
+ expect_no_error(
479
+ p3_a <- tune ::: check_parameters(w3 , data = mtcars )
486
480
)
487
481
)
488
482
expect_false(any(dials :: has_unknowns(p3_a $ object )))
@@ -500,9 +494,8 @@ test_that("check parameter finalization", {
500
494
extract_parameter_set_dials(w4 ) %> %
501
495
update(mtry = dials :: mtry(c(1 , 10 )))
502
496
503
- expect_error(
504
- p4_b <- tune ::: check_parameters(w4 , p4_a , data = mtcars ),
505
- regex = NA
497
+ expect_no_error(
498
+ p4_b <- tune ::: check_parameters(w4 , p4_a , data = mtcars )
506
499
)
507
500
expect_true(inherits(p4_b , " parameters" ))
508
501
@@ -511,9 +504,8 @@ test_that("check parameter finalization", {
511
504
add_recipe(rec_tune ) %> %
512
505
add_model(lm1 )
513
506
514
- expect_error(
515
- p5 <- tune ::: check_parameters(w5 , data = mtcars ),
516
- regex = NA
507
+ expect_no_error(
508
+ p5 <- tune ::: check_parameters(w5 , data = mtcars )
517
509
)
518
510
expect_true(inherits(p5 , " parameters" ))
519
511
})
0 commit comments