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

replace rlang::warn() with cli::cli_warn() #350

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions R/grids.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@
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(
c(
"{.arg size} is not an argument to {.fn grid_regular}.",
i = "Did you mean {.arg levels}?"
)
)
}
UseMethod("grid_regular")
}
Expand Down Expand Up @@ -166,8 +171,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(c(
"{.arg levels} is not an argument to {.fn grid_random}.",
i = "Did you mean {.arg size}?")
)
}
UseMethod("grid_random")
Expand Down
15 changes: 11 additions & 4 deletions R/space_filling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(c(
"{.arg levels} is not an argument to {.fn grid_space_filling}.",
i = "Did you mean {.arg size}?")
)
}
UseMethod("grid_space_filling")
Expand Down Expand Up @@ -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(c(
"{.arg levels} is not an argument to {.fn grid_max_entropy}.",
i = "Did you mean {.arg size}?")
)
}
UseMethod("grid_max_entropy")
}
Expand Down Expand Up @@ -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(c(
"{.arg levels} is not an argument to {.fn grid_latin_hypercube}.",
i = "Did you mean {.arg size}?")
)
}
UseMethod("grid_latin_hypercube")
}
Expand Down
15 changes: 10 additions & 5 deletions tests/testthat/_snaps/grids.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -22,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
Expand All @@ -39,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
Expand All @@ -56,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
Expand All @@ -73,7 +77,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
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/_snaps/space_filling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading