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

Enforce empty dots for parameters.list() #378

Merged
merged 2 commits into from
Feb 12, 2025
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* The constructors, `new_*_parameter()`, now label unlabeled parameter (i.e., constructed with `label = NULL`) as such (#349).

* `parameters.list()` now enforces the unused ellipsis to be empty (#378).

## Breaking changes

* The `grid_*()` functions now error instead of warn when provided with the wrong argument to control the grid size. So `grid_space_filling()`, `grid_random()`, `grid_max_entropy()`, and `grid_latin_hypercube()` now error if used with a `levels` argument and `grid_regular()` now errors if used with a `size` argument (#368).
Expand Down
4 changes: 3 additions & 1 deletion R/parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ parameters.param <- function(x, ...) {
#' @export
#' @rdname parameters
parameters.list <- function(x, ...) {
check_dots_empty()

elem_param <- purrr::map_lgl(x, inherits, "param")
if (any(!elem_param)) {
cli::cli_abort("The objects should all be {.cls param} objects.")
}
elem_name <- purrr::map_chr(x, ~ names(.x$label))
elem_name <- purrr::map_chr(x, ~names(.x$label))
elem_id <- names(x)
if (length(elem_id) == 0) {
elem_id <- elem_name
Expand Down
Loading