diff --git a/tests/testthat/_snaps/misc.md b/tests/testthat/_snaps/misc.md index ae66946c..f14e4982 100644 --- a/tests/testthat/_snaps/misc.md +++ b/tests/testthat/_snaps/misc.md @@ -70,3 +70,13 @@ Error: ! `inclusive` must be a logical vector of length 2, not an integer vector. +# vctrs-helpers-parameters + + Code + dials:::df_size(2) + Condition + Error in `dials:::df_size()`: + ! Cannot get the df size of a non-list. + i This is an internal error that was detected in the dials package. + Please report it at with a reprex () and the full backtrace. + diff --git a/tests/testthat/_snaps/space_filling.md b/tests/testthat/_snaps/space_filling.md index 5a5aabdc..1079463e 100644 --- a/tests/testthat/_snaps/space_filling.md +++ b/tests/testthat/_snaps/space_filling.md @@ -22,6 +22,17 @@ x This argument contains unknowns: `mtry`. i See the `dials::finalize()` function. +--- + + Code + grid_max_entropy(mixture(), levels = 11) + Condition + Warning: + `levels` is not an argument to `grid_max_entropy()`. + i Did you mean `size`? + Error in `parameters()`: + ! The objects should all be objects. + # `grid_latin_hypercube()` is deprecated Code @@ -46,6 +57,17 @@ x This argument contains unknowns: `mtry`. i See the `dials::finalize()` function. +--- + + Code + grid_latin_hypercube(mixture(), levels = 11) + Condition + Warning: + `levels` is not an argument to `grid_latin_hypercube()`. + i Did you mean `size`? + Error in `parameters()`: + ! The objects should all be objects. + # S3 methods for space-filling Code diff --git a/tests/testthat/test-misc.R b/tests/testthat/test-misc.R index d4046e65..e89dad45 100644 --- a/tests/testthat/test-misc.R +++ b/tests/testthat/test-misc.R @@ -53,3 +53,12 @@ test_that("check_inclusive()", { expect_snapshot(error = TRUE, check_inclusive(c(TRUE, NA))) expect_snapshot(error = TRUE, check_inclusive(1:2)) }) + + +test_that("vctrs-helpers-parameters", { + expect_false(dials:::is_parameters(2)) + expect_snapshot( + error = TRUE, + dials:::df_size(2) + ) +}) diff --git a/tests/testthat/test-space_filling.R b/tests/testthat/test-space_filling.R index 511ce560..282352d9 100644 --- a/tests/testthat/test-space_filling.R +++ b/tests/testthat/test-space_filling.R @@ -31,6 +31,15 @@ test_that("max entropy designs", { ) expect_equal(ncol(grid_3), 1L) + grid_4 <- grid_max_entropy( + list(cost = cost(), mix = mixture()), + size = 11, + original = FALSE + ) + expect_equal(nrow(grid_4), 11L) + expect_true(all(grid_4$mix > 0 & grid_4$mix < 1)) + expect_true(all(grid_4$cost > -10 & grid_4$cost < 5)) + expect_snapshot( error = TRUE, grid_max_entropy( @@ -39,6 +48,14 @@ test_that("max entropy designs", { original = FALSE ) ) + + expect_snapshot( + error = TRUE, + grid_max_entropy( + mixture(), + levels = 11 + ) + ) }) test_that("`grid_latin_hypercube()` is deprecated", { @@ -74,6 +91,15 @@ test_that("latin square designs", { ) expect_equal(ncol(grid_3), 1L) + grid_4 <- grid_latin_hypercube( + list(cost = cost(), mix = mixture()), + size = 11, + original = FALSE + ) + expect_equal(nrow(grid_4), 11L) + expect_true(all(grid_4$mix > 0 & grid_4$mix < 1)) + expect_true(all(grid_4$cost > -10 & grid_4$cost < 5)) + expect_lt( nrow(grid_latin_hypercube(prod_degree(), prune_method(), size = 20)), 20 @@ -87,6 +113,14 @@ test_that("latin square designs", { original = FALSE ) ) + + expect_snapshot( + error = TRUE, + grid_latin_hypercube( + mixture(), + levels = 11 + ) + ) })