Skip to content

Commit e7f7b41

Browse files
authored
transition from deprecated map_df*() variants (#942)
1 parent 07525af commit e7f7b41

File tree

11 files changed

+32
-22
lines changed

11 files changed

+32
-22
lines changed

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ importFrom(purrr,imap_lgl)
359359
importFrom(purrr,map)
360360
importFrom(purrr,map_chr)
361361
importFrom(purrr,map_dbl)
362-
importFrom(purrr,map_df)
363-
importFrom(purrr,map_dfr)
364362
importFrom(purrr,map_lgl)
365363
importFrom(rlang,abort)
366364
importFrom(rlang,call2)

R/aaa_models.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,11 @@ show_model_info <- function(model) {
957957
cat(" engines: \n")
958958

959959
weight_info <-
960-
purrr::map_df(
960+
purrr::map(
961961
model,
962962
~ get_from_env(paste0(.x, "_fit")) %>% mutate(model = .x)
963963
) %>%
964+
purrr::list_rbind() %>%
964965
dplyr::mutate(protect = map(value, ~ .x$protect)) %>%
965966
dplyr::select(-value) %>%
966967
dplyr::mutate(

R/boost_tree.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,10 @@ multi_predict._xgb.Booster <-
492492
type <- "numeric"
493493
}
494494

495-
res <- map_df(trees, xgb_by_tree, object = object, new_data = new_data,
496-
type = type, ...)
495+
res <-
496+
map(trees, xgb_by_tree, object = object, new_data = new_data,
497+
type = type, ...) %>%
498+
purrr::list_rbind()
497499
res <- arrange(res, .row, trees)
498500
res <- split(res[, -1], res$.row)
499501
names(res) <- NULL
@@ -612,8 +614,9 @@ multi_predict._C5.0 <-
612614
type <- "class"
613615

614616
res <-
615-
map_df(trees, C50_by_tree, object = object,
616-
new_data = new_data, type = type, ...)
617+
map(trees, C50_by_tree, object = object,
618+
new_data = new_data, type = type, ...) %>%
619+
purrr::list_rbind()
617620
res <- arrange(res, .row, trees)
618621
res <- split(res[, -1], res$.row)
619622
names(res) <- NULL

R/engine_docs.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ extensions <- function() {
7777
update_model_info_file <- function(path = "inst/models.tsv") {
7878
mods <- get_from_env("models")
7979
info <-
80-
purrr::map_dfr(mods, ~ get_from_env(.x) %>% dplyr::mutate(model = .x)) %>%
80+
purrr::map(mods, ~ get_from_env(.x) %>% dplyr::mutate(model = .x)) %>%
81+
purrr::list_rbind() %>%
8182
dplyr::arrange(model, mode, engine) %>%
8283
dplyr::select(model, mode, engine)
8384
exts <-
84-
purrr::map_dfr(
85+
purrr::map(
8586
mods,
8687
~ get_from_env(paste0(.x, "_pkgs")) %>% dplyr::mutate(model = .x)
8788
) %>%
89+
purrr::list_rbind() %>%
8890
tidyr::unnest(cols = "pkg") %>%
8991
dplyr::inner_join(tibble::tibble(pkg = extensions()), by = "pkg")
9092

@@ -310,5 +312,5 @@ list_md_problems <- function() {
310312
tibble(basename(file), line, problem)
311313
}
312314

313-
purrr::map_dfr(md_files, get_errors)
315+
purrr::map(md_files, get_errors) %>% purrr::list_rbind()
314316
}

R/install_packages.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ install_engine_packages <- function(extension = TRUE, extras = TRUE,
1414
bio_pkgs <- c(bio_pkgs, "mixOmics")
1515
}
1616

17-
engine_packages <- purrr::map_dfr(
17+
engine_packages <- purrr::map(
1818
ls(envir = get_model_env(), pattern = "_pkgs$"),
1919
get_from_env
2020
) %>%
21+
purrr::list_rbind() %>%
2122
dplyr::pull(pkg) %>%
2223
unlist() %>%
2324
unique() %>%

R/mars.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ check_args.mars <- function(object) {
126126

127127
earth_submodel_pred <- function(object, new_data, terms = 2:3, ...) {
128128
load_libs(object, quiet = TRUE, attach = TRUE)
129-
map_dfr(terms, earth_reg_updater, object = object, newdata = new_data, ...)
129+
map(terms, earth_reg_updater, object = object, newdata = new_data, ...) %>%
130+
purrr::list_rbind()
130131
}
131132

132133
earth_reg_updater <- function(num, object, new_data, ...) {
@@ -184,8 +185,9 @@ multi_predict._earth <-
184185
}
185186

186187
res <-
187-
map_df(num_terms, earth_by_terms, object = object,
188-
new_data = new_data, type = type, ...)
188+
map(num_terms, earth_by_terms, object = object,
189+
new_data = new_data, type = type, ...) %>%
190+
purrr::list_rbind()
189191
res <- arrange(res, .row, num_terms)
190192
res <- split(res[, -1], res$.row)
191193
names(res) <- NULL

R/mlp.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ mlp_num_weights <- function(p, hidden_units, classes) {
359359

360360
## -----------------------------------------------------------------------------
361361

362-
#' @importFrom purrr map_df map
362+
#' @importFrom purrr map
363363
#' @importFrom dplyr arrange select
364364
#' @rdname multi_predict
365365
#' @param epochs An integer vector for the number of training epochs.
@@ -384,7 +384,8 @@ multi_predict._torch_mlp <-
384384
purrr::map(epochs,
385385
~ predict(object, new_data, type, epochs = .x) %>%
386386
dplyr::mutate(epochs = .x)) %>%
387-
purrr::map_dfr(~ .x %>% dplyr::mutate(.row = 1:nrow(new_data))) %>%
387+
purrr::map(~ .x %>% dplyr::mutate(.row = 1:nrow(new_data))) %>%
388+
purrr::list_rbind() %>%
388389
dplyr::arrange(.row, epochs)
389390
res <- split(dplyr::select(res, -.row), res$.row)
390391
names(res) <- NULL

R/nearest_neighbor.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ multi_predict._train.kknn <-
161161
}
162162

163163
res <-
164-
purrr::map_df(neighbors, knn_by_k, object = object,
165-
new_data = new_data, type = type, ...)
164+
purrr::map(neighbors, knn_by_k, object = object,
165+
new_data = new_data, type = type, ...) %>%
166+
purrr::list_rbind()
166167
res <- dplyr::arrange(res, .row, neighbors)
167168
res <- split(res[, -1], res$.row)
168169
names(res) <- NULL

R/parsnip-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' @importFrom glue glue_collapse
1616
#' @importFrom lifecycle deprecated
1717
#' @importFrom pillar type_sum
18-
#' @importFrom purrr as_vector imap imap_lgl map map_chr map_dbl map_df map_dfr
18+
#' @importFrom purrr as_vector imap imap_lgl map map_chr map_dbl
1919
#' @importFrom purrr map_lgl %||%
2020
#' @importFrom rlang abort call2 caller_env current_env enquo enquos eval_tidy
2121
#' @importFrom rlang expr get_expr is_empty is_missing is_null is_quosure

R/varying.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ varying_args.recipe <- function(object, full = TRUE, ...) {
112112
return(varying_tbl())
113113
}
114114

115-
map_dfr(object$steps, varying_args, full = full)
115+
map(object$steps, varying_args, full = full) %>% purrr::list_rbind()
116116
}
117117

118118
#' @export

0 commit comments

Comments
 (0)