-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement `tune_args()` and `tunable()` * remove redundant method * namespace fn in test * more machinery from recipes * add vctrs to Imports * test `find_tune_id()` * add snapshot * address `vec_rbind()` internal error re: bad recycling * update for new object structure * add `extract_parameter_set_dials()` method * migrate check helper from workflows * generate snaps
- Loading branch information
1 parent
317a4db
commit 776c2f4
Showing
23 changed files
with
517 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#' @export | ||
extract_parameter_set_dials.tailor <- function(x, ...) { | ||
all_args <- generics::tunable(x) | ||
tuning_param <- generics::tune_args(x) | ||
res <- | ||
dplyr::inner_join( | ||
tuning_param %>% dplyr::select(-tunable), | ||
all_args, | ||
by = c("name", "source", "component", "component_id") | ||
) %>% | ||
dplyr::mutate(object = purrr::map(call_info, eval_call_info)) | ||
|
||
dials::parameters_constr( | ||
res$name, | ||
res$id, | ||
res$source, | ||
res$component, | ||
res$component_id, | ||
res$object | ||
) | ||
} | ||
|
||
eval_call_info <- function(x) { | ||
if (!is.null(x)) { | ||
# Look for other options | ||
allowed_opts <- c("range", "trans", "values") | ||
if (any(names(x) %in% allowed_opts)) { | ||
opts <- x[names(x) %in% allowed_opts] | ||
} else { | ||
opts <- list() | ||
} | ||
res <- try(rlang::eval_tidy(rlang::call2(x$fun, .ns = x$pkg, !!!opts)), silent = TRUE) | ||
if (inherits(res, "try-error")) { | ||
cli::cli_abort( | ||
"Error when calling {.fn {x$fun}}: {as.character(res)}" | ||
) | ||
} | ||
} else { | ||
res <- NA | ||
} | ||
res | ||
} | ||
|
||
#' @export | ||
extract_parameter_dials.tailor <- function(x, parameter, ...) { | ||
extract_parameter_dials(extract_parameter_set_dials(x), parameter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# extract single parameter from tailor with no adjustments | ||
|
||
Code | ||
extract_parameter_dials(tailor(), parameter = "none there") | ||
Condition | ||
Error in `extract_parameter_dials()`: | ||
! No parameter exists with id "none there". | ||
|
||
# extract single parameter from tailor with no tunable parameters | ||
|
||
Code | ||
extract_parameter_dials(tlr, parameter = "none there") | ||
Condition | ||
Error in `extract_parameter_dials()`: | ||
! No parameter exists with id "none there". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.