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

Less noise #125

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
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)

hfrick marked this conversation as resolved.
Show resolved Hide resolved
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
6 changes: 4 additions & 2 deletions tests/testthat/test-engine-parameters-c5.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ test_that('single tree Bayesian search', {
expect_error(
tree_search <-
tree_mod %>%
tune_bayes(Class ~ ., resamples = folds, initial = 3, iter = 2),
tune_bayes(Class ~ ., resamples = folds, initial = 3, iter = 2) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(tree_search)), 10)
Expand All @@ -61,7 +62,8 @@ test_that('boosted tree Bayesian search', {
expect_error(
boost_search <-
boost_mod %>%
tune_bayes(Class ~ ., resamples = folds, initial = 3, iter = 2),
tune_bayes(Class ~ ., resamples = folds, initial = 3, iter = 2) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(boost_search)), 10)
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-engine-parameters-earth.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ test_that('Bayes search', {
expect_error(
mars_search <-
mars_mod %>%
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2),
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(mars_search)), 10)
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-engine-parameters-randomForest.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ test_that('grid search', {
expect_error(
rf_tune <-
rf_mod %>%
tune_grid(mpg ~ ., resamples = rs, grid = 4),
tune_grid(mpg ~ ., resamples = rs, grid = 4) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(rf_tune)), 8)
Expand All @@ -32,7 +33,8 @@ test_that('Bayes search', {
expect_error(
rf_search <-
rf_mod %>%
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2),
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(rf_search)), 10)
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-engine-parameters-ranger.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ test_that('grid search', {
expect_error(
rf_tune <-
rf_mod %>%
tune_grid(mpg ~ ., resamples = rs, grid = 4),
tune_grid(mpg ~ ., resamples = rs, grid = 4) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(rf_tune)), 8)
Expand All @@ -33,7 +34,8 @@ test_that('Bayes search', {
expect_error(
rf_search <-
rf_mod %>%
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2),
tune_bayes(mpg ~ ., resamples = rs, initial = 3, iter = 2) %>%
suppressMessages(),
regex = NA
)
expect_equal(nrow(collect_metrics(rf_search)), 10)
Expand Down
12 changes: 7 additions & 5 deletions tests/testthat/test-parsnip-model-formula.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that('error without model formula (workflow, no tune)', {
skip_if_not_installed("parsnip", min_version = "1.1.1.9001")
skip_if_not_installed("parsnip", minimum_version = "1.1.1.9001")

library(parsnip)
library(workflows)
Expand All @@ -15,7 +15,7 @@ test_that('error without model formula (workflow, no tune)', {
})

test_that('error without model formula (workflow, with tune)', {
skip_if_not_installed("parsnip", min_version = "1.1.1.9001")
skip_if_not_installed("parsnip", minimum_version = "1.1.1.9001")

library(parsnip)
library(workflows)
Expand All @@ -28,13 +28,14 @@ test_that('error without model formula (workflow, with tune)', {

expect_warning(
gam_res <- gam_wflow %>% fit_resamples(bootstraps(mtcars))
)
) %>%
suppressMessages()

expect_snapshot(show_notes(gam_res))
})

test_that('error without model formula (no workflow, with tune)', {
skip_if_not_installed("parsnip", min_version = "1.1.1.9001")
skip_if_not_installed("parsnip", minimum_version = "1.1.1.9001")

library(parsnip)
library(tune)
Expand All @@ -44,7 +45,8 @@ test_that('error without model formula (no workflow, with tune)', {

expect_warning(
gam_res <- gam_spec %>% fit_resamples(mpg ~ ., bootstraps(mtcars))
)
) %>%
suppressMessages()

expect_snapshot(show_notes(gam_res))
})
4 changes: 3 additions & 1 deletion tests/testthat/test-stacks-columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ test_that("stacks can accommodate outcome levels that are not valid colnames", {
expect_true(".pred_Adelie.1_tuned_1_1" %in% colnames(data_st))

# glmnet will likely present warnings
blended <- data_st %>%
suppressMessages(
blended <- data_st %>%
blend_predictions()
)

# ...though model fitting should work as expected
expect_silent(
Expand Down
22 changes: 16 additions & 6 deletions tests/testthat/test-stacks-tuning.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ test_that("stacking with grid search works", {
seed = 1,
resamples = folds,
metrics = metric
)
) %>%
suppressMessages()

data_st_grid <-
stacks() %>%
Expand Down Expand Up @@ -129,11 +130,13 @@ test_that("stacking with Bayesian tuning works", {
seed = 1,
resamples = folds,
metrics = metric
)
) %>%
suppressMessages()

data_st_bayes <-
stacks() %>%
add_candidates(wf_set_bayes)
add_candidates(wf_set_bayes) %>%
suppressMessages()

expect_true(inherits(data_st_bayes, "tbl_df"))

Expand Down Expand Up @@ -234,7 +237,14 @@ test_that("stacking with finetune works (sim_anneal)", {

wf_set_sim_anneal <-
workflow_map(
wf_set %>% option_add(control = control_sim_anneal(save_pred = TRUE, save_workflow = TRUE)),
wf_set %>%
option_add(
control = control_sim_anneal(
save_pred = TRUE,
save_workflow = TRUE,
verbose_iter = FALSE
)
),
fn = "tune_sim_anneal",
seed = 1,
resamples = folds,
Expand Down Expand Up @@ -282,7 +292,6 @@ test_that("stacking with finetune works (sim_anneal)", {
expect_true(inherits(preds_sim_anneal, "tbl_df"))
})


test_that("stacking with finetune works (win_loss)", {
skip_if(utils::packageVersion("stacks") < "1.0.0.9000")

Expand All @@ -293,7 +302,8 @@ test_that("stacking with finetune works (win_loss)", {
seed = 1,
resamples = folds,
metrics = metric
)
) %>%
suppressMessages()

data_st_win_loss <-
stacks() %>%
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-stan-linear.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library(testthat)
library(parsnip)
library(rlang)
library(modeldata)

## -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-stan-logistic.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library(testthat)
library(parsnip)
library(rlang)
library(tibble)
library(modeldata)

Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-stan-poisson.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

## -----------------------------------------------------------------------------

library(rlang)
library(poissonreg)
library(tidyr)

Expand All @@ -22,10 +21,6 @@ stan_spec <- poisson_reg() %>% set_engine("stan", refresh = 0)
hurdle_spec <- poisson_reg() %>% set_engine("hurdle")
zeroinfl_spec <- poisson_reg() %>% set_engine("zeroinfl")

new_empty_quosure <- function(expr) {
new_quosure(expr, env = empty_env())
}

# ------------------------------------------------------------------------------

test_that('stan_glm execution', {
Expand Down Expand Up @@ -142,6 +137,3 @@ test_that('stan intervals', {
tolerance = 1e-2,
ignore_attr = TRUE)
})



3 changes: 2 additions & 1 deletion tests/testthat/test-tune_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test_that('tune recipe and model, which has_unknowns', {
)
folds <- vfold_cv(mtcars)
res <- tune_bayes(wflow, resamples = folds, param_info = pset,
initial = iter1, iter = iter2)
initial = iter1, iter = iter2) %>%
suppressMessages()
expect_equal(unique(res$id), folds$id)
expect_equal(
colnames(res$.metrics[[1]]),
Expand Down
Loading