Skip to content

Commit

Permalink
more missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Oct 30, 2024
1 parent bf4e1cf commit 9dff29b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/tidymodels/dials/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.

22 changes: 22 additions & 0 deletions tests/testthat/_snaps/space_filling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <param> objects.

# `grid_latin_hypercube()` is deprecated

Code
Expand All @@ -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 <param> objects.

# S3 methods for space-filling

Code
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
})
34 changes: 34 additions & 0 deletions tests/testthat/test-space_filling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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", {
Expand Down Expand Up @@ -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
Expand All @@ -87,6 +113,14 @@ test_that("latin square designs", {
original = FALSE
)
)

expect_snapshot(
error = TRUE,
grid_latin_hypercube(
mixture(),
levels = 11
)
)
})


Expand Down

0 comments on commit 9dff29b

Please sign in to comment.