Skip to content

Commit

Permalink
update snaps with parsnip cli error formatting (#219)
Browse files Browse the repository at this point in the history
* update snaps with parsnip cli error formatting
* bump minimum parsnip version
  • Loading branch information
simonpcouch authored Aug 26, 2024
1 parent d575e4e commit 1e9b262
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 25 deletions.
11 changes: 6 additions & 5 deletions tests/testthat/_snaps/glmnet-linear.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
-(1:4), ]) %>% predict(mtcars[-(1:4), ], penalty = 0:1)
Condition
Error in `.check_glmnet_penalty_predict()`:
! `penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
! `penalty` should be a single numeric value.
i `multi_predict()` can be used to get multiple predictions per row of data.

---

Code
linear_reg() %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[-(1:4), ])
Condition
Error in `.check_glmnet_penalty_fit()`:
! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
* There are 0 values for `penalty`.
* To try multiple values for total regularization, use the tune package.
* To predict multiple penalties, use `multi_predict()`
x For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
! There are 0 values for `penalty`.
i To try multiple values for total regularization, use the tune package.
i To predict multiple penalties, use `multi_predict()`.

---

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/_snaps/glmnet-logistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
penalty = 0:1)
Condition
Error in `.check_glmnet_penalty_predict()`:
! `penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
! `penalty` should be a single numeric value.
i `multi_predict()` can be used to get multiple predictions per row of data.

---

Expand All @@ -23,10 +24,10 @@
int_rate + term, data = lending_club)
Condition
Error in `.check_glmnet_penalty_fit()`:
! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
* There are 0 values for `penalty`.
* To try multiple values for total regularization, use the tune package.
* To predict multiple penalties, use `multi_predict()`
x For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
! There are 0 values for `penalty`.
i To try multiple values for total regularization, use the tune package.
i To predict multiple penalties, use `multi_predict()`.

---

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/_snaps/glmnet-multinom.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
predict(hpc_data, penalty = 0:1)
Condition
Error in `.check_glmnet_penalty_predict()`:
! `penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
! `penalty` should be a single numeric value.
i `multi_predict()` can be used to get multiple predictions per row of data.

---

Code
multinom_reg() %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data)
Condition
Error in `.check_glmnet_penalty_fit()`:
! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
* There are 0 values for `penalty`.
* To try multiple values for total regularization, use the tune package.
* To predict multiple penalties, use `multi_predict()`
x For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
! There are 0 values for `penalty`.
i To try multiple values for total regularization, use the tune package.
i To predict multiple penalties, use `multi_predict()`.

---

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/_snaps/glmnet-poisson.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
poisson_reg() %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[-(1:4), ])
Condition
Error in `.check_glmnet_penalty_fit()`:
! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
* There are 0 values for `penalty`.
* To try multiple values for total regularization, use the tune package.
* To predict multiple penalties, use `multi_predict()`
x For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
! There are 0 values for `penalty`.
i To try multiple values for total regularization, use the tune package.
i To predict multiple penalties, use `multi_predict()`.

# predict() errors with multiple penalty values

Expand All @@ -16,5 +16,6 @@
-(1:4), ]) %>% predict(mtcars[-(1:4), ], penalty = 0:1)
Condition
Error in `.check_glmnet_penalty_predict()`:
! `penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
! `penalty` should be a single numeric value.
i `multi_predict()` can be used to get multiple predictions per row of data.

2 changes: 1 addition & 1 deletion tests/testthat/test-glmnet-linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ test_that('multi_predict() with default or single penalty value', {

test_that('error traps', {
skip_if_not_installed("glmnet")
skip_if_not_installed("parsnip", minimum_version = "1.2.0.9001")
skip_if_not_installed("parsnip", minimum_version = "1.2.1.9001")

expect_snapshot(error = TRUE, {
linear_reg(penalty = 0.01) %>%
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-glmnet-logistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ test_that("class predictions are factors with all levels", {

test_that('error traps', {
skip_if_not_installed("glmnet")
skip_if_not_installed("parsnip", minimum_version = "1.2.0.9001")
skip_if_not_installed("parsnip", minimum_version = "1.2.1.9001")

data("lending_club", package = "modeldata", envir = rlang::current_env())

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-glmnet-multinom.R
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ test_that("class predictions are factors with all levels", {

test_that('error traps', {
skip_if_not_installed("glmnet")
skip_if_not_installed("parsnip", minimum_version = "1.2.0.9001")
skip_if_not_installed("parsnip", minimum_version = "1.2.1.9001")

data("hpc_data", package = "modeldata", envir = rlang::current_env())

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-glmnet-poisson.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ test_that("formula interface can deal with missing values", {
test_that("model errors on missing penalty value", {
skip_if_not_installed("glmnet")

skip_if_not_installed("parsnip", minimum_version = "1.0.3.9000")
skip_if_not_installed("parsnip", minimum_version = "1.2.1.9001")
expect_snapshot(error = TRUE, {
poisson_reg() %>%
set_engine("glmnet") %>%
Expand All @@ -134,7 +134,7 @@ test_that("model errors on missing penalty value", {

test_that("predict() errors with multiple penalty values", {
skip_if_not_installed("glmnet")
skip_if_not_installed("parsnip", minimum_version = "1.2.0.9001")
skip_if_not_installed("parsnip", minimum_version = "1.2.1.9001")

skip_if_not_installed("poissonreg", minimum_version = "1.0.1.9000")
expect_snapshot(error = TRUE, {
Expand Down

0 comments on commit 1e9b262

Please sign in to comment.