You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve checking of parameter inputs to parameters() and grid_*() functions #422
Original title: Consolidate check_list_of_param() and validate_params()
We only really need one function, but we will give it allow_na and allow_unknown arguments. A possible name is check_param_list() as it should operate on the list of param objects.
The grid functions, which currently call validate_params(), need to then collect the dots in a list first but that's not too much overhead and only have to maintain and remember about one checking function.
Looking at this from the perspective of the outcome, i.e., the error messages, rather than the code structure. Note that the nice-looking error message in validate_params() about which elements should be param objects never actually fires because it's caught in parameters() first.
library(dials)
#> Loading required package: scales# constructor -----------------------------# no input# should error (for now) but has a cli error that shouldn't show
parameters()
#> Error:#> ! ! Could not evaluate cli `{}` expression: `x`.#> Caused by error in `eval(expr, envir = envir)`:#> ! argument "x" is missing, with no default# dispatch from param object## should error but doesn't tell you which one is wrong
parameters(mtry(), "min_n")
#> Error in `parameters()`:#> ! The objects should all be <param> objects.# dispatch from list## should error but doesn't tell you which one is wrong
parameters(list(mtry(), "min_n"))
#> Error in `parameters()`:#> ! The objects should all be <param> objects.# grid functions ----------------------# should this error or just return an empty tibble? # #428# if it should error, it needs a better error message
grid_regular()
#> Error in `UseMethod()`:#> ! no applicable method for 'grid_regular' applied to an object of class "NULL"# dispatch from param object## fires from constructor, ## thus doesn't tell you which one is wrong *and* ## has the wrong call
grid_regular(penalty(), "min_n")
#> Error in `parameters()`:#> ! The objects should all be <param> objects.# dispatch from list## fires from constructor, ## thus doesn't tell you which one is wrong *and* ## has the wrong call
grid_regular(list(mtry(), "min_n"))
#> Error in `parameters()`:#> ! The objects should all be <param> objects.
changed the title [-]Consolidate `check_list_of_param()` and `validate_params()`[/-][+]Improve checking of parameter inputs to `parameters()` and `grid_*()` functions[/+]on Apr 8, 2026
Activity
hfrick commentedon Feb 24, 2026
Looking at this from the perspective of the outcome, i.e., the error messages, rather than the code structure. Note that the nice-looking error message in
validate_params()about which elements should beparamobjects never actually fires because it's caught inparameters()first.Created on 2026-02-23 with reprex v2.1.1
[-]Consolidate `check_list_of_param()` and `validate_params()`[/-][+]Improve checking of parameter inputs to `parameters()` and `grid_*()` functions[/+]