Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing updates after inactivity #121

Merged
merged 18 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions tests/testthat/_snaps/glmnet-linear.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
Code
linear_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[
-(1:4), ]) %>% predict(mtcars[-(1:4), ], penalty = 0:1)
Error <rlang_error>
`penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
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.

---

Code
linear_reg() %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[-(1:4), ])
Error <rlang_error>
For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
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()`
Expand All @@ -21,6 +23,7 @@
Code
linear_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars) %>%
multi_predict(mtcars, type = "class")
Error <rlang_error>
For class predictions, the object should be a classification model.
Condition
Error in `check_pred_type()`:
! For class predictions, the object should be a classification model.

20 changes: 12 additions & 8 deletions tests/testthat/_snaps/glmnet-logistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

Code
multi_predict(class_fit, newdata = wa_churn[1:4, vars], type = "prob")
Error <rlang_error>
Please use `new_data` instead of `newdata`.
Condition
Error in `multi_predict()`:
! Please use `new_data` instead of `newdata`.

# error traps

Code
logistic_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(Class ~ log(
funded_amnt) + int_rate + term, data = lending_club) %>% predict(lending_club,
penalty = 0:1)
Error <rlang_error>
`penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
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.

---

Code
logistic_reg() %>% set_engine("glmnet") %>% fit(Class ~ log(funded_amnt) +
int_rate + term, data = lending_club)
Error <rlang_error>
For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
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()`
Expand All @@ -31,6 +34,7 @@
logistic_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(Class ~ log(
funded_amnt) + int_rate + term, data = lending_club) %>% multi_predict(
lending_club, type = "time")
Error <rlang_error>
For event time predictions, the object should be a censored regression.
Condition
Error in `check_pred_type()`:
! For event time predictions, the object should be a censored regression.

20 changes: 12 additions & 8 deletions tests/testthat/_snaps/glmnet-multinom.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

Code
multi_predict(xy_fit, newdata = hpc[rows, 1:4], penalty = c(0.1, 0.5))
Error <rlang_error>
Please use `new_data` instead of `newdata`.
Condition
Error in `multi_predict()`:
! Please use `new_data` instead of `newdata`.

# error traps

Code
multinom_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data) %>%
predict(hpc_data, penalty = 0:1)
Error <rlang_error>
`penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.
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.

---

Code
multinom_reg() %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data)
Error <rlang_error>
For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
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()`
Expand All @@ -28,6 +31,7 @@
Code
multinom_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data) %>%
multi_predict(hpc_data, type = "numeric")
Error <rlang_error>
For numeric predictions, the object should be a regression model.
Condition
Error in `check_pred_type()`:
! For numeric predictions, the object should be a regression model.

24 changes: 13 additions & 11 deletions tests/testthat/_snaps/glmnet-poisson.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# error traps

Code
poisson_reg(penalty = 0.1) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[
-(1:4), ]) %>% predict(mtcars[-(1:4), ], penalty = 0:1)
Error <rlang_error>
`penalty` should be a single numeric value. `multi_predict()` can be used to get multiple predictions per row of data.

---
# model errors on missing penalty value

Code
poisson_reg() %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[-(1:4), ])
Error <rlang_error>
For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
Condition
Error in `.check_glmnet_penalty_fit()`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thought re: new call output.

! 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()`

# predict() errors with multiple penalty values

Code
poisson_reg(penalty = 0.1) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars[
-(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.

16 changes: 8 additions & 8 deletions tests/testthat/_snaps/parsnip-extension-messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Code
bag_tree() %>% set_engine("rpart") %>% set_mode("regression")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` regression model specifications using the `rpart` engine.
i The parsnip extension package baguette implements support for this specification.
i Please install (if needed) and load to continue.
Expand All @@ -20,7 +20,7 @@

Code
bag_tree() %>% set_mode("censored regression")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` censored regression model specifications.
i The parsnip extension package censored implements support for this specification.
i Please install (if needed) and load to continue.
Expand All @@ -38,7 +38,7 @@

Code
bag_tree()
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` model specifications.
i The parsnip extension packages censored and baguette implement support for this specification.
i Please install (if needed) and load to continue.
Expand All @@ -56,7 +56,7 @@

Code
bag_tree() %>% set_engine("rpart")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` model specifications using the `rpart` engine.
i The parsnip extension packages censored and baguette implement support for this specification.
i Please install (if needed) and load to continue.
Expand Down Expand Up @@ -102,7 +102,7 @@

Code
bag_tree() %>% set_mode("regression") %>% set_engine("rpart")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` regression model specifications using the `rpart` engine.
i The parsnip extension package baguette implements support for this specification.
i Please install (if needed) and load to continue.
Expand All @@ -120,7 +120,7 @@

Code
bag_tree() %>% set_mode("classification") %>% set_engine("C5.0")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `bag_tree` classification model specifications using the `C5.0` engine.
i The parsnip extension package baguette implements support for this specification.
i Please install (if needed) and load to continue.
Expand Down Expand Up @@ -182,7 +182,7 @@

Code
decision_tree() %>% set_engine("partykit") %>% set_mode("regression")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `decision_tree` regression model specifications using the `partykit` engine.
i The parsnip extension package bonsai implements support for this specification.
i Please install (if needed) and load to continue.
Expand Down Expand Up @@ -216,7 +216,7 @@

Code
decision_tree() %>% set_mode("regression") %>% set_engine("partykit")
Message <rlang_message>
Message
! parsnip could not locate an implementation for `decision_tree` regression model specifications using the `partykit` engine.
i The parsnip extension package bonsai implements support for this specification.
i Please install (if needed) and load to continue.
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/parsnip-model-formula.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# error with model formula (workflow, no tune)
# error without model formula (workflow, no tune)

Code
gam_fit <- gam_wflow %>% fit(mtcars)
Expand All @@ -7,7 +7,7 @@
! When working with generalized additive models, please supply the model specification to `workflows::add_model()` along with a `formula` argument.
i See `?parsnip::model_formula()` to learn more.

# error with model formula (workflow, with tune)
# error without model formula (workflow, with tune)

Code
show_notes(gam_res)
Expand All @@ -18,7 +18,7 @@
! When working with generalized additive models, please supply the model specification to `workflows::add_model()` along with a `formula` argument.
i See `?parsnip::model_formula()` to learn more.

# error with model formula (no workflow, with tune)
# error without model formula (no workflow, with tune)

Code
show_notes(gam_res)
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/_snaps/parsnip-survival-censoring-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

Code
predict(alt_obj, time = 100)
Error <rlang_error>
Don't know how to predict with a censoring model of type: reverse_km
Condition
Error in `predict()`:
! Don't know how to predict with a censoring model of type: reverse_km

33 changes: 20 additions & 13 deletions tests/testthat/_snaps/parsnip-survival-censoring-weights.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,50 @@

Code
.censoring_weights_graf("nothing useful")
Error <rlang_error>
There is no `.censoring_weights_graf()` method for objects with class(es): 'character'
Condition
Error in `.censoring_weights_graf()`:
! There is no `.censoring_weights_graf()` method for objects with class(es): 'character'

---

Code
.censoring_weights_graf(workflows::workflow())
Error <rlang_error>
The workflow does not have a model fit object.
Condition
Error in `.censoring_weights_graf()`:
! The workflow does not have a model fit object.

---

Code
.censoring_weights_graf(cox_model, lung)
Error <rlang_error>
There should be a single column of class `Surv`
Condition
Error:
! There should be a single column of class `Surv`

---

Code
lung_left <- lung[1, , drop = FALSE]
lung_left$surv <- Surv(10, 0, type = "left")
.censoring_weights_graf(cox_model, lung_left)
Error <rlang_error>
For this usage, the allowed censoring type is: 'right'
Condition
Error in `.censoring_weights_graf()`:
! For this usage, the allowed censoring type is: 'right'

---

Code
.censoring_weights_graf(cox_model, lung2)
Error <rlang_error>
The input should have a list column called `.pred`.
Condition
Error:
! The input should have a list column called `.pred`.

---

Code
.censoring_weights_graf(cox_model, preds, cens_predictors = "shouldn't be using this anyway!")
Warning <rlang_warning>
Condition
Warning:
The 'cens_predictors' argument to the survival weighting function is not currently used.
Output
# A tibble: 3 x 2
Expand All @@ -53,6 +59,7 @@

Code
.censoring_weights_graf(wrong_model, mtcars)
Error <rlang_error>
The model needs to be for mode 'censored regression', not for mode 'regression'.
Condition
Error in `.check_censor_model()`:
! The model needs to be for mode 'censored regression', not for mode 'regression'.

15 changes: 9 additions & 6 deletions tests/testthat/_snaps/parsnip-survival-standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

Code
parsnip:::.is_surv(1)
Error <rlang_error>
The object does not have class `Surv`.
Condition
Error:
! The object does not have class `Surv`.

# .check_cens_type()

Code
parsnip:::.check_cens_type(left_c, type = "right", fail = TRUE)
Error <rlang_error>
For this usage, the allowed censoring type is: 'right'
Condition
Error:
! For this usage, the allowed censoring type is: 'right'

---

Code
parsnip:::.check_cens_type(left_c, type = c("right", "interval"), fail = TRUE)
Error <rlang_error>
For this usage, the allowed censoring types are: 'right' and 'interval'
Condition
Error:
! For this usage, the allowed censoring types are: 'right' and 'interval'

8 changes: 6 additions & 2 deletions tests/testthat/_snaps/randomForest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

Code
f_fit <- spec %>% fit(body_mass_g ~ ., data = penguins)
Warning <rlang_warning>
Condition
Warning:
1000 columns were requested but there were 6 predictors in the data. 6 will be used.
Warning:
1000 samples were requested but there were 333 rows in the data. 333 will be used.

---

Code
xy_fit <- spec %>% fit_xy(x = penguins[, -6], y = penguins$body_mass_g)
Warning <rlang_warning>
Condition
Warning:
1000 columns were requested but there were 6 predictors in the data. 6 will be used.
Warning:
1000 samples were requested but there were 333 rows in the data. 333 will be used.

Loading