Skip to content
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

Remove deprecated $with_column() and subnamespace $arr #402

Merged
merged 2 commits into from
Sep 29, 2023
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- Setting and getting polars options is now made with `pl$options`,
`pl$set_options()` and `pl$reset_options()` (#384).
- Method `$with_column()` has been removed (it was deprecated since 0.8.0). Use
`$with_columns()` instead (#402).
- Subnamespace `$arr` has been removed (it was deprecated since 0.8.1). Use `$list`
instead (#402).

## What's changed

Expand Down
10 changes: 0 additions & 10 deletions R/dataframe__frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,6 @@ DataFrame_shift_and_fill = function(fill_value, periods = 1) {
#' Add columns or modify existing ones with expressions. This is
#' the equivalent of `dplyr::mutate()` as it keeps unmentioned columns (unlike
#' `$select()`).
#' **`$with_column()` function is deprecated, use `$with_columns()` instead.**
#'
#' @name DataFrame_with_columns
#' @aliases with_columns
Expand Down Expand Up @@ -794,15 +793,6 @@ DataFrame_with_columns = function(...) {
unwrap("in $with_columns()")
}

#' @rdname DataFrame_with_columns
#' @aliases with_column
#' @param expr a single expression or string

DataFrame_with_column = function(expr) {
warning("`with_column()` is deprecated and will be removed in polars 0.9.0. Please use `with_columns()` instead.")
self$with_columns(expr)
}



#' Limit a DataFrame
Expand Down
29 changes: 0 additions & 29 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -4208,7 +4208,6 @@ Expr_set_sorted = function(descending = FALSE) {
#' @docType NULL
#' @format NULL
#' @aliases list
#' @name Expr_list
#' @details use to_struct to wrap a DataFrame. Notice implode() is sometimes referred to
#' as list() .
#' @format NULL
Expand All @@ -4220,15 +4219,6 @@ Expr_set_sorted = function(descending = FALSE) {
#' df$select(pl$all()$implode())
Expr_implode = "use_extendr_wrapper"

## TODO REMOVE AT A BREAKING CHANGE
Expr_list = function() {
if (is.null(runtime_state$warned_deprecate_list)) {
runtime_state$warned_deprecate_list = TRUE
warning("polars pl$list and <Expr>$list are deprecated, use $implode instead.")
}
self$implode()
}



#' Shrink numeric columns to the minimal required datatype.
Expand All @@ -4255,25 +4245,6 @@ Expr_shrink_dtype = "use_extendr_wrapper"



#' arr: list related methods DEPRECATED
#' @description
#' Deprecated since 0.8.1, will be removed in 0.9.0.
#' USE `<Expr>$list$...` instead. Subnamespace is simply renamed.
#' @keywords Expr
#' @return Expr
#' @seealso \code{\link[=Expr_list]{<Expr>$list$...}}
Expr_arr = method_as_property(function() {
if (!isTRUE(runtime_state$warned_deprecate_sns_arr_expr)) {
warning(
"in <Expr>$arr$: `<Expr>$arr$...` is deprecated since 0.8.1 and will be removed in polars 0.9.0.",
"\nUse `<Expr>$list$` instead. It is only a renaming to match py-polars renaming.",
call. = FALSE
)
runtime_state$warned_deprecate_sns_arr_expr = TRUE
}
expr_list_make_sub_ns(self)
})

#' list: list related methods
#' @description
#' Create an object namespace of all list related methods.
Expand Down
2 changes: 0 additions & 2 deletions R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,6 @@ LazyFrame$unique <- function(subset, keep, maintain_order) .Call(wrap__LazyFrame

LazyFrame$groupby <- function(exprs, maintain_order) .Call(wrap__LazyFrame__groupby, self, exprs, maintain_order)

LazyFrame$with_column <- function(expr) .Call(wrap__LazyFrame__with_column, self, expr)

LazyFrame$with_row_count <- function(name, offset) .Call(wrap__LazyFrame__with_row_count, self, name, offset)

LazyFrame$join_asof <- function(other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) .Call(wrap__LazyFrame__join_asof, self, other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str)
Expand Down
9 changes: 0 additions & 9 deletions R/functions__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ pl$implode = function(name) { # -> Expr
unwrap("in pl$implode():")
}

## TODO REMOVE AT A BREAKING CHANGE
pl$list = function(name) {
if (is.null(runtime_state$warned_deprecate_list)) {
runtime_state$warned_deprecate_list = TRUE
warning("polars pl$list and <Expr>$list are deprecated, use $implode instead.")
}
pl$implode(name)
}

#' pl$first
#' @name pl_first
#' @description Depending on the input type this function does different things:
Expand Down
3 changes: 0 additions & 3 deletions R/lazyframe__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ LazyFrame_with_columns = function(...) {
unwrap("in $with_columns()")
}

#' @rdname LazyFrame_with_columns

LazyFrame_with_column = "use_extendr_wrapper"

#' @inherit DataFrame_with_row_count title description params
#' @return A new LazyFrame with a counter column in front
Expand Down
2 changes: 1 addition & 1 deletion R/rbackground.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ print.RThreadHandle = function(x, ...) as.character(x) |> cat("\n")
#' Sys.sleep(1.5)
#' x * 0.43
#' }, in_background = TRUE)$alias("kml")
#' handle = pl$LazyFrame(mtcars)$with_column(prexpr)$collect_in_background()
#' handle = pl$LazyFrame(mtcars)$with_columns(prexpr)$collect_in_background()
#' if (!handle$is_finished()) print("not done yet")
#' df = handle$join() # get result
#' df
Expand Down
29 changes: 0 additions & 29 deletions R/series__series.R
Original file line number Diff line number Diff line change
Expand Up @@ -959,35 +959,6 @@ Series_is_numeric = function() {
in_DataType(self$dtype, pl$numeric_dtypes)
}


#' arr: list related methods on Series of dtype List DEPRECATED
#' @description
#' DEPRECATED AND REMOVED FROM polars 0.9.0 use `<Series>$list$` instead
#' @keywords Series
#' @return Series
#' @aliases Series_arr
#' @seealso \code{\link[=Series_list]{<Series>$list$...}}
#' @examples
#' s = pl$Series(list(1:3, 1:2, NULL))
#' s
#' s$arr$first()
Series_arr = method_as_property(function() {
if (!isTRUE(runtime_state$warned_deprecate_sns_arr_series)) {
warning(
"in <Series>$arr$: `<Series>$arr$...` is deprecated since 0.8.1 and will be removed in polars 0.9.0.",
"\nUse `<Series>$list$` instead. It is only a renaming to match py-polars renaming.",
call. = FALSE
)
runtime_state$warned_deprecate_sns_arr_series = TRUE
}
df = pl$DataFrame(self)
arr = expr_list_make_sub_ns(pl$col(self$name))
lapply(arr, \(f) {
\(...) df$select(f(...))
})
})


#' list: list related methods on Series of dtype List
#' @description
#' Create an object namespace of all list related methods.
Expand Down
7 changes: 0 additions & 7 deletions man/DataFrame_with_columns.Rd

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

19 changes: 0 additions & 19 deletions man/Expr_arr.Rd

This file was deleted.

27 changes: 27 additions & 0 deletions man/Expr_implode.Rd

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

19 changes: 1 addition & 18 deletions man/Expr_list.Rd

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

9 changes: 0 additions & 9 deletions man/LazyFrame_with_columns.Rd

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

2 changes: 1 addition & 1 deletion man/RThreadHandle_RThreadHandle_class.Rd

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

23 changes: 0 additions & 23 deletions man/Series_arr.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/pl_pl.Rd

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

6 changes: 0 additions & 6 deletions src/rust/src/lazy/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,6 @@ impl LazyFrame {
}
}

fn with_column(&self, expr: &Expr) -> LazyFrame {
R!("warning('`with_column()` is deprecated and will be removed in polars 0.9.0. Please use `with_columns()` instead.')")
.expect("warning will not fail");
LazyFrame(self.0.clone().with_column(expr.0.clone()))
}

fn with_row_count(&self, name: Robj, offset: Robj) -> RResult<Self> {
Ok(self
.0
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-expr_arr.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,3 @@ test_that("eval", {
)
})


test_that("Series$list$ warn once but give same ns as $list$", {
runtime_state$warned_deprecate_sns_arr_expr = FALSE
expect_warning(pl$lit(42)$arr)
expect_no_warning(pl$lit(42)$arr)
expect_no_warning(pl$lit(42)$list)
expect_identical(ls(pl$lit(42)$arr), ls(pl$lit(42)$list))
})
9 changes: 0 additions & 9 deletions tests/testthat/test-series.R
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,3 @@ test_that("n_unique", {
expect_identical(pl$Series(x)$n_unique(), 6)
expect_grepl_error(pl$Series(c())$n_unique(), "operation not supported for dtype")
})


test_that("$list$ warn once but give same ns as $list$", {
runtime_state$warned_deprecate_sns_arr_series = FALSE
expect_warning(pl$Series(42)$arr)
expect_no_warning(pl$Series(42)$arr)
expect_no_warning(pl$Series(42)$list)
expect_identical(ls(pl$Series(42)$arr), ls(pl$Series(42)$list))
})
Loading