-
Notifications
You must be signed in to change notification settings - Fork 42
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
sort ids via vctrs, pass sorting to pull_*()
helpers
#730
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,14 @@ tune_grid_loop <- function(resamples, | |
rng | ||
) | ||
|
||
resamples <- pull_metrics(resamples, results, control) | ||
resamples <- pull_notes(resamples, results, control) | ||
resamples <- pull_extracts(resamples, results, control) | ||
resamples <- pull_predictions(resamples, results, control) | ||
# carry out arranging by id before extracting each element of results (#728) | ||
resample_ids <- grep("^id", names(resamples), value = TRUE) | ||
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. This is the pattern used by |
||
id_order <- vctrs::vec_order(resamples[resample_ids]) | ||
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. I don't suspect this is any different than passing those columns to 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.
|
||
|
||
resamples <- pull_metrics(resamples, results, control, order = id_order) | ||
resamples <- pull_notes(resamples, results, control, order = id_order) | ||
resamples <- pull_extracts(resamples, results, control, order = id_order) | ||
resamples <- pull_predictions(resamples, results, control, order = id_order) | ||
resamples <- pull_all_outcome_names(resamples, results) | ||
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. Note that this function doesn't gain an |
||
|
||
resamples | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ extract_details <- function(object, extractor) { | |
|
||
# Grab the new results, make sure that they align row-wise with the rsample | ||
# object and then bind columns | ||
pulley <- function(resamples, res, col) { | ||
pulley <- function(resamples, res, col, order) { | ||
if (all(purrr::map_lgl(res, inherits, "simpleError"))) { | ||
res <- | ||
resamples %>% | ||
|
@@ -22,7 +22,9 @@ pulley <- function(resamples, res, col) { | |
all_null <- all(purrr::map_lgl(res, is.null)) | ||
|
||
id_cols <- grep("^id", names(resamples), value = TRUE) | ||
resamples <- dplyr::arrange(resamples, !!!syms(id_cols)) | ||
|
||
resamples <- vctrs::vec_slice(resamples, order) | ||
|
||
pulled_vals <- purrr::map(res, ~ .x[[col]]) %>% purrr::list_rbind() | ||
|
||
if (nrow(pulled_vals) == 0) { | ||
|
@@ -65,22 +67,22 @@ maybe_repair <- function(x) { | |
} | ||
|
||
|
||
pull_metrics <- function(resamples, res, control) { | ||
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. The remainder of the changes in this file just newly pass |
||
out <- pulley(resamples, res, ".metrics") | ||
pull_metrics <- function(resamples, res, control, order) { | ||
out <- pulley(resamples, res, ".metrics", order = order) | ||
out$.metrics <- maybe_repair(out$.metrics) | ||
out | ||
} | ||
|
||
pull_extracts <- function(resamples, res, control) { | ||
pull_extracts <- function(resamples, res, control, order) { | ||
if (!is.null(control$extract)) { | ||
resamples <- pulley(resamples, res, ".extracts") | ||
resamples <- pulley(resamples, res, ".extracts", order = order) | ||
} | ||
resamples | ||
} | ||
|
||
pull_predictions <- function(resamples, res, control) { | ||
pull_predictions <- function(resamples, res, control, order) { | ||
if (control$save_pred) { | ||
resamples <- pulley(resamples, res, ".predictions") | ||
resamples <- pulley(resamples, res, ".predictions", order = order) | ||
resamples$.predictions <- maybe_repair(resamples$.predictions) | ||
} | ||
resamples | ||
|
@@ -126,8 +128,10 @@ ensure_tibble <- function(x) { | |
res | ||
} | ||
|
||
pull_notes <- function(resamples, res, control) { | ||
resamples$.notes <- purrr::map(res, ~ purrr::pluck(.x, ".notes")) | ||
pull_notes <- function(resamples, res, control, order) { | ||
notes <- purrr::map(res, ~ purrr::pluck(.x, ".notes")) | ||
resamples$.notes <- notes[order] | ||
|
||
resamples | ||
} | ||
|
||
|
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.
Previously this sorting happened independently for each of the
pull_*()
functions that callpulley()
. For those that don't callpulley()
, the ordering is wrong.