diff --git a/tests/testthat/_snaps/glmnet-linear.md b/tests/testthat/_snaps/glmnet-linear.md index b3a14e94..950ada48 100644 --- a/tests/testthat/_snaps/glmnet-linear.md +++ b/tests/testthat/_snaps/glmnet-linear.md @@ -25,6 +25,6 @@ linear_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(mpg ~ ., data = mtcars) %>% multi_predict(mtcars, type = "class") Condition - Error in `check_pred_type()`: + Error in `multi_predict()`: ! For class predictions, the object should be a classification model. diff --git a/tests/testthat/_snaps/glmnet-logistic.md b/tests/testthat/_snaps/glmnet-logistic.md index 0840124a..a9408d92 100644 --- a/tests/testthat/_snaps/glmnet-logistic.md +++ b/tests/testthat/_snaps/glmnet-logistic.md @@ -36,6 +36,6 @@ funded_amnt) + int_rate + term, data = lending_club) %>% multi_predict( lending_club, type = "time") Condition - Error in `check_pred_type()`: + Error in `multi_predict()`: ! For event time predictions, the object should be a censored regression. diff --git a/tests/testthat/_snaps/glmnet-multinom.md b/tests/testthat/_snaps/glmnet-multinom.md index 8f3f5ca7..bb06bfcc 100644 --- a/tests/testthat/_snaps/glmnet-multinom.md +++ b/tests/testthat/_snaps/glmnet-multinom.md @@ -33,6 +33,6 @@ multinom_reg(penalty = 0.01) %>% set_engine("glmnet") %>% fit(class ~ ., data = hpc_data) %>% multi_predict(hpc_data, type = "numeric") Condition - Error in `check_pred_type()`: + Error in `multi_predict()`: ! For numeric predictions, the object should be a regression model. diff --git a/tests/testthat/_snaps/parsnip-case-weights.md b/tests/testthat/_snaps/parsnip-case-weights.md new file mode 100644 index 00000000..514109c6 --- /dev/null +++ b/tests/testthat/_snaps/parsnip-case-weights.md @@ -0,0 +1,46 @@ +# boost_tree - xgboost case weights + + Code + print(wt_fit$fit$call) + Output + xgboost::xgb.train(params = list(eta = 0.3, max_depth = 6, gamma = 0, + colsample_bytree = 1, colsample_bynode = 1, min_child_weight = 1, + subsample = 1), data = x$data, nrounds = 15, watchlist = x$watchlist, + verbose = 0, nthread = 1, objective = "binary:logistic") + +# decision_tree - rpart case weights + + Code + print(wt_fit$fit$call) + Output + rpart::rpart(formula = Class ~ ., data = data, weights = weights) + +# logistic_reg - stan case weights + + Code + print(wt_fit$fit$call) + Output + rstanarm::stan_glm(formula = Class ~ ., family = stats::binomial, + data = data, weights = weights, seed = ~1, refresh = 0) + +# mars - earth case weights + + Code + print(wt_fit$fit$call) + Output + earth(formula = Class ~ ., data = data, weights = weights, keepxy = TRUE, + glm = ~list(family = stats::binomial)) + +# mlp - nnet case weights + + Case weights are not enabled by the underlying model implementation. + +# rand_forest - ranger case weights + + Code + print(wt_fit$fit$call) + Output + ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, + verbose = FALSE, seed = sample.int(10^5, 1), probability = TRUE, + case.weights = weights) + diff --git a/tests/testthat/_snaps/parsnip-survival-censoring-model.md b/tests/testthat/_snaps/parsnip-survival-censoring-model.md index 903474e2..8f882d18 100644 --- a/tests/testthat/_snaps/parsnip-survival-censoring-model.md +++ b/tests/testthat/_snaps/parsnip-survival-censoring-model.md @@ -21,5 +21,5 @@ predict(alt_obj, time = 100) Condition Error in `predict()`: - ! Don't know how to predict with a censoring model of type: reverse_km + ! Don't know how to predict with a censoring model of type reverse_km. diff --git a/tests/testthat/_snaps/parsnip-survival-censoring-weights.md b/tests/testthat/_snaps/parsnip-survival-censoring-weights.md index 8ba79a25..0d001db9 100644 --- a/tests/testthat/_snaps/parsnip-survival-censoring-weights.md +++ b/tests/testthat/_snaps/parsnip-survival-censoring-weights.md @@ -4,7 +4,7 @@ .censoring_weights_graf("nothing useful") Condition Error in `.censoring_weights_graf()`: - ! There is no `.censoring_weights_graf()` method for objects with class(es): 'character' + ! There is no `.censoring_weights_graf()` method for objects with class . --- @@ -12,7 +12,7 @@ .censoring_weights_graf(cox_model, lung) Condition Error: - ! There should be a single column of class `Surv` + ! There should be a single column of class . --- @@ -22,7 +22,7 @@ .censoring_weights_graf(cox_model, lung_left) Condition Error in `.censoring_weights_graf()`: - ! For this usage, the allowed censoring type is: 'right' + ! For this usage, the allowed censoring type is "right". --- @@ -30,7 +30,7 @@ .censoring_weights_graf(cox_model, lung2) Condition Error: - ! The input should have a list column called `.pred`. + ! The input should have a list column called ".pred". --- @@ -38,7 +38,7 @@ .censoring_weights_graf(cox_model, preds, cens_predictors = "shouldn't be using this anyway!") Condition Warning: - The 'cens_predictors' argument to the survival weighting function is not currently used. + `cens_predictors` is not currently used. Output # A tibble: 3 x 2 .pred surv @@ -60,6 +60,6 @@ Code .censoring_weights_graf(wrong_model, mtcars) Condition - Error in `.check_censor_model()`: - ! The model needs to be for mode 'censored regression', not for mode 'regression'. + Error in `.censoring_weights_graf()`: + ! The model needs to be for mode "censored regression", not for mode 'regression'. diff --git a/tests/testthat/_snaps/parsnip-survival-standalone.md b/tests/testthat/_snaps/parsnip-survival-standalone.md index 8e941ebb..c9a0baa9 100644 --- a/tests/testthat/_snaps/parsnip-survival-standalone.md +++ b/tests/testthat/_snaps/parsnip-survival-standalone.md @@ -4,7 +4,7 @@ parsnip:::.is_surv(1) Condition Error: - ! The object does not have class `Surv`. + ! The object does not have class . # .check_cens_type() @@ -12,7 +12,7 @@ parsnip:::.check_cens_type(left_c, type = "right", fail = TRUE) Condition Error: - ! For this usage, the allowed censoring type is: 'right' + ! For this usage, the allowed censoring type is "right". --- @@ -20,5 +20,5 @@ parsnip:::.check_cens_type(left_c, type = c("right", "interval"), fail = TRUE) Condition Error: - ! For this usage, the allowed censoring types are: 'right' and 'interval' + ! For this usage, the allowed censoring types are "right" or "interval". diff --git a/tests/testthat/_snaps/randomForest.md b/tests/testthat/_snaps/randomForest.md index 00b1400d..d2504242 100644 --- a/tests/testthat/_snaps/randomForest.md +++ b/tests/testthat/_snaps/randomForest.md @@ -4,9 +4,11 @@ f_fit <- spec %>% fit(body_mass_g ~ ., data = penguins) Condition Warning: - 1000 columns were requested but there were 6 predictors in the data. 6 will be used. + ! 1000 columns were requested but there were 6 predictors in the data. + i 6 predictors will be used. Warning: - 1000 samples were requested but there were 333 rows in the data. 333 will be used. + ! 1000 samples were requested but there were 333 rows in the data. + i 333 samples will be used. --- @@ -14,7 +16,9 @@ xy_fit <- spec %>% fit_xy(x = penguins[, -6], y = penguins$body_mass_g) Condition Warning: - 1000 columns were requested but there were 6 predictors in the data. 6 will be used. + ! 1000 columns were requested but there were 6 predictors in the data. + i 6 predictors will be used. Warning: - 1000 samples were requested but there were 333 rows in the data. 333 will be used. + ! 1000 samples were requested but there were 333 rows in the data. + i 333 samples will be used. diff --git a/tests/testthat/_snaps/recipes-varying.md b/tests/testthat/_snaps/recipes-varying.md new file mode 100644 index 00000000..ffd98987 --- /dev/null +++ b/tests/testthat/_snaps/recipes-varying.md @@ -0,0 +1,13 @@ +# recipe steps with non-varying args error if specified as varying() + + Code + varying_args(rec_bad_varying) + Condition + Error in `map()`: + i In index: 1. + Caused by error in `map2()`: + i In index: 5. + i With name: skip. + Caused by error in `.f()`: + ! The argument skip for a recipe step of type "step_type" is not allowed to vary. + diff --git a/tests/testthat/_snaps/recipes1.1.0/recipes-nnmf_sparse.md b/tests/testthat/_snaps/recipes1.1.0/recipes-nnmf_sparse.md new file mode 100644 index 00000000..f47bed4c --- /dev/null +++ b/tests/testthat/_snaps/recipes1.1.0/recipes-nnmf_sparse.md @@ -0,0 +1,36 @@ +# Correct values + + Code + print(rec) + Message + + -- Recipe ---------------------------------------------------------------------- + + -- Inputs + Number of variables by role + outcome: 1 + predictor: 4 + + -- Operations + * Non-negative matrix factorization for: all_predictors() + +# No NNF + + Code + print(rec) + Message + + -- Recipe ---------------------------------------------------------------------- + + -- Inputs + Number of variables by role + outcome: 1 + predictor: 4 + + -- Training information + Training data contained 150 data points and no incomplete rows. + + -- Operations + * No non-negative matrix factorization was extracted from: Sepal.Length, + Sepal.Width, Petal.Length, Petal.Width | Trained + diff --git a/tests/testthat/_snaps/survival-tune-bayes.md b/tests/testthat/_snaps/survival-tune-bayes.md index 21b7630a..afac488a 100644 --- a/tests/testthat/_snaps/survival-tune-bayes.md +++ b/tests/testthat/_snaps/survival-tune-bayes.md @@ -13,9 +13,6 @@ Code expect_snapshot_plot(print(autoplot(bayes_dynamic_res)), "dyn-bayes") - Condition - Warning in `filter_plot_eval_time()`: - No evaluation time was set; a value of 5 was used. # Bayesian tuning survival models with mixture of metric types @@ -32,9 +29,6 @@ Code expect_snapshot_plot(print(autoplot(bayes_mixed_res)), "mix-bayes-0-times") - Condition - Warning in `filter_plot_eval_time()`: - No evaluation time was set; a value of 5 was used. --- diff --git a/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes-2-times-perf.png b/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes-2-times-perf.png index 6a8722c5..63d7f24e 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes-2-times-perf.png and b/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes-2-times-perf.png differ diff --git a/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes.png b/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes.png index c887e33c..f753b40b 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes.png and b/tests/testthat/_snaps/survival-tune-bayes/dyn-bayes.png differ diff --git a/tests/testthat/_snaps/survival-tune-bayes/int-bayes-2-times-perf.png b/tests/testthat/_snaps/survival-tune-bayes/int-bayes-2-times-perf.png index df48d6e8..64dc99da 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/int-bayes-2-times-perf.png and b/tests/testthat/_snaps/survival-tune-bayes/int-bayes-2-times-perf.png differ diff --git a/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-0-times.png b/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-0-times.png index e2bf169f..6307d3f8 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-0-times.png and b/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-0-times.png differ diff --git a/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-2-times-perf.png b/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-2-times-perf.png index ec7444db..97223e89 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-2-times-perf.png and b/tests/testthat/_snaps/survival-tune-bayes/mix-bayes-2-times-perf.png differ diff --git a/tests/testthat/_snaps/survival-tune-bayes/stc-bayes-2-times-perf.png b/tests/testthat/_snaps/survival-tune-bayes/stc-bayes-2-times-perf.png index a8edeeac..19518868 100644 Binary files a/tests/testthat/_snaps/survival-tune-bayes/stc-bayes-2-times-perf.png and b/tests/testthat/_snaps/survival-tune-bayes/stc-bayes-2-times-perf.png differ diff --git a/tests/testthat/test-glmnet-linear.R b/tests/testthat/test-glmnet-linear.R index 26bac500..d8e177c3 100644 --- a/tests/testthat/test-glmnet-linear.R +++ b/tests/testthat/test-glmnet-linear.R @@ -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.1.9001") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") expect_snapshot(error = TRUE, { linear_reg(penalty = 0.01) %>% diff --git a/tests/testthat/test-glmnet-logistic.R b/tests/testthat/test-glmnet-logistic.R index 2be46e8e..52336b08 100644 --- a/tests/testthat/test-glmnet-logistic.R +++ b/tests/testthat/test-glmnet-logistic.R @@ -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.1.9001") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") data("lending_club", package = "modeldata", envir = rlang::current_env()) diff --git a/tests/testthat/test-glmnet-multinom.R b/tests/testthat/test-glmnet-multinom.R index 5dea6a2c..8b7f7197 100644 --- a/tests/testthat/test-glmnet-multinom.R +++ b/tests/testthat/test-glmnet-multinom.R @@ -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.1.9001") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") data("hpc_data", package = "modeldata", envir = rlang::current_env()) diff --git a/tests/testthat/test-parsnip-survival-censoring-model.R b/tests/testthat/test-parsnip-survival-censoring-model.R index 71cd70c6..548e4690 100644 --- a/tests/testthat/test-parsnip-survival-censoring-model.R +++ b/tests/testthat/test-parsnip-survival-censoring-model.R @@ -115,7 +115,7 @@ test_that("predict() avoids zero probabilities", { }) test_that("Handle unknown censoring model", { - skip_if_not_installed("parsnip", minimum_version = "1.1.0.9002") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") mod_fit <- survival_reg() %>% fit(Surv(time, status) ~ age + sex, data = lung) diff --git a/tests/testthat/test-parsnip-survival-censoring-weights.R b/tests/testthat/test-parsnip-survival-censoring-weights.R index b3aba3d1..d9b3ab51 100644 --- a/tests/testthat/test-parsnip-survival-censoring-weights.R +++ b/tests/testthat/test-parsnip-survival-censoring-weights.R @@ -174,6 +174,8 @@ test_that('compute Graf weights', { }) test_that("error messages in context of .censoring_weights_graf()", { + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") + lung2 <- lung %>% dplyr::mutate(surv = Surv(time, status), .keep = "unused") @@ -228,7 +230,7 @@ test_that("error for .censoring_weights_graf.workflow()", { test_that("error for .censoring_weights_graf() from .check_censor_model()", { # temporarily its own test, see above - skip_if_not_installed("parsnip", minimum_version = "1.1.0.9003") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") wrong_model <- fit(linear_reg(), mpg ~ ., data = mtcars) expect_snapshot(error = TRUE, .censoring_weights_graf(wrong_model, mtcars)) }) diff --git a/tests/testthat/test-parsnip-survival-standalone.R b/tests/testthat/test-parsnip-survival-standalone.R index 0d48b8ed..7708756a 100644 --- a/tests/testthat/test-parsnip-survival-standalone.R +++ b/tests/testthat/test-parsnip-survival-standalone.R @@ -1,6 +1,7 @@ skip_if_not_installed("survival") test_that(".is_surv()", { + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") times <- seq(1, 100, length.out = 5) events <- c(1, 0, 1, 0, 1) right_c <- survival::Surv(times, events) @@ -11,6 +12,7 @@ test_that(".is_surv()", { }) test_that(".check_cens_type()", { + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") times <- seq(1, 100, length.out = 5) events <- c(1, 0, 1, 0, 1) left_c <- survival::Surv(times, events, type = "left") diff --git a/tests/testthat/test-randomForest.R b/tests/testthat/test-randomForest.R index 6a8ebb41..f989b38e 100644 --- a/tests/testthat/test-randomForest.R +++ b/tests/testthat/test-randomForest.R @@ -218,6 +218,7 @@ test_that('randomForest regression prediction', { test_that('argument checks for data dimensions', { skip_if_not_installed("randomForest") + skip_if_not_installed("parsnip", minimum_version = "1.2.1.9002") data(penguins, package = "modeldata") penguins <- na.omit(penguins) diff --git a/tests/testthat/test-recipes-varying.R b/tests/testthat/test-recipes-varying.R index 498a61fc..c44b6cc3 100644 --- a/tests/testthat/test-recipes-varying.R +++ b/tests/testthat/test-recipes-varying.R @@ -61,13 +61,14 @@ test_that('recipe parameters', { test_that("recipe steps with non-varying args error if specified as varying()", { withr::local_options(lifecycle_verbosity = "quiet") + skip("not applicable") rec_bad_varying <- rec_1 rec_bad_varying$steps[[1]]$skip <- varying() - expect_error( + expect_snapshot( varying_args(rec_bad_varying), - "The following argument for a recipe step of type 'step_center' is not allowed to vary: 'skip'." + error = TRUE ) })