Skip to content

Commit

Permalink
expect_warning() -> expect_snapshot()
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Oct 24, 2024
1 parent 29d15f5 commit f163645
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
30 changes: 29 additions & 1 deletion tests/testthat/_snaps/lightgbm.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
bill_length_mm ~ ., data = penguins)
Condition
Warning:
The following arguments cannot be manually modified and were removed: feature_fraction_bynode.
The argument `feature_fraction_bynode` cannot be manually modified and was removed.
Error:
! The supplied argument `mtry = 0.5` must be greater than or equal to 1.
Expand All @@ -65,6 +65,34 @@

# training wrapper warns on protected arguments

Code
.res <- boost_tree() %>% set_engine("lightgbm", colnames = paste0("X", 1:ncol(
penguins))) %>% set_mode("regression") %>% fit(bill_length_mm ~ ., data = penguins)
Condition
Warning:
The following argument(s) are guarded by bonsai and will not be passed to LightGBM: colnames

---

Code
.res <- boost_tree() %>% set_engine("lightgbm", colnames = paste0("X", 1:ncol(
penguins)), callbacks = list(p = print)) %>% set_mode("regression") %>% fit(
bill_length_mm ~ ., data = penguins)
Condition
Warning:
The following argument(s) are guarded by bonsai and will not be passed to LightGBM: colnames, callbacks

---

Code
.res <- boost_tree() %>% set_engine("lightgbm", colnames = paste0("X", 1:ncol(
penguins))) %>% set_mode("regression") %>% fit(bill_length_mm ~ ., data = penguins)
Condition
Warning:
The following argument(s) are guarded by bonsai and will not be passed to LightGBM: colnames

---

Code
boost_tree() %>% set_engine("lightgbm", n_iter = 10) %>% set_mode("regression") %>%
fit(bill_length_mm ~ ., data = penguins)
Expand Down
22 changes: 10 additions & 12 deletions tests/testthat/test-lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -515,35 +515,33 @@ test_that("training wrapper warns on protected arguments", {

penguins <- penguins[complete.cases(penguins),]

expect_warning(
boost_tree() %>%
expect_snapshot(
.res <- boost_tree() %>%
set_engine("lightgbm", colnames = paste0("X", 1:ncol(penguins))) %>%
set_mode("regression") %>%
fit(bill_length_mm ~ ., data = penguins),
"guarded by bonsai.*colnames"
fit(bill_length_mm ~ ., data = penguins)
)

expect_warning(
boost_tree() %>%
expect_snapshot(
.res <- boost_tree() %>%
set_engine(
"lightgbm",
colnames = paste0("X", 1:ncol(penguins)),
callbacks = list(p = print)
) %>%
set_mode("regression") %>%
fit(bill_length_mm ~ ., data = penguins),
"guarded by bonsai.*colnames, callbacks"
fit(bill_length_mm ~ ., data = penguins)
)

expect_warning(
boost_tree() %>%
expect_snapshot(
.res <-
boost_tree() %>%
set_engine(
"lightgbm",
colnames = paste0("X", 1:ncol(penguins))
) %>%
set_mode("regression") %>%
fit(bill_length_mm ~ ., data = penguins),
"guarded by bonsai.*colnames"
fit(bill_length_mm ~ ., data = penguins)
)

expect_snapshot(
Expand Down

0 comments on commit f163645

Please sign in to comment.