Skip to content

Commit

Permalink
more msg updates
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed Nov 21, 2024
1 parent 17b3f3d commit 2e2b7da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
44 changes: 21 additions & 23 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ check_parameters <- function(wflow, pset = NULL, data, grid_names = character(0)
unk_names <- pset$id[unk]
num_unk <- length(unk_names)
msg <-
cli::format_inline("Creating pre-processing data to finalize {num_unk}
unknown parameter{?s}: {.val {unk_names}}")
cli::format_inline(
"Creating pre-processing data to finalize {num_unk} unknown parameter{?s}: {.val {unk_names}}")

tune_log(list(verbose = TRUE), split_labels = NULL, msg, type = "info")

Expand Down Expand Up @@ -217,37 +217,35 @@ check_bayes_initial_size <- function(num_param, num_grid, race = FALSE) {
and {num_grid} grid point{?s} {?was/were} requested."
)

msg_list <- c(
"{msg}",
"i" = "The GP model requires 2+ initial points. For best performance,
supply more initial points than there are tuning parameters."
)
bullet_msg <-
c(
`!` = "{msg}",
`*` = cli::pluralize(
"There are {cli::qty(diff)}{?as many/more} tuning parameters
{cli::qty(diff)}{?as/than} there are initial points.
This is likely to cause numerical issues in the first few
search iterations.")
)


if (race) {
race_msg <- "With racing, only completely resampled parameters are used."
} else {
race_msg <- NULL
msg_list <- c(msg_list, "i" = race_msg)
bullet_msg <- c(bullet_msg, `*` = race_msg)
}

if (num_grid == 1) {
cli::cli_abort(
c(
"{msg}",
"i" = "The GP model requires 2+ initial points. For best performance,
supply more initial points than there are tuning parameters.",
"i" = "{race_msg}"
)
)
cli::cli_abort(msg_list)
}

if (num_grid < num_param + 1) {
diff <- num_param - num_grid + 1
cli::cli_bullets(
c(
`!` = msg,
`*` = cli::pluralize(
"There are {cli::qty(diff)}{?as many/more} tuning parameters
{cli::qty(diff)}{?as/than} there are initial points.
This is likely to cause numerical issues in the first few
search iterations."),
`*` = race_msg
)
)
cli::cli_bullets(bullet_msg)
}

invisible(NULL)
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/_snaps/bayes.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
tune:::check_bayes_initial_size(5, 3, FALSE)
Message
! There are 5 tuning parameters and 3 grid points were requested.
* There are more tuning parameters than there are initial points. This is
* There are as many tuning parameters as there are initial points. This is
likely to cause numerical issues in the first few search iterations.

---
Expand All @@ -474,7 +474,7 @@
tune:::check_bayes_initial_size(5, 3, TRUE)
Message
! There are 5 tuning parameters and 3 grid points were requested.
* There are more tuning parameters than there are initial points. This is
* There are as many tuning parameters as there are initial points. This is
likely to cause numerical issues in the first few search iterations.
* With racing, only completely resampled parameters are used.

Expand All @@ -495,7 +495,6 @@
Error in `tune:::check_bayes_initial_size()`:
! There are 5 tuning parameters and 1 grid point was requested.
i The GP model requires 2+ initial points. For best performance, supply more initial points than there are tuning parameters.
i

---

Expand All @@ -515,7 +514,6 @@
Error in `tune:::check_bayes_initial_size()`:
! There is 1 tuning parameter and 1 grid point was requested.
i The GP model requires 2+ initial points. For best performance, supply more initial points than there are tuning parameters.
i

# missing performance values

Expand Down

0 comments on commit 2e2b7da

Please sign in to comment.