Skip to content

Commit

Permalink
Less noise (#125)
Browse files Browse the repository at this point in the history
* shhhhhhh

`suppressMessage()` because we don't do anything with them

* removing unused rlang calls

* suppress messages and fix arg name

the messages are not as overwhelming in the interactive case but quite a lot otherwise
  • Loading branch information
hfrick authored Nov 13, 2023
1 parent 04ee2d1 commit c9bdd3f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 27 deletions.
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
6 changes: 4 additions & 2 deletions tests/testthat/test-parsnip-model-formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ 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))
})
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

0 comments on commit c9bdd3f

Please sign in to comment.