From 7576d48c6cccaf060e8ddae39f51e924313bcd7a Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 19 Sep 2024 09:50:18 -0700 Subject: [PATCH 1/4] rlang::warn() -> cli::cli_warn() --- R/grids.R | 10 +++++++--- R/space_filling.R | 15 +++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/R/grids.R b/R/grids.R index e2e89d56..e7056dc9 100644 --- a/R/grids.R +++ b/R/grids.R @@ -49,7 +49,10 @@ grid_regular <- function(x, ..., levels = 3, original = TRUE, filter = NULL) { dots <- list(...) if (any(names(dots) == "size")) { - rlang::warn("`size` is not an argument to `grid_regular()`. Did you mean `levels`?") + cli::cli_warn( + "{.arg size} is not an argument to {.fn grid_regular}. + Did you mean {.arg levels}?" + ) } UseMethod("grid_regular") } @@ -166,8 +169,9 @@ make_regular_grid <- function(..., grid_random <- function(x, ..., size = 5, original = TRUE, filter = NULL) { dots <- list(...) if (any(names(dots) == "levels")) { - rlang::warn( - "`levels` is not an argument to `grid_random()`. Did you mean `size`?" + cli::cli_warn( + "{.arg levels} is not an argument to {.fn grid_random}. + Did you mean {.arg size}?" ) } UseMethod("grid_random") diff --git a/R/space_filling.R b/R/space_filling.R index 79c46e0a..59a36958 100644 --- a/R/space_filling.R +++ b/R/space_filling.R @@ -92,8 +92,9 @@ grid_space_filling <- function(x, ..., size = 5, type = "any", original = TRUE) { dots <- list(...) if (any(names(dots) == "levels")) { - rlang::warn( - "`levels` is not an argument to `grid_space_filling()`. Did you mean `size`?" + cli::cli_warn( + "{.arg levels} is not an argument to {.fn grid_space_filling}. + Did you mean {.arg size}?" ) } UseMethod("grid_space_filling") @@ -282,7 +283,10 @@ grid_max_entropy <- function(x, dots <- list(...) if (any(names(dots) == "levels")) { - rlang::warn("`levels` is not an argument to `grid_max_entropy()`. Did you mean `size`?") + cli::cli_warn( + "{.arg levels} is not an argument to {.fn grid_max_entropy}. + Did you mean {.arg size}?" + ) } UseMethod("grid_max_entropy") } @@ -409,7 +413,10 @@ grid_latin_hypercube <- function(x, ..., size = 3, original = TRUE) { dots <- list(...) if (any(names(dots) == "levels")) { - rlang::warn("`levels` is not an argument to `grid_latin_hypercube()`. Did you mean `size`?") + cli::cli_warn( + "{.arg levels} is not an argument to {.fn grid_latin_hypercube. + Did you mean {.arg size}?" + ) } UseMethod("grid_latin_hypercube") } From 79d6da4ef4f0df9d34c8c0e274803c887a50def9 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 19 Sep 2024 09:52:42 -0700 Subject: [PATCH 2/4] add missing end parentheses --- R/space_filling.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/space_filling.R b/R/space_filling.R index 59a36958..6644e7f4 100644 --- a/R/space_filling.R +++ b/R/space_filling.R @@ -414,7 +414,7 @@ grid_latin_hypercube <- function(x, ..., size = 3, original = TRUE) { dots <- list(...) if (any(names(dots) == "levels")) { cli::cli_warn( - "{.arg levels} is not an argument to {.fn grid_latin_hypercube. + "{.arg levels} is not an argument to {.fn grid_latin_hypercube}. Did you mean {.arg size}?" ) } From 678cbe5c0d8471358e6b66fc28269a74458b095a Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 19 Sep 2024 13:53:07 -0700 Subject: [PATCH 3/4] add info bullet to grid_regular() warning --- R/grids.R | 6 ++++-- tests/testthat/_snaps/grids.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/grids.R b/R/grids.R index e7056dc9..695da082 100644 --- a/R/grids.R +++ b/R/grids.R @@ -50,8 +50,10 @@ grid_regular <- function(x, ..., levels = 3, original = TRUE, filter = NULL) { dots <- list(...) if (any(names(dots) == "size")) { cli::cli_warn( - "{.arg size} is not an argument to {.fn grid_regular}. - Did you mean {.arg levels}?" + c( + "{.arg size} is not an argument to {.fn grid_regular}.", + i = "Did you mean {.arg levels}?" + ) ) } UseMethod("grid_regular") diff --git a/tests/testthat/_snaps/grids.md b/tests/testthat/_snaps/grids.md index fc9d5ab3..7af9a5c7 100644 --- a/tests/testthat/_snaps/grids.md +++ b/tests/testthat/_snaps/grids.md @@ -12,7 +12,8 @@ grid_regular(mixture(), trees(), size = 3) Condition Warning: - `size` is not an argument to `grid_regular()`. Did you mean `levels`? + `size` is not an argument to `grid_regular()`. + i Did you mean `levels`? Error in `parameters()`: ! The objects should all be `param` objects. @@ -73,7 +74,8 @@ grid_regular(p, size = 5) Condition Warning: - `size` is not an argument to `grid_regular()`. Did you mean `levels`? + `size` is not an argument to `grid_regular()`. + i Did you mean `levels`? Output # A tibble: 9 x 2 penalty mixture From a8461082ac24f3275900824aa70ee13f49174a32 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Fri, 20 Sep 2024 10:48:09 +0100 Subject: [PATCH 4/4] add info bullet to warnings --- R/grids.R | 6 +++--- R/space_filling.R | 18 +++++++++--------- tests/testthat/_snaps/grids.md | 9 ++++++--- tests/testthat/_snaps/space_filling.md | 3 ++- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/R/grids.R b/R/grids.R index 695da082..cdd7ae54 100644 --- a/R/grids.R +++ b/R/grids.R @@ -171,9 +171,9 @@ make_regular_grid <- function(..., grid_random <- function(x, ..., size = 5, original = TRUE, filter = NULL) { dots <- list(...) if (any(names(dots) == "levels")) { - cli::cli_warn( - "{.arg levels} is not an argument to {.fn grid_random}. - Did you mean {.arg size}?" + cli::cli_warn(c( + "{.arg levels} is not an argument to {.fn grid_random}.", + i = "Did you mean {.arg size}?") ) } UseMethod("grid_random") diff --git a/R/space_filling.R b/R/space_filling.R index 6644e7f4..ac7862ff 100644 --- a/R/space_filling.R +++ b/R/space_filling.R @@ -92,9 +92,9 @@ grid_space_filling <- function(x, ..., size = 5, type = "any", original = TRUE) { dots <- list(...) if (any(names(dots) == "levels")) { - cli::cli_warn( - "{.arg levels} is not an argument to {.fn grid_space_filling}. - Did you mean {.arg size}?" + cli::cli_warn(c( + "{.arg levels} is not an argument to {.fn grid_space_filling}.", + i = "Did you mean {.arg size}?") ) } UseMethod("grid_space_filling") @@ -283,9 +283,9 @@ grid_max_entropy <- function(x, dots <- list(...) if (any(names(dots) == "levels")) { - cli::cli_warn( - "{.arg levels} is not an argument to {.fn grid_max_entropy}. - Did you mean {.arg size}?" + cli::cli_warn(c( + "{.arg levels} is not an argument to {.fn grid_max_entropy}.", + i = "Did you mean {.arg size}?") ) } UseMethod("grid_max_entropy") @@ -413,9 +413,9 @@ grid_latin_hypercube <- function(x, ..., size = 3, original = TRUE) { dots <- list(...) if (any(names(dots) == "levels")) { - cli::cli_warn( - "{.arg levels} is not an argument to {.fn grid_latin_hypercube}. - Did you mean {.arg size}?" + cli::cli_warn(c( + "{.arg levels} is not an argument to {.fn grid_latin_hypercube}.", + i = "Did you mean {.arg size}?") ) } UseMethod("grid_latin_hypercube") diff --git a/tests/testthat/_snaps/grids.md b/tests/testthat/_snaps/grids.md index 7af9a5c7..0958df24 100644 --- a/tests/testthat/_snaps/grids.md +++ b/tests/testthat/_snaps/grids.md @@ -23,7 +23,8 @@ grid_space_filling(p, levels = 5, type = "latin_hypercube") Condition Warning: - `levels` is not an argument to `grid_space_filling()`. Did you mean `size`? + `levels` is not an argument to `grid_space_filling()`. + i Did you mean `size`? Output # A tibble: 5 x 2 penalty mixture @@ -40,7 +41,8 @@ grid_space_filling(p, levels = 5, type = "max_entropy") Condition Warning: - `levels` is not an argument to `grid_space_filling()`. Did you mean `size`? + `levels` is not an argument to `grid_space_filling()`. + i Did you mean `size`? Output # A tibble: 5 x 2 penalty mixture @@ -57,7 +59,8 @@ grid_random(p, levels = 5) Condition Warning: - `levels` is not an argument to `grid_random()`. Did you mean `size`? + `levels` is not an argument to `grid_random()`. + i Did you mean `size`? Output # A tibble: 5 x 2 penalty mixture diff --git a/tests/testthat/_snaps/space_filling.md b/tests/testthat/_snaps/space_filling.md index 68ebf2f9..5a5aabdc 100644 --- a/tests/testthat/_snaps/space_filling.md +++ b/tests/testthat/_snaps/space_filling.md @@ -52,7 +52,8 @@ des <- grid_space_filling(prm, levels = size, type = "uniform") Condition Warning: - `levels` is not an argument to `grid_space_filling()`. Did you mean `size`? + `levels` is not an argument to `grid_space_filling()`. + i Did you mean `size`? # very small designs