Skip to content

Commit

Permalink
Deprecate arr to use list instead (#375)
Browse files Browse the repository at this point in the history
Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>
  • Loading branch information
sorhawell and etiennebacher authored Sep 8, 2023
1 parent c35369c commit fa23733
Show file tree
Hide file tree
Showing 48 changed files with 555 additions and 440 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ S3method("$",ChainedWhen)
S3method("$",DataFrame)
S3method("$",DataTypeVector)
S3method("$",Expr)
S3method("$",ExprArrNameSpace)
S3method("$",ExprBinNameSpace)
S3method("$",ExprCatNameSpace)
S3method("$",ExprDTNameSpace)
S3method("$",ExprListNameSpace)
S3method("$",ExprMetaNameSpace)
S3method("$",ExprStrNameSpace)
S3method("$",ExprStructNameSpace)
Expand Down Expand Up @@ -54,7 +54,7 @@ S3method(">",Series)
S3method(">=",Expr)
S3method(">=",Series)
S3method("[",DataFrame)
S3method("[",ExprArrNameSpace)
S3method("[",ExprListNameSpace)
S3method("[",LazyFrame)
S3method("[[",ChainedThen)
S3method("[[",ChainedWhen)
Expand Down
35 changes: 27 additions & 8 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ Expr_apply = function(f, return_type = NULL, strict_return_type = TRUE, allow_fa
#' # vectors to literal implicitly
#' (pl$lit(2) + 1:4) / 4:1
Expr_lit = function(x) {
.Call(wrap__Expr__lit, x) |> #use .call reduces eval from 22us to 15us, not a bottle-next anyways
.Call(wrap__Expr__lit, x) |> # use .call reduces eval from 22us to 15us, not a bottle-next anyways
unwrap("in $lit()")
}

Expand Down Expand Up @@ -4252,13 +4252,32 @@ Expr_shrink_dtype = "use_extendr_wrapper"



#' arr: list related methods
#' 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 removed from polars 0.9.0.",
"Use `<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.
#' See the individual method pages for full details
#' @keywords Expr
#' @return Expr
#' @aliases arr_ns
#' @aliases list_ns
#' @examples
#' df_with_list = pl$DataFrame(
#' group = c(1, 1, 2, 2, 3),
Expand All @@ -4270,10 +4289,10 @@ Expr_shrink_dtype = "use_extendr_wrapper"
#' pl$col("value") * 3L
#' )
#' df_with_list$with_columns(
#' pl$col("value")$arr$lengths()$alias("group_size")
#' pl$col("value")$list$lengths()$alias("group_size")
#' )
Expr_arr = method_as_property(function() {
expr_arr_make_sub_ns(self)
Expr_list = method_as_property(function() {
expr_list_make_sub_ns(self)
})


Expand Down Expand Up @@ -4394,7 +4413,7 @@ Expr_to_struct = function() {
#' pl$Series(list(1:1, 1:2, 1:3, 1:4))
#' $print()
#' $to_lit()
#' $arr$lengths()
#' $list$lengths()
#' $sum()
#' $cast(pl$dtypes$Int8)
#' $lit_to_s()
Expand All @@ -4414,7 +4433,7 @@ Expr_lit_to_s = function() {
#' pl$Series(list(1:1, 1:2, 1:3, 1:4))
#' $print()
#' $to_lit()
#' $arr$lengths()
#' $list$lengths()
#' $sum()
#' $cast(pl$dtypes$Int8)
#' $lit_to_df()
Expand Down
Loading

0 comments on commit fa23733

Please sign in to comment.