-
Notifications
You must be signed in to change notification settings - Fork 2
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
implement tune_args()
and tunable()
#51
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95e28be
implement `tune_args()` and `tunable()`
simonpcouch 97b6c9b
remove redundant method
simonpcouch cc34d8a
namespace fn in test
simonpcouch 9586c09
more machinery from recipes
simonpcouch 1117bce
add vctrs to Imports
simonpcouch 1e21f19
test `find_tune_id()`
simonpcouch 71d1224
add snapshot
simonpcouch 6b3013e
address `vec_rbind()` internal error re: bad recycling
simonpcouch 6df8c9e
update for new object structure
simonpcouch 5a0e3e3
add `extract_parameter_set_dials()` method
simonpcouch 67634c5
migrate check helper from workflows
simonpcouch 2221e95
generate snaps
simonpcouch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make a small standalone file? If not, add some notes/link to original and (same for other replicas below) |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no arguments here, but I'm curious why you made that change. Is it for readability (since these aren't likely to be called a large number of times)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling that out. I'd like to revisit that and return to using
new_tibble()
, though there was a vector recycling issue that resulted in an interval vctrs error later on; I think we'll just need to do some manualrep()
ping.