Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ S3method(print,purrr_rate_delay)
S3method(rate_sleep,purrr_rate_backoff)
S3method(rate_sleep,purrr_rate_delay)
export("%>%")
export("%@%")
export("%||%")
export("pluck<-")
export(accumulate)
export(accumulate2)
export(accumulate_right)
export(array_branch)
export(array_tree)
export(as_mapper)
export(as_vector)
export(assign_in)
export(at_depth)
export(attr_getter)
export(auto_browse)
export(chuck)
Expand All @@ -31,9 +28,7 @@ export(compose)
export(cross)
export(cross2)
export(cross3)
export(cross_d)
export(cross_df)
export(cross_n)
export(detect)
export(detect_index)
export(discard)
Expand Down Expand Up @@ -182,8 +177,6 @@ export(rbernoulli)
export(rdunif)
export(reduce)
export(reduce2)
export(reduce2_right)
export(reduce_right)
export(rep_along)
export(rerun)
export(safely)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# purrr (development version)

* 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()`.

# purrr 1.1.0

* purrr now requires R >= 4.1, so we can rely on the base pipe and lambda
Expand Down
46 changes: 5 additions & 41 deletions R/adverb-partial.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@
#' These dots support quasiquotation. If you unquote a value, it is
#' evaluated only once at function creation time. Otherwise, it is
#' evaluated each time the function is called.
#' @param .env `r lifecycle::badge("deprecated")` The environments are
#' now captured via quosures.
#' @param .first `r lifecycle::badge("deprecated")` Please pass an
#' empty argument `... = ` to specify the position of future
#' arguments.
#' @param .lazy `r lifecycle::badge("deprecated")` Please unquote the
#' arguments that should be evaluated once at function creation time
#' with `!!`.
#'
#' @inheritSection safely Adverbs
#' @inherit safely return
#' @family adverbs
Expand Down Expand Up @@ -88,13 +79,7 @@
#' # `... = ` argument:
#' my_list <- partial(list, 1, ... = , 2)
#' my_list("foo")
partial <- function(
.f,
...,
.env = deprecated(),
.lazy = deprecated(),
.first = deprecated()
) {
partial <- function(.f, ...) {
args <- enquos(...)

fn_expr <- enexpr(.f)
Expand All @@ -109,22 +94,6 @@ partial <- function(
)
)

if (lifecycle::is_present(.env)) {
lifecycle::deprecate_warn("0.3.0", "partial(.env)", always = TRUE)
}
if (lifecycle::is_present(.lazy)) {
lifecycle::deprecate_warn("0.3.0", "partial(.lazy)", always = TRUE)
if (!.lazy) {
args <- map(
args,
~ new_quosure(eval_tidy(.x, env = caller_env()), empty_env())
)
}
}
if (lifecycle::is_present(.first)) {
lifecycle::deprecate_warn("0.3.0", "partial(.first)", always = TRUE)
}

env <- caller_env()
heterogeneous_envs <- !every(args, quo_is_same_env, env)

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

if (is_false(.first)) {
# For compatibility
call <- call_modify(call2(fn_sym), ... = , !!!args)
} else {
# Pass on `...` from parent function. It should be last, this way if
# `args` also contain a `...` argument, the position in `args`
# prevails.
call <- call_modify(call2(fn_sym), !!!args, ... = )
}
# Pass on `...` from parent function. It should be last, this way if
# `args` also contain a `...` argument, the position in `args`
# prevails.
call <- call_modify(call2(fn_sym), !!!args, ... = )

if (heterogeneous_envs) {
# Forward caller environment where S3 methods might be defined.
Expand Down
16 changes: 0 additions & 16 deletions R/deprec-cross.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,3 @@ cross_df <- function(.l, .filter = NULL) {
simplify_all() |>
tibble::as_tibble()
}

#' @export
#' @usage NULL
#' @rdname cross
cross_n <- function(...) {
lifecycle::deprecate_stop("0.2.3", "purrr::cross_n()")
cross(...)
}

#' @export
#' @usage NULL
#' @rdname cross
cross_d <- function(...) {
lifecycle::deprecate_stop("0.2.3", "purrr::cross_d()")
cross_df(...)
}
11 changes: 0 additions & 11 deletions R/deprec-map.R

This file was deleted.

19 changes: 0 additions & 19 deletions R/deprec-utils.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
#' Infix attribute accessor
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' This function was deprecated in purrr 0.3.0. Instead, lease use the `%@%`
#' operator exported in rlang. It has an interface more consistent with `@`:
#' uses NSE, supports S4 fields, and has an assignment variant.
#'
#' @param x Object
#' @param name Attribute name
#' @export
#' @name get-attr
#' @keywords internal
`%@%` <- function(x, name) {
lifecycle::deprecate_warn("0.3.0", I("%@%"), I("rlang::%@%"), always = TRUE)
attr(x, name, exact = TRUE)
}

#' Generate random sample from a Bernoulli distribution
#'
#' @description
Expand Down
32 changes: 4 additions & 28 deletions R/detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#' @param .dir If `"forward"`, the default, starts at the beginning of
#' the vector and move towards the end; if `"backward"`, starts at
#' the end of the vector and moves towards the beginning.
#' @param .right `r lifecycle::badge("deprecated")` Please use `.dir` instead.
#' @param .default The value returned when nothing is detected.
#' @return `detect` the value of the first item that matches the
#' predicate; `detect_index` the position of the matching item.
Expand Down Expand Up @@ -51,18 +50,11 @@
#'
#' # If you need to find all positions, use map_lgl():
#' which(map_lgl(x, "foo"))
detect <- function(
.x,
.f,
...,
.dir = c("forward", "backward"),
.right = NULL,
.default = NULL
) {
detect <- function(.x, .f, ..., .dir = c("forward", "backward"), .default = NULL) {
.f <- as_predicate(.f, ..., .mapper = TRUE)
.dir <- arg_match0(.dir, c("forward", "backward"))

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

#' @export
#' @rdname detect
detect_index <- function(
.x,
.f,
...,
.dir = c("forward", "backward"),
.right = NULL
) {
detect_index <- function(.x, .f, ..., .dir = c("forward", "backward")) {
.f <- as_predicate(.f, ..., .mapper = TRUE)
.dir <- arg_match0(.dir, c("forward", "backward"))

for (i in index(.x, .dir, .right, "detect_index")) {
for (i in index(.x, .dir, "detect_index")) {
if (.f(.x[[i]], ...)) {
return(i)
}
Expand All @@ -94,16 +80,6 @@ detect_index <- function(


index <- function(x, dir, right = NULL, fn) {
if (!is_null(right)) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = paste0(fn, "(.right)"),
with = paste0(fn, "(.dir)"),
always = TRUE
)
dir <- if (right) "backward" else "forward"
}

idx <- seq_along(x)
if (dir == "backward") {
idx <- rev(idx)
Expand Down
79 changes: 0 additions & 79 deletions R/reduce.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,6 @@ seq_len2 <- function(start, end) {
#'
#' @inheritSection reduce Direction
#'
#' @section Life cycle:
#'
#' `accumulate_right()` is soft-deprecated in favour of the `.dir`
#' argument as of rlang 0.3.0. Note that the algorithm has
#' slightly changed: the accumulated value is passed to the right
#' rather than the left, which is consistent with a right reduction.
#'
#' @seealso [reduce()] when you only need the final reduced value.
#' @examples
#' # With an associative operation, the final value is always the
Expand Down Expand Up @@ -513,75 +506,3 @@ accumulate_names <- function(nms, init, dir) {

nms
}

#' Reduce from the right (retired)
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' `reduce_right()` is soft-deprecated as of purrr 0.3.0. Please use
#' the `.dir` argument of `reduce()` instead. Note that the algorithm
#' has changed. Whereas `reduce_right()` computed `f(f(3, 2), 1)`,
#' `reduce(.dir = \"backward\")` computes `f(1, f(2, 3))`. This is the
#' standard way of reducing from the right.
#'
#' To update your code with the same reduction as `reduce_right()`,
#' simply reverse your vector and use a left reduction:
#'
#' ```R
#' # Before:
#' reduce_right(1:3, f)
#'
#' # After:
#' reduce(rev(1:3), f)
#' ```
#'
#' `reduce2_right()` is deprecated as of purrr 0.3.0 without
#' replacement. It is not clear what algorithmic properties should a
#' right reduction have in this case. Please reach out if you know
#' about a use case for a right reduction with a ternary function.
#'
#' @inheritParams reduce
#' @keywords internal
#' @export
reduce_right <- function(.x, .f, ..., .init) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = "reduce_right()",
with = "reduce(.dir)",
always = TRUE
)

.x <- rev(.x) # Compatibility
reduce_impl(.x, .f, ..., .dir = "forward", .init = .init)
}
#' @rdname reduce_right
#' @export
reduce2_right <- function(.x, .y, .f, ..., .init) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = "reduce2_right()",
with = I("reverse your vectors and use `reduce2()`"),
always = TRUE
)

reduce2_impl(.x, .y, .f, ..., .init = .init, .left = FALSE)
}

#' @rdname reduce_right
#' @export
accumulate_right <- function(.x, .f, ..., .init) {
lifecycle::deprecate_warn(
when = "0.3.0",
what = "accumulate_right()",
with = "accumulate(.dir)",
always = TRUE
)

# Note the order of arguments is switched
f <- function(y, x) {
.f(x, y, ...)
}

accumulate(.x, f, .init = .init, .dir = "backward")
}
9 changes: 0 additions & 9 deletions man/accumulate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions man/at_depth.Rd

This file was deleted.

2 changes: 0 additions & 2 deletions man/cross.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions man/detect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading