Skip to content

Commit 928c928

Browse files
authored
Remove functions/arguments deprecated in purrr 0.3.0 (#1193)
Some of these hung on because we didn't properly flag as deprecated, but I think it's time to let them go. The revdep checks support this decision. Part of #1148
1 parent 465b566 commit 928c928

27 files changed

+1314
-629
lines changed

NAMESPACE

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ S3method(print,purrr_rate_delay)
1111
S3method(rate_sleep,purrr_rate_backoff)
1212
S3method(rate_sleep,purrr_rate_delay)
1313
export("%>%")
14-
export("%@%")
1514
export("%||%")
1615
export("pluck<-")
1716
export(accumulate)
1817
export(accumulate2)
19-
export(accumulate_right)
2018
export(array_branch)
2119
export(array_tree)
2220
export(as_mapper)
2321
export(as_vector)
2422
export(assign_in)
25-
export(at_depth)
2623
export(attr_getter)
2724
export(auto_browse)
2825
export(chuck)
@@ -31,9 +28,7 @@ export(compose)
3128
export(cross)
3229
export(cross2)
3330
export(cross3)
34-
export(cross_d)
3531
export(cross_df)
36-
export(cross_n)
3732
export(detect)
3833
export(detect_index)
3934
export(discard)
@@ -182,8 +177,6 @@ export(rbernoulli)
182177
export(rdunif)
183178
export(reduce)
184179
export(reduce2)
185-
export(reduce2_right)
186-
export(reduce_right)
187180
export(rep_along)
188181
export(rerun)
189182
export(safely)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# purrr (development version)
22

3+
* All functions and arguments deprecated in purrr 0.3.0 have now been removed. This includes `%@%`, `accumulate_right()`, `at_depth()`, `cross_d()`, `cross_n()`, `reduce2_right()`, and `reduce_right()`.
4+
35
# purrr 1.1.0
46

57
* purrr now requires R >= 4.1, so we can rely on the base pipe and lambda

R/adverb-partial.R

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131
#' These dots support quasiquotation. If you unquote a value, it is
3232
#' evaluated only once at function creation time. Otherwise, it is
3333
#' evaluated each time the function is called.
34-
#' @param .env `r lifecycle::badge("deprecated")` The environments are
35-
#' now captured via quosures.
36-
#' @param .first `r lifecycle::badge("deprecated")` Please pass an
37-
#' empty argument `... = ` to specify the position of future
38-
#' arguments.
39-
#' @param .lazy `r lifecycle::badge("deprecated")` Please unquote the
40-
#' arguments that should be evaluated once at function creation time
41-
#' with `!!`.
42-
#'
4334
#' @inheritSection safely Adverbs
4435
#' @inherit safely return
4536
#' @family adverbs
@@ -88,13 +79,7 @@
8879
#' # `... = ` argument:
8980
#' my_list <- partial(list, 1, ... = , 2)
9081
#' my_list("foo")
91-
partial <- function(
92-
.f,
93-
...,
94-
.env = deprecated(),
95-
.lazy = deprecated(),
96-
.first = deprecated()
97-
) {
82+
partial <- function(.f, ...) {
9883
args <- enquos(...)
9984

10085
fn_expr <- enexpr(.f)
@@ -109,22 +94,6 @@ partial <- function(
10994
)
11095
)
11196

112-
if (lifecycle::is_present(.env)) {
113-
lifecycle::deprecate_warn("0.3.0", "partial(.env)", always = TRUE)
114-
}
115-
if (lifecycle::is_present(.lazy)) {
116-
lifecycle::deprecate_warn("0.3.0", "partial(.lazy)", always = TRUE)
117-
if (!.lazy) {
118-
args <- map(
119-
args,
120-
~ new_quosure(eval_tidy(.x, env = caller_env()), empty_env())
121-
)
122-
}
123-
}
124-
if (lifecycle::is_present(.first)) {
125-
lifecycle::deprecate_warn("0.3.0", "partial(.first)", always = TRUE)
126-
}
127-
12897
env <- caller_env()
12998
heterogeneous_envs <- !every(args, quo_is_same_env, env)
13099

@@ -135,15 +104,10 @@ partial <- function(
135104
# Reuse function symbol if possible
136105
fn_sym <- if (is_symbol(fn_expr)) fn_expr else quote(.fn)
137106

138-
if (is_false(.first)) {
139-
# For compatibility
140-
call <- call_modify(call2(fn_sym), ... = , !!!args)
141-
} else {
142-
# Pass on `...` from parent function. It should be last, this way if
143-
# `args` also contain a `...` argument, the position in `args`
144-
# prevails.
145-
call <- call_modify(call2(fn_sym), !!!args, ... = )
146-
}
107+
# Pass on `...` from parent function. It should be last, this way if
108+
# `args` also contain a `...` argument, the position in `args`
109+
# prevails.
110+
call <- call_modify(call2(fn_sym), !!!args, ... = )
147111

148112
if (heterogeneous_envs) {
149113
# Forward caller environment where S3 methods might be defined.

R/deprec-cross.R

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,3 @@ cross_df <- function(.l, .filter = NULL) {
203203
simplify_all() |>
204204
tibble::as_tibble()
205205
}
206-
207-
#' @export
208-
#' @usage NULL
209-
#' @rdname cross
210-
cross_n <- function(...) {
211-
lifecycle::deprecate_stop("0.2.3", "purrr::cross_n()")
212-
cross(...)
213-
}
214-
215-
#' @export
216-
#' @usage NULL
217-
#' @rdname cross
218-
cross_d <- function(...) {
219-
lifecycle::deprecate_stop("0.2.3", "purrr::cross_d()")
220-
cross_df(...)
221-
}

R/deprec-map.R

Lines changed: 0 additions & 11 deletions
This file was deleted.

R/deprec-utils.R

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
#' Infix attribute accessor
2-
#'
3-
#' @description
4-
#' `r lifecycle::badge("deprecated")`
5-
#'
6-
#' This function was deprecated in purrr 0.3.0. Instead, lease use the `%@%`
7-
#' operator exported in rlang. It has an interface more consistent with `@`:
8-
#' uses NSE, supports S4 fields, and has an assignment variant.
9-
#'
10-
#' @param x Object
11-
#' @param name Attribute name
12-
#' @export
13-
#' @name get-attr
14-
#' @keywords internal
15-
`%@%` <- function(x, name) {
16-
lifecycle::deprecate_warn("0.3.0", I("%@%"), I("rlang::%@%"), always = TRUE)
17-
attr(x, name, exact = TRUE)
18-
}
19-
201
#' Generate random sample from a Bernoulli distribution
212
#'
223
#' @description

R/detect.R

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#' @param .dir If `"forward"`, the default, starts at the beginning of
1616
#' the vector and move towards the end; if `"backward"`, starts at
1717
#' the end of the vector and moves towards the beginning.
18-
#' @param .right `r lifecycle::badge("deprecated")` Please use `.dir` instead.
1918
#' @param .default The value returned when nothing is detected.
2019
#' @return `detect` the value of the first item that matches the
2120
#' predicate; `detect_index` the position of the matching item.
@@ -51,18 +50,11 @@
5150
#'
5251
#' # If you need to find all positions, use map_lgl():
5352
#' which(map_lgl(x, "foo"))
54-
detect <- function(
55-
.x,
56-
.f,
57-
...,
58-
.dir = c("forward", "backward"),
59-
.right = NULL,
60-
.default = NULL
61-
) {
53+
detect <- function(.x, .f, ..., .dir = c("forward", "backward"), .default = NULL) {
6254
.f <- as_predicate(.f, ..., .mapper = TRUE)
6355
.dir <- arg_match0(.dir, c("forward", "backward"))
6456

65-
for (i in index(.x, .dir, .right, "detect")) {
57+
for (i in index(.x, .dir, "detect")) {
6658
if (.f(.x[[i]], ...)) {
6759
return(.x[[i]])
6860
}
@@ -73,17 +65,11 @@ detect <- function(
7365

7466
#' @export
7567
#' @rdname detect
76-
detect_index <- function(
77-
.x,
78-
.f,
79-
...,
80-
.dir = c("forward", "backward"),
81-
.right = NULL
82-
) {
68+
detect_index <- function(.x, .f, ..., .dir = c("forward", "backward")) {
8369
.f <- as_predicate(.f, ..., .mapper = TRUE)
8470
.dir <- arg_match0(.dir, c("forward", "backward"))
8571

86-
for (i in index(.x, .dir, .right, "detect_index")) {
72+
for (i in index(.x, .dir, "detect_index")) {
8773
if (.f(.x[[i]], ...)) {
8874
return(i)
8975
}
@@ -94,16 +80,6 @@ detect_index <- function(
9480

9581

9682
index <- function(x, dir, right = NULL, fn) {
97-
if (!is_null(right)) {
98-
lifecycle::deprecate_warn(
99-
when = "0.3.0",
100-
what = paste0(fn, "(.right)"),
101-
with = paste0(fn, "(.dir)"),
102-
always = TRUE
103-
)
104-
dir <- if (right) "backward" else "forward"
105-
}
106-
10783
idx <- seq_along(x)
10884
if (dir == "backward") {
10985
idx <- rev(idx)

R/reduce.R

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,6 @@ seq_len2 <- function(start, end) {
386386
#'
387387
#' @inheritSection reduce Direction
388388
#'
389-
#' @section Life cycle:
390-
#'
391-
#' `accumulate_right()` is soft-deprecated in favour of the `.dir`
392-
#' argument as of rlang 0.3.0. Note that the algorithm has
393-
#' slightly changed: the accumulated value is passed to the right
394-
#' rather than the left, which is consistent with a right reduction.
395-
#'
396389
#' @seealso [reduce()] when you only need the final reduced value.
397390
#' @examples
398391
#' # With an associative operation, the final value is always the
@@ -513,75 +506,3 @@ accumulate_names <- function(nms, init, dir) {
513506

514507
nms
515508
}
516-
517-
#' Reduce from the right (retired)
518-
#'
519-
#' @description
520-
#' `r lifecycle::badge("deprecated")`
521-
#'
522-
#' `reduce_right()` is soft-deprecated as of purrr 0.3.0. Please use
523-
#' the `.dir` argument of `reduce()` instead. Note that the algorithm
524-
#' has changed. Whereas `reduce_right()` computed `f(f(3, 2), 1)`,
525-
#' `reduce(.dir = \"backward\")` computes `f(1, f(2, 3))`. This is the
526-
#' standard way of reducing from the right.
527-
#'
528-
#' To update your code with the same reduction as `reduce_right()`,
529-
#' simply reverse your vector and use a left reduction:
530-
#'
531-
#' ```R
532-
#' # Before:
533-
#' reduce_right(1:3, f)
534-
#'
535-
#' # After:
536-
#' reduce(rev(1:3), f)
537-
#' ```
538-
#'
539-
#' `reduce2_right()` is deprecated as of purrr 0.3.0 without
540-
#' replacement. It is not clear what algorithmic properties should a
541-
#' right reduction have in this case. Please reach out if you know
542-
#' about a use case for a right reduction with a ternary function.
543-
#'
544-
#' @inheritParams reduce
545-
#' @keywords internal
546-
#' @export
547-
reduce_right <- function(.x, .f, ..., .init) {
548-
lifecycle::deprecate_warn(
549-
when = "0.3.0",
550-
what = "reduce_right()",
551-
with = "reduce(.dir)",
552-
always = TRUE
553-
)
554-
555-
.x <- rev(.x) # Compatibility
556-
reduce_impl(.x, .f, ..., .dir = "forward", .init = .init)
557-
}
558-
#' @rdname reduce_right
559-
#' @export
560-
reduce2_right <- function(.x, .y, .f, ..., .init) {
561-
lifecycle::deprecate_warn(
562-
when = "0.3.0",
563-
what = "reduce2_right()",
564-
with = I("reverse your vectors and use `reduce2()`"),
565-
always = TRUE
566-
)
567-
568-
reduce2_impl(.x, .y, .f, ..., .init = .init, .left = FALSE)
569-
}
570-
571-
#' @rdname reduce_right
572-
#' @export
573-
accumulate_right <- function(.x, .f, ..., .init) {
574-
lifecycle::deprecate_warn(
575-
when = "0.3.0",
576-
what = "accumulate_right()",
577-
with = "accumulate(.dir)",
578-
always = TRUE
579-
)
580-
581-
# Note the order of arguments is switched
582-
f <- function(y, x) {
583-
.f(x, y, ...)
584-
}
585-
586-
accumulate(.x, f, .init = .init, .dir = "backward")
587-
}

man/accumulate.Rd

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/at_depth.Rd

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)