Setters, getters, and validators for parameter ranges.
range_validate(object, range, ukn_ok = TRUE) range_get(object, original = TRUE) range_set(object, range)
object | An object with class |
---|---|
range | A two-element numeric vector or list (including |
ukn_ok | A single logical for whether |
original | A single logical. Should the range values be in the natural
units ( |
range_validate()
returns the new range if it passes the validation
process (and throws an error otherwise).
range_get()
returns the current range of the object.
range_set()
returns an updated version of the parameter object with
a new range.
library(dplyr) my_lambda <- penalty() %>% value_set(-4:-1) try( range_validate(my_lambda, c(-10, NA)), silent = TRUE ) %>% print()#> [1] "Error : Value ranges must be non-missing.\n" #> attr(,"class") #> [1] "try-error" #> attr(,"condition") #> <error/`Inf` and `unknown()` are acceptable values.> #> Value ranges must be non-missing. #> Backtrace: #> 1. pkgdown::deploy_to_branch(new_process = FALSE) #> 2. pkgdown::build_site(...) #> 3. pkgdown:::build_site_local(...) #> 4. pkgdown::build_reference(...) #> 5. purrr::map(...) #> 6. pkgdown:::.f(.x[[i]], ...) #> 8. pkgdown:::data_reference_topic(...) #> 9. pkgdown:::run_examples(...) #> 10. pkgdown:::highlight_examples(code, topic, env = env) #> 11. downlit::evaluate_and_highlight(...) #> 12. evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. evaluate:::evaluate_call(...) #> 23. [ base::eval(...) ] with 1 more call #> 33. dials::range_validate(my_lambda, c(-10, NA))range_get(my_lambda)#> $lower #> [1] 1e-10 #> #> $upper #> [1] 1 #>#> $lower #> [1] 1e-10 #> #> $upper #> [1] 100 #>