From cdbda2e7b9e922603e80f2d302a7b47e57cadd57 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:20:18 +0100 Subject: [PATCH 01/32] rename LazyFrame --- NAMESPACE | 44 +++---- R/after-wrappers.R | 4 +- R/as_polars.R | 6 +- R/extendr-wrappers.R | 108 +++++++++--------- R/lazyframe__lazy.R | 6 +- R/s3_methods.R | 32 +++--- man/LazyFrame_class.Rd | 2 +- man/S3_as.data.frame.Rd | 4 +- man/S3_as.matrix.Rd | 4 +- man/S3_dim.Rd | 4 +- man/S3_dimnames.Rd | 4 +- man/S3_extract.Rd | 4 +- man/S3_head.Rd | 4 +- man/S3_length.Rd | 4 +- man/S3_max.Rd | 4 +- man/S3_mean.Rd | 4 +- man/S3_median.Rd | 4 +- man/S3_min.Rd | 4 +- man/S3_na.omit.Rd | 6 +- man/S3_names.Rd | 4 +- man/S3_sum.Rd | 4 +- man/S3_tail.Rd | 4 +- man/S3_unique.Rd | 4 +- man/as_polars_df.Rd | 4 +- man/as_polars_lf.Rd | 4 +- ...Rd => dot-DollarNames.RPolarsLazyFrame.Rd} | 6 +- ...LazyFrame.Rd => print.RPolarsLazyFrame.Rd} | 6 +- src/rust/src/concat.rs | 10 +- src/rust/src/lazy/dataframe.rs | 64 +++++------ src/rust/src/rbackground.rs | 2 +- src/rust/src/rdataframe/mod.rs | 6 +- src/rust/src/rdataframe/read_csv.rs | 6 +- src/rust/src/rdataframe/read_ipc.rs | 2 +- src/rust/src/rdataframe/read_ndjson.rs | 6 +- src/rust/src/rdataframe/read_parquet.rs | 6 +- src/rust/src/sql.rs | 2 +- src/rust/src/utils/mod.rs | 12 +- 37 files changed, 205 insertions(+), 199 deletions(-) rename man/{dot-DollarNames.LazyFrame.Rd => dot-DollarNames.RPolarsLazyFrame.Rd} (72%) rename man/{print.LazyFrame.Rd => print.RPolarsLazyFrame.Rd} (76%) diff --git a/NAMESPACE b/NAMESPACE index 03ca176ee..c0173120a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,13 +18,13 @@ S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) S3method("$",ExprStructNameSpace) S3method("$",GroupBy) -S3method("$",LazyFrame) S3method("$",LazyGroupBy) S3method("$",ProtoExprArray) S3method("$",RField) S3method("$",RNullValues) S3method("$",RPolarsDataType) S3method("$",RPolarsErr) +S3method("$",RPolarsLazyFrame) S3method("$",RPolarsSQLContext) S3method("$",RPolarsStringCacheHolder) S3method("$",RThreadHandle) @@ -60,7 +60,7 @@ S3method(">=",Expr) S3method(">=",Series) S3method("[",DataFrame) S3method("[",ExprListNameSpace) -S3method("[",LazyFrame) +S3method("[",RPolarsLazyFrame) S3method("[",Series) S3method("[",rpolars_raw_list) S3method("[[",ChainedThen) @@ -69,13 +69,13 @@ S3method("[[",DataFrame) S3method("[[",DataTypeVector) S3method("[[",Expr) S3method("[[",GroupBy) -S3method("[[",LazyFrame) S3method("[[",LazyGroupBy) S3method("[[",ProtoExprArray) S3method("[[",RField) S3method("[[",RNullValues) S3method("[[",RPolarsDataType) S3method("[[",RPolarsErr) +S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsStringCacheHolder) S3method("[[",RThreadHandle) @@ -90,9 +90,9 @@ S3method(.DollarNames,ChainedWhen) S3method(.DollarNames,DataFrame) S3method(.DollarNames,Expr) S3method(.DollarNames,GroupBy) -S3method(.DollarNames,LazyFrame) S3method(.DollarNames,RField) S3method(.DollarNames,RPolarsErr) +S3method(.DollarNames,RPolarsLazyFrame) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RThreadHandle) S3method(.DollarNames,Series) @@ -104,63 +104,63 @@ S3method(as.character,RPolarsErr) S3method(as.character,RThreadHandle) S3method(as.character,Series) S3method(as.data.frame,DataFrame) -S3method(as.data.frame,LazyFrame) +S3method(as.data.frame,RPolarsLazyFrame) S3method(as.list,Expr) S3method(as.list,rpolars_raw_list) S3method(as.matrix,DataFrame) -S3method(as.matrix,LazyFrame) +S3method(as.matrix,RPolarsLazyFrame) S3method(as.vector,Series) S3method(as_polars_df,ArrowTabular) S3method(as_polars_df,DataFrame) S3method(as_polars_df,GroupBy) -S3method(as_polars_df,LazyFrame) S3method(as_polars_df,LazyGroupBy) +S3method(as_polars_df,RPolarsLazyFrame) S3method(as_polars_df,Series) S3method(as_polars_df,data.frame) S3method(as_polars_df,default) -S3method(as_polars_lf,LazyFrame) S3method(as_polars_lf,LazyGroupBy) +S3method(as_polars_lf,RPolarsLazyFrame) S3method(as_polars_lf,default) S3method(as_polars_series,POSIXlt) S3method(as_polars_series,default) S3method(as_polars_series,vctrs_rcrd) S3method(c,Series) S3method(dim,DataFrame) -S3method(dim,LazyFrame) +S3method(dim,RPolarsLazyFrame) S3method(dimnames,DataFrame) -S3method(dimnames,LazyFrame) +S3method(dimnames,RPolarsLazyFrame) S3method(head,DataFrame) -S3method(head,LazyFrame) +S3method(head,RPolarsLazyFrame) S3method(length,DataFrame) -S3method(length,LazyFrame) +S3method(length,RPolarsLazyFrame) S3method(length,Series) S3method(max,DataFrame) -S3method(max,LazyFrame) +S3method(max,RPolarsLazyFrame) S3method(max,Series) S3method(mean,DataFrame) -S3method(mean,LazyFrame) +S3method(mean,RPolarsLazyFrame) S3method(mean,Series) S3method(median,DataFrame) -S3method(median,LazyFrame) +S3method(median,RPolarsLazyFrame) S3method(median,Series) S3method(min,DataFrame) -S3method(min,LazyFrame) +S3method(min,RPolarsLazyFrame) S3method(min,Series) S3method(na.omit,DataFrame) -S3method(na.omit,LazyFrame) +S3method(na.omit,RPolarsLazyFrame) S3method(names,DataFrame) -S3method(names,LazyFrame) +S3method(names,RPolarsLazyFrame) S3method(print,ChainedThen) S3method(print,ChainedWhen) S3method(print,DataFrame) S3method(print,Expr) S3method(print,GroupBy) -S3method(print,LazyFrame) S3method(print,LazyGroupBy) S3method(print,PTime) S3method(print,RField) S3method(print,RPolarsDataType) S3method(print,RPolarsErr) +S3method(print,RPolarsLazyFrame) S3method(print,RThreadHandle) S3method(print,Series) S3method(print,Then) @@ -168,12 +168,12 @@ S3method(print,When) S3method(print,polars_info) S3method(row.names,DataFrame) S3method(sum,DataFrame) -S3method(sum,LazyFrame) +S3method(sum,RPolarsLazyFrame) S3method(sum,Series) S3method(tail,DataFrame) -S3method(tail,LazyFrame) +S3method(tail,RPolarsLazyFrame) S3method(unique,DataFrame) -S3method(unique,LazyFrame) +S3method(unique,RPolarsLazyFrame) export(.pr) export(GroupBy_ungroup) export(LazyGroupBy_ungroup) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index fb9799879..cfcf78114 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -80,7 +80,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$Series = extendr_method_to_pure_functions(Series) .pr$DataFrame = extendr_method_to_pure_functions(DataFrame) .pr$GroupBy = NULL # derived from DataFrame in R, has no rust calls -.pr$LazyFrame = extendr_method_to_pure_functions(LazyFrame) +.pr$LazyFrame = extendr_method_to_pure_functions(RPolarsLazyFrame) .pr$LazyGroupBy = extendr_method_to_pure_functions(LazyGroupBy) .pr$DataType = extendr_method_to_pure_functions(RPolarsDataType) .pr$DataTypeVector = extendr_method_to_pure_functions(DataTypeVector) @@ -267,7 +267,7 @@ DataType = clone_env_one_level_deep(RPolarsDataType) # used for printing public environment pl_class_names = sort( c( - "LazyFrame", "Series", "LazyGroupBy", "DataType", "Expr", "DataFrame", + "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "Expr", "DataFrame", "When", "Then", "ChainedWhen", "ChainedThen", "RPolarsSQLContext" ) ) # TODO discover all public class automatically diff --git a/R/as_polars.R b/R/as_polars.R index 30a2805fa..43b1f57de 100644 --- a/R/as_polars.R +++ b/R/as_polars.R @@ -67,7 +67,7 @@ as_polars_df.Series = function(x, ...) { #' @param n_rows Number of rows to fetch. Defaults to `Inf`, meaning all rows. #' @inheritParams LazyFrame_collect #' @export -as_polars_df.LazyFrame = function( +as_polars_df.RPolarsLazyFrame = function( x, n_rows = Inf, ..., @@ -103,7 +103,7 @@ as_polars_df.LazyFrame = function( #' @rdname as_polars_df #' @export as_polars_df.LazyGroupBy = function(x, ...) { - as_polars_df.LazyFrame(x$ungroup(), ...) + as_polars_df.RPolarsLazyFrame(x$ungroup(), ...) } @@ -153,7 +153,7 @@ as_polars_lf.default = function(x, ...) { #' @rdname as_polars_lf #' @export -as_polars_lf.LazyFrame = function(x, ...) { +as_polars_lf.RPolarsLazyFrame = function(x, ...) { x } diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index ba7cacbb7..b2d52ce6d 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -1003,110 +1003,116 @@ ProtoExprArray$print <- function() invisible(.Call(wrap__ProtoExprArray__print, LazyFrame <- new.env(parent = emptyenv()) -LazyFrame$print <- function() .Call(wrap__LazyFrame__print, self) +LazyFrame$print <- function() .Call(wrap__RPolarsLazyFrame__print, self) -LazyFrame$describe_plan <- function() invisible(.Call(wrap__LazyFrame__describe_plan, self)) +LazyFrame$describe_plan <- function() invisible(.Call(wrap__RPolarsLazyFrame__describe_plan, self)) -LazyFrame$debug_plan <- function() .Call(wrap__LazyFrame__debug_plan, self) +LazyFrame$debug_plan <- function() .Call(wrap__RPolarsLazyFrame__debug_plan, self) -LazyFrame$describe_optimized_plan <- function() .Call(wrap__LazyFrame__describe_optimized_plan, self) +LazyFrame$describe_optimized_plan <- function() .Call(wrap__RPolarsLazyFrame__describe_optimized_plan, self) -LazyFrame$collect <- function() .Call(wrap__LazyFrame__collect, self) +LazyFrame$collect <- function() .Call(wrap__RPolarsLazyFrame__collect, self) -LazyFrame$collect_in_background <- function() .Call(wrap__LazyFrame__collect_in_background, self) +LazyFrame$collect_in_background <- function() .Call(wrap__RPolarsLazyFrame__collect_in_background, self) -LazyFrame$sink_parquet <- function(path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) .Call(wrap__LazyFrame__sink_parquet, self, path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) +LazyFrame$sink_parquet <- function(path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_parquet, self, path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) -LazyFrame$sink_ipc <- function(path, compression_method, maintain_order) .Call(wrap__LazyFrame__sink_ipc, self, path, compression_method, maintain_order) +LazyFrame$sink_ipc <- function(path, compression_method, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_ipc, self, path, compression_method, maintain_order) -LazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__LazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) +LazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) -LazyFrame$first <- function() .Call(wrap__LazyFrame__first, self) +LazyFrame$first <- function() .Call(wrap__RPolarsLazyFrame__first, self) -LazyFrame$last <- function() .Call(wrap__LazyFrame__last, self) +LazyFrame$last <- function() .Call(wrap__RPolarsLazyFrame__last, self) -LazyFrame$max <- function() .Call(wrap__LazyFrame__max, self) +LazyFrame$max <- function() .Call(wrap__RPolarsLazyFrame__max, self) -LazyFrame$min <- function() .Call(wrap__LazyFrame__min, self) +LazyFrame$min <- function() .Call(wrap__RPolarsLazyFrame__min, self) -LazyFrame$mean <- function() .Call(wrap__LazyFrame__mean, self) +LazyFrame$mean <- function() .Call(wrap__RPolarsLazyFrame__mean, self) -LazyFrame$median <- function() .Call(wrap__LazyFrame__median, self) +LazyFrame$median <- function() .Call(wrap__RPolarsLazyFrame__median, self) -LazyFrame$sum <- function() .Call(wrap__LazyFrame__sum, self) +LazyFrame$sum <- function() .Call(wrap__RPolarsLazyFrame__sum, self) -LazyFrame$std <- function(ddof) .Call(wrap__LazyFrame__std, self, ddof) +LazyFrame$std <- function(ddof) .Call(wrap__RPolarsLazyFrame__std, self, ddof) -LazyFrame$var <- function(ddof) .Call(wrap__LazyFrame__var, self, ddof) +LazyFrame$var <- function(ddof) .Call(wrap__RPolarsLazyFrame__var, self, ddof) -LazyFrame$quantile <- function(quantile, interpolation) .Call(wrap__LazyFrame__quantile, self, quantile, interpolation) +LazyFrame$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsLazyFrame__quantile, self, quantile, interpolation) -LazyFrame$shift <- function(periods) .Call(wrap__LazyFrame__shift, self, periods) +LazyFrame$shift <- function(periods) .Call(wrap__RPolarsLazyFrame__shift, self, periods) -LazyFrame$shift_and_fill <- function(fill_value, periods) .Call(wrap__LazyFrame__shift_and_fill, self, fill_value, periods) +LazyFrame$shift_and_fill <- function(fill_value, periods) .Call(wrap__RPolarsLazyFrame__shift_and_fill, self, fill_value, periods) -LazyFrame$reverse <- function() .Call(wrap__LazyFrame__reverse, self) +LazyFrame$reverse <- function() .Call(wrap__RPolarsLazyFrame__reverse, self) -LazyFrame$drop <- function(columns) .Call(wrap__LazyFrame__drop, self, columns) +LazyFrame$drop <- function(columns) .Call(wrap__RPolarsLazyFrame__drop, self, columns) -LazyFrame$fill_nan <- function(fill_value) .Call(wrap__LazyFrame__fill_nan, self, fill_value) +LazyFrame$fill_nan <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_nan, self, fill_value) -LazyFrame$fill_null <- function(fill_value) .Call(wrap__LazyFrame__fill_null, self, fill_value) +LazyFrame$fill_null <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_null, self, fill_value) -LazyFrame$slice <- function(offset, length) .Call(wrap__LazyFrame__slice, self, offset, length) +LazyFrame$slice <- function(offset, length) .Call(wrap__RPolarsLazyFrame__slice, self, offset, length) -LazyFrame$with_columns <- function(exprs) .Call(wrap__LazyFrame__with_columns, self, exprs) +LazyFrame$with_columns <- function(exprs) .Call(wrap__RPolarsLazyFrame__with_columns, self, exprs) -LazyFrame$unnest <- function(names) .Call(wrap__LazyFrame__unnest, self, names) +LazyFrame$unnest <- function(names) .Call(wrap__RPolarsLazyFrame__unnest, self, names) -LazyFrame$select <- function(exprs) .Call(wrap__LazyFrame__select, self, exprs) +LazyFrame$select <- function(exprs) .Call(wrap__RPolarsLazyFrame__select, self, exprs) -LazyFrame$select_str_as_lit <- function(exprs) .Call(wrap__LazyFrame__select_str_as_lit, self, exprs) +LazyFrame$select_str_as_lit <- function(exprs) .Call(wrap__RPolarsLazyFrame__select_str_as_lit, self, exprs) -LazyFrame$limit <- function(n) .Call(wrap__LazyFrame__limit, self, n) +LazyFrame$limit <- function(n) .Call(wrap__RPolarsLazyFrame__limit, self, n) -LazyFrame$tail <- function(n) .Call(wrap__LazyFrame__tail, self, n) +LazyFrame$tail <- function(n) .Call(wrap__RPolarsLazyFrame__tail, self, n) -LazyFrame$filter <- function(expr) .Call(wrap__LazyFrame__filter, self, expr) +LazyFrame$filter <- function(expr) .Call(wrap__RPolarsLazyFrame__filter, self, expr) -LazyFrame$drop_nulls <- function(subset) .Call(wrap__LazyFrame__drop_nulls, self, subset) +LazyFrame$drop_nulls <- function(subset) .Call(wrap__RPolarsLazyFrame__drop_nulls, self, subset) -LazyFrame$unique <- function(subset, keep, maintain_order) .Call(wrap__LazyFrame__unique, self, subset, keep, maintain_order) +LazyFrame$unique <- function(subset, keep, maintain_order) .Call(wrap__RPolarsLazyFrame__unique, self, subset, keep, maintain_order) -LazyFrame$group_by <- function(exprs, maintain_order) .Call(wrap__LazyFrame__group_by, self, exprs, maintain_order) +LazyFrame$group_by <- function(exprs, maintain_order) .Call(wrap__RPolarsLazyFrame__group_by, self, exprs, maintain_order) -LazyFrame$with_row_count <- function(name, offset) .Call(wrap__LazyFrame__with_row_count, self, name, offset) +LazyFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsLazyFrame__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) +LazyFrame$join_asof <- function(other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) .Call(wrap__RPolarsLazyFrame__join_asof, self, other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) -LazyFrame$join <- function(other, left_on, right_on, how, suffix, allow_parallel, force_parallel) .Call(wrap__LazyFrame__join, self, other, left_on, right_on, how, suffix, allow_parallel, force_parallel) +LazyFrame$join <- function(other, left_on, right_on, how, suffix, allow_parallel, force_parallel) .Call(wrap__RPolarsLazyFrame__join, self, other, left_on, right_on, how, suffix, allow_parallel, force_parallel) -LazyFrame$sort_by_exprs <- function(by, dotdotdot, descending, nulls_last, maintain_order) .Call(wrap__LazyFrame__sort_by_exprs, self, by, dotdotdot, descending, nulls_last, maintain_order) +LazyFrame$sort_by_exprs <- function(by, dotdotdot, descending, nulls_last, maintain_order) .Call(wrap__RPolarsLazyFrame__sort_by_exprs, self, by, dotdotdot, descending, nulls_last, maintain_order) -LazyFrame$melt <- function(id_vars, value_vars, value_name, variable_name, streamable) .Call(wrap__LazyFrame__melt, self, id_vars, value_vars, value_name, variable_name, streamable) +LazyFrame$melt <- function(id_vars, value_vars, value_name, variable_name, streamable) .Call(wrap__RPolarsLazyFrame__melt, self, id_vars, value_vars, value_name, variable_name, streamable) -LazyFrame$rename <- function(existing, new) .Call(wrap__LazyFrame__rename, self, existing, new) +LazyFrame$rename <- function(existing, new) .Call(wrap__RPolarsLazyFrame__rename, self, existing, new) -LazyFrame$schema <- function() .Call(wrap__LazyFrame__schema, self) +LazyFrame$schema <- function() .Call(wrap__RPolarsLazyFrame__schema, self) -LazyFrame$fetch <- function(n_rows) .Call(wrap__LazyFrame__fetch, self, n_rows) +LazyFrame$fetch <- function(n_rows) .Call(wrap__RPolarsLazyFrame__fetch, self, n_rows) -LazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) .Call(wrap__LazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) +LazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) .Call(wrap__RPolarsLazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) -LazyFrame$get_optimization_toggle <- function() .Call(wrap__LazyFrame__get_optimization_toggle, self) +LazyFrame$get_optimization_toggle <- function() .Call(wrap__RPolarsLazyFrame__get_optimization_toggle, self) -LazyFrame$profile <- function() .Call(wrap__LazyFrame__profile, self) +LazyFrame$profile <- function() .Call(wrap__RPolarsLazyFrame__profile, self) -LazyFrame$explode <- function(dotdotdot) .Call(wrap__LazyFrame__explode, self, dotdotdot) +LazyFrame$explode <- function(dotdotdot) .Call(wrap__RPolarsLazyFrame__explode, self, dotdotdot) -LazyFrame$clone_in_rust <- function() .Call(wrap__LazyFrame__clone_in_rust, self) +LazyFrame$clone_in_rust <- function() .Call(wrap__RPolarsLazyFrame__clone_in_rust, self) -LazyFrame$with_context <- function(contexts) .Call(wrap__LazyFrame__with_context, self, contexts) +LazyFrame$with_context <- function(contexts) .Call(wrap__RPolarsLazyFrame__with_context, self, contexts) + +RPolarsLazyFrame <- LazyFrame #' @export -`$.LazyFrame` <- function (self, name) { func <- LazyFrame[[name]]; environment(func) <- environment(); func } +`$.RPolarsLazyFrame` <- function (self, name) { func <- RPolarsLazyFrame[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsLazyFrame` <- `$.RPolarsLazyFrame` + +`$.LazyFrame` <- function (self, name) { func <- LazyFrame[[name]]; environment(func) <- environment(); func } + `[[.LazyFrame` <- `$.LazyFrame` LazyGroupBy <- new.env(parent = emptyenv()) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index cd1932f05..1fb9500cd 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -6,7 +6,7 @@ #' instantiated `LazyFrame`-object is an `externalptr` to a lowlevel rust polars #' LazyFrame object. The pointer address is the only statefullness of the #' LazyFrame object on the R side. Any other state resides on the rust side. The -#' S3 method `.DollarNames.LazyFrame` exposes all public `$foobar()`-methods which +#' S3 method `.DollarNames.RPolarsLazyFrame` exposes all public `$foobar()`-methods which #' are callable onto the object. #' #' Most methods return another `LazyFrame`-class instance or similar which allows @@ -108,7 +108,7 @@ LazyFrame #' @inherit .DollarNames.DataFrame return #' @keywords internal -.DollarNames.LazyFrame = function(x, pattern = "") { +.DollarNames.RPolarsLazyFrame = function(x, pattern = "") { paste0(ls(LazyFrame, pattern = pattern), "()") } @@ -161,7 +161,7 @@ pl$LazyFrame = function(...) { #' @export #' #' @examples pl$LazyFrame(iris) -print.LazyFrame = function(x, ...) { +print.RPolarsLazyFrame = function(x, ...) { print("polars LazyFrame naive plan: (run ldf$describe_optimized_plan() to see the optimized plan)") cloned_x = .pr$LazyFrame$print(x) invisible(cloned_x) diff --git a/R/s3_methods.R b/R/s3_methods.R index 4f6fed553..3b99383b2 100644 --- a/R/s3_methods.R +++ b/R/s3_methods.R @@ -130,7 +130,7 @@ #' @export #' @rdname S3_extract -`[.LazyFrame` = `[.DataFrame` +`[.RPolarsLazyFrame` = `[.DataFrame` #' @export #' @rdname S3_extract @@ -150,7 +150,7 @@ head.DataFrame = function(x, n = 6L, ...) x$limit(n = n) #' @export #' @rdname S3_head -head.LazyFrame = head.DataFrame +head.RPolarsLazyFrame = head.DataFrame #' Take the last n rows #' @@ -164,7 +164,7 @@ tail.DataFrame = function(x, n = 6L, ...) x$tail(n = n) #' @export #' @rdname S3_tail -tail.LazyFrame = tail.DataFrame +tail.RPolarsLazyFrame = tail.DataFrame #' Get the dimensions #' @@ -176,7 +176,7 @@ dim.DataFrame = function(x) x$shape #' @export #' @rdname S3_dim -dim.LazyFrame = function(x) c(NA, x$width) +dim.RPolarsLazyFrame = function(x) c(NA, x$width) #' Get the length #' @@ -189,7 +189,7 @@ length.DataFrame = function(x) x$width #' @export #' @rdname S3_length -length.LazyFrame = length.DataFrame +length.RPolarsLazyFrame = length.DataFrame #' @export #' @rdname S3_length @@ -205,7 +205,7 @@ names.DataFrame = function(x) x$columns #' @export #' @rdname S3_names -names.LazyFrame = function(x) x$columns +names.RPolarsLazyFrame = function(x) x$columns #' Get the row names #' @@ -225,7 +225,7 @@ dimnames.DataFrame = function(x) list(row.names(x), names(x)) #' @export #' @rdname S3_dimnames -dimnames.LazyFrame = function(x) list(NULL, names(x)) +dimnames.RPolarsLazyFrame = function(x) list(NULL, names(x)) #' Convert to a data.frame #' @@ -239,7 +239,7 @@ as.data.frame.DataFrame = function(x, ...) x$to_data_frame(...) #' @export #' @rdname S3_as.data.frame -as.data.frame.LazyFrame = function(x, ...) x$collect()$to_data_frame(...) +as.data.frame.RPolarsLazyFrame = function(x, ...) x$collect()$to_data_frame(...) #' Convert to a matrix #' @@ -251,7 +251,7 @@ as.matrix.DataFrame = function(x, ...) as.matrix(as.data.frame(x, ...)) #' @export #' @rdname S3_as.matrix -as.matrix.LazyFrame = as.matrix.DataFrame +as.matrix.RPolarsLazyFrame = as.matrix.DataFrame #' Compute the mean #' @@ -265,7 +265,7 @@ mean.DataFrame = function(x, ...) x$mean() #' @export #' @rdname S3_mean -mean.LazyFrame = function(x, ...) x$mean() +mean.RPolarsLazyFrame = function(x, ...) x$mean() #' @export #' @rdname S3_mean @@ -285,7 +285,7 @@ median.DataFrame = function(x, ...) x$median() #' @export #' @importFrom stats median #' @rdname S3_median -median.LazyFrame = function(x, ...) x$median() +median.RPolarsLazyFrame = function(x, ...) x$median() #' @export #' @importFrom stats median @@ -304,7 +304,7 @@ min.DataFrame = function(x, ...) x$min() #' @export #' @rdname S3_min -min.LazyFrame = function(x, ...) x$min() +min.RPolarsLazyFrame = function(x, ...) x$min() #' @export #' @rdname S3_min @@ -322,7 +322,7 @@ max.DataFrame = function(x, ...) x$max() #' @export #' @rdname S3_max -max.LazyFrame = function(x, ...) x$max() +max.RPolarsLazyFrame = function(x, ...) x$max() #' @export #' @rdname S3_max @@ -340,7 +340,7 @@ sum.DataFrame = function(x, ...) x$sum() #' @export #' @rdname S3_sum -sum.LazyFrame = function(x, ...) x$sum() +sum.RPolarsLazyFrame = function(x, ...) x$sum() #' @export #' @rdname S3_sum @@ -442,7 +442,7 @@ c.Series = \(x, ...) { #' na.omit(df) #' na.omit(df, subset = "a") #' na.omit(df, subset = c("a", "b")) -na.omit.LazyFrame = function(object, subset = NULL, ...) { +na.omit.RPolarsLazyFrame = function(object, subset = NULL, ...) { if (!is.null(subset) && !is.atomic(subset) && !is.character(subset)) { stop("subset must be NULL, a string, or a character vector") } @@ -484,7 +484,7 @@ unique.DataFrame = function(x, incomparables = FALSE, subset = NULL, keep = "fir #' @export #' @rdname S3_unique -unique.LazyFrame = function(x, incomparables = FALSE, subset = NULL, keep = "first", ...) { +unique.RPolarsLazyFrame = function(x, incomparables = FALSE, subset = NULL, keep = "first", ...) { if (!is.null(subset) && !is.atomic(subset) && !is.character(subset)) { stop("subset must be NULL, a string, or a character vector") } diff --git a/man/LazyFrame_class.Rd b/man/LazyFrame_class.Rd index f14b71ccf..f759fac69 100644 --- a/man/LazyFrame_class.Rd +++ b/man/LazyFrame_class.Rd @@ -12,7 +12,7 @@ the public and private methods/function calls to the polars rust side. The instantiated \code{LazyFrame}-object is an \code{externalptr} to a lowlevel rust polars LazyFrame object. The pointer address is the only statefullness of the LazyFrame object on the R side. Any other state resides on the rust side. The -S3 method \code{.DollarNames.LazyFrame} exposes all public \verb{$foobar()}-methods which +S3 method \code{.DollarNames.RPolarsLazyFrame} exposes all public \verb{$foobar()}-methods which are callable onto the object. Most methods return another \code{LazyFrame}-class instance or similar which allows diff --git a/man/S3_as.data.frame.Rd b/man/S3_as.data.frame.Rd index 55e55a639..752acd3de 100644 --- a/man/S3_as.data.frame.Rd +++ b/man/S3_as.data.frame.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{as.data.frame.DataFrame} \alias{as.data.frame.DataFrame} -\alias{as.data.frame.LazyFrame} +\alias{as.data.frame.RPolarsLazyFrame} \title{Convert to a data.frame} \usage{ \method{as.data.frame}{DataFrame}(x, ...) -\method{as.data.frame}{LazyFrame}(x, ...) +\method{as.data.frame}{RPolarsLazyFrame}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_as.matrix.Rd b/man/S3_as.matrix.Rd index 3a26c84f5..8f88fae26 100644 --- a/man/S3_as.matrix.Rd +++ b/man/S3_as.matrix.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{as.matrix.DataFrame} \alias{as.matrix.DataFrame} -\alias{as.matrix.LazyFrame} +\alias{as.matrix.RPolarsLazyFrame} \title{Convert to a matrix} \usage{ \method{as.matrix}{DataFrame}(x, ...) -\method{as.matrix}{LazyFrame}(x, ...) +\method{as.matrix}{RPolarsLazyFrame}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_dim.Rd b/man/S3_dim.Rd index 7ed36ba5c..d2346aa13 100644 --- a/man/S3_dim.Rd +++ b/man/S3_dim.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{dim.DataFrame} \alias{dim.DataFrame} -\alias{dim.LazyFrame} +\alias{dim.RPolarsLazyFrame} \title{Get the dimensions} \usage{ \method{dim}{DataFrame}(x) -\method{dim}{LazyFrame}(x) +\method{dim}{RPolarsLazyFrame}(x) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_dimnames.Rd b/man/S3_dimnames.Rd index 76c4d55a8..fc0a1c5bf 100644 --- a/man/S3_dimnames.Rd +++ b/man/S3_dimnames.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{dimnames.DataFrame} \alias{dimnames.DataFrame} -\alias{dimnames.LazyFrame} +\alias{dimnames.RPolarsLazyFrame} \title{Get the row and column names} \usage{ \method{dimnames}{DataFrame}(x) -\method{dimnames}{LazyFrame}(x) +\method{dimnames}{RPolarsLazyFrame}(x) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_extract.Rd b/man/S3_extract.Rd index 74ed0ea9c..2e2260f40 100644 --- a/man/S3_extract.Rd +++ b/man/S3_extract.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{[.DataFrame} \alias{[.DataFrame} -\alias{[.LazyFrame} +\alias{[.RPolarsLazyFrame} \alias{[.Series} \title{Extract Parts of a Polars Object} \usage{ \method{[}{DataFrame}(x, i, j, drop = TRUE) -\method{[}{LazyFrame}(x, i, j, drop = TRUE) +\method{[}{RPolarsLazyFrame}(x, i, j, drop = TRUE) \method{[}{Series}(x, i) } diff --git a/man/S3_head.Rd b/man/S3_head.Rd index 1998e0aa6..12d9f571a 100644 --- a/man/S3_head.Rd +++ b/man/S3_head.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{head.DataFrame} \alias{head.DataFrame} -\alias{head.LazyFrame} +\alias{head.RPolarsLazyFrame} \title{Take the first n rows} \usage{ \method{head}{DataFrame}(x, n = 6L, ...) -\method{head}{LazyFrame}(x, n = 6L, ...) +\method{head}{RPolarsLazyFrame}(x, n = 6L, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_length.Rd b/man/S3_length.Rd index fd4db865a..57ac45fcc 100644 --- a/man/S3_length.Rd +++ b/man/S3_length.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{length.DataFrame} \alias{length.DataFrame} -\alias{length.LazyFrame} +\alias{length.RPolarsLazyFrame} \alias{length.Series} \title{Get the length} \usage{ \method{length}{DataFrame}(x) -\method{length}{LazyFrame}(x) +\method{length}{RPolarsLazyFrame}(x) \method{length}{Series}(x) } diff --git a/man/S3_max.Rd b/man/S3_max.Rd index 54c4b690c..c6b3bed9a 100644 --- a/man/S3_max.Rd +++ b/man/S3_max.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{max.DataFrame} \alias{max.DataFrame} -\alias{max.LazyFrame} +\alias{max.RPolarsLazyFrame} \alias{max.Series} \title{Compute the maximum value} \usage{ \method{max}{DataFrame}(x, ...) -\method{max}{LazyFrame}(x, ...) +\method{max}{RPolarsLazyFrame}(x, ...) \method{max}{Series}(x, ...) } diff --git a/man/S3_mean.Rd b/man/S3_mean.Rd index ada07e620..0c40a7ff4 100644 --- a/man/S3_mean.Rd +++ b/man/S3_mean.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{mean.DataFrame} \alias{mean.DataFrame} -\alias{mean.LazyFrame} +\alias{mean.RPolarsLazyFrame} \alias{mean.Series} \title{Compute the mean} \usage{ \method{mean}{DataFrame}(x, ...) -\method{mean}{LazyFrame}(x, ...) +\method{mean}{RPolarsLazyFrame}(x, ...) \method{mean}{Series}(x, ...) } diff --git a/man/S3_median.Rd b/man/S3_median.Rd index cfef6fbd1..65606f7fc 100644 --- a/man/S3_median.Rd +++ b/man/S3_median.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{median.DataFrame} \alias{median.DataFrame} -\alias{median.LazyFrame} +\alias{median.RPolarsLazyFrame} \alias{median.Series} \title{Compute the median} \usage{ \method{median}{DataFrame}(x, ...) -\method{median}{LazyFrame}(x, ...) +\method{median}{RPolarsLazyFrame}(x, ...) \method{median}{Series}(x, ...) } diff --git a/man/S3_min.Rd b/man/S3_min.Rd index 425efac00..643a2149b 100644 --- a/man/S3_min.Rd +++ b/man/S3_min.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{min.DataFrame} \alias{min.DataFrame} -\alias{min.LazyFrame} +\alias{min.RPolarsLazyFrame} \alias{min.Series} \title{Compute the minimum value} \usage{ \method{min}{DataFrame}(x, ...) -\method{min}{LazyFrame}(x, ...) +\method{min}{RPolarsLazyFrame}(x, ...) \method{min}{Series}(x, ...) } diff --git a/man/S3_na.omit.Rd b/man/S3_na.omit.Rd index 48a5b3d6b..2568edfbb 100644 --- a/man/S3_na.omit.Rd +++ b/man/S3_na.omit.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{na.omit.LazyFrame} -\alias{na.omit.LazyFrame} +\name{na.omit.RPolarsLazyFrame} +\alias{na.omit.RPolarsLazyFrame} \alias{na.omit.DataFrame} \title{Drop missing values} \usage{ -\method{na.omit}{LazyFrame}(object, subset = NULL, ...) +\method{na.omit}{RPolarsLazyFrame}(object, subset = NULL, ...) \method{na.omit}{DataFrame}(object, subset = NULL, ...) } diff --git a/man/S3_names.Rd b/man/S3_names.Rd index 7dc3caba5..1ab440d49 100644 --- a/man/S3_names.Rd +++ b/man/S3_names.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{names.DataFrame} \alias{names.DataFrame} -\alias{names.LazyFrame} +\alias{names.RPolarsLazyFrame} \title{Get the column names} \usage{ \method{names}{DataFrame}(x) -\method{names}{LazyFrame}(x) +\method{names}{RPolarsLazyFrame}(x) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_sum.Rd b/man/S3_sum.Rd index f0080bd47..989b65bbf 100644 --- a/man/S3_sum.Rd +++ b/man/S3_sum.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/s3_methods.R \name{sum.DataFrame} \alias{sum.DataFrame} -\alias{sum.LazyFrame} +\alias{sum.RPolarsLazyFrame} \alias{sum.Series} \title{Compute the sum} \usage{ \method{sum}{DataFrame}(x, ...) -\method{sum}{LazyFrame}(x, ...) +\method{sum}{RPolarsLazyFrame}(x, ...) \method{sum}{Series}(x, ...) } diff --git a/man/S3_tail.Rd b/man/S3_tail.Rd index 08350b674..1ea5a4e46 100644 --- a/man/S3_tail.Rd +++ b/man/S3_tail.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{tail.DataFrame} \alias{tail.DataFrame} -\alias{tail.LazyFrame} +\alias{tail.RPolarsLazyFrame} \title{Take the last n rows} \usage{ \method{tail}{DataFrame}(x, n = 6L, ...) -\method{tail}{LazyFrame}(x, n = 6L, ...) +\method{tail}{RPolarsLazyFrame}(x, n = 6L, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_unique.Rd b/man/S3_unique.Rd index 4c4146d2c..7c4598918 100644 --- a/man/S3_unique.Rd +++ b/man/S3_unique.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{unique.DataFrame} \alias{unique.DataFrame} -\alias{unique.LazyFrame} +\alias{unique.RPolarsLazyFrame} \title{Drop duplicated rows} \usage{ \method{unique}{DataFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) -\method{unique}{LazyFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) +\method{unique}{RPolarsLazyFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/as_polars_df.Rd b/man/as_polars_df.Rd index 3a6b93e63..d11e401a0 100644 --- a/man/as_polars_df.Rd +++ b/man/as_polars_df.Rd @@ -7,7 +7,7 @@ \alias{as_polars_df.DataFrame} \alias{as_polars_df.GroupBy} \alias{as_polars_df.Series} -\alias{as_polars_df.LazyFrame} +\alias{as_polars_df.RPolarsLazyFrame} \alias{as_polars_df.LazyGroupBy} \alias{as_polars_df.ArrowTabular} \title{To polars DataFrame} @@ -24,7 +24,7 @@ as_polars_df(x, ...) \method{as_polars_df}{Series}(x, ...) -\method{as_polars_df}{LazyFrame}( +\method{as_polars_df}{RPolarsLazyFrame}( x, n_rows = Inf, ..., diff --git a/man/as_polars_lf.Rd b/man/as_polars_lf.Rd index d3808a9d9..bd7781e4d 100644 --- a/man/as_polars_lf.Rd +++ b/man/as_polars_lf.Rd @@ -3,7 +3,7 @@ \name{as_polars_lf} \alias{as_polars_lf} \alias{as_polars_lf.default} -\alias{as_polars_lf.LazyFrame} +\alias{as_polars_lf.RPolarsLazyFrame} \alias{as_polars_lf.LazyGroupBy} \title{To polars LazyFrame} \usage{ @@ -11,7 +11,7 @@ as_polars_lf(x, ...) \method{as_polars_lf}{default}(x, ...) -\method{as_polars_lf}{LazyFrame}(x, ...) +\method{as_polars_lf}{RPolarsLazyFrame}(x, ...) \method{as_polars_lf}{LazyGroupBy}(x, ...) } diff --git a/man/dot-DollarNames.LazyFrame.Rd b/man/dot-DollarNames.RPolarsLazyFrame.Rd similarity index 72% rename from man/dot-DollarNames.LazyFrame.Rd rename to man/dot-DollarNames.RPolarsLazyFrame.Rd index ff551cfb1..bed21da19 100644 --- a/man/dot-DollarNames.LazyFrame.Rd +++ b/man/dot-DollarNames.RPolarsLazyFrame.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/lazyframe__lazy.R -\name{.DollarNames.LazyFrame} -\alias{.DollarNames.LazyFrame} +\name{.DollarNames.RPolarsLazyFrame} +\alias{.DollarNames.RPolarsLazyFrame} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{LazyFrame}(x, pattern = "") +\method{.DollarNames}{RPolarsLazyFrame}(x, pattern = "") } \arguments{ \item{x}{LazyFrame} diff --git a/man/print.LazyFrame.Rd b/man/print.RPolarsLazyFrame.Rd similarity index 76% rename from man/print.LazyFrame.Rd rename to man/print.RPolarsLazyFrame.Rd index b661aad86..23a8540b7 100644 --- a/man/print.LazyFrame.Rd +++ b/man/print.RPolarsLazyFrame.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/lazyframe__lazy.R -\name{print.LazyFrame} -\alias{print.LazyFrame} +\name{print.RPolarsLazyFrame} +\alias{print.RPolarsLazyFrame} \title{print LazyFrame s3 method} \usage{ -\method{print}{LazyFrame}(x, ...) +\method{print}{RPolarsLazyFrame}(x, ...) } \arguments{ \item{x}{DataFrame} diff --git a/src/rust/src/concat.rs b/src/rust/src/concat.rs index 2a182d40c..9352c7e0d 100644 --- a/src/rust/src/concat.rs +++ b/src/rust/src/concat.rs @@ -1,7 +1,7 @@ use crate::rdataframe::DataFrame; use crate::robj_to; -use crate::rdataframe::LazyFrame; +use crate::rdataframe::RPolarsLazyFrame; use crate::rpolarserr::*; use crate::series::Series; use extendr_api::prelude::*; @@ -12,7 +12,7 @@ use polars_core::functions as pl_functions; use std::result::Result; #[extendr] -fn concat_lf(l: Robj, rechunk: bool, parallel: bool, to_supertypes: bool) -> RResult { +fn concat_lf(l: Robj, rechunk: bool, parallel: bool, to_supertypes: bool) -> RResult { let vlf = robj_to!(Vec, PLLazyFrame, l)?; dsl::concat( vlf, @@ -23,7 +23,7 @@ fn concat_lf(l: Robj, rechunk: bool, parallel: bool, to_supertypes: bool) -> RRe }, ) .map_err(polars_to_rpolars_err) - .map(LazyFrame) + .map(RPolarsLazyFrame) } #[extendr] @@ -32,7 +32,7 @@ fn concat_lf_diagonal( rechunk: bool, parallel: bool, to_supertypes: bool, -) -> RResult { +) -> RResult { let vlf = robj_to!(Vec, PLLazyFrame, l)?; dsl::concat_lf_diagonal( vlf, @@ -43,7 +43,7 @@ fn concat_lf_diagonal( }, ) .map_err(polars_to_rpolars_err) - .map(LazyFrame) + .map(RPolarsLazyFrame) } #[extendr] diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index fa22ecc21..b6bb57201 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -25,22 +25,22 @@ use polars_lazy::prelude::CsvWriterOptions; use std::result::Result; #[derive(Clone)] -pub struct LazyFrame(pub pl::LazyFrame); +pub struct RPolarsLazyFrame(pub pl::LazyFrame); -impl std::fmt::Debug for LazyFrame { +impl std::fmt::Debug for RPolarsLazyFrame { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "LazyFrame:") } } -impl From for LazyFrame { +impl From for RPolarsLazyFrame { fn from(item: pl::LazyFrame) -> Self { - LazyFrame(item) + RPolarsLazyFrame(item) } } #[extendr] -impl LazyFrame { +impl RPolarsLazyFrame { fn print(&self) -> Self { rprintln!("{}", self.0.describe_plan()); self.clone() @@ -237,7 +237,7 @@ impl LazyFrame { self.0.clone().reverse().into() } - fn drop(&self, columns: Robj) -> Result { + fn drop(&self, columns: Robj) -> Result { Ok(self .0 .clone() @@ -261,8 +261,8 @@ impl LazyFrame { .into()) } - fn slice(&self, offset: Robj, length: Robj) -> Result { - Ok(LazyFrame(self.0.clone().slice( + fn slice(&self, offset: Robj, length: Robj) -> Result { + Ok(RPolarsLazyFrame(self.0.clone().slice( robj_to!(i64, offset)?, robj_to!(Option, u32, length)?.unwrap_or(u32::MAX), ))) @@ -271,47 +271,47 @@ impl LazyFrame { pub fn with_columns(&self, exprs: Robj) -> RResult { let exprs = robj_to!(VecPLExprColNamed, exprs).when("preparing expressions for $with_columns()")?; - Ok(LazyFrame(self.clone().0.with_columns(exprs))) + Ok(RPolarsLazyFrame(self.clone().0.with_columns(exprs))) } pub fn unnest(&self, names: Vec) -> RResult { - Ok(LazyFrame(self.clone().0.unnest(names))) + Ok(RPolarsLazyFrame(self.clone().0.unnest(names))) } pub fn select(&self, exprs: Robj) -> RResult { let exprs = robj_to!(VecPLExprColNamed, exprs).when("preparing expressions for $select()")?; - Ok(LazyFrame(self.clone().0.select(exprs))) + Ok(RPolarsLazyFrame(self.clone().0.select(exprs))) } pub fn select_str_as_lit(&self, exprs: Robj) -> RResult { let exprs = robj_to!(VecPLExprNamed, exprs).when("preparing columns for DataFrame")?; - Ok(LazyFrame(self.clone().0.select(exprs))) + Ok(RPolarsLazyFrame(self.clone().0.select(exprs))) } fn limit(&self, n: Robj) -> Result { Ok(self.0.clone().limit(robj_to!(u32, n)?).into()) } - fn tail(&self, n: Robj) -> Result { - Ok(LazyFrame(self.0.clone().tail(robj_to!(u32, n)?))) + fn tail(&self, n: Robj) -> Result { + Ok(RPolarsLazyFrame(self.0.clone().tail(robj_to!(u32, n)?))) } - fn filter(&self, expr: &Expr) -> LazyFrame { + fn filter(&self, expr: &Expr) -> RPolarsLazyFrame { let new_df = self.clone().0.filter(expr.0.clone()); - LazyFrame(new_df) + RPolarsLazyFrame(new_df) } - fn drop_nulls(&self, subset: &ProtoExprArray) -> LazyFrame { + fn drop_nulls(&self, subset: &ProtoExprArray) -> RPolarsLazyFrame { if subset.0.is_empty() { - LazyFrame(self.0.clone().drop_nulls(None)) + RPolarsLazyFrame(self.0.clone().drop_nulls(None)) } else { let vec = pra_to_vec(subset, "select"); - LazyFrame(self.0.clone().drop_nulls(Some(vec))) + RPolarsLazyFrame(self.0.clone().drop_nulls(Some(vec))) } } - fn unique(&self, subset: Robj, keep: Robj, maintain_order: Robj) -> Result { + fn unique(&self, subset: Robj, keep: Robj, maintain_order: Robj) -> Result { let ke = new_unique_keep_strategy(robj_to!(str, keep)?)?; let maintain_order = robj_to!(bool, maintain_order)?; let subset = robj_to!(Option, Vec, String, subset)?; @@ -422,8 +422,8 @@ impl LazyFrame { suffix: Robj, allow_parallel: Robj, force_parallel: Robj, - ) -> RResult { - Ok(LazyFrame( + ) -> RResult { + Ok(RPolarsLazyFrame( self.0 .clone() .join_builder() @@ -477,7 +477,7 @@ impl LazyFrame { Ok(self.0.clone().melt(args).into()) } - fn rename(&self, existing: Robj, new: Robj) -> Result { + fn rename(&self, existing: Robj, new: Robj) -> Result { Ok(self .0 .clone() @@ -564,7 +564,7 @@ impl LazyFrame { profile_with_r_func_support(self.0.clone()).map(|(r, p)| list!(result = r, profile = p)) } - fn explode(&self, dotdotdot: Robj) -> RResult { + fn explode(&self, dotdotdot: Robj) -> RResult { Ok(self .0 .clone() @@ -572,7 +572,7 @@ impl LazyFrame { .into()) } - pub fn clone_in_rust(&self) -> LazyFrame { + pub fn clone_in_rust(&self) -> RPolarsLazyFrame { self.clone() } @@ -601,15 +601,15 @@ impl LazyGroupBy { self.clone() } - fn ungroup(&self) -> LazyFrame { - LazyFrame( + fn ungroup(&self) -> RPolarsLazyFrame { + RPolarsLazyFrame( pl::LazyFrame::from(self.lgb.logical_plan.clone()) .with_optimizations(self.opt_state.clone()), ) } - fn agg(&self, exprs: Robj) -> Result { - Ok(LazyFrame( + fn agg(&self, exprs: Robj) -> Result { + Ok(RPolarsLazyFrame( self.lgb.clone().agg(robj_to!(VecPLExprColNamed, exprs)?), )) } @@ -617,7 +617,7 @@ impl LazyGroupBy { fn head(&self, n: f64) -> List { r_result_list( try_f64_into_usize(n) - .map(|n| LazyFrame(self.lgb.clone().head(Some(n)))) + .map(|n| RPolarsLazyFrame(self.lgb.clone().head(Some(n)))) .map_err(|err| format!("head: {}", err)), ) } @@ -625,7 +625,7 @@ impl LazyGroupBy { fn tail(&self, n: f64) -> List { r_result_list( try_f64_into_usize(n) - .map(|n| LazyFrame(self.lgb.clone().tail(Some(n)))) + .map(|n| RPolarsLazyFrame(self.lgb.clone().tail(Some(n)))) .map_err(|err| format!("tail: {}", err)), ) } @@ -633,6 +633,6 @@ impl LazyGroupBy { extendr_module! { mod dataframe; - impl LazyFrame; + impl RPolarsLazyFrame; impl LazyGroupBy; } diff --git a/src/rust/src/rbackground.rs b/src/rust/src/rbackground.rs index 234cfc1f4..1750f2065 100644 --- a/src/rust/src/rbackground.rs +++ b/src/rust/src/rbackground.rs @@ -571,7 +571,7 @@ pub fn test_rthreadhandle() -> RThreadHandle> { .alias("Price"), ) }; - let rlf = crate::lazy::dataframe::LazyFrame::from(plf) + let rlf = crate::lazy::dataframe::RPolarsLazyFrame::from(plf) .collect() .unwrap(); Ok(rlf) diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index ae159ae46..c5bf64d4a 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -119,8 +119,8 @@ impl DataFrame { DataFrame::new_with_capacity(0) } - pub fn lazy(&self) -> LazyFrame { - LazyFrame(self.0.clone().lazy()) + pub fn lazy(&self) -> RPolarsLazyFrame { + RPolarsLazyFrame(self.0.clone().lazy()) } //internal use only @@ -318,7 +318,7 @@ impl DataFrame { } else { lazy_df.group_by(group_exprs) }; - LazyFrame(lgb.agg(agg_exprs)).collect() + RPolarsLazyFrame(lgb.agg(agg_exprs)).collect() } pub fn to_struct(&self, name: &str) -> Series { diff --git a/src/rust/src/rdataframe/read_csv.rs b/src/rust/src/rdataframe/read_csv.rs index 912ce4594..70b885a73 100644 --- a/src/rust/src/rdataframe/read_csv.rs +++ b/src/rust/src/rdataframe/read_csv.rs @@ -2,7 +2,7 @@ use crate::rdatatype::DataTypeVector; -use crate::lazy::dataframe::LazyFrame; +use crate::lazy::dataframe::RPolarsLazyFrame; use crate::robj_to; use crate::rpolarserr::*; use polars::io::RowCount; @@ -69,7 +69,7 @@ pub fn new_from_csv( eol_char: Robj, raise_if_empty: Robj, truncate_ragged_lines: Robj, -) -> RResult { +) -> RResult { let offset = robj_to!(Option, u32, row_count_offset)?.unwrap_or(0); let opt_rowcount = robj_to!(Option, String, row_count_name)?.map(|name| RowCount { name, offset }); @@ -124,7 +124,7 @@ pub fn new_from_csv( .raise_if_empty(robj_to!(bool, raise_if_empty)?) .finish() .map_err(polars_to_rpolars_err) - .map(LazyFrame) + .map(RPolarsLazyFrame) } extendr_module! { diff --git a/src/rust/src/rdataframe/read_ipc.rs b/src/rust/src/rdataframe/read_ipc.rs index 260d61e8d..547484f6e 100644 --- a/src/rust/src/rdataframe/read_ipc.rs +++ b/src/rust/src/rdataframe/read_ipc.rs @@ -1,4 +1,4 @@ -use crate::lazy::dataframe::LazyFrame as RLazyFrame; +use crate::lazy::dataframe::RPolarsLazyFrame as RLazyFrame; use crate::robj_to; use crate::rpolarserr::RResult; use extendr_api::prelude::*; diff --git a/src/rust/src/rdataframe/read_ndjson.rs b/src/rust/src/rdataframe/read_ndjson.rs index 2b2bf06aa..42e907a1c 100644 --- a/src/rust/src/rdataframe/read_ndjson.rs +++ b/src/rust/src/rdataframe/read_ndjson.rs @@ -1,6 +1,6 @@ //read ndjson -use crate::lazy::dataframe::LazyFrame; +use crate::lazy::dataframe::RPolarsLazyFrame; use crate::robj_to; use crate::rpolarserr::*; use polars::io::RowCount; @@ -22,7 +22,7 @@ pub fn new_from_ndjson( rechunk: Robj, row_count_name: Robj, row_count_offset: Robj, -) -> RResult { +) -> RResult { let offset = robj_to!(Option, u32, row_count_offset)?.unwrap_or(0); let opt_rowcount = robj_to!(Option, String, row_count_name)?.map(|name| RowCount { name, offset }); @@ -43,7 +43,7 @@ pub fn new_from_ndjson( .with_rechunk(robj_to!(bool, rechunk)?) .finish() .map_err(polars_to_rpolars_err) - .map(LazyFrame) + .map(RPolarsLazyFrame) } extendr_module! { diff --git a/src/rust/src/rdataframe/read_parquet.rs b/src/rust/src/rdataframe/read_parquet.rs index c351fcc78..52eabb1ae 100644 --- a/src/rust/src/rdataframe/read_parquet.rs +++ b/src/rust/src/rdataframe/read_parquet.rs @@ -1,4 +1,4 @@ -use crate::lazy::dataframe::LazyFrame; +use crate::lazy::dataframe::RPolarsLazyFrame; use crate::robj_to; use crate::rpolarserr::{polars_to_rpolars_err, RResult}; @@ -21,7 +21,7 @@ pub fn new_from_parquet( low_memory: Robj, hive_partitioning: Robj, //retries: Robj // not supported yet, with CloudOptions -) -> RResult { +) -> RResult { let offset = robj_to!(Option, u32, row_count)?.unwrap_or(0); let opt_rowcount = robj_to!(Option, String, row_name)?.map(|name| RowCount { name, offset }); let args = pl::ScanArgsParquet { @@ -38,7 +38,7 @@ pub fn new_from_parquet( pl::LazyFrame::scan_parquet(robj_to!(String, path)?, args) .map_err(polars_to_rpolars_err) - .map(LazyFrame) + .map(RPolarsLazyFrame) } extendr_module! { diff --git a/src/rust/src/sql.rs b/src/rust/src/sql.rs index e9636efd8..87fbf4fa0 100644 --- a/src/rust/src/sql.rs +++ b/src/rust/src/sql.rs @@ -18,7 +18,7 @@ impl RPolarsSQLContext { } } - pub fn execute(&mut self, query: &str) -> RResult { + pub fn execute(&mut self, query: &str) -> RResult { Ok(self .context .execute(query) diff --git a/src/rust/src/utils/mod.rs b/src/rust/src/utils/mod.rs index 70ed0976d..ddf6bb62d 100644 --- a/src/rust/src/utils/mod.rs +++ b/src/rust/src/utils/mod.rs @@ -12,7 +12,7 @@ use crate::series::Series; use std::any::type_name as tn; //use std::intrinsics::read_via_copy; use crate::lazy::dsl::robj_to_col; -use crate::rdataframe::{DataFrame, LazyFrame}; +use crate::rdataframe::{DataFrame, RPolarsLazyFrame}; use extendr_api::eval_string_with_params; use extendr_api::prelude::{list, Result as EResult, Strings}; use extendr_api::Attributes; @@ -806,18 +806,18 @@ fn internal_rust_wrap_e(robj: Robj, str_to_lit: bool) -> RResult { } } -pub fn robj_to_lazyframe(robj: extendr_api::Robj) -> RResult { +pub fn robj_to_lazyframe(robj: extendr_api::Robj) -> RResult { let robj = unpack_r_result_list(robj)?; let rv = rdbg(&robj); // closure to allow ?-convert extendr::Result to RResult - let res = || -> RResult { - let lf: ExternalPtr = + let res = || -> RResult { + let lf: ExternalPtr = (unpack_r_eval(R!("polars:::result(polars::as_polars_lf({{robj}}))"))?).try_into()?; - Ok(LazyFrame(lf.0.clone())) + Ok(RPolarsLazyFrame(lf.0.clone())) }(); - res.bad_val(rv).mistyped(tn::()) + res.bad_val(rv).mistyped(tn::()) } pub fn robj_to_dataframe(robj: extendr_api::Robj) -> RResult { From adf0a94ba0f1efc3812ee9a1031fef12f548da57 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:58:41 +0100 Subject: [PATCH 02/32] DataFrame -> RPolarsDataFrame [skip ci] --- NAMESPACE | 48 +++++----- R/after-wrappers.R | 4 +- R/as_polars.R | 2 +- R/dataframe__frame.R | 10 +- R/error__rpolarserr.R | 2 +- R/expr__expr.R | 8 +- R/extendr-wrappers.R | 92 ++++++++++--------- R/functions__whenthen.R | 8 +- R/group_by.R | 2 +- R/lazyframe__lazy.R | 2 +- R/pkg-knitr.R | 4 +- R/pkg-nanoarrow.R | 14 +-- R/s3_methods.R | 48 +++++----- R/sql.R | 2 +- R/zzz.R | 12 +-- man/DataFrame_class.Rd | 2 +- man/S3_as.data.frame.Rd | 6 +- man/S3_as.matrix.Rd | 6 +- man/S3_dim.Rd | 6 +- man/S3_dimnames.Rd | 6 +- man/S3_extract.Rd | 6 +- man/S3_head.Rd | 6 +- man/S3_length.Rd | 6 +- man/S3_max.Rd | 6 +- man/S3_mean.Rd | 6 +- man/S3_median.Rd | 6 +- man/S3_min.Rd | 6 +- man/S3_na.omit.Rd | 4 +- man/S3_names.Rd | 6 +- man/S3_rownames.Rd | 6 +- man/S3_sum.Rd | 6 +- man/S3_tail.Rd | 6 +- man/S3_unique.Rd | 6 +- man/as_polars_df.Rd | 4 +- ...Rd => dot-DollarNames.RPolarsDataFrame.Rd} | 6 +- ...rame.Rd => knit_print.RPolarsDataFrame.Rd} | 6 +- ...DataFrame.Rd => print.RPolarsDataFrame.Rd} | 6 +- src/rust/src/concat.rs | 8 +- src/rust/src/concurrent.rs | 14 +-- src/rust/src/conversion_s_to_r.rs | 4 +- src/rust/src/lazy/dataframe.rs | 2 +- src/rust/src/rbackground.rs | 14 +-- src/rust/src/rdataframe/mod.rs | 42 ++++----- src/rust/src/rlib.rs | 14 +-- src/rust/src/series.rs | 16 ++-- src/rust/src/utils/mod.rs | 10 +- 46 files changed, 255 insertions(+), 251 deletions(-) rename man/{dot-DollarNames.DataFrame.Rd => dot-DollarNames.RPolarsDataFrame.Rd} (76%) rename man/{knit_print.DataFrame.Rd => knit_print.RPolarsDataFrame.Rd} (87%) rename man/{print.DataFrame.Rd => print.RPolarsDataFrame.Rd} (75%) diff --git a/NAMESPACE b/NAMESPACE index c0173120a..2e17a1eea 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,7 +6,6 @@ S3method("!=",RPolarsDataType) S3method("!=",Series) S3method("$",ChainedThen) S3method("$",ChainedWhen) -S3method("$",DataFrame) S3method("$",DataTypeVector) S3method("$",Expr) S3method("$",ExprBinNameSpace) @@ -22,6 +21,7 @@ S3method("$",LazyGroupBy) S3method("$",ProtoExprArray) S3method("$",RField) S3method("$",RNullValues) +S3method("$",RPolarsDataFrame) S3method("$",RPolarsDataType) S3method("$",RPolarsErr) S3method("$",RPolarsLazyFrame) @@ -34,8 +34,8 @@ S3method("$",VecDataFrame) S3method("$",When) S3method("$",pl_polars_env) S3method("$",private_polars_env) -S3method("$<-",DataFrame) S3method("$<-",RField) +S3method("$<-",RPolarsDataFrame) S3method("%%",Expr) S3method("%/%",Expr) S3method("&",Expr) @@ -58,14 +58,13 @@ S3method(">",Expr) S3method(">",Series) S3method(">=",Expr) S3method(">=",Series) -S3method("[",DataFrame) S3method("[",ExprListNameSpace) +S3method("[",RPolarsDataFrame) S3method("[",RPolarsLazyFrame) S3method("[",Series) S3method("[",rpolars_raw_list) S3method("[[",ChainedThen) S3method("[[",ChainedWhen) -S3method("[[",DataFrame) S3method("[[",DataTypeVector) S3method("[[",Expr) S3method("[[",GroupBy) @@ -73,6 +72,7 @@ S3method("[[",LazyGroupBy) S3method("[[",ProtoExprArray) S3method("[[",RField) S3method("[[",RNullValues) +S3method("[[",RPolarsDataFrame) S3method("[[",RPolarsDataType) S3method("[[",RPolarsErr) S3method("[[",RPolarsLazyFrame) @@ -87,10 +87,10 @@ S3method("^",Expr) S3method("|",Expr) S3method(.DollarNames,ChainedThen) S3method(.DollarNames,ChainedWhen) -S3method(.DollarNames,DataFrame) S3method(.DollarNames,Expr) S3method(.DollarNames,GroupBy) S3method(.DollarNames,RField) +S3method(.DollarNames,RPolarsDataFrame) S3method(.DollarNames,RPolarsErr) S3method(.DollarNames,RPolarsLazyFrame) S3method(.DollarNames,RPolarsSQLContext) @@ -103,17 +103,17 @@ S3method(.DollarNames,method_environment) S3method(as.character,RPolarsErr) S3method(as.character,RThreadHandle) S3method(as.character,Series) -S3method(as.data.frame,DataFrame) +S3method(as.data.frame,RPolarsDataFrame) S3method(as.data.frame,RPolarsLazyFrame) S3method(as.list,Expr) S3method(as.list,rpolars_raw_list) -S3method(as.matrix,DataFrame) +S3method(as.matrix,RPolarsDataFrame) S3method(as.matrix,RPolarsLazyFrame) S3method(as.vector,Series) S3method(as_polars_df,ArrowTabular) -S3method(as_polars_df,DataFrame) S3method(as_polars_df,GroupBy) S3method(as_polars_df,LazyGroupBy) +S3method(as_polars_df,RPolarsDataFrame) S3method(as_polars_df,RPolarsLazyFrame) S3method(as_polars_df,Series) S3method(as_polars_df,data.frame) @@ -125,39 +125,39 @@ S3method(as_polars_series,POSIXlt) S3method(as_polars_series,default) S3method(as_polars_series,vctrs_rcrd) S3method(c,Series) -S3method(dim,DataFrame) +S3method(dim,RPolarsDataFrame) S3method(dim,RPolarsLazyFrame) -S3method(dimnames,DataFrame) +S3method(dimnames,RPolarsDataFrame) S3method(dimnames,RPolarsLazyFrame) -S3method(head,DataFrame) +S3method(head,RPolarsDataFrame) S3method(head,RPolarsLazyFrame) -S3method(length,DataFrame) +S3method(length,RPolarsDataFrame) S3method(length,RPolarsLazyFrame) S3method(length,Series) -S3method(max,DataFrame) +S3method(max,RPolarsDataFrame) S3method(max,RPolarsLazyFrame) S3method(max,Series) -S3method(mean,DataFrame) +S3method(mean,RPolarsDataFrame) S3method(mean,RPolarsLazyFrame) S3method(mean,Series) -S3method(median,DataFrame) +S3method(median,RPolarsDataFrame) S3method(median,RPolarsLazyFrame) S3method(median,Series) -S3method(min,DataFrame) +S3method(min,RPolarsDataFrame) S3method(min,RPolarsLazyFrame) S3method(min,Series) -S3method(na.omit,DataFrame) +S3method(na.omit,RPolarsDataFrame) S3method(na.omit,RPolarsLazyFrame) -S3method(names,DataFrame) +S3method(names,RPolarsDataFrame) S3method(names,RPolarsLazyFrame) S3method(print,ChainedThen) S3method(print,ChainedWhen) -S3method(print,DataFrame) S3method(print,Expr) S3method(print,GroupBy) S3method(print,LazyGroupBy) S3method(print,PTime) S3method(print,RField) +S3method(print,RPolarsDataFrame) S3method(print,RPolarsDataType) S3method(print,RPolarsErr) S3method(print,RPolarsLazyFrame) @@ -166,13 +166,13 @@ S3method(print,Series) S3method(print,Then) S3method(print,When) S3method(print,polars_info) -S3method(row.names,DataFrame) -S3method(sum,DataFrame) +S3method(row.names,RPolarsDataFrame) +S3method(sum,RPolarsDataFrame) S3method(sum,RPolarsLazyFrame) S3method(sum,Series) -S3method(tail,DataFrame) +S3method(tail,RPolarsDataFrame) S3method(tail,RPolarsLazyFrame) -S3method(unique,DataFrame) +S3method(unique,RPolarsDataFrame) S3method(unique,RPolarsLazyFrame) export(.pr) export(GroupBy_ungroup) @@ -180,7 +180,7 @@ export(LazyGroupBy_ungroup) export(as_polars_df) export(as_polars_lf) export(as_polars_series) -export(knit_print.DataFrame) +export(knit_print.RPolarsDataFrame) export(pl) importFrom(stats,median) importFrom(stats,na.omit) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index cfcf78114..d6a3a3276 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -78,7 +78,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { #' .pr$print_env(.pr, ".pr the collection of private method calls to rust-polars") .pr = new.env(parent = emptyenv()) .pr$Series = extendr_method_to_pure_functions(Series) -.pr$DataFrame = extendr_method_to_pure_functions(DataFrame) +.pr$DataFrame = extendr_method_to_pure_functions(RPolarsDataFrame) .pr$GroupBy = NULL # derived from DataFrame in R, has no rust calls .pr$LazyFrame = extendr_method_to_pure_functions(RPolarsLazyFrame) .pr$LazyGroupBy = extendr_method_to_pure_functions(LazyGroupBy) @@ -267,7 +267,7 @@ DataType = clone_env_one_level_deep(RPolarsDataType) # used for printing public environment pl_class_names = sort( c( - "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "Expr", "DataFrame", + "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "Expr", "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", "RPolarsSQLContext" ) ) # TODO discover all public class automatically diff --git a/R/as_polars.R b/R/as_polars.R index 43b1f57de..edcc881aa 100644 --- a/R/as_polars.R +++ b/R/as_polars.R @@ -44,7 +44,7 @@ as_polars_df.data.frame = function(x, ...) { #' @rdname as_polars_df #' @export -as_polars_df.DataFrame = function(x, ...) { +as_polars_df.RPolarsDataFrame = function(x, ...) { x } diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 65f6d250d..9275a495a 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -7,7 +7,7 @@ #' `DataFrame`-object is an `externalptr` to a low-level Rust polars DataFrame #' object. #' -#' The S3 method `.DollarNames.DataFrame` exposes all public `$foobar()`-methods +#' The S3 method `.DollarNames.RPolarsDataFrame` exposes all public `$foobar()`-methods #' which are callable onto the object. Most methods return another `DataFrame`- #' class instance or similar which allows for method chaining. This class system #' could be called "environment classes" (in lack of a better name) and is the @@ -82,7 +82,7 @@ DataFrame #' @export #' @return Doesn't return a value. This is used for autocompletion in RStudio. #' @keywords internal -.DollarNames.DataFrame = function(x, pattern = "") { +.DollarNames.RPolarsDataFrame = function(x, pattern = "") { get_method_usages(DataFrame, pattern = pattern) } @@ -93,7 +93,7 @@ DataFrame #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.VecDataFrame = function(x, pattern = "") { get_method_usages(VecDataFrame, pattern = pattern) @@ -218,7 +218,7 @@ pl$DataFrame = function(..., make_names_unique = TRUE, schema = NULL) { #' @export #' #' @examples pl$DataFrame(iris) -print.DataFrame = function(x, ...) { +print.RPolarsDataFrame = function(x, ...) { x$print() invisible(x) } @@ -283,7 +283,7 @@ DataFrame.property_setters = new.env(parent = emptyenv()) #' # to verify inside code of a property, use the [[]] syntax instead. #' df[["columns"]] # to see property code, .pr is the internal polars api into rust polars #' DataFrame.property_setters$columns # and even more obscure to see setter code -"$<-.DataFrame" = function(self, name, value) { +"$<-.RPolarsDataFrame" = function(self, name, value) { name = sub("<-$", "", name) # stop if method is not a setter diff --git a/R/error__rpolarserr.R b/R/error__rpolarserr.R index b851e3bb9..9e94acd38 100644 --- a/R/error__rpolarserr.R +++ b/R/error__rpolarserr.R @@ -4,7 +4,7 @@ #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsErr = function(x, pattern = "") { get_method_usages(RPolarsErr, pattern = pattern) diff --git a/R/expr__expr.R b/R/expr__expr.R index 89457ef6d..70ac6fc30 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -51,7 +51,7 @@ Expr_print = function() { #' #' @param x Name of an `Expr` object #' @param pattern String used to auto-complete -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @export #' @keywords internal .DollarNames.Expr = function(x, pattern = "") { @@ -1576,9 +1576,9 @@ Expr_sort_by = function(by, descending = FALSE) { # TODO coontribute pyPolars, if exceeding u32 return Null, if exceeding column return Error # either it should be error or Null. -# pl.DataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(5294967296.0)) #return Null -# pl.DataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(-3)) #return Null -# pl.DataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(7)) #return Error +# pl.RPolarsDataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(5294967296.0)) #return Null +# pl.RPolarsDataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(-3)) #return Null +# pl.RPolarsDataFrame({"a":[0,1,2,3,4],"b":[4,3,2,1,0]}).select(pl.col("a").take(7)) #return Error #' Gather values by index #' diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index b2d52ce6d..58004c5e6 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -121,94 +121,100 @@ using_string_cache <- function() .Call(wrap__using_string_cache) DataFrame <- new.env(parent = emptyenv()) -DataFrame$shape <- function() .Call(wrap__DataFrame__shape, self) +DataFrame$shape <- function() .Call(wrap__RPolarsDataFrame__shape, self) -DataFrame$n_chunks <- function(strategy) .Call(wrap__DataFrame__n_chunks, self, strategy) +DataFrame$n_chunks <- function(strategy) .Call(wrap__RPolarsDataFrame__n_chunks, self, strategy) -DataFrame$rechunk <- function() .Call(wrap__DataFrame__rechunk, self) +DataFrame$rechunk <- function() .Call(wrap__RPolarsDataFrame__rechunk, self) -DataFrame$clone_in_rust <- function() .Call(wrap__DataFrame__clone_in_rust, self) +DataFrame$clone_in_rust <- function() .Call(wrap__RPolarsDataFrame__clone_in_rust, self) -DataFrame$default <- function() .Call(wrap__DataFrame__default) +DataFrame$default <- function() .Call(wrap__RPolarsDataFrame__default) -DataFrame$lazy <- function() .Call(wrap__DataFrame__lazy, self) +DataFrame$lazy <- function() .Call(wrap__RPolarsDataFrame__lazy, self) -DataFrame$drop_all_in_place <- function() invisible(.Call(wrap__DataFrame__drop_all_in_place, self)) +DataFrame$drop_all_in_place <- function() invisible(.Call(wrap__RPolarsDataFrame__drop_all_in_place, self)) -DataFrame$new_with_capacity <- function(capacity) .Call(wrap__DataFrame__new_with_capacity, capacity) +DataFrame$new_with_capacity <- function(capacity) .Call(wrap__RPolarsDataFrame__new_with_capacity, capacity) -DataFrame$set_column_from_robj <- function(robj, name) .Call(wrap__DataFrame__set_column_from_robj, self, robj, name) +DataFrame$set_column_from_robj <- function(robj, name) .Call(wrap__RPolarsDataFrame__set_column_from_robj, self, robj, name) -DataFrame$set_column_from_series <- function(x) .Call(wrap__DataFrame__set_column_from_series, self, x) +DataFrame$set_column_from_series <- function(x) .Call(wrap__RPolarsDataFrame__set_column_from_series, self, x) -DataFrame$with_row_count <- function(name, offset) .Call(wrap__DataFrame__with_row_count, self, name, offset) +DataFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsDataFrame__with_row_count, self, name, offset) -DataFrame$print <- function() .Call(wrap__DataFrame__print, self) +DataFrame$print <- function() .Call(wrap__RPolarsDataFrame__print, self) -DataFrame$columns <- function() .Call(wrap__DataFrame__columns, self) +DataFrame$columns <- function() .Call(wrap__RPolarsDataFrame__columns, self) -DataFrame$set_column_names_mut <- function(names) .Call(wrap__DataFrame__set_column_names_mut, self, names) +DataFrame$set_column_names_mut <- function(names) .Call(wrap__RPolarsDataFrame__set_column_names_mut, self, names) -DataFrame$get_column <- function(name) .Call(wrap__DataFrame__get_column, self, name) +DataFrame$get_column <- function(name) .Call(wrap__RPolarsDataFrame__get_column, self, name) -DataFrame$get_columns <- function() .Call(wrap__DataFrame__get_columns, self) +DataFrame$get_columns <- function() .Call(wrap__RPolarsDataFrame__get_columns, self) -DataFrame$dtypes <- function() .Call(wrap__DataFrame__dtypes, self) +DataFrame$dtypes <- function() .Call(wrap__RPolarsDataFrame__dtypes, self) -DataFrame$dtype_strings <- function() .Call(wrap__DataFrame__dtype_strings, self) +DataFrame$dtype_strings <- function() .Call(wrap__RPolarsDataFrame__dtype_strings, self) -DataFrame$schema <- function() .Call(wrap__DataFrame__schema, self) +DataFrame$schema <- function() .Call(wrap__RPolarsDataFrame__schema, self) -DataFrame$to_list <- function() .Call(wrap__DataFrame__to_list, self) +DataFrame$to_list <- function() .Call(wrap__RPolarsDataFrame__to_list, self) -DataFrame$to_list_unwind <- function() .Call(wrap__DataFrame__to_list_unwind, self) +DataFrame$to_list_unwind <- function() .Call(wrap__RPolarsDataFrame__to_list_unwind, self) -DataFrame$to_list_tag_structs <- function() .Call(wrap__DataFrame__to_list_tag_structs, self) +DataFrame$to_list_tag_structs <- function() .Call(wrap__RPolarsDataFrame__to_list_tag_structs, self) -DataFrame$frame_equal <- function(other) .Call(wrap__DataFrame__frame_equal, self, other) +DataFrame$frame_equal <- function(other) .Call(wrap__RPolarsDataFrame__frame_equal, self, other) -DataFrame$select_at_idx <- function(idx) .Call(wrap__DataFrame__select_at_idx, self, idx) +DataFrame$select_at_idx <- function(idx) .Call(wrap__RPolarsDataFrame__select_at_idx, self, idx) -DataFrame$drop_in_place <- function(names) .Call(wrap__DataFrame__drop_in_place, self, names) +DataFrame$drop_in_place <- function(names) .Call(wrap__RPolarsDataFrame__drop_in_place, self, names) -DataFrame$select <- function(exprs) .Call(wrap__DataFrame__select, self, exprs) +DataFrame$select <- function(exprs) .Call(wrap__RPolarsDataFrame__select, self, exprs) -DataFrame$with_columns <- function(exprs) .Call(wrap__DataFrame__with_columns, self, exprs) +DataFrame$with_columns <- function(exprs) .Call(wrap__RPolarsDataFrame__with_columns, self, exprs) -DataFrame$by_agg <- function(group_exprs, agg_exprs, maintain_order) .Call(wrap__DataFrame__by_agg, self, group_exprs, agg_exprs, maintain_order) +DataFrame$by_agg <- function(group_exprs, agg_exprs, maintain_order) .Call(wrap__RPolarsDataFrame__by_agg, self, group_exprs, agg_exprs, maintain_order) -DataFrame$to_struct <- function(name) .Call(wrap__DataFrame__to_struct, self, name) +DataFrame$to_struct <- function(name) .Call(wrap__RPolarsDataFrame__to_struct, self, name) -DataFrame$unnest <- function(names) .Call(wrap__DataFrame__unnest, self, names) +DataFrame$unnest <- function(names) .Call(wrap__RPolarsDataFrame__unnest, self, names) -DataFrame$export_stream <- function(stream_ptr) invisible(.Call(wrap__DataFrame__export_stream, self, stream_ptr)) +DataFrame$export_stream <- function(stream_ptr) invisible(.Call(wrap__RPolarsDataFrame__export_stream, self, stream_ptr)) -DataFrame$from_arrow_record_batches <- function(rbr) .Call(wrap__DataFrame__from_arrow_record_batches, rbr) +DataFrame$from_arrow_record_batches <- function(rbr) .Call(wrap__RPolarsDataFrame__from_arrow_record_batches, rbr) -DataFrame$estimated_size <- function() .Call(wrap__DataFrame__estimated_size, self) +DataFrame$estimated_size <- function() .Call(wrap__RPolarsDataFrame__estimated_size, self) -DataFrame$null_count <- function() .Call(wrap__DataFrame__null_count, self) +DataFrame$null_count <- function() .Call(wrap__RPolarsDataFrame__null_count, self) -DataFrame$melt <- function(id_vars, value_vars, value_name, variable_name) .Call(wrap__DataFrame__melt, self, id_vars, value_vars, value_name, variable_name) +DataFrame$melt <- function(id_vars, value_vars, value_name, variable_name) .Call(wrap__RPolarsDataFrame__melt, self, id_vars, value_vars, value_name, variable_name) -DataFrame$pivot_expr <- function(values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) .Call(wrap__DataFrame__pivot_expr, self, values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) +DataFrame$pivot_expr <- function(values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) .Call(wrap__RPolarsDataFrame__pivot_expr, self, values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) -DataFrame$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__DataFrame__sample_n, self, n, with_replacement, shuffle, seed) +DataFrame$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_n, self, n, with_replacement, shuffle, seed) -DataFrame$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__DataFrame__sample_frac, self, frac, with_replacement, shuffle, seed) +DataFrame$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_frac, self, frac, with_replacement, shuffle, seed) -DataFrame$transpose <- function(keep_names_as, new_col_names) .Call(wrap__DataFrame__transpose, self, keep_names_as, new_col_names) +DataFrame$transpose <- function(keep_names_as, new_col_names) .Call(wrap__RPolarsDataFrame__transpose, self, keep_names_as, new_col_names) -DataFrame$write_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__DataFrame__write_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) +DataFrame$write_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__RPolarsDataFrame__write_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) -DataFrame$write_json <- function(file, pretty, row_oriented) .Call(wrap__DataFrame__write_json, self, file, pretty, row_oriented) +DataFrame$write_json <- function(file, pretty, row_oriented) .Call(wrap__RPolarsDataFrame__write_json, self, file, pretty, row_oriented) -DataFrame$write_ndjson <- function(file) .Call(wrap__DataFrame__write_ndjson, self, file) +DataFrame$write_ndjson <- function(file) .Call(wrap__RPolarsDataFrame__write_ndjson, self, file) + +RPolarsDataFrame <- DataFrame #' @export -`$.DataFrame` <- function (self, name) { func <- DataFrame[[name]]; environment(func) <- environment(); func } +`$.RPolarsDataFrame` <- function (self, name) { func <- RPolarsDataFrame[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsDataFrame` <- `$.RPolarsDataFrame` + +`$.DataFrame` <- function (self, name) { func <- DataFrame[[name]]; environment(func) <- environment(); func } + `[[.DataFrame` <- `$.DataFrame` VecDataFrame <- new.env(parent = emptyenv()) diff --git a/R/functions__whenthen.R b/R/functions__whenthen.R index 41ccb04b2..b6f2530ef 100644 --- a/R/functions__whenthen.R +++ b/R/functions__whenthen.R @@ -149,7 +149,7 @@ print.ChainedThen = function(x, ...) { #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.When = function(x, pattern = "") { paste0(ls(When, pattern = pattern), "()") @@ -161,7 +161,7 @@ print.ChainedThen = function(x, ...) { #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.Then = function(x, pattern = "") { paste0(ls(Then, pattern = pattern), "()") @@ -173,7 +173,7 @@ print.ChainedThen = function(x, ...) { #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.ChainedThen = function(x, pattern = "") { paste0(ls(ChainedThen, pattern = pattern), "()") @@ -185,7 +185,7 @@ print.ChainedThen = function(x, ...) { #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.ChainedWhen = function(x, pattern = "") { paste0(ls(ChainedWhen, pattern = pattern), "()") diff --git a/R/group_by.R b/R/group_by.R index c47cb7472..b74192bc5 100644 --- a/R/group_by.R +++ b/R/group_by.R @@ -31,7 +31,7 @@ GroupBy = new.env(parent = emptyenv()) #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.GroupBy = function(x, pattern = "") { paste0(ls(GroupBy, pattern = pattern), "()") diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 1fb9500cd..5e68c7c68 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -105,7 +105,7 @@ LazyFrame #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsLazyFrame = function(x, pattern = "") { diff --git a/R/pkg-knitr.R b/R/pkg-knitr.R index 4799ad450..a2803a0a9 100644 --- a/R/pkg-knitr.R +++ b/R/pkg-knitr.R @@ -10,13 +10,13 @@ #' #' - `options(polars.df_print = "default")` for the default print method. #' - `options(polars.df_print = "html")` for the HTML table. -#' @name knit_print.DataFrame +#' @name knit_print.RPolarsDataFrame #' @param x a polars DataFrame to knit_print #' @param ... additional arguments, not used #' @return invisible x or NULL #' @keywords DataFrame #' @export -knit_print.DataFrame = function(x, ...) { +knit_print.RPolarsDataFrame = function(x, ...) { .print_opt = getOption("polars.df_print", "auto") .rmd_df_print = knitr::opts_knit$get("rmarkdown.df_print") if (isTRUE(.print_opt == "html") || diff --git a/R/pkg-nanoarrow.R b/R/pkg-nanoarrow.R index a8ead6316..372b5cd7f 100644 --- a/R/pkg-nanoarrow.R +++ b/R/pkg-nanoarrow.R @@ -23,7 +23,7 @@ #' nanoarrow_array_stream = as_nanoarrow_array_stream(df) #' rdf = as.data.frame(nanoarrow_array_stream) #' print(head(rdf)) -as_nanoarrow_array_stream.DataFrame = function(x, ..., schema = NULL) { +as_nanoarrow_array_stream.RPolarsDataFrame = function(x, ..., schema = NULL) { # Don't support the schema argument yet stopifnot(is.null(schema)) stream = nanoarrow::nanoarrow_allocate_array_stream() @@ -36,8 +36,8 @@ as_nanoarrow_array_stream.DataFrame = function(x, ..., schema = NULL) { #' @examples #' nanoarrow_array_schema = infer_nanoarrow_schema(df) #' print(nanoarrow_array_schema) -infer_nanoarrow_schema.DataFrame = function(x, ...) { - as_nanoarrow_array_stream.DataFrame(x)$get_schema() +infer_nanoarrow_schema.RPolarsDataFrame = function(x, ...) { + as_nanoarrow_array_stream.RPolarsDataFrame(x)$get_schema() } #' @rdname nanoarrow @@ -46,8 +46,8 @@ infer_nanoarrow_schema.DataFrame = function(x, ...) { #' library(arrow) #' arrow_table = as_arrow_table(df) #' print(arrow_table) -as_arrow_table.DataFrame = function(x, ...) { - reader = as_record_batch_reader.DataFrame(x) +as_arrow_table.RPolarsDataFrame = function(x, ...) { + reader = as_record_batch_reader.RPolarsDataFrame(x) reader$read_table() } @@ -56,6 +56,6 @@ as_arrow_table.DataFrame = function(x, ...) { #' @examples #' arrow_record_batch_reader = as_record_batch_reader(df) # requires arrow #' print(arrow_record_batch_reader) -as_record_batch_reader.DataFrame = function(x, ..., schema = NULL) { - arrow::as_record_batch_reader(as_nanoarrow_array_stream.DataFrame(x, schema = schema)) +as_record_batch_reader.RPolarsDataFrame = function(x, ..., schema = NULL) { + arrow::as_record_batch_reader(as_nanoarrow_array_stream.RPolarsDataFrame(x, schema = schema)) } diff --git a/R/s3_methods.R b/R/s3_methods.R index 3b99383b2..e2c01244e 100644 --- a/R/s3_methods.R +++ b/R/s3_methods.R @@ -33,7 +33,7 @@ #' lf[pl$col("a") >= 2, pl$col("b")$alias("new"), drop = FALSE] |> #' as.data.frame() #' @export -`[.DataFrame` = function(x, i, j, drop = TRUE) { +`[.RPolarsDataFrame` = function(x, i, j, drop = TRUE) { uw = \(res) unwrap(res, "in `[` (Extract):") # Special case for only `i` being specified @@ -130,7 +130,7 @@ #' @export #' @rdname S3_extract -`[.RPolarsLazyFrame` = `[.DataFrame` +`[.RPolarsLazyFrame` = `[.RPolarsDataFrame` #' @export #' @rdname S3_extract @@ -146,11 +146,11 @@ #' #' @export #' @rdname S3_head -head.DataFrame = function(x, n = 6L, ...) x$limit(n = n) +head.RPolarsDataFrame = function(x, n = 6L, ...) x$limit(n = n) #' @export #' @rdname S3_head -head.RPolarsLazyFrame = head.DataFrame +head.RPolarsLazyFrame = head.RPolarsDataFrame #' Take the last n rows #' @@ -160,11 +160,11 @@ head.RPolarsLazyFrame = head.DataFrame #' #' @export #' @rdname S3_tail -tail.DataFrame = function(x, n = 6L, ...) x$tail(n = n) +tail.RPolarsDataFrame = function(x, n = 6L, ...) x$tail(n = n) #' @export #' @rdname S3_tail -tail.RPolarsLazyFrame = tail.DataFrame +tail.RPolarsLazyFrame = tail.RPolarsDataFrame #' Get the dimensions #' @@ -172,7 +172,7 @@ tail.RPolarsLazyFrame = tail.DataFrame #' #' @export #' @rdname S3_dim -dim.DataFrame = function(x) x$shape +dim.RPolarsDataFrame = function(x) x$shape #' @export #' @rdname S3_dim @@ -185,11 +185,11 @@ dim.RPolarsLazyFrame = function(x) c(NA, x$width) #' #' @export #' @rdname S3_length -length.DataFrame = function(x) x$width +length.RPolarsDataFrame = function(x) x$width #' @export #' @rdname S3_length -length.RPolarsLazyFrame = length.DataFrame +length.RPolarsLazyFrame = length.RPolarsDataFrame #' @export #' @rdname S3_length @@ -201,7 +201,7 @@ length.Series = function(x) x$len() #' #' @export #' @rdname S3_names -names.DataFrame = function(x) x$columns +names.RPolarsDataFrame = function(x) x$columns #' @export #' @rdname S3_names @@ -213,7 +213,7 @@ names.RPolarsLazyFrame = function(x) x$columns #' #' @export #' @rdname S3_rownames -row.names.DataFrame = function(x) as.character(seq_len(nrow(x))) +row.names.RPolarsDataFrame = function(x) as.character(seq_len(nrow(x))) #' Get the row and column names #' @@ -221,7 +221,7 @@ row.names.DataFrame = function(x) as.character(seq_len(nrow(x))) #' #' @export #' @rdname S3_dimnames -dimnames.DataFrame = function(x) list(row.names(x), names(x)) +dimnames.RPolarsDataFrame = function(x) list(row.names(x), names(x)) #' @export #' @rdname S3_dimnames @@ -234,7 +234,7 @@ dimnames.RPolarsLazyFrame = function(x) list(NULL, names(x)) #' #' @export #' @rdname S3_as.data.frame -as.data.frame.DataFrame = function(x, ...) x$to_data_frame(...) +as.data.frame.RPolarsDataFrame = function(x, ...) x$to_data_frame(...) #' @export @@ -243,15 +243,15 @@ as.data.frame.RPolarsLazyFrame = function(x, ...) x$collect()$to_data_frame(...) #' Convert to a matrix #' -#' @inheritParams as.data.frame.DataFrame +#' @inheritParams as.data.frame.RPolarsDataFrame #' #' @export #' @rdname S3_as.matrix -as.matrix.DataFrame = function(x, ...) as.matrix(as.data.frame(x, ...)) +as.matrix.RPolarsDataFrame = function(x, ...) as.matrix(as.data.frame(x, ...)) #' @export #' @rdname S3_as.matrix -as.matrix.RPolarsLazyFrame = as.matrix.DataFrame +as.matrix.RPolarsLazyFrame = as.matrix.RPolarsDataFrame #' Compute the mean #' @@ -261,7 +261,7 @@ as.matrix.RPolarsLazyFrame = as.matrix.DataFrame #' #' @export #' @rdname S3_mean -mean.DataFrame = function(x, ...) x$mean() +mean.RPolarsDataFrame = function(x, ...) x$mean() #' @export #' @rdname S3_mean @@ -280,7 +280,7 @@ mean.Series = function(x, ...) x$mean() #' @export #' @rdname S3_median #' @importFrom stats median -median.DataFrame = function(x, ...) x$median() +median.RPolarsDataFrame = function(x, ...) x$median() #' @export #' @importFrom stats median @@ -300,7 +300,7 @@ median.Series = function(x, ...) x$median() #' #' @export #' @rdname S3_min -min.DataFrame = function(x, ...) x$min() +min.RPolarsDataFrame = function(x, ...) x$min() #' @export #' @rdname S3_min @@ -318,7 +318,7 @@ min.Series = function(x, ...) x$min() #' #' @export #' @rdname S3_max -max.DataFrame = function(x, ...) x$max() +max.RPolarsDataFrame = function(x, ...) x$max() #' @export #' @rdname S3_max @@ -336,7 +336,7 @@ max.Series = function(x, ...) x$max() #' #' @export #' @rdname S3_sum -sum.DataFrame = function(x, ...) x$sum() +sum.RPolarsDataFrame = function(x, ...) x$sum() #' @export #' @rdname S3_sum @@ -399,7 +399,7 @@ print.Series = function(x, ...) { #' @return char vec #' @export #' @noRd -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.Series = function(x, pattern = "") { get_method_usages(Series, pattern = pattern) @@ -451,7 +451,7 @@ na.omit.RPolarsLazyFrame = function(object, subset = NULL, ...) { #' @export #' @rdname S3_na.omit -na.omit.DataFrame = function(object, subset = NULL, ...) { +na.omit.RPolarsDataFrame = function(object, subset = NULL, ...) { if (!is.null(subset) && !is.atomic(subset) && !is.character(subset)) { stop("subset must be NULL, a string, or a character vector") } @@ -475,7 +475,7 @@ na.omit.DataFrame = function(object, subset = NULL, ...) { #' z = as.numeric(c(1, 1, 1:4)) #' ) #' unique(df) -unique.DataFrame = function(x, incomparables = FALSE, subset = NULL, keep = "first", ...) { +unique.RPolarsDataFrame = function(x, incomparables = FALSE, subset = NULL, keep = "first", ...) { if (!is.null(subset) && !is.atomic(subset) && !is.character(subset)) { stop("subset must be NULL, a string, or a character vector") } diff --git a/R/sql.R b/R/sql.R index 3f1f1ac54..9ad59ffeb 100644 --- a/R/sql.R +++ b/R/sql.R @@ -20,7 +20,7 @@ RPolarsSQLContext #' @return char vec #' @export #' @noRd -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsSQLContext = function(x, pattern = "") { get_method_usages(RPolarsSQLContext, pattern = pattern) diff --git a/R/zzz.R b/R/zzz.R index 7a68cf66b..d6dd64197 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -72,7 +72,7 @@ replace_private_with_pub_methods(ChainedThen, "^ChainedThen_") #' @param x string, name of method in method_environment (sub-namespace) #' @param pattern code-stump as string to auto-complete #' @export -#' @inherit .DollarNames.DataFrame return +#' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.method_environment = function(x, pattern = "") { # I ponder why R chose to let attributes of environments be mutable also?! @@ -137,11 +137,11 @@ pl$mem_address = mem_address move_env_elements(pl$dtypes, pl, names(pl$dtypes), remove = FALSE) # register S3 methods for packages in Suggests - s3_register("nanoarrow::as_nanoarrow_array_stream", "DataFrame") - s3_register("nanoarrow::infer_nanoarrow_schema", "DataFrame") - s3_register("arrow::as_record_batch_reader", "DataFrame") - s3_register("arrow::as_arrow_table", "DataFrame") - s3_register("knitr::knit_print", "DataFrame") + s3_register("nanoarrow::as_nanoarrow_array_stream", "RPolarsDataFrame") + s3_register("nanoarrow::infer_nanoarrow_schema", "RPolarsDataFrame") + s3_register("arrow::as_record_batch_reader", "RPolarsDataFrame") + s3_register("arrow::as_arrow_table", "RPolarsDataFrame") + s3_register("knitr::knit_print", "RPolarsDataFrame") pl$numeric_dtypes = pl$dtypes[substr(names(pl$dtypes), 1, 3) %in% c("Int", "Flo")] diff --git a/man/DataFrame_class.Rd b/man/DataFrame_class.Rd index b140f2215..64e9e9052 100644 --- a/man/DataFrame_class.Rd +++ b/man/DataFrame_class.Rd @@ -12,7 +12,7 @@ and private methods/function calls to the polars Rust side. The instantiated \code{DataFrame}-object is an \code{externalptr} to a low-level Rust polars DataFrame object. -The S3 method \code{.DollarNames.DataFrame} exposes all public \verb{$foobar()}-methods +The S3 method \code{.DollarNames.RPolarsDataFrame} exposes all public \verb{$foobar()}-methods which are callable onto the object. Most methods return another \code{DataFrame}- class instance or similar which allows for method chaining. This class system could be called "environment classes" (in lack of a better name) and is the diff --git a/man/S3_as.data.frame.Rd b/man/S3_as.data.frame.Rd index 752acd3de..934ebeb38 100644 --- a/man/S3_as.data.frame.Rd +++ b/man/S3_as.data.frame.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{as.data.frame.DataFrame} -\alias{as.data.frame.DataFrame} +\name{as.data.frame.RPolarsDataFrame} +\alias{as.data.frame.RPolarsDataFrame} \alias{as.data.frame.RPolarsLazyFrame} \title{Convert to a data.frame} \usage{ -\method{as.data.frame}{DataFrame}(x, ...) +\method{as.data.frame}{RPolarsDataFrame}(x, ...) \method{as.data.frame}{RPolarsLazyFrame}(x, ...) } diff --git a/man/S3_as.matrix.Rd b/man/S3_as.matrix.Rd index 8f88fae26..d3230d637 100644 --- a/man/S3_as.matrix.Rd +++ b/man/S3_as.matrix.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{as.matrix.DataFrame} -\alias{as.matrix.DataFrame} +\name{as.matrix.RPolarsDataFrame} +\alias{as.matrix.RPolarsDataFrame} \alias{as.matrix.RPolarsLazyFrame} \title{Convert to a matrix} \usage{ -\method{as.matrix}{DataFrame}(x, ...) +\method{as.matrix}{RPolarsDataFrame}(x, ...) \method{as.matrix}{RPolarsLazyFrame}(x, ...) } diff --git a/man/S3_dim.Rd b/man/S3_dim.Rd index d2346aa13..2e36a44b7 100644 --- a/man/S3_dim.Rd +++ b/man/S3_dim.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{dim.DataFrame} -\alias{dim.DataFrame} +\name{dim.RPolarsDataFrame} +\alias{dim.RPolarsDataFrame} \alias{dim.RPolarsLazyFrame} \title{Get the dimensions} \usage{ -\method{dim}{DataFrame}(x) +\method{dim}{RPolarsDataFrame}(x) \method{dim}{RPolarsLazyFrame}(x) } diff --git a/man/S3_dimnames.Rd b/man/S3_dimnames.Rd index fc0a1c5bf..7b4d6f57a 100644 --- a/man/S3_dimnames.Rd +++ b/man/S3_dimnames.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{dimnames.DataFrame} -\alias{dimnames.DataFrame} +\name{dimnames.RPolarsDataFrame} +\alias{dimnames.RPolarsDataFrame} \alias{dimnames.RPolarsLazyFrame} \title{Get the row and column names} \usage{ -\method{dimnames}{DataFrame}(x) +\method{dimnames}{RPolarsDataFrame}(x) \method{dimnames}{RPolarsLazyFrame}(x) } diff --git a/man/S3_extract.Rd b/man/S3_extract.Rd index 2e2260f40..1d9ff7097 100644 --- a/man/S3_extract.Rd +++ b/man/S3_extract.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{[.DataFrame} -\alias{[.DataFrame} +\name{[.RPolarsDataFrame} +\alias{[.RPolarsDataFrame} \alias{[.RPolarsLazyFrame} \alias{[.Series} \title{Extract Parts of a Polars Object} \usage{ -\method{[}{DataFrame}(x, i, j, drop = TRUE) +\method{[}{RPolarsDataFrame}(x, i, j, drop = TRUE) \method{[}{RPolarsLazyFrame}(x, i, j, drop = TRUE) diff --git a/man/S3_head.Rd b/man/S3_head.Rd index 12d9f571a..6ce24a336 100644 --- a/man/S3_head.Rd +++ b/man/S3_head.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{head.DataFrame} -\alias{head.DataFrame} +\name{head.RPolarsDataFrame} +\alias{head.RPolarsDataFrame} \alias{head.RPolarsLazyFrame} \title{Take the first n rows} \usage{ -\method{head}{DataFrame}(x, n = 6L, ...) +\method{head}{RPolarsDataFrame}(x, n = 6L, ...) \method{head}{RPolarsLazyFrame}(x, n = 6L, ...) } diff --git a/man/S3_length.Rd b/man/S3_length.Rd index 57ac45fcc..eeaaf271b 100644 --- a/man/S3_length.Rd +++ b/man/S3_length.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{length.DataFrame} -\alias{length.DataFrame} +\name{length.RPolarsDataFrame} +\alias{length.RPolarsDataFrame} \alias{length.RPolarsLazyFrame} \alias{length.Series} \title{Get the length} \usage{ -\method{length}{DataFrame}(x) +\method{length}{RPolarsDataFrame}(x) \method{length}{RPolarsLazyFrame}(x) diff --git a/man/S3_max.Rd b/man/S3_max.Rd index c6b3bed9a..a772441d0 100644 --- a/man/S3_max.Rd +++ b/man/S3_max.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{max.DataFrame} -\alias{max.DataFrame} +\name{max.RPolarsDataFrame} +\alias{max.RPolarsDataFrame} \alias{max.RPolarsLazyFrame} \alias{max.Series} \title{Compute the maximum value} \usage{ -\method{max}{DataFrame}(x, ...) +\method{max}{RPolarsDataFrame}(x, ...) \method{max}{RPolarsLazyFrame}(x, ...) diff --git a/man/S3_mean.Rd b/man/S3_mean.Rd index 0c40a7ff4..a696f949a 100644 --- a/man/S3_mean.Rd +++ b/man/S3_mean.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{mean.DataFrame} -\alias{mean.DataFrame} +\name{mean.RPolarsDataFrame} +\alias{mean.RPolarsDataFrame} \alias{mean.RPolarsLazyFrame} \alias{mean.Series} \title{Compute the mean} \usage{ -\method{mean}{DataFrame}(x, ...) +\method{mean}{RPolarsDataFrame}(x, ...) \method{mean}{RPolarsLazyFrame}(x, ...) diff --git a/man/S3_median.Rd b/man/S3_median.Rd index 65606f7fc..3155ec65a 100644 --- a/man/S3_median.Rd +++ b/man/S3_median.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{median.DataFrame} -\alias{median.DataFrame} +\name{median.RPolarsDataFrame} +\alias{median.RPolarsDataFrame} \alias{median.RPolarsLazyFrame} \alias{median.Series} \title{Compute the median} \usage{ -\method{median}{DataFrame}(x, ...) +\method{median}{RPolarsDataFrame}(x, ...) \method{median}{RPolarsLazyFrame}(x, ...) diff --git a/man/S3_min.Rd b/man/S3_min.Rd index 643a2149b..c30ba976a 100644 --- a/man/S3_min.Rd +++ b/man/S3_min.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{min.DataFrame} -\alias{min.DataFrame} +\name{min.RPolarsDataFrame} +\alias{min.RPolarsDataFrame} \alias{min.RPolarsLazyFrame} \alias{min.Series} \title{Compute the minimum value} \usage{ -\method{min}{DataFrame}(x, ...) +\method{min}{RPolarsDataFrame}(x, ...) \method{min}{RPolarsLazyFrame}(x, ...) diff --git a/man/S3_na.omit.Rd b/man/S3_na.omit.Rd index 2568edfbb..3babd0602 100644 --- a/man/S3_na.omit.Rd +++ b/man/S3_na.omit.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/s3_methods.R \name{na.omit.RPolarsLazyFrame} \alias{na.omit.RPolarsLazyFrame} -\alias{na.omit.DataFrame} +\alias{na.omit.RPolarsDataFrame} \title{Drop missing values} \usage{ \method{na.omit}{RPolarsLazyFrame}(object, subset = NULL, ...) -\method{na.omit}{DataFrame}(object, subset = NULL, ...) +\method{na.omit}{RPolarsDataFrame}(object, subset = NULL, ...) } \arguments{ \item{object}{A \link[=DataFrame_class]{DataFrame} or \link[=LazyFrame_class]{LazyFrame}} diff --git a/man/S3_names.Rd b/man/S3_names.Rd index 1ab440d49..84ae8dd18 100644 --- a/man/S3_names.Rd +++ b/man/S3_names.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{names.DataFrame} -\alias{names.DataFrame} +\name{names.RPolarsDataFrame} +\alias{names.RPolarsDataFrame} \alias{names.RPolarsLazyFrame} \title{Get the column names} \usage{ -\method{names}{DataFrame}(x) +\method{names}{RPolarsDataFrame}(x) \method{names}{RPolarsLazyFrame}(x) } diff --git a/man/S3_rownames.Rd b/man/S3_rownames.Rd index bb4b93cb4..adcd18e9e 100644 --- a/man/S3_rownames.Rd +++ b/man/S3_rownames.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{row.names.DataFrame} -\alias{row.names.DataFrame} +\name{row.names.RPolarsDataFrame} +\alias{row.names.RPolarsDataFrame} \title{Get the row names} \usage{ -\method{row.names}{DataFrame}(x) +\method{row.names}{RPolarsDataFrame}(x) } \arguments{ \item{x}{A Polars DataFrame} diff --git a/man/S3_sum.Rd b/man/S3_sum.Rd index 989b65bbf..26a80b173 100644 --- a/man/S3_sum.Rd +++ b/man/S3_sum.Rd @@ -1,12 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{sum.DataFrame} -\alias{sum.DataFrame} +\name{sum.RPolarsDataFrame} +\alias{sum.RPolarsDataFrame} \alias{sum.RPolarsLazyFrame} \alias{sum.Series} \title{Compute the sum} \usage{ -\method{sum}{DataFrame}(x, ...) +\method{sum}{RPolarsDataFrame}(x, ...) \method{sum}{RPolarsLazyFrame}(x, ...) diff --git a/man/S3_tail.Rd b/man/S3_tail.Rd index 1ea5a4e46..9d33be352 100644 --- a/man/S3_tail.Rd +++ b/man/S3_tail.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{tail.DataFrame} -\alias{tail.DataFrame} +\name{tail.RPolarsDataFrame} +\alias{tail.RPolarsDataFrame} \alias{tail.RPolarsLazyFrame} \title{Take the last n rows} \usage{ -\method{tail}{DataFrame}(x, n = 6L, ...) +\method{tail}{RPolarsDataFrame}(x, n = 6L, ...) \method{tail}{RPolarsLazyFrame}(x, n = 6L, ...) } diff --git a/man/S3_unique.Rd b/man/S3_unique.Rd index 7c4598918..c3b9651e9 100644 --- a/man/S3_unique.Rd +++ b/man/S3_unique.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{unique.DataFrame} -\alias{unique.DataFrame} +\name{unique.RPolarsDataFrame} +\alias{unique.RPolarsDataFrame} \alias{unique.RPolarsLazyFrame} \title{Drop duplicated rows} \usage{ -\method{unique}{DataFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) +\method{unique}{RPolarsDataFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) \method{unique}{RPolarsLazyFrame}(x, incomparables = FALSE, subset = NULL, keep = "first", ...) } diff --git a/man/as_polars_df.Rd b/man/as_polars_df.Rd index d11e401a0..b06563d7e 100644 --- a/man/as_polars_df.Rd +++ b/man/as_polars_df.Rd @@ -4,7 +4,7 @@ \alias{as_polars_df} \alias{as_polars_df.default} \alias{as_polars_df.data.frame} -\alias{as_polars_df.DataFrame} +\alias{as_polars_df.RPolarsDataFrame} \alias{as_polars_df.GroupBy} \alias{as_polars_df.Series} \alias{as_polars_df.RPolarsLazyFrame} @@ -18,7 +18,7 @@ as_polars_df(x, ...) \method{as_polars_df}{data.frame}(x, ...) -\method{as_polars_df}{DataFrame}(x, ...) +\method{as_polars_df}{RPolarsDataFrame}(x, ...) \method{as_polars_df}{GroupBy}(x, ...) diff --git a/man/dot-DollarNames.DataFrame.Rd b/man/dot-DollarNames.RPolarsDataFrame.Rd similarity index 76% rename from man/dot-DollarNames.DataFrame.Rd rename to man/dot-DollarNames.RPolarsDataFrame.Rd index 72edb94a6..b49a5c94e 100644 --- a/man/dot-DollarNames.DataFrame.Rd +++ b/man/dot-DollarNames.RPolarsDataFrame.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dataframe__frame.R -\name{.DollarNames.DataFrame} -\alias{.DollarNames.DataFrame} +\name{.DollarNames.RPolarsDataFrame} +\alias{.DollarNames.RPolarsDataFrame} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{DataFrame}(x, pattern = "") +\method{.DollarNames}{RPolarsDataFrame}(x, pattern = "") } \arguments{ \item{x}{DataFrame} diff --git a/man/knit_print.DataFrame.Rd b/man/knit_print.RPolarsDataFrame.Rd similarity index 87% rename from man/knit_print.DataFrame.Rd rename to man/knit_print.RPolarsDataFrame.Rd index e40b335cb..2c083c011 100644 --- a/man/knit_print.DataFrame.Rd +++ b/man/knit_print.RPolarsDataFrame.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkg-knitr.R -\name{knit_print.DataFrame} -\alias{knit_print.DataFrame} +\name{knit_print.RPolarsDataFrame} +\alias{knit_print.RPolarsDataFrame} \title{knit print polars DataFrame} \usage{ -knit_print.DataFrame(x, ...) +knit_print.RPolarsDataFrame(x, ...) } \arguments{ \item{x}{a polars DataFrame to knit_print} diff --git a/man/print.DataFrame.Rd b/man/print.RPolarsDataFrame.Rd similarity index 75% rename from man/print.DataFrame.Rd rename to man/print.RPolarsDataFrame.Rd index b88b5d15e..46f281c8f 100644 --- a/man/print.DataFrame.Rd +++ b/man/print.RPolarsDataFrame.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dataframe__frame.R -\name{print.DataFrame} -\alias{print.DataFrame} +\name{print.RPolarsDataFrame} +\alias{print.RPolarsDataFrame} \title{S3 method to print a DataFrame} \usage{ -\method{print}{DataFrame}(x, ...) +\method{print}{RPolarsDataFrame}(x, ...) } \arguments{ \item{x}{DataFrame} diff --git a/src/rust/src/concat.rs b/src/rust/src/concat.rs index 9352c7e0d..c8229f3aa 100644 --- a/src/rust/src/concat.rs +++ b/src/rust/src/concat.rs @@ -1,7 +1,5 @@ -use crate::rdataframe::DataFrame; +use crate::rdataframe::{RPolarsDataFrame, RPolarsLazyFrame}; use crate::robj_to; - -use crate::rdataframe::RPolarsLazyFrame; use crate::rpolarserr::*; use crate::series::Series; use extendr_api::prelude::*; @@ -47,11 +45,11 @@ fn concat_lf_diagonal( } #[extendr] -pub fn concat_df_horizontal(l: Robj) -> RResult { +pub fn concat_df_horizontal(l: Robj) -> RResult { let df_vec = robj_to!(Vec, PLDataFrame, l)?; pl_functions::concat_df_horizontal(&df_vec) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } #[extendr] diff --git a/src/rust/src/concurrent.rs b/src/rust/src/concurrent.rs index 139ba8b30..976b4d863 100644 --- a/src/rust/src/concurrent.rs +++ b/src/rust/src/concurrent.rs @@ -1,5 +1,5 @@ //use crate::rdataframe::rseries::ptr_str_to_rseries; -use crate::rdataframe::DataFrame; +use crate::rdataframe::RPolarsDataFrame; use crate::utils::extendr_concurrent::ParRObj; use crate::utils::extendr_concurrent::{concurrent_handler, ThreadCom}; use crate::CONFIG; @@ -89,7 +89,7 @@ fn serve_r(rfsig: RFnSignature) -> Result> // This functions allows to call .collect() on polars lazy frame. A lazy frame may contain user defined functions // which could call R from any spawned thread by polars. This function is a bridge between multithraedded polars // and mostly single threaded only R -pub fn collect_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult { +pub fn collect_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult { let new_df = if ThreadCom::try_from_global(&CONFIG).is_ok() { #[cfg(feature = "rpolars_debug_print")] println!("in collect: concurrent handler already started"); @@ -123,10 +123,10 @@ pub fn collect_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult }; //wrap ok - Ok(DataFrame(new_df?)) + Ok(RPolarsDataFrame(new_df?)) } -pub fn profile_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult<(DataFrame, DataFrame)> { +pub fn profile_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult<(RPolarsDataFrame, RPolarsDataFrame)> { if ThreadCom::try_from_global(&CONFIG).is_ok() { lazy_df.profile() } else { @@ -143,10 +143,10 @@ pub fn profile_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult<(DataFrame .map_err(|err| RPolarsErr::new().plain(err.to_string()))? } .map_err(polars_to_rpolars_err) - .map(|(result_df, profile_df)| (DataFrame(result_df), DataFrame(profile_df))) + .map(|(result_df, profile_df)| (RPolarsDataFrame(result_df), RPolarsDataFrame(profile_df))) } -pub fn fetch_with_r_func_support(lazy_df: pl::LazyFrame, n_rows: usize) -> RResult { +pub fn fetch_with_r_func_support(lazy_df: pl::LazyFrame, n_rows: usize) -> RResult { if ThreadCom::try_from_global(&CONFIG).is_ok() { lazy_df.fetch(n_rows) } else { @@ -163,5 +163,5 @@ pub fn fetch_with_r_func_support(lazy_df: pl::LazyFrame, n_rows: usize) -> RResu .map_err(|err| RPolarsErr::new().plain(err.to_string()))? } .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } diff --git a/src/rust/src/conversion_s_to_r.rs b/src/rust/src/conversion_s_to_r.rs index 9702fd4e3..0cfa1cf09 100644 --- a/src/rust/src/conversion_s_to_r.rs +++ b/src/rust/src/conversion_s_to_r.rs @@ -1,7 +1,7 @@ use extendr_api::prelude::*; use polars::prelude::{self as pl}; -use crate::rdataframe::DataFrame; +use crate::rdataframe::RPolarsDataFrame; use pl::PolarsError as pl_error; // #[extendr] @@ -145,7 +145,7 @@ pub fn pl_series_to_list( } Struct(_) => { let df = s.clone().into_frame().unnest([s.name()]).unwrap(); - let mut l = DataFrame(df).to_list_result()?; + let mut l = RPolarsDataFrame(df).to_list_result()?; //TODO contribute extendr_api set_attrib mutates &self, change signature to surprise anyone if tag_structs { diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index b6bb57201..61f1df3d8 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -5,7 +5,7 @@ use crate::conversion::strings_to_smartstrings; use crate::lazy::dsl::*; -use crate::rdataframe::DataFrame as RDF; +use crate::rdataframe::RPolarsDataFrame as RDF; use crate::rdatatype::{ new_asof_strategy, new_ipc_compression, new_parquet_compression, new_unique_keep_strategy, RPolarsDataType, diff --git a/src/rust/src/rbackground.rs b/src/rust/src/rbackground.rs index 1750f2065..124a36e01 100644 --- a/src/rust/src/rbackground.rs +++ b/src/rust/src/rbackground.rs @@ -1,4 +1,4 @@ -use crate::rdataframe::DataFrame as RDF; +use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::rerr; use crate::rpolarserr::{ @@ -59,8 +59,8 @@ impl RThreadHandle { } #[extendr] -impl RThreadHandle> { - fn join(&mut self) -> RResult { +impl RThreadHandle> { + fn join(&mut self) -> RResult { // Could use *.flatten() when it's stable self.join_generic().and_then(std::convert::identity) } @@ -552,7 +552,7 @@ pub fn test_rbackgroundhandler(lambda: Robj, arg: Robj) -> RResult { } #[extendr] -pub fn test_rthreadhandle() -> RThreadHandle> { +pub fn test_rthreadhandle() -> RThreadHandle> { RThreadHandle::new(move || { println!("Intense sleeping in Rust for 10 seconds!"); let duration = std::time::Duration::from_millis(10000); @@ -579,15 +579,15 @@ pub fn test_rthreadhandle() -> RThreadHandle> { } #[extendr] -pub fn test_serde_df(df: &RDF) -> RResult { +pub fn test_serde_df(df: &RPolarsDataFrame) -> RResult { let x = serialize_dataframe(&mut df.0.clone())?; let df2 = deserialize_dataframe(x.as_slice())?; - Ok(RDF(df2)) + Ok(RPolarsDataFrame(df2)) } extendr_module! { mod rbackground; - impl RThreadHandle>; + impl RThreadHandle>; fn setup_renv; fn set_global_rpool_cap; fn get_global_rpool_cap; diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index c5bf64d4a..98bb53880 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -72,16 +72,16 @@ impl Iterator for OwnedDataFrameIterator { } #[derive(Debug, Clone)] -pub struct DataFrame(pub pl::DataFrame); +pub struct RPolarsDataFrame(pub pl::DataFrame); -impl From for DataFrame { +impl From for RPolarsDataFrame { fn from(item: pl::DataFrame) -> Self { - DataFrame(item) + RPolarsDataFrame(item) } } #[extendr] -impl DataFrame { +impl RPolarsDataFrame { pub fn shape(&self) -> Robj { let shp = self.0.shape(); r!([shp.0, shp.1]) @@ -110,13 +110,13 @@ impl DataFrame { self.0.agg_chunks().into() } - pub fn clone_in_rust(&self) -> DataFrame { + pub fn clone_in_rust(&self) -> RPolarsDataFrame { self.clone() } #[allow(clippy::should_implement_trait)] pub fn default() -> Self { - DataFrame::new_with_capacity(0) + RPolarsDataFrame::new_with_capacity(0) } pub fn lazy(&self) -> RPolarsLazyFrame { @@ -131,7 +131,7 @@ impl DataFrame { //internal use pub fn new_with_capacity(capacity: i32) -> Self { let empty_series: Vec = Vec::with_capacity(capacity as usize); - DataFrame(pl::DataFrame::new(empty_series).unwrap()) + RPolarsDataFrame(pl::DataFrame::new(empty_series).unwrap()) } //internal use @@ -276,7 +276,7 @@ impl DataFrame { r_result_list(robj_list_res) } - pub fn frame_equal(&self, other: &DataFrame) -> bool { + pub fn frame_equal(&self, other: &RPolarsDataFrame) -> bool { self.0.frame_equal(&other.0) } @@ -294,11 +294,11 @@ impl DataFrame { Series(self.0.drop_in_place(names).unwrap()) } - pub fn select(&self, exprs: Robj) -> RResult { + pub fn select(&self, exprs: Robj) -> RResult { self.lazy().select(exprs)?.collect() } - pub fn with_columns(&self, exprs: Robj) -> RResult { + pub fn with_columns(&self, exprs: Robj) -> RResult { self.lazy().with_columns(exprs)?.collect() } @@ -308,7 +308,7 @@ impl DataFrame { group_exprs: Robj, agg_exprs: Robj, maintain_order: Robj, - ) -> RResult { + ) -> RResult { let group_exprs: Vec = robj_to!(VecPLExprCol, group_exprs)?; let agg_exprs: Vec = robj_to!(VecPLExprColNamed, agg_exprs)?; let maintain_order = robj_to!(Option, bool, maintain_order)?.unwrap_or(false); @@ -349,8 +349,8 @@ impl DataFrame { } } - pub fn from_arrow_record_batches(rbr: Robj) -> Result { - Ok(DataFrame(crate::arrow_interop::to_rust::to_rust_df(rbr)?)) + pub fn from_arrow_record_batches(rbr: Robj) -> Result { + Ok(RPolarsDataFrame(crate::arrow_interop::to_rust::to_rust_df(rbr)?)) } pub fn estimated_size(&self) -> f64 { @@ -379,7 +379,7 @@ impl DataFrame { self.0 .melt2(args) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } pub fn pivot_expr( @@ -408,7 +408,7 @@ impl DataFrame { robj_to!(Option, str, separator)?, ) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } pub fn sample_n( @@ -427,7 +427,7 @@ impl DataFrame { robj_to!(Option, u64, seed)?, ) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } pub fn sample_frac( @@ -446,7 +446,7 @@ impl DataFrame { robj_to!(Option, u64, seed)?, ) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } pub fn transpose(&self, keep_names_as: Robj, new_col_names: Robj) -> RResult { @@ -456,7 +456,7 @@ impl DataFrame { self.0 .transpose(opt_s, opt_either_vec_s) .map_err(polars_to_rpolars_err) - .map(DataFrame) + .map(RPolarsDataFrame) } pub fn write_csv( @@ -518,7 +518,7 @@ impl DataFrame { } } -impl DataFrame { +impl RPolarsDataFrame { pub fn to_list_result(&self) -> Result { //convert DataFrame to Result of to R vectors, error if DataType is not supported let robj_vec_res: Result, _> = self @@ -545,7 +545,7 @@ impl VecDataFrame { VecDataFrame(Vec::with_capacity(n as usize)) } - pub fn push(&mut self, df: &DataFrame) { + pub fn push(&mut self, df: &RPolarsDataFrame) { self.0.push(df.0.clone()); } @@ -562,6 +562,6 @@ extendr_module! { use read_parquet; use rdatatype; - impl DataFrame; + impl RPolarsDataFrame; impl VecDataFrame; } diff --git a/src/rust/src/rlib.rs b/src/rust/src/rlib.rs index e2c1348c1..d4d50b8a5 100644 --- a/src/rust/src/rlib.rs +++ b/src/rust/src/rlib.rs @@ -1,6 +1,6 @@ use crate::lazy::dsl::Expr; use crate::lazy::dsl::ProtoExprArray; -use crate::rdataframe::DataFrame; +use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::{rdbg, RResult}; use crate::series::Series; @@ -131,7 +131,7 @@ fn struct_(exprs: Robj, eager: Robj, schema: Robj) -> Result { .select(&[struct_expr.0]) .collect() .map_err(|err| format!("during eager evaluation of struct: {}", err))?; - Ok(crate::rdataframe::DataFrame(df).into()) + Ok(crate::rdataframe::RPolarsDataFrame(df).into()) } else { Ok(struct_expr.into()) } @@ -151,7 +151,7 @@ fn arrow_stream_to_df(robj_str: Robj) -> RResult { .when("unpack struct from producer") .hint("producer exported a plain Series not a Struct series")?; let df: pl::DataFrame = ca.clone().into(); - Ok(DataFrame(df).into_robj()) + Ok(RPolarsDataFrame(df).into_robj()) } #[extendr] @@ -162,8 +162,8 @@ fn arrow_stream_to_series(robj_str: Robj) -> RResult { #[extendr] unsafe fn export_df_to_arrow_stream(robj_df: Robj, robj_str: Robj) -> RResult { - let res: ExternalPtr = robj_df.try_into()?; - let pl_df = DataFrame(res.0.clone()).0; + let res: ExternalPtr = robj_df.try_into()?; + let pl_df = RPolarsDataFrame(res.0.clone()).0; //safety robj_str must be ptr to a arrow2 stream ready to export into unsafe { crate::arrow_interop::to_rust::export_df_as_stream(pl_df, &robj_str)?; @@ -172,7 +172,7 @@ unsafe fn export_df_to_arrow_stream(robj_df: Robj, robj_str: Robj) -> RResult) -> Result { +fn rb_list_to_df(r_batches: List, names: Vec) -> Result { let mut iter = r_batches.into_iter().map(|(_, robj)| { let robj = call!(r"\(x) x$columns", robj)?; let l = robj.as_list().ok_or_else(|| "not a list!?".to_string())?; @@ -184,7 +184,7 @@ fn rb_list_to_df(r_batches: List, names: Vec) -> Result for Series { impl From<&Expr> for pl::PolarsResult { fn from(expr: &Expr) -> Self { - DataFrame::default() + RPolarsDataFrame::default() .lazy() .0 .select(&[expr.0.clone()]) @@ -114,10 +114,10 @@ impl Series { &self, sort: bool, parallel: bool, - ) -> std::result::Result { + ) -> std::result::Result { self.0 .value_counts(sort, parallel) - .map(DataFrame) + .map(RPolarsDataFrame) .map_err(|err| format!("in value_counts: {:?}", err)) } @@ -490,8 +490,8 @@ impl Series { .map(Series) } - pub fn to_frame(&self) -> std::result::Result { - let mut df = DataFrame::new_with_capacity(1); + pub fn to_frame(&self) -> std::result::Result { + let mut df = RPolarsDataFrame::new_with_capacity(1); df.set_column_from_series(self)?; Ok(df) } @@ -574,8 +574,8 @@ impl Series { Ok(Series(s)) } - pub fn into_frame(&self) -> DataFrame { - DataFrame(pl::DataFrame::new_no_checks(vec![self.0.clone()])) + pub fn into_frame(&self) -> RPolarsDataFrame { + RPolarsDataFrame(pl::DataFrame::new_no_checks(vec![self.0.clone()])) } } diff --git a/src/rust/src/utils/mod.rs b/src/rust/src/utils/mod.rs index ddf6bb62d..b9e5ad9e6 100644 --- a/src/rust/src/utils/mod.rs +++ b/src/rust/src/utils/mod.rs @@ -12,7 +12,7 @@ use crate::series::Series; use std::any::type_name as tn; //use std::intrinsics::read_via_copy; use crate::lazy::dsl::robj_to_col; -use crate::rdataframe::{DataFrame, RPolarsLazyFrame}; +use crate::rdataframe::{RPolarsDataFrame, RPolarsLazyFrame}; use extendr_api::eval_string_with_params; use extendr_api::prelude::{list, Result as EResult, Strings}; use extendr_api::Attributes; @@ -820,15 +820,15 @@ pub fn robj_to_lazyframe(robj: extendr_api::Robj) -> RResult { res.bad_val(rv).mistyped(tn::()) } -pub fn robj_to_dataframe(robj: extendr_api::Robj) -> RResult { +pub fn robj_to_dataframe(robj: extendr_api::Robj) -> RResult { let robj = unpack_r_result_list(robj)?; let robj_clone = robj.clone(); // closure to allow ?-convert extendr::Result to RResult - let res = || -> RResult { - let df: ExternalPtr = + let res = || -> RResult { + let df: ExternalPtr = (unpack_r_eval(R!("polars:::result(polars::as_polars_df({{robj}}))"))?).try_into()?; - Ok(DataFrame(df.0.clone())) + Ok(RPolarsDataFrame(df.0.clone())) }(); res.bad_val(rdbg(robj_clone)) From 330271e09e92887f27185b47564979761c556f6c Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:29:43 +0100 Subject: [PATCH 03/32] Expr -> RPolarsExpr [skip ci] --- NAMESPACE | 46 +- R/after-wrappers.R | 7 +- R/dataframe__frame.R | 8 +- R/expr__datetime.R | 2 +- R/expr__expr.R | 38 +- R/expr__list.R | 4 +- R/extendr-wrappers.R | 574 +++++++++--------- R/lazyframe__lazy.R | 6 +- R/zzz.R | 2 +- man/ExprList_get.Rd | 6 +- man/Expr_add.Rd | 4 +- man/Expr_div.Rd | 4 +- man/Expr_eq.Rd | 4 +- man/Expr_floor_div.Rd | 4 +- man/Expr_gt.Rd | 4 +- man/Expr_gt_eq.Rd | 4 +- man/Expr_lt.Rd | 4 +- man/Expr_lt_eq.Rd | 4 +- man/Expr_mod.Rd | 4 +- man/Expr_mul.Rd | 4 +- man/Expr_neq.Rd | 4 +- man/Expr_not.Rd | 4 +- man/Expr_print.Rd | 6 +- man/Expr_sub.Rd | 4 +- ...as.list.Expr.Rd => as.list.RPolarsExpr.Rd} | 6 +- ...Expr.Rd => dot-DollarNames.RPolarsExpr.Rd} | 6 +- src/rust/src/construct_expr.rs | 4 +- src/rust/src/lazy/dataframe.rs | 3 +- src/rust/src/lazy/dsl.rs | 228 +++---- src/rust/src/lazy/whenthen.rs | 6 +- src/rust/src/rlib.rs | 35 +- src/rust/src/series.rs | 6 +- src/rust/src/utils/mod.rs | 18 +- 33 files changed, 535 insertions(+), 528 deletions(-) rename man/{as.list.Expr.Rd => as.list.RPolarsExpr.Rd} (76%) rename man/{dot-DollarNames.Expr.Rd => dot-DollarNames.RPolarsExpr.Rd} (78%) diff --git a/NAMESPACE b/NAMESPACE index 14b8de3d3..05510950d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,17 +1,15 @@ # Generated by roxygen2: do not edit by hand -S3method("!",Expr) -S3method("!=",Expr) +S3method("!",RPolarsExpr) S3method("!=",RPolarsDataType) +S3method("!=",RPolarsExpr) S3method("!=",Series) S3method("$",ChainedThen) S3method("$",ChainedWhen) S3method("$",DataTypeVector) -S3method("$",Expr) S3method("$",ExprBinNameSpace) S3method("$",ExprCatNameSpace) S3method("$",ExprDTNameSpace) -S3method("$",ExprListNameSpace) S3method("$",ExprMetaNameSpace) S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) @@ -24,6 +22,8 @@ S3method("$",RNullValues) S3method("$",RPolarsDataFrame) S3method("$",RPolarsDataType) S3method("$",RPolarsErr) +S3method("$",RPolarsExpr) +S3method("$",RPolarsExprListNameSpace) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsSQLContext) S3method("$",RPolarsStringCacheHolder) @@ -36,37 +36,36 @@ S3method("$",pl_polars_env) S3method("$",private_polars_env) S3method("$<-",RField) S3method("$<-",RPolarsDataFrame) -S3method("%%",Expr) -S3method("%/%",Expr) -S3method("&",Expr) -S3method("*",Expr) +S3method("%%",RPolarsExpr) +S3method("%/%",RPolarsExpr) +S3method("&",RPolarsExpr) +S3method("*",RPolarsExpr) S3method("*",Series) -S3method("+",Expr) +S3method("+",RPolarsExpr) S3method("+",Series) -S3method("-",Expr) +S3method("-",RPolarsExpr) S3method("-",Series) -S3method("/",Expr) +S3method("/",RPolarsExpr) S3method("/",Series) -S3method("<",Expr) +S3method("<",RPolarsExpr) S3method("<",Series) -S3method("<=",Expr) +S3method("<=",RPolarsExpr) S3method("<=",Series) -S3method("==",Expr) S3method("==",RPolarsDataType) +S3method("==",RPolarsExpr) S3method("==",Series) -S3method(">",Expr) +S3method(">",RPolarsExpr) S3method(">",Series) -S3method(">=",Expr) +S3method(">=",RPolarsExpr) S3method(">=",Series) -S3method("[",ExprListNameSpace) S3method("[",RPolarsDataFrame) +S3method("[",RPolarsExprListNameSpace) S3method("[",RPolarsLazyFrame) S3method("[",Series) S3method("[",rpolars_raw_list) S3method("[[",ChainedThen) S3method("[[",ChainedWhen) S3method("[[",DataTypeVector) -S3method("[[",Expr) S3method("[[",GroupBy) S3method("[[",LazyGroupBy) S3method("[[",ProtoExprArray) @@ -75,6 +74,7 @@ S3method("[[",RNullValues) S3method("[[",RPolarsDataFrame) S3method("[[",RPolarsDataType) S3method("[[",RPolarsErr) +S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsStringCacheHolder) @@ -83,15 +83,15 @@ S3method("[[",Series) S3method("[[",Then) S3method("[[",VecDataFrame) S3method("[[",When) -S3method("^",Expr) -S3method("|",Expr) +S3method("^",RPolarsExpr) +S3method("|",RPolarsExpr) S3method(.DollarNames,ChainedThen) S3method(.DollarNames,ChainedWhen) -S3method(.DollarNames,Expr) S3method(.DollarNames,GroupBy) S3method(.DollarNames,RField) S3method(.DollarNames,RPolarsDataFrame) S3method(.DollarNames,RPolarsErr) +S3method(.DollarNames,RPolarsExpr) S3method(.DollarNames,RPolarsLazyFrame) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RThreadHandle) @@ -105,7 +105,7 @@ S3method(as.character,RThreadHandle) S3method(as.character,Series) S3method(as.data.frame,RPolarsDataFrame) S3method(as.data.frame,RPolarsLazyFrame) -S3method(as.list,Expr) +S3method(as.list,RPolarsExpr) S3method(as.list,rpolars_raw_list) S3method(as.matrix,RPolarsDataFrame) S3method(as.matrix,RPolarsLazyFrame) @@ -152,7 +152,6 @@ S3method(names,RPolarsDataFrame) S3method(names,RPolarsLazyFrame) S3method(print,ChainedThen) S3method(print,ChainedWhen) -S3method(print,Expr) S3method(print,GroupBy) S3method(print,LazyGroupBy) S3method(print,PTime) @@ -160,6 +159,7 @@ S3method(print,RField) S3method(print,RPolarsDataFrame) S3method(print,RPolarsDataType) S3method(print,RPolarsErr) +S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) S3method(print,RThreadHandle) S3method(print,Series) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index d6a3a3276..2da108edc 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -85,7 +85,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$DataType = extendr_method_to_pure_functions(RPolarsDataType) .pr$DataTypeVector = extendr_method_to_pure_functions(DataTypeVector) .pr$RField = extendr_method_to_pure_functions(RField) -.pr$Expr = extendr_method_to_pure_functions(Expr) +.pr$Expr = extendr_method_to_pure_functions(RPolarsExpr) .pr$ProtoExprArray = extendr_method_to_pure_functions(ProtoExprArray) .pr$When = extendr_method_to_pure_functions(When) .pr$Then = extendr_method_to_pure_functions(Then) @@ -267,8 +267,9 @@ DataType = clone_env_one_level_deep(RPolarsDataType) # used for printing public environment pl_class_names = sort( c( - "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "Expr", "RPolarsDataFrame", - "When", "Then", "ChainedWhen", "ChainedThen", "RPolarsSQLContext" + "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "RPolarsExpr", + "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", + "RPolarsSQLContext" ) ) # TODO discover all public class automatically diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 9275a495a..737361858 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -914,9 +914,9 @@ DataFrame_to_list = function(unnest_structs = TRUE) { #' df1$join(other = df2, how = "cross") DataFrame_join = function( other, # : LazyFrame or DataFrame, - left_on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, - right_on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, - on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, + left_on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, + right_on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, + on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, how = c("inner", "left", "outer", "semi", "anti", "cross"), suffix = "_right", allow_parallel = TRUE, @@ -1409,7 +1409,7 @@ DataFrame_pivot = function( separator = "_") { pcase( # if string, call it on Expr-method of pl$element() and capture any Error as Result - is_string(aggregate_function), result(`$.Expr`(pl$element(), aggregate_function)()), + is_string(aggregate_function), result(`$.RPolarsExpr`(pl$element(), aggregate_function)()), # Expr or NULL pass as is is.null(aggregate_function) || inherits(aggregate_function, "Expr"), Ok(aggregate_function), diff --git a/R/expr__datetime.R b/R/expr__datetime.R index 986679dc7..4ebe6237c 100644 --- a/R/expr__datetime.R +++ b/R/expr__datetime.R @@ -90,7 +90,7 @@ ExprDT_round = function(every, offset = NULL) { unwrap("in dt$round()") } -# ExprDT_combine = function(self, tm: time | pli.Expr, tu: TimeUnit = "us") -> pli.Expr: +# ExprDT_combine = function(self, tm: time | pli.RPolarsExpr, tu: TimeUnit = "us") -> pli.RPolarsExpr: #' Combine Data and Time diff --git a/R/expr__expr.R b/R/expr__expr.R index ff83f4bcf..92487fc06 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -33,7 +33,7 @@ NULL #' #' @examples #' print(pl$col("some_column")$sum()) -print.Expr = function(x, ...) { +print.RPolarsExpr = function(x, ...) { cat("polars Expr: ") x$print() invisible(x) @@ -54,7 +54,7 @@ Expr_print = function() { #' @inherit .DollarNames.RPolarsDataFrame return #' @export #' @keywords internal -.DollarNames.Expr = function(x, pattern = "") { +.DollarNames.RPolarsExpr = function(x, pattern = "") { paste0(ls(Expr, pattern = pattern), "()") } @@ -66,7 +66,7 @@ Expr_print = function() { #' @return One Expr wrapped in a list #' @export #' @keywords internal -as.list.Expr = function(x, ...) { +as.list.RPolarsExpr = function(x, ...) { list(x) } @@ -171,7 +171,7 @@ Expr_add = function(other) { #' @rdname Expr_add #' @param e1 Expr only #' @param e2 Expr or anything that can be converted to a literal -"+.Expr" = function(e1, e2) { +"+.RPolarsExpr" = function(e1, e2) { if (missing(e2)) { return(e1) } @@ -193,7 +193,7 @@ Expr_div = function(other) { #' @export #' @rdname Expr_div #' @inheritParams Expr_add -"/.Expr" = function(e1, e2) result(wrap_e(e1)$div(e2)) |> unwrap("using the '/'-operator") +"/.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$div(e2)) |> unwrap("using the '/'-operator") #' Floor divide two expressions #' @@ -210,7 +210,7 @@ Expr_floor_div = function(other) { #' @export #' @rdname Expr_floor_div #' @inheritParams Expr_add -"%/%.Expr" = function(e1, e2) result(wrap_e(e1)$floor_div(e2)) |> unwrap("using the '%/%'-operator") +"%/%.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$floor_div(e2)) |> unwrap("using the '%/%'-operator") #' Modulo two expressions #' @@ -236,7 +236,7 @@ Expr_mod = function(other) { #' @export #' @rdname Expr_mod #' @inheritParams Expr_add -"%%.Expr" = function(e1, e2) result(wrap_e(e1)$mod(e2)) |> unwrap("using the '%%'-operator") +"%%.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$mod(e2)) |> unwrap("using the '%%'-operator") #' Substract two expressions #' @@ -254,7 +254,7 @@ Expr_sub = function(other) { #' @export #' @rdname Expr_sub #' @inheritParams Expr_add -"-.Expr" = function(e1, e2) { +"-.RPolarsExpr" = function(e1, e2) { result( if (missing(e2)) wrap_e(0L)$sub(e1) else wrap_e(e1)$sub(e2) ) |> unwrap("using the '-'-operator") @@ -275,7 +275,7 @@ Expr_mul = Expr_mul = function(other) { #' @export #' @rdname Expr_mul #' @inheritParams Expr_add -"*.Expr" = function(e1, e2) result(wrap_e(e1)$mul(e2)) |> unwrap("using the '*'-operator") +"*.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$mul(e2)) |> unwrap("using the '*'-operator") #' Negate a boolean expression @@ -291,7 +291,7 @@ Expr_not = "use_extendr_wrapper" #' @export #' @rdname Expr_not #' @param x Expr -"!.Expr" = function(x) x$not() +"!.RPolarsExpr" = function(x) x$not() #' Check strictly lower inequality #' @@ -307,7 +307,7 @@ Expr_lt = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_lt -"<.Expr" = function(e1, e2) result(wrap_e(e1)$lt(e2)) |> unwrap("using the '<'-operator") +"<.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$lt(e2)) |> unwrap("using the '<'-operator") #' Check strictly greater inequality #' @@ -323,7 +323,7 @@ Expr_gt = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_gt -">.Expr" = function(e1, e2) result(wrap_e(e1)$gt(e2)) |> unwrap("using the '>'-operator") +">.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$gt(e2)) |> unwrap("using the '>'-operator") #' Check equality #' @@ -341,7 +341,7 @@ Expr_eq = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_eq -"==.Expr" = function(e1, e2) result(wrap_e(e1)$eq(e2)) |> unwrap("using the '=='-operator") +"==.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$eq(e2)) |> unwrap("using the '=='-operator") #' Check equality without `null` propagation #' @@ -374,7 +374,7 @@ Expr_neq = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_neq -"!=.Expr" = function(e1, e2) result(wrap_e(e1)$neq(e2)) |> unwrap("using the '!='-operator") +"!=.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$neq(e2)) |> unwrap("using the '!='-operator") #' Check inequality without `null` propagation #' @@ -405,7 +405,7 @@ Expr_lt_eq = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_lt_eq -"<=.Expr" = function(e1, e2) result(wrap_e(e1)$lt_eq(e2)) |> unwrap("using the '<='-operator") +"<=.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$lt_eq(e2)) |> unwrap("using the '<='-operator") #' Check greater or equal inequality @@ -422,7 +422,7 @@ Expr_gt_eq = function(other) { #' @export #' @inheritParams Expr_add #' @rdname Expr_gt_eq -">=.Expr" = function(e1, e2) result(wrap_e(e1)$gt_eq(e2)) |> unwrap("using the '>='-operator") +">=.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$gt_eq(e2)) |> unwrap("using the '>='-operator") @@ -963,7 +963,7 @@ Expr_and = function(other) { .pr$Expr$and(self, other) |> unwrap("in $and()") } #' @export -"&.Expr" = function(e1, e2) result(wrap_e(e1)$and(e2)) |> unwrap("using the '&'-operator") +"&.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$and(e2)) |> unwrap("using the '&'-operator") #' Apply logical OR on two expressions @@ -980,7 +980,7 @@ Expr_or = function(other) { .pr$Expr$or(self, other) |> unwrap("in $or()") } #' @export -"|.Expr" = function(e1, e2) result(wrap_e(e1)$or(e2)) |> unwrap("using the '|'-operator") +"|.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$or(e2)) |> unwrap("using the '|'-operator") #' Apply logical XOR on two expressions @@ -2131,7 +2131,7 @@ Expr_pow = function(exponent) { .pr$Expr$pow(self, exponent) |> unwrap("in $pow()") } #' @export -"^.Expr" = function(e1, e2) result(wrap_e(e1)$pow(e2)) |> unwrap("using '^'-operator") +"^.RPolarsExpr" = function(e1, e2) result(wrap_e(e1)$pow(e2)) |> unwrap("using '^'-operator") #' Check whether a value is in a vector diff --git a/R/expr__list.R b/R/expr__list.R index 44a5db3f9..79eeb2e66 100644 --- a/R/expr__list.R +++ b/R/expr__list.R @@ -154,12 +154,12 @@ ExprList_get = function(index) .pr$Expr$list_get(self, wrap_e(index, str_to_lit #' @param x ExprListNameSpace #' @param index value to get #' @details -#' `[.ExprListNameSpace` used as e.g. `pl$col("a")$arr[0]` same as `pl$col("a")$get(0)` +#' `[.RPolarsExprListNameSpace` used as e.g. `pl$col("a")$arr[0]` same as `pl$col("a")$get(0)` #' @examples #' df = pl$DataFrame(list(a = list(3:1, NULL, 1:2))) # NULL or integer() or list() #' df$select(pl$col("a")$list[0]) #' df$select(pl$col("a")$list[c(2, 0, -1)]) -`[.ExprListNameSpace` = function(x, index) { # S3 sub class-name set in zzz.R +`[.RPolarsExprListNameSpace` = function(x, index) { # S3 sub class-name set in zzz.R x$get(index) } diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 58004c5e6..49556fb58 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -419,576 +419,582 @@ ChainedThen$otherwise <- function(statement) .Call(wrap__ChainedThen__otherwise, Expr <- new.env(parent = emptyenv()) -Expr$col <- function(name) .Call(wrap__Expr__col, name) +Expr$col <- function(name) .Call(wrap__RPolarsExpr__col, name) -Expr$dtype_cols <- function(dtypes) .Call(wrap__Expr__dtype_cols, dtypes) +Expr$dtype_cols <- function(dtypes) .Call(wrap__RPolarsExpr__dtype_cols, dtypes) -Expr$cols <- function(names) .Call(wrap__Expr__cols, names) +Expr$cols <- function(names) .Call(wrap__RPolarsExpr__cols, names) -Expr$lit <- function(robj) .Call(wrap__Expr__lit, robj) +Expr$lit <- function(robj) .Call(wrap__RPolarsExpr__lit, robj) -Expr$gt <- function(other) .Call(wrap__Expr__gt, self, other) +Expr$gt <- function(other) .Call(wrap__RPolarsExpr__gt, self, other) -Expr$gt_eq <- function(other) .Call(wrap__Expr__gt_eq, self, other) +Expr$gt_eq <- function(other) .Call(wrap__RPolarsExpr__gt_eq, self, other) -Expr$lt <- function(other) .Call(wrap__Expr__lt, self, other) +Expr$lt <- function(other) .Call(wrap__RPolarsExpr__lt, self, other) -Expr$lt_eq <- function(other) .Call(wrap__Expr__lt_eq, self, other) +Expr$lt_eq <- function(other) .Call(wrap__RPolarsExpr__lt_eq, self, other) -Expr$neq <- function(other) .Call(wrap__Expr__neq, self, other) +Expr$neq <- function(other) .Call(wrap__RPolarsExpr__neq, self, other) -Expr$neq_missing <- function(other) .Call(wrap__Expr__neq_missing, self, other) +Expr$neq_missing <- function(other) .Call(wrap__RPolarsExpr__neq_missing, self, other) -Expr$eq <- function(other) .Call(wrap__Expr__eq, self, other) +Expr$eq <- function(other) .Call(wrap__RPolarsExpr__eq, self, other) -Expr$eq_missing <- function(other) .Call(wrap__Expr__eq_missing, self, other) +Expr$eq_missing <- function(other) .Call(wrap__RPolarsExpr__eq_missing, self, other) -Expr$and <- function(other) .Call(wrap__Expr__and, self, other) +Expr$and <- function(other) .Call(wrap__RPolarsExpr__and, self, other) -Expr$or <- function(other) .Call(wrap__Expr__or, self, other) +Expr$or <- function(other) .Call(wrap__RPolarsExpr__or, self, other) -Expr$xor <- function(other) .Call(wrap__Expr__xor, self, other) +Expr$xor <- function(other) .Call(wrap__RPolarsExpr__xor, self, other) -Expr$to_physical <- function() .Call(wrap__Expr__to_physical, self) +Expr$to_physical <- function() .Call(wrap__RPolarsExpr__to_physical, self) -Expr$cast <- function(data_type, strict) .Call(wrap__Expr__cast, self, data_type, strict) +Expr$cast <- function(data_type, strict) .Call(wrap__RPolarsExpr__cast, self, data_type, strict) -Expr$sort <- function(descending, nulls_last) .Call(wrap__Expr__sort, self, descending, nulls_last) +Expr$sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__sort, self, descending, nulls_last) -Expr$arg_sort <- function(descending, nulls_last) .Call(wrap__Expr__arg_sort, self, descending, nulls_last) +Expr$arg_sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__arg_sort, self, descending, nulls_last) -Expr$top_k <- function(k) .Call(wrap__Expr__top_k, self, k) +Expr$top_k <- function(k) .Call(wrap__RPolarsExpr__top_k, self, k) -Expr$bottom_k <- function(k) .Call(wrap__Expr__bottom_k, self, k) +Expr$bottom_k <- function(k) .Call(wrap__RPolarsExpr__bottom_k, self, k) -Expr$arg_max <- function() .Call(wrap__Expr__arg_max, self) +Expr$arg_max <- function() .Call(wrap__RPolarsExpr__arg_max, self) -Expr$arg_min <- function() .Call(wrap__Expr__arg_min, self) +Expr$arg_min <- function() .Call(wrap__RPolarsExpr__arg_min, self) -Expr$search_sorted <- function(element) .Call(wrap__Expr__search_sorted, self, element) +Expr$search_sorted <- function(element) .Call(wrap__RPolarsExpr__search_sorted, self, element) -Expr$gather <- function(idx) .Call(wrap__Expr__gather, self, idx) +Expr$gather <- function(idx) .Call(wrap__RPolarsExpr__gather, self, idx) -Expr$sort_by <- function(by, descending) .Call(wrap__Expr__sort_by, self, by, descending) +Expr$sort_by <- function(by, descending) .Call(wrap__RPolarsExpr__sort_by, self, by, descending) -Expr$backward_fill <- function(limit) .Call(wrap__Expr__backward_fill, self, limit) +Expr$backward_fill <- function(limit) .Call(wrap__RPolarsExpr__backward_fill, self, limit) -Expr$forward_fill <- function(limit) .Call(wrap__Expr__forward_fill, self, limit) +Expr$forward_fill <- function(limit) .Call(wrap__RPolarsExpr__forward_fill, self, limit) -Expr$shift <- function(periods) .Call(wrap__Expr__shift, self, periods) +Expr$shift <- function(periods) .Call(wrap__RPolarsExpr__shift, self, periods) -Expr$shift_and_fill <- function(periods, fill_value) .Call(wrap__Expr__shift_and_fill, self, periods, fill_value) +Expr$shift_and_fill <- function(periods, fill_value) .Call(wrap__RPolarsExpr__shift_and_fill, self, periods, fill_value) -Expr$fill_null <- function(expr) .Call(wrap__Expr__fill_null, self, expr) +Expr$fill_null <- function(expr) .Call(wrap__RPolarsExpr__fill_null, self, expr) -Expr$fill_null_with_strategy <- function(strategy, limit) .Call(wrap__Expr__fill_null_with_strategy, self, strategy, limit) +Expr$fill_null_with_strategy <- function(strategy, limit) .Call(wrap__RPolarsExpr__fill_null_with_strategy, self, strategy, limit) -Expr$fill_nan <- function(expr) .Call(wrap__Expr__fill_nan, self, expr) +Expr$fill_nan <- function(expr) .Call(wrap__RPolarsExpr__fill_nan, self, expr) -Expr$reverse <- function() .Call(wrap__Expr__reverse, self) +Expr$reverse <- function() .Call(wrap__RPolarsExpr__reverse, self) -Expr$std <- function(ddof) .Call(wrap__Expr__std, self, ddof) +Expr$std <- function(ddof) .Call(wrap__RPolarsExpr__std, self, ddof) -Expr$var <- function(ddof) .Call(wrap__Expr__var, self, ddof) +Expr$var <- function(ddof) .Call(wrap__RPolarsExpr__var, self, ddof) -Expr$max <- function() .Call(wrap__Expr__max, self) +Expr$max <- function() .Call(wrap__RPolarsExpr__max, self) -Expr$min <- function() .Call(wrap__Expr__min, self) +Expr$min <- function() .Call(wrap__RPolarsExpr__min, self) -Expr$nan_min <- function() .Call(wrap__Expr__nan_min, self) +Expr$nan_min <- function() .Call(wrap__RPolarsExpr__nan_min, self) -Expr$nan_max <- function() .Call(wrap__Expr__nan_max, self) +Expr$nan_max <- function() .Call(wrap__RPolarsExpr__nan_max, self) -Expr$mean <- function() .Call(wrap__Expr__mean, self) +Expr$mean <- function() .Call(wrap__RPolarsExpr__mean, self) -Expr$median <- function() .Call(wrap__Expr__median, self) +Expr$median <- function() .Call(wrap__RPolarsExpr__median, self) -Expr$sum <- function() .Call(wrap__Expr__sum, self) +Expr$sum <- function() .Call(wrap__RPolarsExpr__sum, self) -Expr$product <- function() .Call(wrap__Expr__product, self) +Expr$product <- function() .Call(wrap__RPolarsExpr__product, self) -Expr$n_unique <- function() .Call(wrap__Expr__n_unique, self) +Expr$n_unique <- function() .Call(wrap__RPolarsExpr__n_unique, self) -Expr$null_count <- function() .Call(wrap__Expr__null_count, self) +Expr$null_count <- function() .Call(wrap__RPolarsExpr__null_count, self) -Expr$arg_unique <- function() .Call(wrap__Expr__arg_unique, self) +Expr$arg_unique <- function() .Call(wrap__RPolarsExpr__arg_unique, self) -Expr$quantile <- function(quantile, interpolation) .Call(wrap__Expr__quantile, self, quantile, interpolation) +Expr$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsExpr__quantile, self, quantile, interpolation) -Expr$filter <- function(predicate) .Call(wrap__Expr__filter, self, predicate) +Expr$filter <- function(predicate) .Call(wrap__RPolarsExpr__filter, self, predicate) -Expr$explode <- function() .Call(wrap__Expr__explode, self) +Expr$explode <- function() .Call(wrap__RPolarsExpr__explode, self) -Expr$flatten <- function() .Call(wrap__Expr__flatten, self) +Expr$flatten <- function() .Call(wrap__RPolarsExpr__flatten, self) -Expr$gather_every <- function(n) .Call(wrap__Expr__gather_every, self, n) +Expr$gather_every <- function(n) .Call(wrap__RPolarsExpr__gather_every, self, n) -Expr$hash <- function(seed, seed_1, seed_2, seed_3) .Call(wrap__Expr__hash, self, seed, seed_1, seed_2, seed_3) +Expr$hash <- function(seed, seed_1, seed_2, seed_3) .Call(wrap__RPolarsExpr__hash, self, seed, seed_1, seed_2, seed_3) -Expr$reinterpret <- function(signed) .Call(wrap__Expr__reinterpret, self, signed) +Expr$reinterpret <- function(signed) .Call(wrap__RPolarsExpr__reinterpret, self, signed) -Expr$interpolate <- function(method) .Call(wrap__Expr__interpolate, self, method) +Expr$interpolate <- function(method) .Call(wrap__RPolarsExpr__interpolate, self, method) -Expr$rolling_min <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_min, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_min <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_min, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_max <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_max, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_max <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_max, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_mean <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_mean, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_mean <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_mean, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_sum <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_sum, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_sum <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_sum, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_std <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_std, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_std <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_std, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_var <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_var, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_var <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_var, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_median <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__Expr__rolling_median, self, window_size, weights, min_periods, center, by_null, closed_null) +Expr$rolling_median <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_median, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_quantile <- function(quantile, interpolation, window_size, weights, min_periods, center, by, closed) .Call(wrap__Expr__rolling_quantile, self, quantile, interpolation, window_size, weights, min_periods, center, by, closed) +Expr$rolling_quantile <- function(quantile, interpolation, window_size, weights, min_periods, center, by, closed) .Call(wrap__RPolarsExpr__rolling_quantile, self, quantile, interpolation, window_size, weights, min_periods, center, by, closed) -Expr$rolling_skew <- function(window_size_f, bias) .Call(wrap__Expr__rolling_skew, self, window_size_f, bias) +Expr$rolling_skew <- function(window_size_f, bias) .Call(wrap__RPolarsExpr__rolling_skew, self, window_size_f, bias) -Expr$abs <- function() .Call(wrap__Expr__abs, self) +Expr$abs <- function() .Call(wrap__RPolarsExpr__abs, self) -Expr$rank <- function(method, descending) .Call(wrap__Expr__rank, self, method, descending) +Expr$rank <- function(method, descending) .Call(wrap__RPolarsExpr__rank, self, method, descending) -Expr$diff <- function(n_float, null_behavior) .Call(wrap__Expr__diff, self, n_float, null_behavior) +Expr$diff <- function(n_float, null_behavior) .Call(wrap__RPolarsExpr__diff, self, n_float, null_behavior) -Expr$pct_change <- function(n_float) .Call(wrap__Expr__pct_change, self, n_float) +Expr$pct_change <- function(n_float) .Call(wrap__RPolarsExpr__pct_change, self, n_float) -Expr$skew <- function(bias) .Call(wrap__Expr__skew, self, bias) +Expr$skew <- function(bias) .Call(wrap__RPolarsExpr__skew, self, bias) -Expr$kurtosis <- function(fisher, bias) .Call(wrap__Expr__kurtosis, self, fisher, bias) +Expr$kurtosis <- function(fisher, bias) .Call(wrap__RPolarsExpr__kurtosis, self, fisher, bias) -Expr$clip <- function(min, max) .Call(wrap__Expr__clip, self, min, max) +Expr$clip <- function(min, max) .Call(wrap__RPolarsExpr__clip, self, min, max) -Expr$clip_min <- function(min) .Call(wrap__Expr__clip_min, self, min) +Expr$clip_min <- function(min) .Call(wrap__RPolarsExpr__clip_min, self, min) -Expr$clip_max <- function(max) .Call(wrap__Expr__clip_max, self, max) +Expr$clip_max <- function(max) .Call(wrap__RPolarsExpr__clip_max, self, max) -Expr$lower_bound <- function() .Call(wrap__Expr__lower_bound, self) +Expr$lower_bound <- function() .Call(wrap__RPolarsExpr__lower_bound, self) -Expr$upper_bound <- function() .Call(wrap__Expr__upper_bound, self) +Expr$upper_bound <- function() .Call(wrap__RPolarsExpr__upper_bound, self) -Expr$sign <- function() .Call(wrap__Expr__sign, self) +Expr$sign <- function() .Call(wrap__RPolarsExpr__sign, self) -Expr$sin <- function() .Call(wrap__Expr__sin, self) +Expr$sin <- function() .Call(wrap__RPolarsExpr__sin, self) -Expr$cos <- function() .Call(wrap__Expr__cos, self) +Expr$cos <- function() .Call(wrap__RPolarsExpr__cos, self) -Expr$tan <- function() .Call(wrap__Expr__tan, self) +Expr$tan <- function() .Call(wrap__RPolarsExpr__tan, self) -Expr$arcsin <- function() .Call(wrap__Expr__arcsin, self) +Expr$arcsin <- function() .Call(wrap__RPolarsExpr__arcsin, self) -Expr$arccos <- function() .Call(wrap__Expr__arccos, self) +Expr$arccos <- function() .Call(wrap__RPolarsExpr__arccos, self) -Expr$arctan <- function() .Call(wrap__Expr__arctan, self) +Expr$arctan <- function() .Call(wrap__RPolarsExpr__arctan, self) -Expr$sinh <- function() .Call(wrap__Expr__sinh, self) +Expr$sinh <- function() .Call(wrap__RPolarsExpr__sinh, self) -Expr$cosh <- function() .Call(wrap__Expr__cosh, self) +Expr$cosh <- function() .Call(wrap__RPolarsExpr__cosh, self) -Expr$tanh <- function() .Call(wrap__Expr__tanh, self) +Expr$tanh <- function() .Call(wrap__RPolarsExpr__tanh, self) -Expr$arcsinh <- function() .Call(wrap__Expr__arcsinh, self) +Expr$arcsinh <- function() .Call(wrap__RPolarsExpr__arcsinh, self) -Expr$arccosh <- function() .Call(wrap__Expr__arccosh, self) +Expr$arccosh <- function() .Call(wrap__RPolarsExpr__arccosh, self) -Expr$arctanh <- function() .Call(wrap__Expr__arctanh, self) +Expr$arctanh <- function() .Call(wrap__RPolarsExpr__arctanh, self) -Expr$reshape <- function(dims) .Call(wrap__Expr__reshape, self, dims) +Expr$reshape <- function(dims) .Call(wrap__RPolarsExpr__reshape, self, dims) -Expr$shuffle <- function(seed) .Call(wrap__Expr__shuffle, self, seed) +Expr$shuffle <- function(seed) .Call(wrap__RPolarsExpr__shuffle, self, seed) -Expr$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__Expr__sample_n, self, n, with_replacement, shuffle, seed) +Expr$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_n, self, n, with_replacement, shuffle, seed) -Expr$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__Expr__sample_frac, self, frac, with_replacement, shuffle, seed) +Expr$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_frac, self, frac, with_replacement, shuffle, seed) -Expr$ewm_mean <- function(alpha, adjust, min_periods, ignore_nulls) .Call(wrap__Expr__ewm_mean, self, alpha, adjust, min_periods, ignore_nulls) +Expr$ewm_mean <- function(alpha, adjust, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_mean, self, alpha, adjust, min_periods, ignore_nulls) -Expr$ewm_std <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__Expr__ewm_std, self, alpha, adjust, bias, min_periods, ignore_nulls) +Expr$ewm_std <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_std, self, alpha, adjust, bias, min_periods, ignore_nulls) -Expr$ewm_var <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__Expr__ewm_var, self, alpha, adjust, bias, min_periods, ignore_nulls) +Expr$ewm_var <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_var, self, alpha, adjust, bias, min_periods, ignore_nulls) -Expr$extend_constant <- function(value, n) .Call(wrap__Expr__extend_constant, self, value, n) +Expr$extend_constant <- function(value, n) .Call(wrap__RPolarsExpr__extend_constant, self, value, n) -Expr$rep <- function(n, rechunk) .Call(wrap__Expr__rep, self, n, rechunk) +Expr$rep <- function(n, rechunk) .Call(wrap__RPolarsExpr__rep, self, n, rechunk) -Expr$value_counts <- function(sort, parallel) .Call(wrap__Expr__value_counts, self, sort, parallel) +Expr$value_counts <- function(sort, parallel) .Call(wrap__RPolarsExpr__value_counts, self, sort, parallel) -Expr$unique_counts <- function() .Call(wrap__Expr__unique_counts, self) +Expr$unique_counts <- function() .Call(wrap__RPolarsExpr__unique_counts, self) -Expr$entropy <- function(base, normalize) .Call(wrap__Expr__entropy, self, base, normalize) +Expr$entropy <- function(base, normalize) .Call(wrap__RPolarsExpr__entropy, self, base, normalize) -Expr$cumulative_eval <- function(expr, min_periods, parallel) .Call(wrap__Expr__cumulative_eval, self, expr, min_periods, parallel) +Expr$cumulative_eval <- function(expr, min_periods, parallel) .Call(wrap__RPolarsExpr__cumulative_eval, self, expr, min_periods, parallel) -Expr$implode <- function() .Call(wrap__Expr__implode, self) +Expr$implode <- function() .Call(wrap__RPolarsExpr__implode, self) -Expr$shrink_dtype <- function() .Call(wrap__Expr__shrink_dtype, self) +Expr$shrink_dtype <- function() .Call(wrap__RPolarsExpr__shrink_dtype, self) -Expr$peak_min <- function() .Call(wrap__Expr__peak_min, self) +Expr$peak_min <- function() .Call(wrap__RPolarsExpr__peak_min, self) -Expr$peak_max <- function() .Call(wrap__Expr__peak_max, self) +Expr$peak_max <- function() .Call(wrap__RPolarsExpr__peak_max, self) -Expr$list_lengths <- function() .Call(wrap__Expr__list_lengths, self) +Expr$list_lengths <- function() .Call(wrap__RPolarsExpr__list_lengths, self) -Expr$list_contains <- function(other) .Call(wrap__Expr__list_contains, self, other) +Expr$list_contains <- function(other) .Call(wrap__RPolarsExpr__list_contains, self, other) -Expr$list_max <- function() .Call(wrap__Expr__list_max, self) +Expr$list_max <- function() .Call(wrap__RPolarsExpr__list_max, self) -Expr$list_min <- function() .Call(wrap__Expr__list_min, self) +Expr$list_min <- function() .Call(wrap__RPolarsExpr__list_min, self) -Expr$list_sum <- function() .Call(wrap__Expr__list_sum, self) +Expr$list_sum <- function() .Call(wrap__RPolarsExpr__list_sum, self) -Expr$list_mean <- function() .Call(wrap__Expr__list_mean, self) +Expr$list_mean <- function() .Call(wrap__RPolarsExpr__list_mean, self) -Expr$list_sort <- function(descending) .Call(wrap__Expr__list_sort, self, descending) +Expr$list_sort <- function(descending) .Call(wrap__RPolarsExpr__list_sort, self, descending) -Expr$list_reverse <- function() .Call(wrap__Expr__list_reverse, self) +Expr$list_reverse <- function() .Call(wrap__RPolarsExpr__list_reverse, self) -Expr$list_unique <- function() .Call(wrap__Expr__list_unique, self) +Expr$list_unique <- function() .Call(wrap__RPolarsExpr__list_unique, self) -Expr$list_gather <- function(index, null_on_oob) .Call(wrap__Expr__list_gather, self, index, null_on_oob) +Expr$list_gather <- function(index, null_on_oob) .Call(wrap__RPolarsExpr__list_gather, self, index, null_on_oob) -Expr$list_get <- function(index) .Call(wrap__Expr__list_get, self, index) +Expr$list_get <- function(index) .Call(wrap__RPolarsExpr__list_get, self, index) -Expr$list_join <- function(separator) .Call(wrap__Expr__list_join, self, separator) +Expr$list_join <- function(separator) .Call(wrap__RPolarsExpr__list_join, self, separator) -Expr$list_arg_min <- function() .Call(wrap__Expr__list_arg_min, self) +Expr$list_arg_min <- function() .Call(wrap__RPolarsExpr__list_arg_min, self) -Expr$list_arg_max <- function() .Call(wrap__Expr__list_arg_max, self) +Expr$list_arg_max <- function() .Call(wrap__RPolarsExpr__list_arg_max, self) -Expr$list_diff <- function(n, null_behavior) .Call(wrap__Expr__list_diff, self, n, null_behavior) +Expr$list_diff <- function(n, null_behavior) .Call(wrap__RPolarsExpr__list_diff, self, n, null_behavior) -Expr$list_shift <- function(periods) .Call(wrap__Expr__list_shift, self, periods) +Expr$list_shift <- function(periods) .Call(wrap__RPolarsExpr__list_shift, self, periods) -Expr$list_slice <- function(offset, length) .Call(wrap__Expr__list_slice, self, offset, length) +Expr$list_slice <- function(offset, length) .Call(wrap__RPolarsExpr__list_slice, self, offset, length) -Expr$list_eval <- function(expr, parallel) .Call(wrap__Expr__list_eval, self, expr, parallel) +Expr$list_eval <- function(expr, parallel) .Call(wrap__RPolarsExpr__list_eval, self, expr, parallel) -Expr$list_to_struct <- function(width_strat, name_gen, upper_bound) .Call(wrap__Expr__list_to_struct, self, width_strat, name_gen, upper_bound) +Expr$list_to_struct <- function(width_strat, name_gen, upper_bound) .Call(wrap__RPolarsExpr__list_to_struct, self, width_strat, name_gen, upper_bound) -Expr$str_to_date <- function(format, strict, exact, cache, ambiguous) .Call(wrap__Expr__str_to_date, self, format, strict, exact, cache, ambiguous) +Expr$str_to_date <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_date, self, format, strict, exact, cache, ambiguous) -Expr$str_to_datetime <- function(format, time_unit, time_zone, strict, exact, cache, ambiguous) .Call(wrap__Expr__str_to_datetime, self, format, time_unit, time_zone, strict, exact, cache, ambiguous) +Expr$str_to_datetime <- function(format, time_unit, time_zone, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_datetime, self, format, time_unit, time_zone, strict, exact, cache, ambiguous) -Expr$str_to_time <- function(format, strict, exact, cache, ambiguous) .Call(wrap__Expr__str_to_time, self, format, strict, exact, cache, ambiguous) +Expr$str_to_time <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_time, self, format, strict, exact, cache, ambiguous) -Expr$dt_truncate <- function(every, offset) .Call(wrap__Expr__dt_truncate, self, every, offset) +Expr$dt_truncate <- function(every, offset) .Call(wrap__RPolarsExpr__dt_truncate, self, every, offset) -Expr$dt_round <- function(every, offset) .Call(wrap__Expr__dt_round, self, every, offset) +Expr$dt_round <- function(every, offset) .Call(wrap__RPolarsExpr__dt_round, self, every, offset) -Expr$dt_time <- function() .Call(wrap__Expr__dt_time, self) +Expr$dt_time <- function() .Call(wrap__RPolarsExpr__dt_time, self) -Expr$dt_combine <- function(time, tu) .Call(wrap__Expr__dt_combine, self, time, tu) +Expr$dt_combine <- function(time, tu) .Call(wrap__RPolarsExpr__dt_combine, self, time, tu) -Expr$dt_strftime <- function(fmt) .Call(wrap__Expr__dt_strftime, self, fmt) +Expr$dt_strftime <- function(fmt) .Call(wrap__RPolarsExpr__dt_strftime, self, fmt) -Expr$dt_year <- function() .Call(wrap__Expr__dt_year, self) +Expr$dt_year <- function() .Call(wrap__RPolarsExpr__dt_year, self) -Expr$dt_iso_year <- function() .Call(wrap__Expr__dt_iso_year, self) +Expr$dt_iso_year <- function() .Call(wrap__RPolarsExpr__dt_iso_year, self) -Expr$dt_quarter <- function() .Call(wrap__Expr__dt_quarter, self) +Expr$dt_quarter <- function() .Call(wrap__RPolarsExpr__dt_quarter, self) -Expr$dt_month <- function() .Call(wrap__Expr__dt_month, self) +Expr$dt_month <- function() .Call(wrap__RPolarsExpr__dt_month, self) -Expr$dt_week <- function() .Call(wrap__Expr__dt_week, self) +Expr$dt_week <- function() .Call(wrap__RPolarsExpr__dt_week, self) -Expr$dt_weekday <- function() .Call(wrap__Expr__dt_weekday, self) +Expr$dt_weekday <- function() .Call(wrap__RPolarsExpr__dt_weekday, self) -Expr$dt_day <- function() .Call(wrap__Expr__dt_day, self) +Expr$dt_day <- function() .Call(wrap__RPolarsExpr__dt_day, self) -Expr$dt_ordinal_day <- function() .Call(wrap__Expr__dt_ordinal_day, self) +Expr$dt_ordinal_day <- function() .Call(wrap__RPolarsExpr__dt_ordinal_day, self) -Expr$dt_hour <- function() .Call(wrap__Expr__dt_hour, self) +Expr$dt_hour <- function() .Call(wrap__RPolarsExpr__dt_hour, self) -Expr$dt_minute <- function() .Call(wrap__Expr__dt_minute, self) +Expr$dt_minute <- function() .Call(wrap__RPolarsExpr__dt_minute, self) -Expr$dt_second <- function() .Call(wrap__Expr__dt_second, self) +Expr$dt_second <- function() .Call(wrap__RPolarsExpr__dt_second, self) -Expr$dt_millisecond <- function() .Call(wrap__Expr__dt_millisecond, self) +Expr$dt_millisecond <- function() .Call(wrap__RPolarsExpr__dt_millisecond, self) -Expr$dt_microsecond <- function() .Call(wrap__Expr__dt_microsecond, self) +Expr$dt_microsecond <- function() .Call(wrap__RPolarsExpr__dt_microsecond, self) -Expr$dt_nanosecond <- function() .Call(wrap__Expr__dt_nanosecond, self) +Expr$dt_nanosecond <- function() .Call(wrap__RPolarsExpr__dt_nanosecond, self) -Expr$timestamp <- function(tu) .Call(wrap__Expr__timestamp, self, tu) +Expr$timestamp <- function(tu) .Call(wrap__RPolarsExpr__timestamp, self, tu) -Expr$dt_epoch_seconds <- function() .Call(wrap__Expr__dt_epoch_seconds, self) +Expr$dt_epoch_seconds <- function() .Call(wrap__RPolarsExpr__dt_epoch_seconds, self) -Expr$dt_with_time_unit <- function(tu) .Call(wrap__Expr__dt_with_time_unit, self, tu) +Expr$dt_with_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_with_time_unit, self, tu) -Expr$dt_cast_time_unit <- function(tu) .Call(wrap__Expr__dt_cast_time_unit, self, tu) +Expr$dt_cast_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_cast_time_unit, self, tu) -Expr$dt_convert_time_zone <- function(tz) .Call(wrap__Expr__dt_convert_time_zone, self, tz) +Expr$dt_convert_time_zone <- function(tz) .Call(wrap__RPolarsExpr__dt_convert_time_zone, self, tz) -Expr$dt_replace_time_zone <- function(tz, ambiguous) .Call(wrap__Expr__dt_replace_time_zone, self, tz, ambiguous) +Expr$dt_replace_time_zone <- function(tz, ambiguous) .Call(wrap__RPolarsExpr__dt_replace_time_zone, self, tz, ambiguous) -Expr$dt_total_days <- function() .Call(wrap__Expr__dt_total_days, self) +Expr$dt_total_days <- function() .Call(wrap__RPolarsExpr__dt_total_days, self) -Expr$dt_total_hours <- function() .Call(wrap__Expr__dt_total_hours, self) +Expr$dt_total_hours <- function() .Call(wrap__RPolarsExpr__dt_total_hours, self) -Expr$dt_total_minutes <- function() .Call(wrap__Expr__dt_total_minutes, self) +Expr$dt_total_minutes <- function() .Call(wrap__RPolarsExpr__dt_total_minutes, self) -Expr$dt_total_seconds <- function() .Call(wrap__Expr__dt_total_seconds, self) +Expr$dt_total_seconds <- function() .Call(wrap__RPolarsExpr__dt_total_seconds, self) -Expr$dt_total_milliseconds <- function() .Call(wrap__Expr__dt_total_milliseconds, self) +Expr$dt_total_milliseconds <- function() .Call(wrap__RPolarsExpr__dt_total_milliseconds, self) -Expr$dt_total_microseconds <- function() .Call(wrap__Expr__dt_total_microseconds, self) +Expr$dt_total_microseconds <- function() .Call(wrap__RPolarsExpr__dt_total_microseconds, self) -Expr$dt_total_nanoseconds <- function() .Call(wrap__Expr__dt_total_nanoseconds, self) +Expr$dt_total_nanoseconds <- function() .Call(wrap__RPolarsExpr__dt_total_nanoseconds, self) -Expr$dt_offset_by <- function(by) .Call(wrap__Expr__dt_offset_by, self, by) +Expr$dt_offset_by <- function(by) .Call(wrap__RPolarsExpr__dt_offset_by, self, by) -Expr$repeat_by <- function(by) .Call(wrap__Expr__repeat_by, self, by) +Expr$repeat_by <- function(by) .Call(wrap__RPolarsExpr__repeat_by, self, by) -Expr$log10 <- function() .Call(wrap__Expr__log10, self) +Expr$log10 <- function() .Call(wrap__RPolarsExpr__log10, self) -Expr$log <- function(base) .Call(wrap__Expr__log, self, base) +Expr$log <- function(base) .Call(wrap__RPolarsExpr__log, self, base) -Expr$exp <- function() .Call(wrap__Expr__exp, self) +Expr$exp <- function() .Call(wrap__RPolarsExpr__exp, self) -Expr$exclude <- function(columns) .Call(wrap__Expr__exclude, self, columns) +Expr$exclude <- function(columns) .Call(wrap__RPolarsExpr__exclude, self, columns) -Expr$exclude_dtype <- function(columns) .Call(wrap__Expr__exclude_dtype, self, columns) +Expr$exclude_dtype <- function(columns) .Call(wrap__RPolarsExpr__exclude_dtype, self, columns) -Expr$alias <- function(s) .Call(wrap__Expr__alias, self, s) +Expr$alias <- function(s) .Call(wrap__RPolarsExpr__alias, self, s) -Expr$drop_nulls <- function() .Call(wrap__Expr__drop_nulls, self) +Expr$drop_nulls <- function() .Call(wrap__RPolarsExpr__drop_nulls, self) -Expr$drop_nans <- function() .Call(wrap__Expr__drop_nans, self) +Expr$drop_nans <- function() .Call(wrap__RPolarsExpr__drop_nans, self) -Expr$cum_sum <- function(reverse) .Call(wrap__Expr__cum_sum, self, reverse) +Expr$cum_sum <- function(reverse) .Call(wrap__RPolarsExpr__cum_sum, self, reverse) -Expr$cum_prod <- function(reverse) .Call(wrap__Expr__cum_prod, self, reverse) +Expr$cum_prod <- function(reverse) .Call(wrap__RPolarsExpr__cum_prod, self, reverse) -Expr$cum_min <- function(reverse) .Call(wrap__Expr__cum_min, self, reverse) +Expr$cum_min <- function(reverse) .Call(wrap__RPolarsExpr__cum_min, self, reverse) -Expr$cum_max <- function(reverse) .Call(wrap__Expr__cum_max, self, reverse) +Expr$cum_max <- function(reverse) .Call(wrap__RPolarsExpr__cum_max, self, reverse) -Expr$cum_count <- function(reverse) .Call(wrap__Expr__cum_count, self, reverse) +Expr$cum_count <- function(reverse) .Call(wrap__RPolarsExpr__cum_count, self, reverse) -Expr$floor <- function() .Call(wrap__Expr__floor, self) +Expr$floor <- function() .Call(wrap__RPolarsExpr__floor, self) -Expr$ceil <- function() .Call(wrap__Expr__ceil, self) +Expr$ceil <- function() .Call(wrap__RPolarsExpr__ceil, self) -Expr$round <- function(decimals) .Call(wrap__Expr__round, self, decimals) +Expr$round <- function(decimals) .Call(wrap__RPolarsExpr__round, self, decimals) -Expr$dot <- function(other) .Call(wrap__Expr__dot, self, other) +Expr$dot <- function(other) .Call(wrap__RPolarsExpr__dot, self, other) -Expr$mode <- function() .Call(wrap__Expr__mode, self) +Expr$mode <- function() .Call(wrap__RPolarsExpr__mode, self) -Expr$first <- function() .Call(wrap__Expr__first, self) +Expr$first <- function() .Call(wrap__RPolarsExpr__first, self) -Expr$last <- function() .Call(wrap__Expr__last, self) +Expr$last <- function() .Call(wrap__RPolarsExpr__last, self) -Expr$head <- function(n) .Call(wrap__Expr__head, self, n) +Expr$head <- function(n) .Call(wrap__RPolarsExpr__head, self, n) -Expr$tail <- function(n) .Call(wrap__Expr__tail, self, n) +Expr$tail <- function(n) .Call(wrap__RPolarsExpr__tail, self, n) -Expr$unique <- function() .Call(wrap__Expr__unique, self) +Expr$unique <- function() .Call(wrap__RPolarsExpr__unique, self) -Expr$unique_stable <- function() .Call(wrap__Expr__unique_stable, self) +Expr$unique_stable <- function() .Call(wrap__RPolarsExpr__unique_stable, self) -Expr$agg_groups <- function() .Call(wrap__Expr__agg_groups, self) +Expr$agg_groups <- function() .Call(wrap__RPolarsExpr__agg_groups, self) -Expr$all <- function(drop_nulls) .Call(wrap__Expr__all, self, drop_nulls) +Expr$all <- function(drop_nulls) .Call(wrap__RPolarsExpr__all, self, drop_nulls) -Expr$any <- function(drop_nulls) .Call(wrap__Expr__any, self, drop_nulls) +Expr$any <- function(drop_nulls) .Call(wrap__RPolarsExpr__any, self, drop_nulls) -Expr$is_duplicated <- function() .Call(wrap__Expr__is_duplicated, self) +Expr$is_duplicated <- function() .Call(wrap__RPolarsExpr__is_duplicated, self) -Expr$is_finite <- function() .Call(wrap__Expr__is_finite, self) +Expr$is_finite <- function() .Call(wrap__RPolarsExpr__is_finite, self) -Expr$is_first_distinct <- function() .Call(wrap__Expr__is_first_distinct, self) +Expr$is_first_distinct <- function() .Call(wrap__RPolarsExpr__is_first_distinct, self) -Expr$is_in <- function(other) .Call(wrap__Expr__is_in, self, other) +Expr$is_in <- function(other) .Call(wrap__RPolarsExpr__is_in, self, other) -Expr$is_infinite <- function() .Call(wrap__Expr__is_infinite, self) +Expr$is_infinite <- function() .Call(wrap__RPolarsExpr__is_infinite, self) -Expr$is_last_distinct <- function() .Call(wrap__Expr__is_last_distinct, self) +Expr$is_last_distinct <- function() .Call(wrap__RPolarsExpr__is_last_distinct, self) -Expr$is_nan <- function() .Call(wrap__Expr__is_nan, self) +Expr$is_nan <- function() .Call(wrap__RPolarsExpr__is_nan, self) -Expr$is_not_null <- function() .Call(wrap__Expr__is_not_null, self) +Expr$is_not_null <- function() .Call(wrap__RPolarsExpr__is_not_null, self) -Expr$is_not_nan <- function() .Call(wrap__Expr__is_not_nan, self) +Expr$is_not_nan <- function() .Call(wrap__RPolarsExpr__is_not_nan, self) -Expr$is_null <- function() .Call(wrap__Expr__is_null, self) +Expr$is_null <- function() .Call(wrap__RPolarsExpr__is_null, self) -Expr$is_unique <- function() .Call(wrap__Expr__is_unique, self) +Expr$is_unique <- function() .Call(wrap__RPolarsExpr__is_unique, self) -Expr$not <- function() .Call(wrap__Expr__not, self) +Expr$not <- function() .Call(wrap__RPolarsExpr__not, self) -Expr$count <- function() .Call(wrap__Expr__count, self) +Expr$count <- function() .Call(wrap__RPolarsExpr__count, self) -Expr$len <- function() .Call(wrap__Expr__len, self) +Expr$len <- function() .Call(wrap__RPolarsExpr__len, self) -Expr$slice <- function(offset, length) .Call(wrap__Expr__slice, self, offset, length) +Expr$slice <- function(offset, length) .Call(wrap__RPolarsExpr__slice, self, offset, length) -Expr$append <- function(other, upcast) .Call(wrap__Expr__append, self, other, upcast) +Expr$append <- function(other, upcast) .Call(wrap__RPolarsExpr__append, self, other, upcast) -Expr$rechunk <- function() .Call(wrap__Expr__rechunk, self) +Expr$rechunk <- function() .Call(wrap__RPolarsExpr__rechunk, self) -Expr$add <- function(other) .Call(wrap__Expr__add, self, other) +Expr$add <- function(other) .Call(wrap__RPolarsExpr__add, self, other) -Expr$floor_div <- function(other) .Call(wrap__Expr__floor_div, self, other) +Expr$floor_div <- function(other) .Call(wrap__RPolarsExpr__floor_div, self, other) -Expr$rem <- function(other) .Call(wrap__Expr__rem, self, other) +Expr$rem <- function(other) .Call(wrap__RPolarsExpr__rem, self, other) -Expr$mul <- function(other) .Call(wrap__Expr__mul, self, other) +Expr$mul <- function(other) .Call(wrap__RPolarsExpr__mul, self, other) -Expr$sub <- function(other) .Call(wrap__Expr__sub, self, other) +Expr$sub <- function(other) .Call(wrap__RPolarsExpr__sub, self, other) -Expr$div <- function(other) .Call(wrap__Expr__div, self, other) +Expr$div <- function(other) .Call(wrap__RPolarsExpr__div, self, other) -Expr$pow <- function(exponent) .Call(wrap__Expr__pow, self, exponent) +Expr$pow <- function(exponent) .Call(wrap__RPolarsExpr__pow, self, exponent) -Expr$over <- function(proto_exprs) .Call(wrap__Expr__over, self, proto_exprs) +Expr$over <- function(proto_exprs) .Call(wrap__RPolarsExpr__over, self, proto_exprs) -Expr$print <- function() invisible(.Call(wrap__Expr__print, self)) +Expr$print <- function() invisible(.Call(wrap__RPolarsExpr__print, self)) -Expr$map_batches <- function(lambda, output_type, agg_list) .Call(wrap__Expr__map_batches, self, lambda, output_type, agg_list) +Expr$map_batches <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches, self, lambda, output_type, agg_list) -Expr$map_batches_in_background <- function(lambda, output_type, agg_list) .Call(wrap__Expr__map_batches_in_background, self, lambda, output_type, agg_list) +Expr$map_batches_in_background <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches_in_background, self, lambda, output_type, agg_list) -Expr$map_elements_in_background <- function(lambda, output_type) .Call(wrap__Expr__map_elements_in_background, self, lambda, output_type) +Expr$map_elements_in_background <- function(lambda, output_type) .Call(wrap__RPolarsExpr__map_elements_in_background, self, lambda, output_type) -Expr$approx_n_unique <- function() .Call(wrap__Expr__approx_n_unique, self) +Expr$approx_n_unique <- function() .Call(wrap__RPolarsExpr__approx_n_unique, self) -Expr$name_keep <- function() .Call(wrap__Expr__name_keep, self) +Expr$name_keep <- function() .Call(wrap__RPolarsExpr__name_keep, self) -Expr$name_suffix <- function(suffix) .Call(wrap__Expr__name_suffix, self, suffix) +Expr$name_suffix <- function(suffix) .Call(wrap__RPolarsExpr__name_suffix, self, suffix) -Expr$name_prefix <- function(prefix) .Call(wrap__Expr__name_prefix, self, prefix) +Expr$name_prefix <- function(prefix) .Call(wrap__RPolarsExpr__name_prefix, self, prefix) -Expr$name_to_lowercase <- function() .Call(wrap__Expr__name_to_lowercase, self) +Expr$name_to_lowercase <- function() .Call(wrap__RPolarsExpr__name_to_lowercase, self) -Expr$name_to_uppercase <- function() .Call(wrap__Expr__name_to_uppercase, self) +Expr$name_to_uppercase <- function() .Call(wrap__RPolarsExpr__name_to_uppercase, self) -Expr$name_map <- function(lambda) .Call(wrap__Expr__name_map, self, lambda) +Expr$name_map <- function(lambda) .Call(wrap__RPolarsExpr__name_map, self, lambda) -Expr$str_len_bytes <- function() .Call(wrap__Expr__str_len_bytes, self) +Expr$str_len_bytes <- function() .Call(wrap__RPolarsExpr__str_len_bytes, self) -Expr$str_len_chars <- function() .Call(wrap__Expr__str_len_chars, self) +Expr$str_len_chars <- function() .Call(wrap__RPolarsExpr__str_len_chars, self) -Expr$str_concat <- function(delimiter, ignore_nulls) .Call(wrap__Expr__str_concat, self, delimiter, ignore_nulls) +Expr$str_concat <- function(delimiter, ignore_nulls) .Call(wrap__RPolarsExpr__str_concat, self, delimiter, ignore_nulls) -Expr$str_to_uppercase <- function() .Call(wrap__Expr__str_to_uppercase, self) +Expr$str_to_uppercase <- function() .Call(wrap__RPolarsExpr__str_to_uppercase, self) -Expr$str_to_lowercase <- function() .Call(wrap__Expr__str_to_lowercase, self) +Expr$str_to_lowercase <- function() .Call(wrap__RPolarsExpr__str_to_lowercase, self) -Expr$str_to_titlecase <- function() .Call(wrap__Expr__str_to_titlecase, self) +Expr$str_to_titlecase <- function() .Call(wrap__RPolarsExpr__str_to_titlecase, self) -Expr$str_strip_chars <- function(matches) .Call(wrap__Expr__str_strip_chars, self, matches) +Expr$str_strip_chars <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars, self, matches) -Expr$str_strip_chars_end <- function(matches) .Call(wrap__Expr__str_strip_chars_end, self, matches) +Expr$str_strip_chars_end <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_end, self, matches) -Expr$str_strip_chars_start <- function(matches) .Call(wrap__Expr__str_strip_chars_start, self, matches) +Expr$str_strip_chars_start <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_start, self, matches) -Expr$str_zfill <- function(alignment) .Call(wrap__Expr__str_zfill, self, alignment) +Expr$str_zfill <- function(alignment) .Call(wrap__RPolarsExpr__str_zfill, self, alignment) -Expr$str_pad_end <- function(width, fillchar) .Call(wrap__Expr__str_pad_end, self, width, fillchar) +Expr$str_pad_end <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_end, self, width, fillchar) -Expr$str_pad_start <- function(width, fillchar) .Call(wrap__Expr__str_pad_start, self, width, fillchar) +Expr$str_pad_start <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_start, self, width, fillchar) -Expr$str_contains <- function(pat, literal, strict) .Call(wrap__Expr__str_contains, self, pat, literal, strict) +Expr$str_contains <- function(pat, literal, strict) .Call(wrap__RPolarsExpr__str_contains, self, pat, literal, strict) -Expr$str_ends_with <- function(sub) .Call(wrap__Expr__str_ends_with, self, sub) +Expr$str_ends_with <- function(sub) .Call(wrap__RPolarsExpr__str_ends_with, self, sub) -Expr$str_starts_with <- function(sub) .Call(wrap__Expr__str_starts_with, self, sub) +Expr$str_starts_with <- function(sub) .Call(wrap__RPolarsExpr__str_starts_with, self, sub) -Expr$str_json_path_match <- function(pat) .Call(wrap__Expr__str_json_path_match, self, pat) +Expr$str_json_path_match <- function(pat) .Call(wrap__RPolarsExpr__str_json_path_match, self, pat) -Expr$str_json_extract <- function(dtype, infer_schema_len) .Call(wrap__Expr__str_json_extract, self, dtype, infer_schema_len) +Expr$str_json_extract <- function(dtype, infer_schema_len) .Call(wrap__RPolarsExpr__str_json_extract, self, dtype, infer_schema_len) -Expr$str_hex_encode <- function() .Call(wrap__Expr__str_hex_encode, self) +Expr$str_hex_encode <- function() .Call(wrap__RPolarsExpr__str_hex_encode, self) -Expr$str_hex_decode <- function(strict) .Call(wrap__Expr__str_hex_decode, self, strict) +Expr$str_hex_decode <- function(strict) .Call(wrap__RPolarsExpr__str_hex_decode, self, strict) -Expr$str_base64_encode <- function() .Call(wrap__Expr__str_base64_encode, self) +Expr$str_base64_encode <- function() .Call(wrap__RPolarsExpr__str_base64_encode, self) -Expr$str_base64_decode <- function(strict) .Call(wrap__Expr__str_base64_decode, self, strict) +Expr$str_base64_decode <- function(strict) .Call(wrap__RPolarsExpr__str_base64_decode, self, strict) -Expr$str_extract <- function(pattern, group_index) .Call(wrap__Expr__str_extract, self, pattern, group_index) +Expr$str_extract <- function(pattern, group_index) .Call(wrap__RPolarsExpr__str_extract, self, pattern, group_index) -Expr$str_extract_all <- function(pattern) .Call(wrap__Expr__str_extract_all, self, pattern) +Expr$str_extract_all <- function(pattern) .Call(wrap__RPolarsExpr__str_extract_all, self, pattern) -Expr$str_count_matches <- function(pattern, literal) .Call(wrap__Expr__str_count_matches, self, pattern, literal) +Expr$str_count_matches <- function(pattern, literal) .Call(wrap__RPolarsExpr__str_count_matches, self, pattern, literal) -Expr$str_split <- function(by, inclusive) .Call(wrap__Expr__str_split, self, by, inclusive) +Expr$str_split <- function(by, inclusive) .Call(wrap__RPolarsExpr__str_split, self, by, inclusive) -Expr$str_split_exact <- function(by, n, inclusive) .Call(wrap__Expr__str_split_exact, self, by, n, inclusive) +Expr$str_split_exact <- function(by, n, inclusive) .Call(wrap__RPolarsExpr__str_split_exact, self, by, n, inclusive) -Expr$str_splitn <- function(by, n) .Call(wrap__Expr__str_splitn, self, by, n) +Expr$str_splitn <- function(by, n) .Call(wrap__RPolarsExpr__str_splitn, self, by, n) -Expr$str_replace <- function(pattern, value, literal) .Call(wrap__Expr__str_replace, self, pattern, value, literal) +Expr$str_replace <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace, self, pattern, value, literal) -Expr$str_replace_all <- function(pattern, value, literal) .Call(wrap__Expr__str_replace_all, self, pattern, value, literal) +Expr$str_replace_all <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace_all, self, pattern, value, literal) -Expr$str_slice <- function(offset, length) .Call(wrap__Expr__str_slice, self, offset, length) +Expr$str_slice <- function(offset, length) .Call(wrap__RPolarsExpr__str_slice, self, offset, length) -Expr$str_explode <- function() .Call(wrap__Expr__str_explode, self) +Expr$str_explode <- function() .Call(wrap__RPolarsExpr__str_explode, self) -Expr$str_parse_int <- function(radix, strict) .Call(wrap__Expr__str_parse_int, self, radix, strict) +Expr$str_parse_int <- function(radix, strict) .Call(wrap__RPolarsExpr__str_parse_int, self, radix, strict) -Expr$bin_contains <- function(lit) .Call(wrap__Expr__bin_contains, self, lit) +Expr$bin_contains <- function(lit) .Call(wrap__RPolarsExpr__bin_contains, self, lit) -Expr$bin_starts_with <- function(sub) .Call(wrap__Expr__bin_starts_with, self, sub) +Expr$bin_starts_with <- function(sub) .Call(wrap__RPolarsExpr__bin_starts_with, self, sub) -Expr$bin_ends_with <- function(sub) .Call(wrap__Expr__bin_ends_with, self, sub) +Expr$bin_ends_with <- function(sub) .Call(wrap__RPolarsExpr__bin_ends_with, self, sub) -Expr$bin_encode_hex <- function() .Call(wrap__Expr__bin_encode_hex, self) +Expr$bin_encode_hex <- function() .Call(wrap__RPolarsExpr__bin_encode_hex, self) -Expr$bin_encode_base64 <- function() .Call(wrap__Expr__bin_encode_base64, self) +Expr$bin_encode_base64 <- function() .Call(wrap__RPolarsExpr__bin_encode_base64, self) -Expr$bin_decode_hex <- function(strict) .Call(wrap__Expr__bin_decode_hex, self, strict) +Expr$bin_decode_hex <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_hex, self, strict) -Expr$bin_decode_base64 <- function(strict) .Call(wrap__Expr__bin_decode_base64, self, strict) +Expr$bin_decode_base64 <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_base64, self, strict) -Expr$struct_field_by_name <- function(name) .Call(wrap__Expr__struct_field_by_name, self, name) +Expr$struct_field_by_name <- function(name) .Call(wrap__RPolarsExpr__struct_field_by_name, self, name) -Expr$struct_rename_fields <- function(names) .Call(wrap__Expr__struct_rename_fields, self, names) +Expr$struct_rename_fields <- function(names) .Call(wrap__RPolarsExpr__struct_rename_fields, self, names) -Expr$meta_pop <- function() .Call(wrap__Expr__meta_pop, self) +Expr$meta_pop <- function() .Call(wrap__RPolarsExpr__meta_pop, self) -Expr$meta_eq <- function(other) .Call(wrap__Expr__meta_eq, self, other) +Expr$meta_eq <- function(other) .Call(wrap__RPolarsExpr__meta_eq, self, other) -Expr$meta_roots <- function() .Call(wrap__Expr__meta_roots, self) +Expr$meta_roots <- function() .Call(wrap__RPolarsExpr__meta_roots, self) -Expr$meta_output_name <- function() .Call(wrap__Expr__meta_output_name, self) +Expr$meta_output_name <- function() .Call(wrap__RPolarsExpr__meta_output_name, self) -Expr$meta_undo_aliases <- function() .Call(wrap__Expr__meta_undo_aliases, self) +Expr$meta_undo_aliases <- function() .Call(wrap__RPolarsExpr__meta_undo_aliases, self) -Expr$meta_has_multiple_outputs <- function() .Call(wrap__Expr__meta_has_multiple_outputs, self) +Expr$meta_has_multiple_outputs <- function() .Call(wrap__RPolarsExpr__meta_has_multiple_outputs, self) -Expr$meta_is_regex_projection <- function() .Call(wrap__Expr__meta_is_regex_projection, self) +Expr$meta_is_regex_projection <- function() .Call(wrap__RPolarsExpr__meta_is_regex_projection, self) -Expr$meta_tree_format <- function() .Call(wrap__Expr__meta_tree_format, self) +Expr$meta_tree_format <- function() .Call(wrap__RPolarsExpr__meta_tree_format, self) -Expr$cat_set_ordering <- function(ordering) .Call(wrap__Expr__cat_set_ordering, self, ordering) +Expr$cat_set_ordering <- function(ordering) .Call(wrap__RPolarsExpr__cat_set_ordering, self, ordering) -Expr$cat_get_categories <- function() .Call(wrap__Expr__cat_get_categories, self) +Expr$cat_get_categories <- function() .Call(wrap__RPolarsExpr__cat_get_categories, self) -Expr$new_count <- function() .Call(wrap__Expr__new_count) +Expr$new_count <- function() .Call(wrap__RPolarsExpr__new_count) -Expr$new_first <- function() .Call(wrap__Expr__new_first) +Expr$new_first <- function() .Call(wrap__RPolarsExpr__new_first) -Expr$new_last <- function() .Call(wrap__Expr__new_last) +Expr$new_last <- function() .Call(wrap__RPolarsExpr__new_last) -Expr$cov <- function(a, b, ddof) .Call(wrap__Expr__cov, a, b, ddof) +Expr$cov <- function(a, b, ddof) .Call(wrap__RPolarsExpr__cov, a, b, ddof) -Expr$rolling_cov <- function(a, b, window_size, min_periods, ddof) .Call(wrap__Expr__rolling_cov, a, b, window_size, min_periods, ddof) +Expr$rolling_cov <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_cov, a, b, window_size, min_periods, ddof) -Expr$corr <- function(a, b, method, ddof, propagate_nans) .Call(wrap__Expr__corr, a, b, method, ddof, propagate_nans) +Expr$corr <- function(a, b, method, ddof, propagate_nans) .Call(wrap__RPolarsExpr__corr, a, b, method, ddof, propagate_nans) -Expr$rolling_corr <- function(a, b, window_size, min_periods, ddof) .Call(wrap__Expr__rolling_corr, a, b, window_size, min_periods, ddof) +Expr$rolling_corr <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_corr, a, b, window_size, min_periods, ddof) -Expr$rolling <- function(index_column, period, offset, closed, check_sorted) .Call(wrap__Expr__rolling, self, index_column, period, offset, closed, check_sorted) +Expr$rolling <- function(index_column, period, offset, closed, check_sorted) .Call(wrap__RPolarsExpr__rolling, self, index_column, period, offset, closed, check_sorted) + +RPolarsExpr <- Expr #' @export -`$.Expr` <- function (self, name) { func <- Expr[[name]]; environment(func) <- environment(); func } +`$.RPolarsExpr` <- function (self, name) { func <- RPolarsExpr[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsExpr` <- `$.RPolarsExpr` + +`$.Expr` <- function (self, name) { func <- Expr[[name]]; environment(func) <- environment(); func } + `[[.Expr` <- `$.Expr` ProtoExprArray <- new.env(parent = emptyenv()) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 5e68c7c68..147734d01 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -981,9 +981,9 @@ LazyFrame_group_by = function(..., maintain_order = pl$options$maintain_order) { #' df1$join(other = df2, how = "cross") LazyFrame_join = function( other, # : LazyFrame or DataFrame, - left_on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, - right_on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, - on = NULL, # : str | pli.Expr | Sequence[str | pli.Expr] | None = None, + left_on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, + right_on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, + on = NULL, # : str | pli.RPolarsExpr | Sequence[str | pli.RPolarsExpr] | None = None, how = c("inner", "left", "outer", "semi", "anti", "cross"), suffix = "_right", allow_parallel = TRUE, diff --git a/R/zzz.R b/R/zzz.R index d6dd64197..2fc80b19b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -28,7 +28,7 @@ replace_private_with_pub_methods(Expr, "^Expr_") # configure subnames spaces of Expr #' @export -`$.ExprListNameSpace` = sub_name_space_accessor_function +`$.RPolarsExprListNameSpace` = sub_name_space_accessor_function expr_list_make_sub_ns = macro_new_subnamespace("^ExprList_", "ExprListNameSpace") #' @export diff --git a/man/ExprList_get.Rd b/man/ExprList_get.Rd index 8ed433784..9a448aabd 100644 --- a/man/ExprList_get.Rd +++ b/man/ExprList_get.Rd @@ -3,13 +3,13 @@ \name{ExprList_get} \alias{ExprList_get} \alias{Expr_list_get} -\alias{[.ExprListNameSpace} +\alias{[.RPolarsExprListNameSpace} \title{Get list} \format{ function } \usage{ -\method{[}{ExprListNameSpace}(x, index) +\method{[}{RPolarsExprListNameSpace}(x, index) } \arguments{ \item{x}{ExprListNameSpace} @@ -23,7 +23,7 @@ Expr Get the value by index in the sublists. } \details{ -\verb{[.ExprListNameSpace} used as e.g. \code{pl$col("a")$arr[0]} same as \code{pl$col("a")$get(0)} +\verb{[.RPolarsExprListNameSpace} used as e.g. \code{pl$col("a")$arr[0]} same as \code{pl$col("a")$get(0)} } \examples{ df = pl$DataFrame(list(a = list(3:1, NULL, 1:2))) # NULL or integer() or list() diff --git a/man/Expr_add.Rd b/man/Expr_add.Rd index e2b16a1ab..67ba02a64 100644 --- a/man/Expr_add.Rd +++ b/man/Expr_add.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_add} \alias{Expr_add} -\alias{+.Expr} +\alias{+.RPolarsExpr} \title{Add two expressions} \usage{ Expr_add(other) -\method{+}{Expr}(e1, e2) +\method{+}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_div.Rd b/man/Expr_div.Rd index 8e4cdb50e..723e8c771 100644 --- a/man/Expr_div.Rd +++ b/man/Expr_div.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_div} \alias{Expr_div} -\alias{/.Expr} +\alias{/.RPolarsExpr} \title{Divide two expressions} \usage{ Expr_div(other) -\method{/}{Expr}(e1, e2) +\method{/}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_eq.Rd b/man/Expr_eq.Rd index 5ba65909a..27530e676 100644 --- a/man/Expr_eq.Rd +++ b/man/Expr_eq.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_eq} \alias{Expr_eq} -\alias{==.Expr} +\alias{==.RPolarsExpr} \title{Check equality} \usage{ Expr_eq(other) -\method{==}{Expr}(e1, e2) +\method{==}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_floor_div.Rd b/man/Expr_floor_div.Rd index f700d2a24..ee11539b1 100644 --- a/man/Expr_floor_div.Rd +++ b/man/Expr_floor_div.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_floor_div} \alias{Expr_floor_div} -\alias{\%/\%.Expr} +\alias{\%/\%.RPolarsExpr} \title{Floor divide two expressions} \usage{ Expr_floor_div(other) -\method{\%/\%}{Expr}(e1, e2) +\method{\%/\%}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_gt.Rd b/man/Expr_gt.Rd index bc6381cd4..b13cdff3b 100644 --- a/man/Expr_gt.Rd +++ b/man/Expr_gt.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_gt} \alias{Expr_gt} -\alias{>.Expr} +\alias{>.RPolarsExpr} \title{Check strictly greater inequality} \usage{ Expr_gt(other) -\method{>}{Expr}(e1, e2) +\method{>}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_gt_eq.Rd b/man/Expr_gt_eq.Rd index 8136c7999..5e1afad23 100644 --- a/man/Expr_gt_eq.Rd +++ b/man/Expr_gt_eq.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_gt_eq} \alias{Expr_gt_eq} -\alias{>=.Expr} +\alias{>=.RPolarsExpr} \title{Check greater or equal inequality} \usage{ Expr_gt_eq(other) -\method{>=}{Expr}(e1, e2) +\method{>=}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_lt.Rd b/man/Expr_lt.Rd index b69a00c81..2e143f41b 100644 --- a/man/Expr_lt.Rd +++ b/man/Expr_lt.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_lt} \alias{Expr_lt} -\alias{<.Expr} +\alias{<.RPolarsExpr} \title{Check strictly lower inequality} \usage{ Expr_lt(other) -\method{<}{Expr}(e1, e2) +\method{<}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_lt_eq.Rd b/man/Expr_lt_eq.Rd index d89e55147..906846774 100644 --- a/man/Expr_lt_eq.Rd +++ b/man/Expr_lt_eq.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_lt_eq} \alias{Expr_lt_eq} -\alias{<=.Expr} +\alias{<=.RPolarsExpr} \title{Check lower or equal inequality} \usage{ Expr_lt_eq(other) -\method{<=}{Expr}(e1, e2) +\method{<=}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_mod.Rd b/man/Expr_mod.Rd index dcf31523f..ca538c3e1 100644 --- a/man/Expr_mod.Rd +++ b/man/Expr_mod.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_mod} \alias{Expr_mod} -\alias{\%\%.Expr} +\alias{\%\%.RPolarsExpr} \title{Modulo two expressions} \usage{ Expr_mod(other) -\method{\%\%}{Expr}(e1, e2) +\method{\%\%}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_mul.Rd b/man/Expr_mul.Rd index 9d50fd35d..ea46e2d3a 100644 --- a/man/Expr_mul.Rd +++ b/man/Expr_mul.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_mul} \alias{Expr_mul} -\alias{*.Expr} +\alias{*.RPolarsExpr} \title{Multiply two expressions} \usage{ Expr_mul(other) -\method{*}{Expr}(e1, e2) +\method{*}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_neq.Rd b/man/Expr_neq.Rd index 506493df0..7d9a585d3 100644 --- a/man/Expr_neq.Rd +++ b/man/Expr_neq.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_neq} \alias{Expr_neq} -\alias{!=.Expr} +\alias{!=.RPolarsExpr} \title{Check inequality} \usage{ Expr_neq(other) -\method{!=}{Expr}(e1, e2) +\method{!=}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/Expr_not.Rd b/man/Expr_not.Rd index aed0277b1..cc27e3622 100644 --- a/man/Expr_not.Rd +++ b/man/Expr_not.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_not} \alias{Expr_not} -\alias{!.Expr} +\alias{!.RPolarsExpr} \title{Negate a boolean expression} \usage{ Expr_not -\method{!}{Expr}(x) +\method{!}{RPolarsExpr}(x) } \arguments{ \item{x}{Expr} diff --git a/man/Expr_print.Rd b/man/Expr_print.Rd index cc26f24f4..1404ade58 100644 --- a/man/Expr_print.Rd +++ b/man/Expr_print.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/expr__expr.R -\name{print.Expr} -\alias{print.Expr} +\name{print.RPolarsExpr} +\alias{print.RPolarsExpr} \alias{Expr_print} \title{S3 method to print an Expr} \usage{ -\method{print}{Expr}(x, ...) +\method{print}{RPolarsExpr}(x, ...) Expr_print() } diff --git a/man/Expr_sub.Rd b/man/Expr_sub.Rd index e6fb1c9ae..2ce082db0 100644 --- a/man/Expr_sub.Rd +++ b/man/Expr_sub.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/expr__expr.R \name{Expr_sub} \alias{Expr_sub} -\alias{-.Expr} +\alias{-.RPolarsExpr} \title{Substract two expressions} \usage{ Expr_sub(other) -\method{-}{Expr}(e1, e2) +\method{-}{RPolarsExpr}(e1, e2) } \arguments{ \item{other}{Literal or object that can be converted to a literal} diff --git a/man/as.list.Expr.Rd b/man/as.list.RPolarsExpr.Rd similarity index 76% rename from man/as.list.Expr.Rd rename to man/as.list.RPolarsExpr.Rd index d415e2818..5ed9c793e 100644 --- a/man/as.list.Expr.Rd +++ b/man/as.list.RPolarsExpr.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/expr__expr.R -\name{as.list.Expr} -\alias{as.list.Expr} +\name{as.list.RPolarsExpr} +\alias{as.list.RPolarsExpr} \title{S3 method to convert an Expr to a list} \usage{ -\method{as.list}{Expr}(x, ...) +\method{as.list}{RPolarsExpr}(x, ...) } \arguments{ \item{x}{Expr} diff --git a/man/dot-DollarNames.Expr.Rd b/man/dot-DollarNames.RPolarsExpr.Rd similarity index 78% rename from man/dot-DollarNames.Expr.Rd rename to man/dot-DollarNames.RPolarsExpr.Rd index 504fd5ea0..de89dd5b0 100644 --- a/man/dot-DollarNames.Expr.Rd +++ b/man/dot-DollarNames.RPolarsExpr.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/expr__expr.R -\name{.DollarNames.Expr} -\alias{.DollarNames.Expr} +\name{.DollarNames.RPolarsExpr} +\alias{.DollarNames.RPolarsExpr} \title{Auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{Expr}(x, pattern = "") +\method{.DollarNames}{RPolarsExpr}(x, pattern = "") } \arguments{ \item{x}{Name of an \code{Expr} object} diff --git a/src/rust/src/construct_expr.rs b/src/rust/src/construct_expr.rs index 8a5c6694f..6460d3efa 100644 --- a/src/rust/src/construct_expr.rs +++ b/src/rust/src/construct_expr.rs @@ -4,7 +4,7 @@ use crate::rpolarserr::*; use extendr_api::prelude::*; #[extendr] -pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { +pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { if robj_to!(bool, str_to_lit)? { robj_to!(Expr, robj) } else { @@ -13,7 +13,7 @@ pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { } #[extendr] -pub fn robj_to_col(name: Robj) -> RResult { +pub fn robj_to_col(name: Robj) -> RResult { let vs: Vec = robj_to!(Vec, String, name)?; Ok(Expr::cols(vs)) } diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index 61f1df3d8..0f8382816 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -3,6 +3,7 @@ use crate::concurrent::{ }; use crate::conversion::strings_to_smartstrings; +use crate::lazy::dsl::RPolarsExpr; use crate::lazy::dsl::*; use crate::rdataframe::RPolarsDataFrame as RDF; @@ -297,7 +298,7 @@ impl RPolarsLazyFrame { Ok(RPolarsLazyFrame(self.0.clone().tail(robj_to!(u32, n)?))) } - fn filter(&self, expr: &Expr) -> RPolarsLazyFrame { + fn filter(&self, expr: &RPolarsExpr) -> RPolarsLazyFrame { let new_df = self.clone().0.filter(expr.0.clone()); RPolarsLazyFrame(new_df) } diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index 0c34ed465..0979d799f 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -30,35 +30,35 @@ use crate::utils::r_expr_to_rust_expr; use crate::utils::unpack_r_eval; #[derive(Clone, Debug)] -pub struct Expr(pub pl::Expr); +pub struct RPolarsExpr(pub pl::Expr); -impl Deref for Expr { +impl Deref for RPolarsExpr { type Target = pl::Expr; fn deref(&self) -> &pl::Expr { &self.0 } } -impl DerefMut for Expr { +impl DerefMut for RPolarsExpr { fn deref_mut(&mut self) -> &mut pl::Expr { &mut self.0 } } -impl From for pl::Expr { - fn from(x: Expr) -> Self { +impl From for pl::Expr { + fn from(x: RPolarsExpr) -> Self { x.0 } } -impl From for Expr { +impl From for RPolarsExpr { fn from(expr: pl::Expr) -> Self { - Expr(expr) + RPolarsExpr(expr) } } #[extendr] -impl Expr { +impl RPolarsExpr { //constructors pub fn col(name: &str) -> Self { dsl::col(name).into() @@ -74,7 +74,7 @@ impl Expr { dsl::cols(names).into() } - pub fn lit(robj: Robj) -> RResult { + pub fn lit(robj: Robj) -> RResult { let rtype = robj.rtype(); let rlen = robj.len(); @@ -150,7 +150,7 @@ impl Expr { } _ if robj.inherits("Expr") => { - let expr: Expr = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + let expr: RPolarsExpr = unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(expr.0) } @@ -170,7 +170,7 @@ impl Expr { (_, _) => rerr().bad_robj(&robj).plain("unsupported R type "), } - .map(Expr) + .map(RPolarsExpr) .when("constructing polars literal from Robj") } @@ -283,7 +283,7 @@ impl Expr { } //TODO expose searchSorted side options - pub fn search_sorted(&self, element: &Expr) -> Self { + pub fn search_sorted(&self, element: &RPolarsExpr) -> Self { use pl::SearchSortedSide as Side; self.0 .clone() @@ -295,8 +295,8 @@ impl Expr { Ok(self.clone().0.gather(robj_to!(PLExpr, idx)?).into()) } - pub fn sort_by(&self, by: Robj, descending: Robj) -> RResult { - let expr = Expr(self.clone().0.sort_by( + pub fn sort_by(&self, by: Robj, descending: Robj) -> RResult { + let expr = RPolarsExpr(self.clone().0.sort_by( robj_to!(VecPLExprCol, by)?, robj_to!(Vec, bool, descending)?, )); @@ -330,7 +330,7 @@ impl Expr { } pub fn fill_null_with_strategy(&self, strategy: &str, limit: Nullable) -> List { - let res = || -> Result { + let res = || -> Result { let limit = null_to_opt(limit).map(try_f64_into_usize).transpose()?; let limit: pl::FillNullLimit = limit.map(|x| x as u32); @@ -345,12 +345,12 @@ impl Expr { ) .with_fmt("fill_null_with_strategy"); - Ok(Expr(expr)) + Ok(RPolarsExpr(expr)) }(); r_result_list(res) } - pub fn fill_nan(&self, expr: &Expr) -> Self { + pub fn fill_nan(&self, expr: &RPolarsExpr) -> Self { self.0.clone().fill_nan(expr.0.clone()).into() } @@ -421,19 +421,19 @@ impl Expr { .into()) } - pub fn filter(&self, predicate: &Expr) -> Expr { + pub fn filter(&self, predicate: &RPolarsExpr) -> RPolarsExpr { self.clone().0.filter(predicate.0.clone()).into() } - pub fn explode(&self) -> Expr { + pub fn explode(&self) -> RPolarsExpr { self.clone().0.explode().into() } - pub fn flatten(&self) -> Expr { + pub fn flatten(&self) -> RPolarsExpr { //same as explode self.clone().0.explode().into() } - pub fn gather_every(&self, n: Robj) -> RResult { + pub fn gather_every(&self, n: Robj) -> RResult { let n = robj_to!(usize, n).and_then(|n| match n { 0 => rerr().bad_arg("n").bad_val("n can't be zero"), _ => Ok(n), @@ -455,8 +455,8 @@ impl Expr { seed_1: Robj, seed_2: Robj, seed_3: Robj, - ) -> Result { - Ok(Expr(self.0.clone().hash( + ) -> Result { + Ok(RPolarsExpr(self.0.clone().hash( robj_to!(u64, seed)?, robj_to!(u64, seed_1)?, robj_to!(u64, seed_2)?, @@ -464,7 +464,7 @@ impl Expr { ))) } - pub fn reinterpret(&self, signed: bool) -> Expr { + pub fn reinterpret(&self, signed: bool) -> RPolarsExpr { use crate::utils::reinterpret; let function = move |s: pl::Series| reinterpret(&s, signed).map(Some); let dt = if signed { @@ -481,7 +481,7 @@ impl Expr { pub fn interpolate(&self, method: &str) -> List { use crate::rdatatype::new_interpolation_method; let im_result = new_interpolation_method(method) - .map(|im| Expr(self.0.clone().interpolate(im))) + .map(|im| RPolarsExpr(self.0.clone().interpolate(im))) .map_err(|err| format!("in interpolate(): {}", err)); r_result_list(im_result) } @@ -678,7 +678,7 @@ impl Expr { pub fn rolling_skew(&self, window_size_f: f64, bias: bool) -> List { use pl::*; let expr = try_f64_into_usize(window_size_f).map(|ws| { - Expr( + RPolarsExpr( self.0 .clone() .rolling_map_float(ws, move |ca| ca.clone().into_series().skew(bias).unwrap()), @@ -699,7 +699,7 @@ impl Expr { method: rank_method, descending: descending, }; - Expr(self.0.clone().rank(options, Some(0u64))) + RPolarsExpr(self.0.clone().rank(options, Some(0u64))) }) .map_err(|err| format!("rank: {}", err)); @@ -707,8 +707,8 @@ impl Expr { } fn diff(&self, n_float: f64, null_behavior: &str) -> List { - let expr_res = || -> Result { - Ok(Expr(self.0.clone().diff( + let expr_res = || -> Result { + Ok(RPolarsExpr(self.0.clone().diff( try_f64_into_i64(n_float)?, new_null_behavior(null_behavior)?, ))) @@ -718,7 +718,7 @@ impl Expr { } fn pct_change(&self, n_float: Robj) -> RResult { - Ok(Expr(self.0.clone().pct_change(robj_to!(PLExpr, n_float)?))) + Ok(RPolarsExpr(self.0.clone().pct_change(robj_to!(PLExpr, n_float)?))) } fn skew(&self, bias: bool) -> Self { @@ -733,17 +733,17 @@ impl Expr { pub fn clip(&self, min: Robj, max: Robj) -> RResult { let av_min = robj_to!(PLExpr, min)?; let av_max = robj_to!(PLExpr, max)?; - Ok(Expr(self.0.clone().clip(av_min, av_max))) + Ok(RPolarsExpr(self.0.clone().clip(av_min, av_max))) } pub fn clip_min(&self, min: Robj) -> RResult { let av_min = robj_to!(PLExpr, min)?; - Ok(Expr(self.0.clone().clip_min(av_min))) + Ok(RPolarsExpr(self.0.clone().clip_min(av_min))) } pub fn clip_max(&self, max: Robj) -> RResult { let av_max = robj_to!(PLExpr, max)?; - Ok(Expr(self.0.clone().clip_max(av_max))) + Ok(RPolarsExpr(self.0.clone().clip_max(av_max))) } pub fn lower_bound(&self) -> Self { @@ -812,7 +812,7 @@ impl Expr { .map(|x| try_f64_into_i64(*x).map_err(String::from)) .collect(); let expr_result = dims_result - .map(|dims| Expr(self.0.clone().reshape(&dims[..]))) + .map(|dims| RPolarsExpr(self.0.clone().reshape(&dims[..]))) .map_err(|err| format!("reshape: {}", err)); r_result_list(expr_result) } @@ -860,7 +860,7 @@ impl Expr { } pub fn ewm_mean(&self, alpha: f64, adjust: bool, min_periods: f64, ignore_nulls: bool) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -882,7 +882,7 @@ impl Expr { min_periods: f64, ignore_nulls: bool, ) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -904,7 +904,7 @@ impl Expr { min_periods: f64, ignore_nulls: bool, ) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -918,15 +918,15 @@ impl Expr { r_result_list(expr_result) } - pub fn extend_constant(&self, value: &Expr, n: f64) -> List { - let expr_res = || -> Result { + pub fn extend_constant(&self, value: &RPolarsExpr, n: f64) -> List { + let expr_res = || -> Result { let av = match value.clone().0 { pl::Expr::Literal(ma) => literal_to_any_value(ma), ma => Err(format!("value [{:?}] was not a literal:", ma)), }?; let n = try_f64_into_usize(n)?; - Ok(Expr( + Ok(RPolarsExpr( self.0 .clone() .apply( @@ -949,7 +949,7 @@ impl Expr { pub fn rep(&self, n: f64, rechunk: bool) -> List { match try_f64_into_usize(n) { Err(err) => r_error_list(format!("rep: arg n invalid, {}", err)), - Ok(n) => r_ok_list(Expr( + Ok(n) => r_ok_list(RPolarsExpr( self.0 .clone() .apply( @@ -979,10 +979,10 @@ impl Expr { self.0.clone().entropy(base, normalize).into() } - fn cumulative_eval(&self, expr: &Expr, min_periods: f64, parallel: bool) -> List { + fn cumulative_eval(&self, expr: &RPolarsExpr, min_periods: f64, parallel: bool) -> List { use pl::*; r_result_list(try_f64_into_usize(min_periods).map(|min_p| { - Expr( + RPolarsExpr( self.0 .clone() .cumulative_eval(expr.0.clone(), min_p, parallel), @@ -1012,7 +1012,7 @@ impl Expr { self.0.clone().list().len().into() } - pub fn list_contains(&self, other: &Expr) -> Expr { + pub fn list_contains(&self, other: &RPolarsExpr) -> RPolarsExpr { self.0.clone().list().contains(other.0.clone()).into() } @@ -1071,7 +1071,7 @@ impl Expr { .into()) } - fn list_get(&self, index: &Expr) -> Self { + fn list_get(&self, index: &RPolarsExpr) -> Self { self.0.clone().list().get(index.clone().0).into() } @@ -1093,8 +1093,8 @@ impl Expr { } fn list_diff(&self, n: f64, null_behavior: &str) -> List { - let expr_res = || -> Result { - Ok(Expr(self.0.clone().list().diff( + let expr_res = || -> Result { + Ok(RPolarsExpr(self.0.clone().list().diff( try_f64_into_i64(n)?, new_null_behavior(null_behavior)?, ))) @@ -1104,8 +1104,8 @@ impl Expr { } fn list_shift(&self, periods: Robj) -> List { - let expr_res = || -> Result { - Ok(Expr( + let expr_res = || -> Result { + Ok(RPolarsExpr( self.0.clone().list().shift(robj_to!(PLExpr, periods)?), )) }() @@ -1113,7 +1113,7 @@ impl Expr { r_result_list(expr_res) } - fn list_slice(&self, offset: &Expr, length: Nullable<&Expr>) -> Self { + fn list_slice(&self, offset: &RPolarsExpr, length: Nullable<&RPolarsExpr>) -> Self { let length = match null_to_opt(length) { Some(i) => i.0.clone(), None => dsl::lit(i64::MAX), @@ -1121,7 +1121,7 @@ impl Expr { self.0.clone().list().slice(offset.0.clone(), length).into() } - fn list_eval(&self, expr: &Expr, parallel: bool) -> Self { + fn list_eval(&self, expr: &RPolarsExpr, parallel: bool) -> Self { use pl::*; self.0.clone().list().eval(expr.0.clone(), parallel).into() } @@ -1156,10 +1156,10 @@ impl Expr { }; //resolve usize from f64 and stategy from str - let res = || -> Result { + let res = || -> Result { let ub = try_f64_into_usize(upper_bound)?; let strat = new_width_strategy(width_strat)?; - Ok(Expr(self.0.clone().list().to_struct(strat, name_gen, ub))) + Ok(RPolarsExpr(self.0.clone().list().to_struct(strat, name_gen, ub))) }(); let res = res.map_err(|err| format!("in to_struct: {}", err)); @@ -1288,7 +1288,7 @@ impl Expr { Ok(self.0.clone().dt().time().into()) } - pub fn dt_combine(&self, time: Robj, tu: Robj) -> RResult { + pub fn dt_combine(&self, time: Robj, tu: Robj) -> RResult { Ok(self .0 .clone() @@ -1349,7 +1349,7 @@ impl Expr { pub fn timestamp(&self, tu: Robj) -> List { let res = robj_to_timeunit(tu) - .map(|tu| Expr(self.0.clone().dt().timestamp(tu))) + .map(|tu| RPolarsExpr(self.0.clone().dt().timestamp(tu))) .map_err(|err| format!("valid tu needed for timestamp: {}", err)); r_result_list(res) } @@ -1367,14 +1367,14 @@ impl Expr { .into() } - pub fn dt_with_time_unit(&self, tu: Robj) -> RResult { - Ok(Expr( + pub fn dt_with_time_unit(&self, tu: Robj) -> RResult { + Ok(RPolarsExpr( self.0.clone().dt().with_time_unit(robj_to!(timeunit, tu)?), )) } - pub fn dt_cast_time_unit(&self, tu: Robj) -> RResult { - Ok(Expr( + pub fn dt_cast_time_unit(&self, tu: Robj) -> RResult { + Ok(RPolarsExpr( self.0.clone().dt().cast_time_unit(robj_to!(timeunit, tu)?), )) } @@ -1384,7 +1384,7 @@ impl Expr { } pub fn dt_replace_time_zone(&self, tz: Nullable, ambiguous: Robj) -> RResult { - Ok(Expr( + Ok(RPolarsExpr( self.0 .clone() .dt() @@ -1468,7 +1468,7 @@ impl Expr { Ok(self.clone().0.dt().offset_by(robj_to!(PLExpr, by)?).into()) } - pub fn repeat_by(&self, by: &Expr) -> Self { + pub fn repeat_by(&self, by: &RPolarsExpr) -> Self { self.clone().0.repeat_by(by.0.clone()).into() } @@ -1539,11 +1539,11 @@ impl Expr { pub fn round(&self, decimals: f64) -> List { let res = try_f64_into_u32(decimals) .map_err(|err| format!("in round: {}", err)) - .map(|n| Expr(self.0.clone().round(n))); + .map(|n| RPolarsExpr(self.0.clone().round(n))); r_result_list(res) } - pub fn dot(&self, other: &Expr) -> Self { + pub fn dot(&self, other: &RPolarsExpr) -> Self { self.0.clone().dot(other.0.clone()).into() } @@ -1645,7 +1645,7 @@ impl Expr { self.0.clone().count().into() } - pub fn slice(&self, offset: &Expr, length: Nullable<&Expr>) -> Self { + pub fn slice(&self, offset: &RPolarsExpr, length: Nullable<&RPolarsExpr>) -> Self { let length = match null_to_opt(length) { Some(i) => i.0.clone(), None => dsl::lit(i64::MAX), @@ -1653,7 +1653,7 @@ impl Expr { self.0.clone().slice(offset.0.clone(), length).into() } - pub fn append(&self, other: &Expr, upcast: bool) -> Self { + pub fn append(&self, other: &RPolarsExpr, upcast: bool) -> Self { self.0.clone().append(other.0.clone(), upcast).into() } @@ -1730,7 +1730,7 @@ impl Expr { self.clone().0.map(f, output_map) } }) - .map(Expr) + .map(RPolarsExpr) } pub fn map_batches_in_background( @@ -1764,7 +1764,7 @@ impl Expr { self.clone().0.map(rbgfunc, output_map) } }) - .map(Expr) + .map(RPolarsExpr) } pub fn map_elements_in_background( @@ -1969,23 +1969,23 @@ impl Expr { .into()) } - pub fn str_contains(&self, pat: &Expr, literal: Nullable, strict: bool) -> Self { - Expr(match null_to_opt(literal) { + pub fn str_contains(&self, pat: &RPolarsExpr, literal: Nullable, strict: bool) -> Self { + RPolarsExpr(match null_to_opt(literal) { Some(true) => self.0.clone().str().contains_literal(pat.0.clone()), _ => self.0.clone().str().contains(pat.0.clone(), strict), }) } - pub fn str_ends_with(&self, sub: &Expr) -> Self { + pub fn str_ends_with(&self, sub: &RPolarsExpr) -> Self { self.0.clone().str().ends_with(sub.0.clone()).into() } - pub fn str_starts_with(&self, sub: &Expr) -> Self { + pub fn str_starts_with(&self, sub: &RPolarsExpr) -> Self { self.0.clone().str().starts_with(sub.0.clone()).into() } pub fn str_json_path_match(&self, pat: Robj) -> List { - let res = || -> Result { + let res = || -> Result { use pl::*; let pat: String = robj_to!(String, pat, "in str$json_path_match: {}")?; let function = move |s: Series| { @@ -1995,7 +1995,7 @@ impl Expr { Err(e) => Err(pl::PolarsError::ComputeError(format!("{e:?}").into())), } }; - Ok(Expr( + Ok(RPolarsExpr( self.0 .clone() .map(function, pl::GetOutput::from_type(pl::DataType::Utf8)) @@ -2068,7 +2068,7 @@ impl Expr { } pub fn str_extract(&self, pattern: Robj, group_index: Robj) -> List { - let res = || -> Result { + let res = || -> Result { let pat = robj_to!(String, pattern)?; let gi = robj_to!(usize, group_index)?; Ok(self.0.clone().str().extract(pat.as_str(), gi).into()) @@ -2077,7 +2077,7 @@ impl Expr { r_result_list(res) } - pub fn str_extract_all(&self, pattern: &Expr) -> Self { + pub fn str_extract_all(&self, pattern: &RPolarsExpr) -> Self { self.0.clone().str().extract_all(pattern.0.clone()).into() } @@ -2091,7 +2091,7 @@ impl Expr { } //NOTE SHOW CASE all R side argument handling - pub fn str_split(&self, by: Robj, inclusive: Robj) -> Result { + pub fn str_split(&self, by: Robj, inclusive: Robj) -> Result { let by = robj_to!(PLExpr, by)?; let inclusive = robj_to!(bool, inclusive)?; if inclusive { @@ -2103,7 +2103,7 @@ impl Expr { //NOTE SHOW CASE all rust side argument handling, n is usize and had to be //handled on rust side anyways - pub fn str_split_exact(&self, by: Robj, n: Robj, inclusive: Robj) -> Result { + pub fn str_split_exact(&self, by: Robj, n: Robj, inclusive: Robj) -> Result { let by = robj_to!(PLExpr, by)?; let n = robj_to!(usize, n)?; let inclusive = robj_to!(bool, inclusive)?; @@ -2115,7 +2115,7 @@ impl Expr { .into()) } - pub fn str_splitn(&self, by: Robj, n: Robj) -> Result { + pub fn str_splitn(&self, by: Robj, n: Robj) -> Result { Ok(self .0 .clone() @@ -2124,7 +2124,7 @@ impl Expr { .into()) } - pub fn str_replace(&self, pattern: Robj, value: Robj, literal: Robj) -> Result { + pub fn str_replace(&self, pattern: Robj, value: Robj, literal: Robj) -> Result { Ok(self .0 .clone() @@ -2142,7 +2142,7 @@ impl Expr { pattern: Robj, value: Robj, literal: Robj, - ) -> Result { + ) -> Result { Ok(self .0 .clone() @@ -2155,14 +2155,14 @@ impl Expr { .into()) } - pub fn str_slice(&self, offset: Robj, length: Robj) -> Result { + pub fn str_slice(&self, offset: Robj, length: Robj) -> Result { let offset = robj_to!(i64, offset)?; let length = robj_to!(Option, u64, length)?; Ok(self.clone().0.str().slice(offset, length).into()) } - pub fn str_explode(&self) -> Result { + pub fn str_explode(&self) -> Result { Ok(self.0.clone().str().explode().into()) } @@ -2255,7 +2255,7 @@ impl Expr { .into() } - pub fn struct_field_by_name(&self, name: Robj) -> Result { + pub fn struct_field_by_name(&self, name: Robj) -> Result { Ok(self .0 .clone() @@ -2268,7 +2268,7 @@ impl Expr { // self.0.clone().struct_().field_by_index(index).into() // } - pub fn struct_rename_fields(&self, names: Robj) -> Result { + pub fn struct_rename_fields(&self, names: Robj) -> Result { let string_vec: Vec = robj_to!(Vec, String, names)?; Ok(self.0.clone().struct_().rename_fields(string_vec).into()) } @@ -2277,7 +2277,7 @@ impl Expr { //multiple export impl. fn meta_pop(&self) -> List { let exprs: Vec = self.0.clone().meta().pop(); - List::from_values(exprs.iter().map(|e| Expr(e.clone()))) + List::from_values(exprs.iter().map(|e| RPolarsExpr(e.clone()))) } fn meta_eq(&self, other: Robj) -> Result { @@ -2306,7 +2306,7 @@ impl Expr { Ok(name.to_string()) } - fn meta_undo_aliases(&self) -> Expr { + fn meta_undo_aliases(&self) -> RPolarsExpr { self.0.clone().meta().undo_aliases().into() } @@ -2328,33 +2328,33 @@ impl Expr { Ok(format!("{e}")) } - fn cat_set_ordering(&self, ordering: Robj) -> Result { + fn cat_set_ordering(&self, ordering: Robj) -> Result { let ordering = robj_to!(Map, str, ordering, |s| { Ok(crate::rdatatype::new_categorical_ordering(s).map_err(Rctx::Plain)?) })?; Ok(self.0.clone().cat().set_ordering(ordering).into()) } - fn cat_get_categories(&self) -> Expr { + fn cat_get_categories(&self) -> RPolarsExpr { self.0.clone().cat().get_categories().into() } // external expression function which typically starts a new expression chain // to avoid name space collisions in R, these static methods are not free functions // as in py-polars. prefix with new_ to not collide with other methods in class - pub fn new_count() -> Expr { + pub fn new_count() -> RPolarsExpr { dsl::count().into() } - pub fn new_first() -> Expr { + pub fn new_first() -> RPolarsExpr { dsl::first().into() } - pub fn new_last() -> Expr { + pub fn new_last() -> RPolarsExpr { dsl::last().into() } - pub fn cov(a: Robj, b: Robj, ddof: Robj) -> RResult { + pub fn cov(a: Robj, b: Robj, ddof: Robj) -> RResult { Ok(pl::cov( robj_to!(PLExprCol, a)?, robj_to!(PLExprCol, b)?, @@ -2438,7 +2438,7 @@ impl Expr { // could not get cfg feature flags conditions to work inside extendr macro // Therefore place it outside here instead #[allow(unused)] -fn f_str_to_titlecase(expr: &Expr) -> RResult { +fn f_str_to_titlecase(expr: &RPolarsExpr) -> RResult { #[cfg(feature = "full_features")] return (Ok(expr.0.clone().str().to_titlecase().into())); @@ -2453,7 +2453,7 @@ fn f_str_to_titlecase(expr: &Expr) -> RResult { //string expression will transformed into an actual expression in different contexts such as select #[derive(Clone, Debug)] pub enum ProtoRexpr { - Expr(Expr), + RPolarsExpr(RPolarsExpr), String(String), } @@ -2463,15 +2463,15 @@ impl ProtoRexpr { ProtoRexpr::String(s.to_owned()) } - pub fn new_expr(r: &Expr) -> Self { - ProtoRexpr::Expr(r.clone()) + pub fn new_expr(r: &RPolarsExpr) -> Self { + ProtoRexpr::RPolarsExpr(r.clone()) } - pub fn to_rexpr(&self, context: &str) -> Expr { + pub fn to_rexpr(&self, context: &str) -> RPolarsExpr { match self { - ProtoRexpr::Expr(r) => r.clone(), + ProtoRexpr::RPolarsExpr(r) => r.clone(), ProtoRexpr::String(s) => match context { - "select" => Expr::col(s), + "select" => RPolarsExpr::col(s), _ => panic!("unknown context"), }, } @@ -2501,7 +2501,7 @@ impl ProtoExprArray { self.0.push(ProtoRexpr::new_str(s)); } - pub fn push_back_rexpr(&mut self, r: &Expr) { + pub fn push_back_rexpr(&mut self, r: &RPolarsExpr) { self.0.push(ProtoRexpr::new_expr(r)); } @@ -2558,13 +2558,13 @@ pub fn make_rolling_options( // #[extendr] // impl WhenThenThen { -// pub fn when(&self, predicate: &Expr) -> WhenThenThen { +// pub fn when(&self, predicate: &RPolarsExpr) -> WhenThenThen { // Self(self.0.clone().when(predicate.0.clone())) // } -// pub fn then(&self, expr: &Expr) -> WhenThenThen { +// pub fn then(&self, expr: &RPolarsExpr) -> WhenThenThen { // Self(self.0.clone().then(expr.0.clone())) // } -// pub fn otherwise(&self, expr: &Expr) -> Expr { +// pub fn otherwise(&self, expr: &RPolarsExpr) -> RPolarsExpr { // self.0.clone().otherwise(expr.0.clone()).into() // } @@ -2578,14 +2578,14 @@ pub fn make_rolling_options( // #[extendr] // impl Then { -// pub fn when(&self, predicate: &Expr) -> WhenThenThen { +// pub fn when(&self, predicate: &RPolarsExpr) -> WhenThenThen { // let e = dsl::when(self.predicate.0.clone()) // .then(self.then.0.clone()) // .when(predicate.0.clone()); // WhenThenThen(e) // } -// pub fn otherwise(&self, expr: &Expr) -> Expr { +// pub fn otherwise(&self, expr: &RPolarsExpr) -> RPolarsExpr { // dsl::ternary_expr( // self.predicate.0.clone(), // self.then.0.clone(), @@ -2602,13 +2602,13 @@ pub fn make_rolling_options( // #[extendr] // impl When { // #[allow(clippy::self_named_constructors)] -// pub fn when(predicate: &Expr) -> When { +// pub fn when(predicate: &RPolarsExpr) -> When { // When { // predicate: predicate.clone(), // } // } -// pub fn then(&self, expr: &Expr) -> WhenThen { +// pub fn then(&self, expr: &RPolarsExpr) -> WhenThen { // WhenThen { // predicate: self.predicate.clone(), // then: expr.clone(), @@ -2621,7 +2621,7 @@ pub fn make_rolling_options( // } #[extendr] -pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { +pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { if robj_to!(bool, str_to_lit)? { robj_to!(Expr, robj) } else { @@ -2630,10 +2630,10 @@ pub fn internal_wrap_e(robj: Robj, str_to_lit: Robj) -> RResult { } #[extendr] -pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { +pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { //let last_type_str = None; - || -> RResult { + || -> RResult { use crate::utils::unpack_r_eval; let name = if name.inherits("Series") { unpack_r_eval(R!("polars:::result({{name}}$to_vector())"))? @@ -2643,7 +2643,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { match () { _ if name.is_string() && name.len() == 1 && dotdotdot.len() == 0 => { - Ok(Expr::col(name.as_str().unwrap_or(&""))) + Ok(RPolarsExpr::col(name.as_str().unwrap_or(&""))) } _ if name.inherits("RPolarsDataType") //or if name is a list and first element is RPolarsDataType @@ -2656,7 +2656,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { let mut name = robj_to!(Vec, PLPolarsDataType, name)?; let mut ddd = robj_to!(Vec, PLPolarsDataType, dotdotdot)?; name.append(&mut ddd); - Ok(Expr(dsl::dtype_cols(name))) + Ok(RPolarsExpr(dsl::dtype_cols(name))) } _ => { @@ -2664,7 +2664,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { let mut ddd = robj_to!(Vec, String, dotdotdot)?; name.append(&mut ddd); - Ok(Expr::cols(name)) + Ok(RPolarsExpr::cols(name)) } } }() @@ -2685,7 +2685,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { #[extendr] extendr_module! { mod dsl; - impl Expr; + impl RPolarsExpr; impl ProtoExprArray; fn internal_wrap_e; fn robj_to_col; diff --git a/src/rust/src/lazy/whenthen.rs b/src/rust/src/lazy/whenthen.rs index e303dcbc2..7110a8617 100644 --- a/src/rust/src/lazy/whenthen.rs +++ b/src/rust/src/lazy/whenthen.rs @@ -1,4 +1,4 @@ -use super::dsl::Expr; +use crate::lazy::dsl::RPolarsExpr; use crate::robj_to; use crate::rpolarserr::RResult; use extendr_api::prelude::*; @@ -47,7 +47,7 @@ impl Then { }) } - fn otherwise(&self, statement: Robj) -> RResult { + fn otherwise(&self, statement: Robj) -> RResult { Ok(self .inner .clone() @@ -73,7 +73,7 @@ impl ChainedThen { }) } - fn otherwise(&self, statement: Robj) -> RResult { + fn otherwise(&self, statement: Robj) -> RResult { Ok(self .inner .clone() diff --git a/src/rust/src/rlib.rs b/src/rust/src/rlib.rs index d4d50b8a5..29f8f041c 100644 --- a/src/rust/src/rlib.rs +++ b/src/rust/src/rlib.rs @@ -1,5 +1,4 @@ -use crate::lazy::dsl::Expr; -use crate::lazy::dsl::ProtoExprArray; +use crate::lazy::dsl::{RPolarsExpr, ProtoExprArray}; use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::{rdbg, RResult}; @@ -13,7 +12,7 @@ use polars::prelude as pl; use std::result::Result; #[extendr] -fn min_horizontal(dotdotdot: Robj) -> RResult { +fn min_horizontal(dotdotdot: Robj) -> RResult { Ok( polars::lazy::dsl::min_horizontal(robj_to!(VecPLExprCol, dotdotdot)?) .map_err(polars_to_rpolars_err)? @@ -22,7 +21,7 @@ fn min_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn max_horizontal(dotdotdot: Robj) -> RResult { +fn max_horizontal(dotdotdot: Robj) -> RResult { Ok( polars::lazy::dsl::max_horizontal(robj_to!(VecPLExprCol, dotdotdot)?) .map_err(polars_to_rpolars_err)? @@ -31,7 +30,7 @@ fn max_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn sum_horizontal(dotdotdot: Robj) -> RResult { +fn sum_horizontal(dotdotdot: Robj) -> RResult { Ok( polars::lazy::dsl::sum_horizontal(robj_to!(VecPLExprCol, dotdotdot)?) .map_err(polars_to_rpolars_err)? @@ -40,7 +39,7 @@ fn sum_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn all_horizontal(dotdotdot: Robj) -> RResult { +fn all_horizontal(dotdotdot: Robj) -> RResult { Ok( polars::lazy::dsl::all_horizontal(robj_to!(VecPLExprCol, dotdotdot)?) .map_err(polars_to_rpolars_err)? @@ -49,7 +48,7 @@ fn all_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn any_horizontal(dotdotdot: Robj) -> RResult { +fn any_horizontal(dotdotdot: Robj) -> RResult { Ok( polars::lazy::dsl::any_horizontal(robj_to!(VecPLExprCol, dotdotdot)?) .map_err(polars_to_rpolars_err)? @@ -58,19 +57,19 @@ fn any_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn coalesce_exprs(exprs: &ProtoExprArray) -> Expr { +fn coalesce_exprs(exprs: &ProtoExprArray) -> RPolarsExpr { let exprs: Vec = exprs.to_vec("select"); pl::coalesce(exprs.as_slice()).into() } #[extendr] -fn concat_list(exprs: &ProtoExprArray) -> Result { +fn concat_list(exprs: &ProtoExprArray) -> Result { let exprs = exprs.to_vec("select"); - Ok(Expr(pl::concat_list(exprs).map_err(|err| err.to_string())?)) + Ok(RPolarsExpr(pl::concat_list(exprs).map_err(|err| err.to_string())?)) } #[extendr] -fn concat_str(dotdotdot: Robj, separator: Robj) -> RResult { +fn concat_str(dotdotdot: Robj, separator: Robj) -> RResult { Ok(pl::concat_str( robj_to!(VecPLExprCol, dotdotdot)?, robj_to!(str, separator)?, @@ -87,7 +86,7 @@ fn r_date_range_lazy( time_unit: Robj, time_zone: Robj, explode: Robj, -) -> RResult { +) -> RResult { let expr = polars::lazy::prelude::date_range( robj_to!(PLExprCol, start)?, robj_to!(PLExprCol, end)?, @@ -97,16 +96,16 @@ fn r_date_range_lazy( robj_to!(Option, String, time_zone)?, ); if robj_to!(bool, explode)? { - Ok(Expr(expr.explode())) + Ok(RPolarsExpr(expr.explode())) } else { - Ok(Expr(expr)) + Ok(RPolarsExpr(expr)) } } //TODO py-polars have some fancy transmute conversions TOExprs trait, maybe imple that too //for now just use inner directly #[extendr] -fn as_struct(exprs: Robj) -> Result { +fn as_struct(exprs: Robj) -> Result { Ok(pl::as_struct(crate::utils::list_expr_to_vec_pl_expr(exprs, true, true)?).into()) } @@ -239,7 +238,7 @@ fn test_print_string(s: String) { } #[extendr] -fn test_robj_to_expr(robj: Robj) -> RResult { +fn test_robj_to_expr(robj: Robj) -> RResult { robj_to!(Expr, robj) } @@ -265,7 +264,7 @@ fn polars_features() -> List { } #[extendr] -fn fold(acc: Robj, lambda: Robj, exprs: Robj) -> RResult { +fn fold(acc: Robj, lambda: Robj, exprs: Robj) -> RResult { let par_fn = ParRObj(lambda); let f = move |acc: pl::Series, x: pl::Series| { let thread_com = ThreadCom::try_from_global(&CONFIG) @@ -278,7 +277,7 @@ fn fold(acc: Robj, lambda: Robj, exprs: Robj) -> RResult { } #[extendr] -fn reduce(lambda: Robj, exprs: Robj) -> RResult { +fn reduce(lambda: Robj, exprs: Robj) -> RResult { let par_fn = ParRObj(lambda); let f = move |acc: pl::Series, x: pl::Series| { let thread_com = ThreadCom::try_from_global(&CONFIG) diff --git a/src/rust/src/series.rs b/src/rust/src/series.rs index 94c0cbc9c..40d785e87 100644 --- a/src/rust/src/series.rs +++ b/src/rust/src/series.rs @@ -8,7 +8,7 @@ use crate::apply_output; use crate::conversion_r_to_s::robjname2series; use crate::conversion_s_to_r::pl_series_to_list; use crate::handle_type; -use crate::lazy::dsl::Expr; +use crate::lazy::dsl::RPolarsExpr; use crate::make_r_na_fun; use crate::rdataframe::RPolarsDataFrame; use crate::rdatatype::RPolarsDataType; @@ -38,8 +38,8 @@ impl From for Series { } } -impl From<&Expr> for pl::PolarsResult { - fn from(expr: &Expr) -> Self { +impl From<&RPolarsExpr> for pl::PolarsResult { + fn from(expr: &RPolarsExpr) -> Self { RPolarsDataFrame::default() .lazy() .0 diff --git a/src/rust/src/utils/mod.rs b/src/rust/src/utils/mod.rs index b9e5ad9e6..f8531329e 100644 --- a/src/rust/src/utils/mod.rs +++ b/src/rust/src/utils/mod.rs @@ -4,7 +4,7 @@ pub mod extendr_helpers; pub mod wrappers; use crate::conversion_r_to_s::robjname2series; -use crate::lazy::dsl::Expr; +use crate::lazy::dsl::RPolarsExpr; use crate::rdatatype::RPolarsDataType; use crate::rpolarserr::{polars_to_rpolars_err, rdbg, rerr, RPolarsErr, RResult, WithRctx}; use crate::series::Series; @@ -767,7 +767,7 @@ pub fn robj_to_pl_duration_string(robj: extendr_api::Robj) -> RResult { //this function is used to convert and Rside Expr into rust side Expr // wrap_e allows to also convert any allowed non Exp -pub fn robj_to_rexpr(robj: extendr_api::Robj, str_to_lit: bool) -> RResult { +pub fn robj_to_rexpr(robj: extendr_api::Robj, str_to_lit: bool) -> RResult { let robj = unpack_r_result_list(robj)?; let robj_clone = robj.clone(); //reserve shallowcopy for writing err msg @@ -784,11 +784,11 @@ pub fn unpack_r_eval(res: extendr_api::Result) -> RResult { })?) } -pub fn r_expr_to_rust_expr(robj_expr: Robj) -> RResult { - let res: ExtendrResult> = robj_expr.clone().try_into(); - Ok(Expr( +pub fn r_expr_to_rust_expr(robj_expr: Robj) -> RResult { + let res: ExtendrResult> = robj_expr.clone().try_into(); + Ok(RPolarsExpr( res.bad_robj(&robj_expr) - .mistyped(tn::()) + .mistyped(tn::()) .when("converting R extptr PolarsExpr to rust RExpr") .plain("internal error: could not convert R Expr (externalptr) to rust Expr")? .0 @@ -796,13 +796,13 @@ pub fn r_expr_to_rust_expr(robj_expr: Robj) -> RResult { )) } -fn internal_rust_wrap_e(robj: Robj, str_to_lit: bool) -> RResult { +fn internal_rust_wrap_e(robj: Robj, str_to_lit: bool) -> RResult { use extendr_api::*; if !str_to_lit && robj.rtype() == Rtype::Strings { robj_to_col(robj, extendr_api::NULL.into()) } else { - Expr::lit(robj) + RPolarsExpr::lit(robj) } } @@ -878,7 +878,7 @@ where T::IntoIter: ExactSizeIterator, { use extendr_api::prelude::*; - let iter = ite.into_iter().map(Expr); + let iter = ite.into_iter().map(RPolarsExpr); List::from_values(iter) } From 845fcda9faaa3c03ea637ea99183be80cab5c2a4 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:45:24 +0100 Subject: [PATCH 04/32] fix examples and tests [skip ci] --- NAMESPACE | 4 ++-- R/dataframe__frame.R | 8 ++++---- R/expr__expr.R | 4 ++-- R/expr__list.R | 4 ++-- R/functions__eager.R | 8 ++++---- R/functions__lazy.R | 22 +++++++++++----------- R/group_by.R | 4 ++-- R/lazyframe__lazy.R | 2 +- R/pkg-knitr.R | 2 +- R/s3_methods.R | 10 +++++----- R/series__series.R | 2 +- R/utils.R | 2 +- R/zzz.R | 2 +- man/ExprList_get.Rd | 6 +++--- src/rust/src/lazy/dsl.rs | 2 +- tests/testthat/test-as_polars.R | 4 ++-- tests/testthat/test-dataframe.R | 2 +- tests/testthat/test-expr_expr.R | 20 ++++++++++---------- tests/testthat/test-groupby.R | 8 ++++---- tests/testthat/test-lazy_functions.R | 6 +++--- tests/testthat/test-s3_methods.R | 2 +- tests/testthat/test-whenthen.R | 4 ++-- 22 files changed, 64 insertions(+), 64 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 05510950d..bc959c263 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ S3method("$",DataTypeVector) S3method("$",ExprBinNameSpace) S3method("$",ExprCatNameSpace) S3method("$",ExprDTNameSpace) +S3method("$",ExprListNameSpace) S3method("$",ExprMetaNameSpace) S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) @@ -23,7 +24,6 @@ S3method("$",RPolarsDataFrame) S3method("$",RPolarsDataType) S3method("$",RPolarsErr) S3method("$",RPolarsExpr) -S3method("$",RPolarsExprListNameSpace) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsSQLContext) S3method("$",RPolarsStringCacheHolder) @@ -58,8 +58,8 @@ S3method(">",RPolarsExpr) S3method(">",Series) S3method(">=",RPolarsExpr) S3method(">=",Series) +S3method("[",ExprListNameSpace) S3method("[",RPolarsDataFrame) -S3method("[",RPolarsExprListNameSpace) S3method("[",RPolarsLazyFrame) S3method("[",Series) S3method("[",rpolars_raw_list) diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 737361858..19a1b2b43 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -158,7 +158,7 @@ pl$DataFrame = function(..., make_names_unique = TRUE, schema = NULL) { } # pass through if already a DataFrame - if (inherits(largs[[1L]], "DataFrame")) { + if (inherits(largs[[1L]], "RPolarsDataFrame")) { return(largs[[1L]]) } @@ -1306,8 +1306,8 @@ DataFrame_join_asof = function( # convert other to LazyFrame, capture any Error as a result, and pass it on other_df_result = pcase( - inherits(other, "DataFrame"), Ok(other$lazy()), - inherits(other, "LazyFrame"), Ok(other), + inherits(other, "RPolarsDataFrame"), Ok(other$lazy()), + inherits(other, "RPolarsLazyFrame"), Ok(other), or_else = Err(" not a LazyFrame or DataFrame") ) @@ -1412,7 +1412,7 @@ DataFrame_pivot = function( is_string(aggregate_function), result(`$.RPolarsExpr`(pl$element(), aggregate_function)()), # Expr or NULL pass as is - is.null(aggregate_function) || inherits(aggregate_function, "Expr"), Ok(aggregate_function), + is.null(aggregate_function) || inherits(aggregate_function, "RPolarsExpr"), Ok(aggregate_function), # anything else pass err or_else = Err(" is neither a string, NULL or an Expr") diff --git a/R/expr__expr.R b/R/expr__expr.R index 92487fc06..d50c0fc8f 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -935,7 +935,7 @@ Expr_apply = function(f, return_type = NULL, strict_return_type = TRUE, #' # vectors to literal implicitly #' (pl$lit(2) + 1:4) / 4:1 Expr_lit = function(x) { - .Call(wrap__Expr__lit, x) |> + .Call(wrap__RPolarsExpr__lit, x) |> unwrap("in $lit()") } @@ -3168,7 +3168,7 @@ Expr_to_r = function(df = NULL, i = 0) { if (is.null(df)) { pl$select(self)$to_series(i)$to_r() } else { - if (!inherits(df, c("DataFrame"))) { + if (!inherits(df, c("RPolarsDataFrame"))) { stop("Expr_to_r: input is not NULL or a DataFrame/Lazyframe") } df$select(self)$to_series(i)$to_r() diff --git a/R/expr__list.R b/R/expr__list.R index 79eeb2e66..44a5db3f9 100644 --- a/R/expr__list.R +++ b/R/expr__list.R @@ -154,12 +154,12 @@ ExprList_get = function(index) .pr$Expr$list_get(self, wrap_e(index, str_to_lit #' @param x ExprListNameSpace #' @param index value to get #' @details -#' `[.RPolarsExprListNameSpace` used as e.g. `pl$col("a")$arr[0]` same as `pl$col("a")$get(0)` +#' `[.ExprListNameSpace` used as e.g. `pl$col("a")$arr[0]` same as `pl$col("a")$get(0)` #' @examples #' df = pl$DataFrame(list(a = list(3:1, NULL, 1:2))) # NULL or integer() or list() #' df$select(pl$col("a")$list[0]) #' df$select(pl$col("a")$list[c(2, 0, -1)]) -`[.RPolarsExprListNameSpace` = function(x, index) { # S3 sub class-name set in zzz.R +`[.ExprListNameSpace` = function(x, index) { # S3 sub class-name set in zzz.R x$get(index) } diff --git a/R/functions__eager.R b/R/functions__eager.R index 24f91da6d..9ba37f172 100644 --- a/R/functions__eager.R +++ b/R/functions__eager.R @@ -76,13 +76,13 @@ pl$concat = function( unwrap("in pl$concat()") first = l[[1L]] - eager = !inherits(first, "LazyFrame") + eager = !inherits(first, "RPolarsLazyFrame") args_modified = names(as.list(sys.call()[-1L])) # check not using any mixing of types which could lead to implicit collect if (eager) { for (i in seq_along(l)) { - if (inherits(l[[i]], c("LazyFrame", "Expr"))) { + if (inherits(l[[i]], c("RPolarsLazyFrame", "RPolarsExpr"))) { .pr$RPolarsErr$new()$ plain("tip: explicitly collect lazy inputs first, e.g. pl$concat(dataframe, lazyframe$collect())")$ plain("LazyFrame or Expr not allowed if first arg is a DataFrame, to avoid implicit collect")$ @@ -151,11 +151,11 @@ pl$concat = function( and_then(Result_out, \(x) { pcase( # run-time assertion for future changes - inherits(x, "DataFrame") && !eager, Err_plain("internal logical error in pl$concat()"), + inherits(x, "RPolarsDataFrame") && !eager, Err_plain("internal logical error in pl$concat()"), # must collect as in rust side only lazy concat is implemented. Eager inputs are wrapped in # lazy and then collected again. This does not mean any user input is collected. - inherits(x, "LazyFrame") && eager, Ok(x$collect()), + inherits(x, "RPolarsLazyFrame") && eager, Ok(x$collect()), or_else = Ok(x) ) }) |> diff --git a/R/functions__lazy.R b/R/functions__lazy.R index 10dccdddd..00c64d324 100644 --- a/R/functions__lazy.R +++ b/R/functions__lazy.R @@ -244,7 +244,7 @@ pl$head = function(column, n = 10) { #-> Expr | Any: pcase( inherits(column, "Series"), result(column$expr$head(n)), is.character(column), result(pl$col(column)$head(n)), - inherits(column, "Expr"), result(column$head(n)), + inherits(column, "RPolarsExpr"), result(column$head(n)), or_else = Err(paste0( "param [column] type is neither Series, charvec nor Expr, but ", str_string(column) @@ -279,7 +279,7 @@ pl$tail = function(column, n = 10) { #-> Expr | Any: pcase( inherits(column, "Series"), result(column$expr$tail(n)), is.character(column), result(pl$col(column)$tail(n)), - inherits(column, "Expr"), result(column$tail(n)), + inherits(column, "RPolarsExpr"), result(column$tail(n)), or_else = Err(paste0( "param [column] type is neither Series, charvec nor Expr, but ", str_string(column) @@ -325,7 +325,7 @@ pl$mean = function(...) { #-> Expr | Any: Ok(pl$col(unlist(column))$mean()), lc == 1L && inherits(column[[1]], "Series") && column[[1]]$len() == 0, Err("The series is empty, so no mean value can be returned."), - lc == 1L && inherits(column[[1]], c("Series", "LazyFrame", "DataFrame")), + lc == 1L && inherits(column[[1]], c("Series", "RPolarsLazyFrame", "RPolarsDataFrame")), Ok(column[[1]]$mean()), or_else = Ok(pl$col(column[[1]])$mean()) ) |> @@ -370,7 +370,7 @@ pl$median = function(...) { #-> Expr | Any: Ok(pl$col(unlist(column))$median()), lc == 1L && inherits(column[[1]], "Series") && column[[1]]$len() == 0, Err("The series is empty, so no median value can be returned."), - lc == 1L && inherits(column[[1]], c("Series", "LazyFrame", "DataFrame")), + lc == 1L && inherits(column[[1]], c("Series", "RPolarsLazyFrame", "RPolarsDataFrame")), Ok(column[[1]]$median()), or_else = Ok(pl$col(column[[1]])$median()) ) |> @@ -402,7 +402,7 @@ pl$median = function(...) { #-> Expr | Any: #' pl$DataFrame(bob = 1:4)$select(pl$n_unique(pl$col("bob"))) pl$n_unique = function(column) { #-> int or Expr pcase( - inherits(column, c("Series", "Expr")), result(column$n_unique()), + inherits(column, c("Series", "RPolarsExpr")), result(column$n_unique()), is_string(column), result(pl$col(column)$n_unique()), or_else = Err(paste("arg [column] is neither Series, Expr or String, but", str_string(column))) ) |> @@ -442,7 +442,7 @@ pl$n_unique = function(column) { #-> int or Expr #' system.time(pl$n_unique(lit_series)$lit_to_s()$print()) pl$approx_n_unique = function(column) { #-> int or Expr pcase( - inherits(column, "Expr"), result(column$approx_n_unique()), + inherits(column, "RPolarsExpr"), result(column$approx_n_unique()), is_string(column), result(pl$col(column)$approx_n_unique()), or_else = Err(paste("arg [column] is neither Expr or String, but", str_string(column))) ) |> @@ -481,7 +481,7 @@ pl$approx_n_unique = function(column) { #-> int or Expr pl$sum = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "Expr")) { + if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { return(column$sum()) } if (is_string(column)) { @@ -525,7 +525,7 @@ pl$sum = function(..., verbose = TRUE) { pl$min = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "Expr")) { + if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { return(column$min()) } if (is_string(column)) { @@ -573,7 +573,7 @@ pl$min = function(..., verbose = TRUE) { pl$max = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "Expr")) { + if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { return(column$max()) } if (is_string(column)) { @@ -630,7 +630,7 @@ pl$coalesce = function(...) { #' @return Expr or Series matching type of input column #' @name pl_std pl$std = function(column, ddof = 1) { - if (inherits(column, "Series") || inherits(column, "Expr")) { + if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { return(column$std(ddof)) } if (is_string(column)) { @@ -649,7 +649,7 @@ pl$std = function(column, ddof = 1) { #' @return Expr or Series matching type of input column #' @name pl_var pl$var = function(column, ddof = 1) { - if (inherits(column, "Series") || inherits(column, "Expr")) { + if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { return(column$var(ddof)) } if (is_string(column)) { diff --git a/R/group_by.R b/R/group_by.R index c5251a6be..6557caaae 100644 --- a/R/group_by.R +++ b/R/group_by.R @@ -43,7 +43,7 @@ GroupBy = new.env(parent = emptyenv()) #' @return The input as grouped DataFrame #' @noRd construct_group_by = function(df, groupby_input, maintain_order) { - if (!inherits(df, "DataFrame")) stop("internal error: construct_group called not on DataFrame") + if (!inherits(df, "RPolarsDataFrame")) stop("internal error: construct_group called not on DataFrame") df = df$clone() attr(df, "private") = list(groupby_input = groupby_input, maintain_order = maintain_order) class(df) = "GroupBy" @@ -297,7 +297,7 @@ GroupBy_null_count = function() { #' gb$ungroup() GroupBy_ungroup = function() { self = .pr$DataFrame$clone_in_rust(self) - class(self) = "DataFrame" + class(self) = "RPolarsDataFrame" attr(self, "private") = NULL self } diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 147734d01..279efb14c 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -990,7 +990,7 @@ LazyFrame_join = function( force_parallel = FALSE) { uw = \(res) unwrap(res, "in $join():") - if (inherits(other, "DataFrame")) { + if (inherits(other, "RPolarsDataFrame")) { other = other$lazy() } diff --git a/R/pkg-knitr.R b/R/pkg-knitr.R index a2803a0a9..d4945ceed 100644 --- a/R/pkg-knitr.R +++ b/R/pkg-knitr.R @@ -166,7 +166,7 @@ to_html_table = function(x, max_cols = 75, max_rows = 40) { #' @return string vector of column type names #' @noRd .get_dtype_strings = function(df) { - if (inherits(df, "DataFrame")) { + if (inherits(df, "RPolarsDataFrame")) { df$dtype_strings() } else { if (!requireNamespace("pillar", quietly = TRUE)) { diff --git a/R/s3_methods.R b/R/s3_methods.R index e2c01244e..d850c760f 100644 --- a/R/s3_methods.R +++ b/R/s3_methods.R @@ -49,13 +49,13 @@ i = i %||% 0 if (is.atomic(i) && is.vector(i)) { - if (inherits(x, "LazyFrame")) { + if (inherits(x, "RPolarsLazyFrame")) { Err_plain("Row selection using vector is not supported for LazyFrames.") |> uw() } if (is.logical(i)) { # nrow() not available for LazyFrame - if (inherits(x, "DataFrame") && length(i) != nrow(x)) { + if (inherits(x, "RPolarsDataFrame") && length(i) != nrow(x)) { stop(sprintf("`i` must be of length %s.", nrow(x)), call. = FALSE) } idx = i @@ -74,7 +74,7 @@ } } x = x$filter(pl$lit(idx)) - } else if (identical(class(i), "Expr")) { + } else if (identical(class(i), "RPolarsExpr")) { x = x$filter(i) } else { Err_plain("`i` must be an Expr or an atomic vector of class logical or integer.") |> uw() @@ -108,7 +108,7 @@ } } x = do.call(x$select, lapply(cols, pl$col)) - } else if (identical(class(j), "Expr")) { + } else if (identical(class(j), "RPolarsExpr")) { x = x$select(j) } else { Err_plain("`j` must be an Expr or an atomic vector of class logical, character, or integer.") |> uw() @@ -116,7 +116,7 @@ } if (drop && x$width == 1L) { - if (inherits(x, "LazyFrame")) { + if (inherits(x, "RPolarsLazyFrame")) { Err_plain( "Single column conversion to a Series using brackets is not supported for LazyFrames.\n", "Please set `drop = FALSE` to prevent conversion or use $collect() before using brackets." diff --git a/R/series__series.R b/R/series__series.R index e0d1cd63b..d14f65642 100644 --- a/R/series__series.R +++ b/R/series__series.R @@ -951,7 +951,7 @@ Series_expr = method_as_property(function() { x = do.call(f, scall) pcase( - inherits(x, "Expr"), df$select(x)$to_series(0), + inherits(x, "RPolarsExpr"), df$select(x)$to_series(0), or_else = x ) } diff --git a/R/utils.R b/R/utils.R index 04e4871a7..5ed6ef3e2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -188,7 +188,7 @@ move_env_elements = function(from_env, to_env, element_names, remove = TRUE) { #' @return VecDataFrame l_to_vdf = function(l) { if (!length(l)) stop("cannot concat empty list l") - do_inherit_DataFrame = sapply(l, inherits, "DataFrame") + do_inherit_DataFrame = sapply(l, inherits, "RPolarsDataFrame") if (!all(do_inherit_DataFrame)) { stop(paste( "element no(s) of concat param l:", diff --git a/R/zzz.R b/R/zzz.R index 2fc80b19b..d6dd64197 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -28,7 +28,7 @@ replace_private_with_pub_methods(Expr, "^Expr_") # configure subnames spaces of Expr #' @export -`$.RPolarsExprListNameSpace` = sub_name_space_accessor_function +`$.ExprListNameSpace` = sub_name_space_accessor_function expr_list_make_sub_ns = macro_new_subnamespace("^ExprList_", "ExprListNameSpace") #' @export diff --git a/man/ExprList_get.Rd b/man/ExprList_get.Rd index 9a448aabd..8ed433784 100644 --- a/man/ExprList_get.Rd +++ b/man/ExprList_get.Rd @@ -3,13 +3,13 @@ \name{ExprList_get} \alias{ExprList_get} \alias{Expr_list_get} -\alias{[.RPolarsExprListNameSpace} +\alias{[.ExprListNameSpace} \title{Get list} \format{ function } \usage{ -\method{[}{RPolarsExprListNameSpace}(x, index) +\method{[}{ExprListNameSpace}(x, index) } \arguments{ \item{x}{ExprListNameSpace} @@ -23,7 +23,7 @@ Expr Get the value by index in the sublists. } \details{ -\verb{[.RPolarsExprListNameSpace} used as e.g. \code{pl$col("a")$arr[0]} same as \code{pl$col("a")$get(0)} +\verb{[.ExprListNameSpace} used as e.g. \code{pl$col("a")$arr[0]} same as \code{pl$col("a")$get(0)} } \examples{ df = pl$DataFrame(list(a = list(3:1, NULL, 1:2))) # NULL or integer() or list() diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index 0979d799f..aac4befe2 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -149,7 +149,7 @@ impl RPolarsExpr { Ok(pl::lit(s.0)) } - _ if robj.inherits("Expr") => { + _ if robj.inherits("RPolarsExpr") => { let expr: RPolarsExpr = unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(expr.0) } diff --git a/tests/testthat/test-as_polars.R b/tests/testthat/test-as_polars.R index 4f2348c6d..286c59c8c 100644 --- a/tests/testthat/test-as_polars.R +++ b/tests/testthat/test-as_polars.R @@ -21,7 +21,7 @@ patrick::with_parameters_test_that("as_polars_df S3 methods", skip_if_not_installed("arrow") pl_df = as_polars_df(x) - expect_s3_class(pl_df, "DataFrame") + expect_s3_class(pl_df, "RPolarsDataFrame") actual = as.data.frame(pl_df) expected = as.data.frame(pl$DataFrame(test_df)) @@ -35,5 +35,5 @@ patrick::with_parameters_test_that("as_polars_df S3 methods", test_that("as_polars_lf S3 method", { skip_if_not_installed("arrow") at = arrow::as_arrow_table(test_df) - expect_s3_class(as_polars_lf(at), "LazyFrame") + expect_s3_class(as_polars_lf(at), "RPolarsLazyFrame") }) diff --git a/tests/testthat/test-dataframe.R b/tests/testthat/test-dataframe.R index c80f42a6d..ba66b8091 100644 --- a/tests/testthat/test-dataframe.R +++ b/tests/testthat/test-dataframe.R @@ -84,7 +84,7 @@ test_that("DataFrame, input free vectors, input empty", { df1$to_list(), df2$to_list() ) df_e = pl$DataFrame() - expect_s3_class(df_e, "DataFrame") + expect_s3_class(df_e, "RPolarsDataFrame") expect_identical(df_e$shape, c(0, 0)) expect_identical(pl$DataFrame()$to_list(), .pr$DataFrame$default()$to_list()) }) diff --git a/tests/testthat/test-expr_expr.R b/tests/testthat/test-expr_expr.R index 452e06fc4..8b54c406c 100644 --- a/tests/testthat/test-expr_expr.R +++ b/tests/testthat/test-expr_expr.R @@ -1,14 +1,14 @@ test_that("expression boolean operators", { - expect_equal(class(pl$col("foo") == pl$col("bar")), "Expr") - expect_equal(class(pl$col("foo") <= pl$col("bar")), "Expr") - expect_equal(class(pl$col("foo") >= pl$col("bar")), "Expr") - expect_equal(class(pl$col("foo") != pl$col("bar")), "Expr") - - expect_equal(class(pl$col("foo") > pl$lit(5)), "Expr") - expect_equal(class(pl$col("foo") < pl$lit(5)), "Expr") - expect_equal(class(pl$col("foo") > 5), "Expr") - expect_equal(class(pl$col("foo") < 5), "Expr") - expect_equal(class(!pl$col("foobar")), "Expr") + expect_equal(class(pl$col("foo") == pl$col("bar")), "RPolarsExpr") + expect_equal(class(pl$col("foo") <= pl$col("bar")), "RPolarsExpr") + expect_equal(class(pl$col("foo") >= pl$col("bar")), "RPolarsExpr") + expect_equal(class(pl$col("foo") != pl$col("bar")), "RPolarsExpr") + + expect_equal(class(pl$col("foo") > pl$lit(5)), "RPolarsExpr") + expect_equal(class(pl$col("foo") < pl$lit(5)), "RPolarsExpr") + expect_equal(class(pl$col("foo") > 5), "RPolarsExpr") + expect_equal(class(pl$col("foo") < 5), "RPolarsExpr") + expect_equal(class(!pl$col("foobar")), "RPolarsExpr") cmp_operators_df = pl$DataFrame(list())$with_columns( diff --git a/tests/testthat/test-groupby.R b/tests/testthat/test-groupby.R index d2ec71856..b658cf457 100644 --- a/tests/testthat/test-groupby.R +++ b/tests/testthat/test-groupby.R @@ -83,7 +83,7 @@ test_that("shift _and_fill", { test_that("groupby, lazygroupby unpack + charvec same as list of strings", { pl$set_options(maintain_order = TRUE) df = pl$DataFrame(mtcars) - to_l = \(x) (if (inherits(x, "DataFrame")) x else x$collect())$to_list() + to_l = \(x) (if (inherits(x, "RPolarsDataFrame")) x else x$collect())$to_list() for (x in list(df, df$lazy())) { df1 = x$group_by(list("cyl", "gear"))$agg(pl$mean("hp")) # args wrapped in list df2 = x$group_by("cyl", "gear")$agg(pl$mean("hp")) # same as free args @@ -97,7 +97,7 @@ test_that("groupby, lazygroupby unpack + charvec same as list of strings", { test_that("agg, lazygroupby unpack + charvec same as list of strings", { pl$set_options(maintain_order = TRUE) df = pl$DataFrame(mtcars) - to_l = \(x) (if (inherits(x, "DataFrame")) x else x$collect())$to_list() + to_l = \(x) (if (inherits(x, "RPolarsDataFrame")) x else x$collect())$to_list() for (x in list(df, df$lazy())) { df1 = x$group_by("cyl")$agg(pl$col("hp")$mean(), pl$col("gear")$mean()) # args wrapped in list df2 = x$group_by("cyl")$agg(list(pl$col("hp")$mean(), pl$col("gear")$mean())) @@ -115,7 +115,7 @@ test_that("LazyGroupBy ungroup", { # tests $ungroup() only changed the class of output, not input (lgb). lgb_ug = lgb$ungroup() - expect_identical(class(lgb_ug), "LazyFrame") + expect_identical(class(lgb_ug), "RPolarsLazyFrame") expect_identical(class(lgb), "LazyGroupBy") expect_equal( @@ -135,7 +135,7 @@ test_that("GroupBy ungroup", { # tests $ungroup() only changed the class of output, not input (lgb). gb_ug = gb$ungroup() - expect_identical(class(gb_ug), "DataFrame") + expect_identical(class(gb_ug), "RPolarsDataFrame") expect_identical(class(gb), "GroupBy") expect_equal( diff --git a/tests/testthat/test-lazy_functions.R b/tests/testthat/test-lazy_functions.R index d8b09bf23..a23a4aad7 100644 --- a/tests/testthat/test-lazy_functions.R +++ b/tests/testthat/test-lazy_functions.R @@ -6,17 +6,17 @@ test_that("pl$sum", { # from string df = pl$DataFrame(a = 1:5)$select(pl$sum("a")) - expect_true(inherits(df, "DataFrame")) + expect_true(inherits(df, "RPolarsDataFrame")) expect_identical(df$to_list()$a, 15L) # from numeric vector df = pl$DataFrame()$select(pl$sum(1:5)) - expect_true(inherits(df, "DataFrame")) + expect_true(inherits(df, "RPolarsDataFrame")) expect_identical(df$to_list()[[1L]], 15L) # from numeric scalar df = pl$DataFrame()$select(pl$sum(1L)) - expect_true(inherits(df, "DataFrame")) + expect_true(inherits(df, "RPolarsDataFrame")) expect_identical(df$to_list()[[1L]], 1L) diff --git a/tests/testthat/test-s3_methods.R b/tests/testthat/test-s3_methods.R index 95b8c101d..dea91ae70 100644 --- a/tests/testthat/test-s3_methods.R +++ b/tests/testthat/test-s3_methods.R @@ -40,7 +40,7 @@ patrick::with_parameters_test_that("inspection", d = pl$DataFrame(mtcars) x = FUN(mtcars) y = FUN(d) - if (inherits(y, "DataFrame")) y <- y$to_data_frame() + if (inherits(y, "RPolarsDataFrame")) y <- y$to_data_frame() expect_equal(x, y, ignore_attr = TRUE) if (.test_name == "as.matrix") { z = FUN(d$lazy()) diff --git a/tests/testthat/test-whenthen.R b/tests/testthat/test-whenthen.R index bc9fe6aa3..4c72e350d 100644 --- a/tests/testthat/test-whenthen.R +++ b/tests/testthat/test-whenthen.R @@ -27,7 +27,7 @@ test_that("Then-class", { expect_true(inherits(pl$when("a")$then("b"), "Then")) expect_true(inherits(pl$when(TRUE)$then(FALSE), "Then")) expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(NA), "ChainedWhen")) - expect_true(inherits(pl$when(TRUE)$then(FALSE)$otherwise(NA), "Expr")) + expect_true(inherits(pl$when(TRUE)$then(FALSE)$otherwise(NA), "RPolarsExpr")) ctx = result(pl$when("a")$then(complex(2)))$err$contexts() expect_identical( @@ -46,7 +46,7 @@ test_that("Chained", { expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(TRUE), "ChainedWhen")) cw = pl$when("a")$then("b")$when("c") expect_true(inherits(cw$then("a"), "ChainedThen")) - expect_true(inherits(cw$then("d")$otherwise("e"), "Expr")) + expect_true(inherits(cw$then("d")$otherwise("e"), "RPolarsExpr")) }) From c0ce021756b669cf91e775a955d1d12ed7bebb58 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:36:52 +0100 Subject: [PATCH 05/32] Series -> RPolarsSeries --- NAMESPACE | 50 +++++------ R/after-wrappers.R | 2 +- R/as_polars.R | 2 +- R/dataframe__frame.R | 2 +- R/extendr-wrappers.R | 106 ++++++++++++----------- R/functions__eager.R | 4 +- R/functions__lazy.R | 30 +++---- R/rbackground.R | 2 +- R/s3_methods.R | 24 ++--- R/series__series.R | 26 +++--- man/RThreadHandle_RThreadHandle_class.Rd | 2 +- man/S3_as.character.Rd | 6 +- man/S3_as.vector.Rd | 6 +- man/S3_c.Rd | 6 +- man/S3_extract.Rd | 4 +- man/S3_length.Rd | 4 +- man/S3_max.Rd | 4 +- man/S3_mean.Rd | 4 +- man/S3_median.Rd | 4 +- man/S3_min.Rd | 4 +- man/S3_print.Rd | 6 +- man/S3_sum.Rd | 4 +- man/Series_add.Rd | 4 +- man/Series_class.Rd | 4 +- man/Series_compare.Rd | 24 ++--- man/Series_div.Rd | 4 +- man/Series_mul.Rd | 4 +- man/Series_sub.Rd | 4 +- man/as_polars_df.Rd | 4 +- src/rust/src/concat.rs | 4 +- src/rust/src/concurrent.rs | 10 +-- src/rust/src/conversion_r_to_s.rs | 6 +- src/rust/src/lazy/dsl.rs | 12 +-- src/rust/src/rbackground.rs | 6 +- src/rust/src/rdataframe/mod.rs | 16 ++-- src/rust/src/rlib.rs | 4 +- src/rust/src/series.rs | 106 +++++++++++------------ src/rust/src/utils/mod.rs | 8 +- tests/testthat/test-dataframe.R | 2 +- tests/testthat/test-rbackground.R | 8 +- tests/testthat/test-s3_methods.R | 6 +- tests/testthat/test-series.R | 6 +- 42 files changed, 275 insertions(+), 269 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index bc959c263..956d88b7c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,7 +3,7 @@ S3method("!",RPolarsExpr) S3method("!=",RPolarsDataType) S3method("!=",RPolarsExpr) -S3method("!=",Series) +S3method("!=",RPolarsSeries) S3method("$",ChainedThen) S3method("$",ChainedWhen) S3method("$",DataTypeVector) @@ -26,9 +26,9 @@ S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsSQLContext) +S3method("$",RPolarsSeries) S3method("$",RPolarsStringCacheHolder) S3method("$",RThreadHandle) -S3method("$",Series) S3method("$",Then) S3method("$",VecDataFrame) S3method("$",When) @@ -40,28 +40,28 @@ S3method("%%",RPolarsExpr) S3method("%/%",RPolarsExpr) S3method("&",RPolarsExpr) S3method("*",RPolarsExpr) -S3method("*",Series) +S3method("*",RPolarsSeries) S3method("+",RPolarsExpr) -S3method("+",Series) +S3method("+",RPolarsSeries) S3method("-",RPolarsExpr) -S3method("-",Series) +S3method("-",RPolarsSeries) S3method("/",RPolarsExpr) -S3method("/",Series) +S3method("/",RPolarsSeries) S3method("<",RPolarsExpr) -S3method("<",Series) +S3method("<",RPolarsSeries) S3method("<=",RPolarsExpr) -S3method("<=",Series) +S3method("<=",RPolarsSeries) S3method("==",RPolarsDataType) S3method("==",RPolarsExpr) -S3method("==",Series) +S3method("==",RPolarsSeries) S3method(">",RPolarsExpr) -S3method(">",Series) +S3method(">",RPolarsSeries) S3method(">=",RPolarsExpr) -S3method(">=",Series) +S3method(">=",RPolarsSeries) S3method("[",ExprListNameSpace) S3method("[",RPolarsDataFrame) S3method("[",RPolarsLazyFrame) -S3method("[",Series) +S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) S3method("[[",ChainedThen) S3method("[[",ChainedWhen) @@ -77,9 +77,9 @@ S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsSQLContext) +S3method("[[",RPolarsSeries) S3method("[[",RPolarsStringCacheHolder) S3method("[[",RThreadHandle) -S3method("[[",Series) S3method("[[",Then) S3method("[[",VecDataFrame) S3method("[[",When) @@ -94,28 +94,28 @@ S3method(.DollarNames,RPolarsErr) S3method(.DollarNames,RPolarsExpr) S3method(.DollarNames,RPolarsLazyFrame) S3method(.DollarNames,RPolarsSQLContext) +S3method(.DollarNames,RPolarsSeries) S3method(.DollarNames,RThreadHandle) -S3method(.DollarNames,Series) S3method(.DollarNames,Then) S3method(.DollarNames,VecDataFrame) S3method(.DollarNames,When) S3method(.DollarNames,method_environment) S3method(as.character,RPolarsErr) +S3method(as.character,RPolarsSeries) S3method(as.character,RThreadHandle) -S3method(as.character,Series) S3method(as.data.frame,RPolarsDataFrame) S3method(as.data.frame,RPolarsLazyFrame) S3method(as.list,RPolarsExpr) S3method(as.list,rpolars_raw_list) S3method(as.matrix,RPolarsDataFrame) S3method(as.matrix,RPolarsLazyFrame) -S3method(as.vector,Series) +S3method(as.vector,RPolarsSeries) S3method(as_polars_df,ArrowTabular) S3method(as_polars_df,GroupBy) S3method(as_polars_df,LazyGroupBy) S3method(as_polars_df,RPolarsDataFrame) S3method(as_polars_df,RPolarsLazyFrame) -S3method(as_polars_df,Series) +S3method(as_polars_df,RPolarsSeries) S3method(as_polars_df,data.frame) S3method(as_polars_df,default) S3method(as_polars_lf,LazyGroupBy) @@ -124,7 +124,7 @@ S3method(as_polars_lf,default) S3method(as_polars_series,POSIXlt) S3method(as_polars_series,default) S3method(as_polars_series,vctrs_rcrd) -S3method(c,Series) +S3method(c,RPolarsSeries) S3method(dim,RPolarsDataFrame) S3method(dim,RPolarsLazyFrame) S3method(dimnames,RPolarsDataFrame) @@ -133,19 +133,19 @@ S3method(head,RPolarsDataFrame) S3method(head,RPolarsLazyFrame) S3method(length,RPolarsDataFrame) S3method(length,RPolarsLazyFrame) -S3method(length,Series) +S3method(length,RPolarsSeries) S3method(max,RPolarsDataFrame) S3method(max,RPolarsLazyFrame) -S3method(max,Series) +S3method(max,RPolarsSeries) S3method(mean,RPolarsDataFrame) S3method(mean,RPolarsLazyFrame) -S3method(mean,Series) +S3method(mean,RPolarsSeries) S3method(median,RPolarsDataFrame) S3method(median,RPolarsLazyFrame) -S3method(median,Series) +S3method(median,RPolarsSeries) S3method(min,RPolarsDataFrame) S3method(min,RPolarsLazyFrame) -S3method(min,Series) +S3method(min,RPolarsSeries) S3method(na.omit,RPolarsDataFrame) S3method(na.omit,RPolarsLazyFrame) S3method(names,RPolarsDataFrame) @@ -161,15 +161,15 @@ S3method(print,RPolarsDataType) S3method(print,RPolarsErr) S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) +S3method(print,RPolarsSeries) S3method(print,RThreadHandle) -S3method(print,Series) S3method(print,Then) S3method(print,When) S3method(print,polars_info) S3method(row.names,RPolarsDataFrame) S3method(sum,RPolarsDataFrame) S3method(sum,RPolarsLazyFrame) -S3method(sum,Series) +S3method(sum,RPolarsSeries) S3method(tail,RPolarsDataFrame) S3method(tail,RPolarsLazyFrame) S3method(unique,RPolarsDataFrame) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index 2da108edc..d0e546a49 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -267,7 +267,7 @@ DataType = clone_env_one_level_deep(RPolarsDataType) # used for printing public environment pl_class_names = sort( c( - "RPolarsLazyFrame", "Series", "LazyGroupBy", "DataType", "RPolarsExpr", + "RPolarsLazyFrame", "RPolarsSeries", "LazyGroupBy", "DataType", "RPolarsExpr", "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", "RPolarsSQLContext" ) diff --git a/R/as_polars.R b/R/as_polars.R index edcc881aa..860b5929a 100644 --- a/R/as_polars.R +++ b/R/as_polars.R @@ -58,7 +58,7 @@ as_polars_df.GroupBy = function(x, ...) { #' @rdname as_polars_df #' @export -as_polars_df.Series = function(x, ...) { +as_polars_df.RPolarsSeries = function(x, ...) { pl$DataFrame(x) } diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 19a1b2b43..f50b59c9e 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -167,7 +167,7 @@ pl$DataFrame = function(..., make_names_unique = TRUE, schema = NULL) { if (length(keys) == 0) keys <- rep(NA_character_, length(largs)) keys = mapply(largs, keys, FUN = function(column, key) { if (is.na(key) || nchar(key) == 0) { - if (inherits(column, "Series")) { + if (inherits(column, "RPolarsSeries")) { key = column$name } else { key = "new_column" diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 49556fb58..562a2bb3d 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -1149,108 +1149,114 @@ LazyGroupBy$tail <- function(n) .Call(wrap__LazyGroupBy__tail, self, n) Series <- new.env(parent = emptyenv()) -Series$new <- function(x, name) .Call(wrap__Series__new, x, name) +Series$new <- function(x, name) .Call(wrap__RPolarsSeries__new, x, name) -Series$clone <- function() .Call(wrap__Series__clone, self) +Series$clone <- function() .Call(wrap__RPolarsSeries__clone, self) -Series$sleep <- function(millis) .Call(wrap__Series__sleep, self, millis) +Series$sleep <- function(millis) .Call(wrap__RPolarsSeries__sleep, self, millis) -Series$panic <- function() .Call(wrap__Series__panic, self) +Series$panic <- function() .Call(wrap__RPolarsSeries__panic, self) -Series$to_r <- function() .Call(wrap__Series__to_r, self) +Series$to_r <- function() .Call(wrap__RPolarsSeries__to_r, self) -Series$rename_mut <- function(name) invisible(.Call(wrap__Series__rename_mut, self, name)) +Series$rename_mut <- function(name) invisible(.Call(wrap__RPolarsSeries__rename_mut, self, name)) -Series$dtype <- function() .Call(wrap__Series__dtype, self) +Series$dtype <- function() .Call(wrap__RPolarsSeries__dtype, self) -Series$n_unique <- function() .Call(wrap__Series__n_unique, self) +Series$n_unique <- function() .Call(wrap__RPolarsSeries__n_unique, self) -Series$name <- function() .Call(wrap__Series__name, self) +Series$name <- function() .Call(wrap__RPolarsSeries__name, self) -Series$sort_mut <- function(descending) .Call(wrap__Series__sort_mut, self, descending) +Series$sort_mut <- function(descending) .Call(wrap__RPolarsSeries__sort_mut, self, descending) -Series$value_counts <- function(sort, parallel) .Call(wrap__Series__value_counts, self, sort, parallel) +Series$value_counts <- function(sort, parallel) .Call(wrap__RPolarsSeries__value_counts, self, sort, parallel) -Series$arg_min <- function() .Call(wrap__Series__arg_min, self) +Series$arg_min <- function() .Call(wrap__RPolarsSeries__arg_min, self) -Series$arg_max <- function() .Call(wrap__Series__arg_max, self) +Series$arg_max <- function() .Call(wrap__RPolarsSeries__arg_max, self) -Series$is_sorted_flag <- function() .Call(wrap__Series__is_sorted_flag, self) +Series$is_sorted_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_flag, self) -Series$is_sorted_reverse_flag <- function() .Call(wrap__Series__is_sorted_reverse_flag, self) +Series$is_sorted_reverse_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_reverse_flag, self) -Series$is_sorted <- function(descending) .Call(wrap__Series__is_sorted, self, descending) +Series$is_sorted <- function(descending) .Call(wrap__RPolarsSeries__is_sorted, self, descending) -Series$series_equal <- function(other, null_equal, strict) .Call(wrap__Series__series_equal, self, other, null_equal, strict) +Series$series_equal <- function(other, null_equal, strict) .Call(wrap__RPolarsSeries__series_equal, self, other, null_equal, strict) -Series$get_fmt <- function(index, str_length) .Call(wrap__Series__get_fmt, self, index, str_length) +Series$get_fmt <- function(index, str_length) .Call(wrap__RPolarsSeries__get_fmt, self, index, str_length) -Series$to_fmt_char <- function(str_length) .Call(wrap__Series__to_fmt_char, self, str_length) +Series$to_fmt_char <- function(str_length) .Call(wrap__RPolarsSeries__to_fmt_char, self, str_length) -Series$compare <- function(other, op) .Call(wrap__Series__compare, self, other, op) +Series$compare <- function(other, op) .Call(wrap__RPolarsSeries__compare, self, other, op) -Series$rep <- function(n, rechunk) .Call(wrap__Series__rep, self, n, rechunk) +Series$rep <- function(n, rechunk) .Call(wrap__RPolarsSeries__rep, self, n, rechunk) -Series$shape <- function() .Call(wrap__Series__shape, self) +Series$shape <- function() .Call(wrap__RPolarsSeries__shape, self) -Series$len <- function() .Call(wrap__Series__len, self) +Series$len <- function() .Call(wrap__RPolarsSeries__len, self) -Series$chunk_lengths <- function() .Call(wrap__Series__chunk_lengths, self) +Series$chunk_lengths <- function() .Call(wrap__RPolarsSeries__chunk_lengths, self) -Series$abs <- function() .Call(wrap__Series__abs, self) +Series$abs <- function() .Call(wrap__RPolarsSeries__abs, self) -Series$alias <- function(name) .Call(wrap__Series__alias, self, name) +Series$alias <- function(name) .Call(wrap__RPolarsSeries__alias, self, name) -Series$all <- function() .Call(wrap__Series__all, self) +Series$all <- function() .Call(wrap__RPolarsSeries__all, self) -Series$any <- function() .Call(wrap__Series__any, self) +Series$any <- function() .Call(wrap__RPolarsSeries__any, self) -Series$add <- function(other) .Call(wrap__Series__add, self, other) +Series$add <- function(other) .Call(wrap__RPolarsSeries__add, self, other) -Series$sub <- function(other) .Call(wrap__Series__sub, self, other) +Series$sub <- function(other) .Call(wrap__RPolarsSeries__sub, self, other) -Series$mul <- function(other) .Call(wrap__Series__mul, self, other) +Series$mul <- function(other) .Call(wrap__RPolarsSeries__mul, self, other) -Series$div <- function(other) .Call(wrap__Series__div, self, other) +Series$div <- function(other) .Call(wrap__RPolarsSeries__div, self, other) -Series$rem <- function(other) .Call(wrap__Series__rem, self, other) +Series$rem <- function(other) .Call(wrap__RPolarsSeries__rem, self, other) -Series$append_mut <- function(other) .Call(wrap__Series__append_mut, self, other) +Series$append_mut <- function(other) .Call(wrap__RPolarsSeries__append_mut, self, other) -Series$map_elements <- function(robj, rdatatype, strict, allow_fail_eval) .Call(wrap__Series__map_elements, self, robj, rdatatype, strict, allow_fail_eval) +Series$map_elements <- function(robj, rdatatype, strict, allow_fail_eval) .Call(wrap__RPolarsSeries__map_elements, self, robj, rdatatype, strict, allow_fail_eval) -Series$mean <- function() .Call(wrap__Series__mean, self) +Series$mean <- function() .Call(wrap__RPolarsSeries__mean, self) -Series$median <- function() .Call(wrap__Series__median, self) +Series$median <- function() .Call(wrap__RPolarsSeries__median, self) -Series$min <- function() .Call(wrap__Series__min, self) +Series$min <- function() .Call(wrap__RPolarsSeries__min, self) -Series$max <- function() .Call(wrap__Series__max, self) +Series$max <- function() .Call(wrap__RPolarsSeries__max, self) -Series$sum <- function() .Call(wrap__Series__sum, self) +Series$sum <- function() .Call(wrap__RPolarsSeries__sum, self) -Series$std <- function(ddof) .Call(wrap__Series__std, self, ddof) +Series$std <- function(ddof) .Call(wrap__RPolarsSeries__std, self, ddof) -Series$var <- function(ddof) .Call(wrap__Series__var, self, ddof) +Series$var <- function(ddof) .Call(wrap__RPolarsSeries__var, self, ddof) -Series$ceil <- function() .Call(wrap__Series__ceil, self) +Series$ceil <- function() .Call(wrap__RPolarsSeries__ceil, self) -Series$floor <- function() .Call(wrap__Series__floor, self) +Series$floor <- function() .Call(wrap__RPolarsSeries__floor, self) -Series$print <- function() invisible(.Call(wrap__Series__print, self)) +Series$print <- function() invisible(.Call(wrap__RPolarsSeries__print, self)) -Series$cum_sum <- function(reverse) .Call(wrap__Series__cum_sum, self, reverse) +Series$cum_sum <- function(reverse) .Call(wrap__RPolarsSeries__cum_sum, self, reverse) -Series$to_frame <- function() .Call(wrap__Series__to_frame, self) +Series$to_frame <- function() .Call(wrap__RPolarsSeries__to_frame, self) -Series$set_sorted_mut <- function(descending) invisible(.Call(wrap__Series__set_sorted_mut, self, descending)) +Series$set_sorted_mut <- function(descending) invisible(.Call(wrap__RPolarsSeries__set_sorted_mut, self, descending)) -Series$from_arrow <- function(name, array) .Call(wrap__Series__from_arrow, name, array) +Series$from_arrow <- function(name, array) .Call(wrap__RPolarsSeries__from_arrow, name, array) + +RPolarsSeries <- Series #' @export -`$.Series` <- function (self, name) { func <- Series[[name]]; environment(func) <- environment(); func } +`$.RPolarsSeries` <- function (self, name) { func <- RPolarsSeries[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsSeries` <- `$.RPolarsSeries` + +`$.Series` <- function (self, name) { func <- Series[[name]]; environment(func) <- environment(); func } + `[[.Series` <- `$.Series` RPolarsSQLContext <- new.env(parent = emptyenv()) diff --git a/R/functions__eager.R b/R/functions__eager.R index 9ba37f172..ce73e3f78 100644 --- a/R/functions__eager.R +++ b/R/functions__eager.R @@ -96,7 +96,7 @@ pl$concat = function( # dispatch on item class and how Result_out = pcase( - how == "vertical" && (inherits(first, "Series") || is.vector(first)), + how == "vertical" && (inherits(first, "RPolarsSeries") || is.vector(first)), { if (any(args_modified %in% c("parallel"))) { warning( @@ -106,7 +106,7 @@ pl$concat = function( } concat_series(l, rechunk, to_supertypes = FALSE) }, - how == "vertical_relaxed" && (inherits(first, "Series") || is.vector(first)), + how == "vertical_relaxed" && (inherits(first, "RPolarsSeries") || is.vector(first)), { if (any(args_modified %in% c("parallel"))) { warning( diff --git a/R/functions__lazy.R b/R/functions__lazy.R index 00c64d324..9030129d3 100644 --- a/R/functions__lazy.R +++ b/R/functions__lazy.R @@ -114,7 +114,7 @@ pl$count = function(column = NULL) { # -> Expr | int: if (is.null(column)) { return(.pr$Expr$new_count()) } - if (inherits(column, "Series")) { + if (inherits(column, "RPolarsSeries")) { return(column$len()) } # add context to any error from pl$col @@ -163,7 +163,7 @@ pl$implode = function(name) { # -> Expr pl$first = function(column = NULL) { #-> Expr | Any: pcase( is.null(column), Ok(.pr$Expr$new_first()), - inherits(column, "Series"), if (column$len() == 0) { + inherits(column, "RPolarsSeries"), if (column$len() == 0) { Err("The series is empty, so no first value can be returned.") } else { # TODO impl a direct slicing Series e.g. as pl$lit(series)$slice(x,y)$to_r() @@ -205,7 +205,7 @@ pl$first = function(column = NULL) { #-> Expr | Any: pl$last = function(column = NULL) { #-> Expr | Any: pcase( is.null(column), Ok(.pr$Expr$new_last()), - inherits(column, "Series"), if (column$len() == 0) { + inherits(column, "RPolarsSeries"), if (column$len() == 0) { Err("The series is empty, so no last value can be returned.") } else { # TODO impl a direct slicing Series e.g. as pl$lit(series)$slice(x,y)$to_r() @@ -242,7 +242,7 @@ pl$last = function(column = NULL) { #-> Expr | Any: #' pl$head(df$get_column("a"), 2) pl$head = function(column, n = 10) { #-> Expr | Any: pcase( - inherits(column, "Series"), result(column$expr$head(n)), + inherits(column, "RPolarsSeries"), result(column$expr$head(n)), is.character(column), result(pl$col(column)$head(n)), inherits(column, "RPolarsExpr"), result(column$head(n)), or_else = Err(paste0( @@ -277,7 +277,7 @@ pl$head = function(column, n = 10) { #-> Expr | Any: #' pl$tail(df$get_column("a"), 2) pl$tail = function(column, n = 10) { #-> Expr | Any: pcase( - inherits(column, "Series"), result(column$expr$tail(n)), + inherits(column, "RPolarsSeries"), result(column$expr$tail(n)), is.character(column), result(pl$col(column)$tail(n)), inherits(column, "RPolarsExpr"), result(column$tail(n)), or_else = Err(paste0( @@ -323,9 +323,9 @@ pl$mean = function(...) { #-> Expr | Any: Err("When there are more than one arguments in pl$mean(), all arguments must be strings."), lc > 1L && stringflag, Ok(pl$col(unlist(column))$mean()), - lc == 1L && inherits(column[[1]], "Series") && column[[1]]$len() == 0, + lc == 1L && inherits(column[[1]], "RPolarsSeries") && column[[1]]$len() == 0, Err("The series is empty, so no mean value can be returned."), - lc == 1L && inherits(column[[1]], c("Series", "RPolarsLazyFrame", "RPolarsDataFrame")), + lc == 1L && inherits(column[[1]], c("RPolarsSeries", "RPolarsLazyFrame", "RPolarsDataFrame")), Ok(column[[1]]$mean()), or_else = Ok(pl$col(column[[1]])$mean()) ) |> @@ -368,9 +368,9 @@ pl$median = function(...) { #-> Expr | Any: Err("When there are more than one arguments in pl$median(), all arguments must be strings."), lc > 1L && stringflag, Ok(pl$col(unlist(column))$median()), - lc == 1L && inherits(column[[1]], "Series") && column[[1]]$len() == 0, + lc == 1L && inherits(column[[1]], "RPolarsSeries") && column[[1]]$len() == 0, Err("The series is empty, so no median value can be returned."), - lc == 1L && inherits(column[[1]], c("Series", "RPolarsLazyFrame", "RPolarsDataFrame")), + lc == 1L && inherits(column[[1]], c("RPolarsSeries", "RPolarsLazyFrame", "RPolarsDataFrame")), Ok(column[[1]]$median()), or_else = Ok(pl$col(column[[1]])$median()) ) |> @@ -402,7 +402,7 @@ pl$median = function(...) { #-> Expr | Any: #' pl$DataFrame(bob = 1:4)$select(pl$n_unique(pl$col("bob"))) pl$n_unique = function(column) { #-> int or Expr pcase( - inherits(column, c("Series", "RPolarsExpr")), result(column$n_unique()), + inherits(column, c("RPolarsSeries", "RPolarsExpr")), result(column$n_unique()), is_string(column), result(pl$col(column)$n_unique()), or_else = Err(paste("arg [column] is neither Series, Expr or String, but", str_string(column))) ) |> @@ -481,7 +481,7 @@ pl$approx_n_unique = function(column) { #-> int or Expr pl$sum = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { + if (inherits(column, "RPolarsSeries") || inherits(column, "RPolarsExpr")) { return(column$sum()) } if (is_string(column)) { @@ -525,7 +525,7 @@ pl$sum = function(..., verbose = TRUE) { pl$min = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { + if (inherits(column, "RPolarsSeries") || inherits(column, "RPolarsExpr")) { return(column$min()) } if (is_string(column)) { @@ -573,7 +573,7 @@ pl$min = function(..., verbose = TRUE) { pl$max = function(..., verbose = TRUE) { column = list2(...) if (length(column) == 1L) column <- column[[1L]] - if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { + if (inherits(column, "RPolarsSeries") || inherits(column, "RPolarsExpr")) { return(column$max()) } if (is_string(column)) { @@ -630,7 +630,7 @@ pl$coalesce = function(...) { #' @return Expr or Series matching type of input column #' @name pl_std pl$std = function(column, ddof = 1) { - if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { + if (inherits(column, "RPolarsSeries") || inherits(column, "RPolarsExpr")) { return(column$std(ddof)) } if (is_string(column)) { @@ -649,7 +649,7 @@ pl$std = function(column, ddof = 1) { #' @return Expr or Series matching type of input column #' @name pl_var pl$var = function(column, ddof = 1) { - if (inherits(column, "Series") || inherits(column, "RPolarsExpr")) { + if (inherits(column, "RPolarsSeries") || inherits(column, "RPolarsExpr")) { return(column$var(ddof)) } if (is_string(column)) { diff --git a/R/rbackground.R b/R/rbackground.R index 86fe0ae96..c77f3e2f3 100644 --- a/R/rbackground.R +++ b/R/rbackground.R @@ -64,7 +64,7 @@ print.RThreadHandle = function(x, ...) as.character(x) |> cat("\n") #' [`$map_batches()`][Expr_map_batches] #' [`$map_elements()`][Expr_map_elements] #' @examples -#' prexpr = pl$col("mpg")$map(\(x) { +#' prexpr = pl$col("mpg")$map_batches(\(x) { #' Sys.sleep(.1) #' x * 0.43 #' }, in_background = TRUE)$alias("kml") diff --git a/R/s3_methods.R b/R/s3_methods.R index d850c760f..21debba87 100644 --- a/R/s3_methods.R +++ b/R/s3_methods.R @@ -134,7 +134,7 @@ #' @export #' @rdname S3_extract -`[.Series` = function(x, i) { +`[.RPolarsSeries` = function(x, i) { pl$select(x)[i, , drop = TRUE] } @@ -193,7 +193,7 @@ length.RPolarsLazyFrame = length.RPolarsDataFrame #' @export #' @rdname S3_length -length.Series = function(x) x$len() +length.RPolarsSeries = function(x) x$len() #' Get the column names #' @@ -269,7 +269,7 @@ mean.RPolarsLazyFrame = function(x, ...) x$mean() #' @export #' @rdname S3_mean -mean.Series = function(x, ...) x$mean() +mean.RPolarsSeries = function(x, ...) x$mean() #' Compute the median #' @@ -290,7 +290,7 @@ median.RPolarsLazyFrame = function(x, ...) x$median() #' @export #' @importFrom stats median #' @rdname S3_median -median.Series = function(x, ...) x$median() +median.RPolarsSeries = function(x, ...) x$median() #' Compute the minimum value #' @@ -308,7 +308,7 @@ min.RPolarsLazyFrame = function(x, ...) x$min() #' @export #' @rdname S3_min -min.Series = function(x, ...) x$min() +min.RPolarsSeries = function(x, ...) x$min() #' Compute the maximum value #' @@ -326,7 +326,7 @@ max.RPolarsLazyFrame = function(x, ...) x$max() #' @export #' @rdname S3_max -max.Series = function(x, ...) x$max() +max.RPolarsSeries = function(x, ...) x$max() #' Compute the sum #' @@ -344,7 +344,7 @@ sum.RPolarsLazyFrame = function(x, ...) x$sum() #' @export #' @rdname S3_sum -sum.Series = function(x, ...) x$sum() +sum.RPolarsSeries = function(x, ...) x$sum() #' Convert to a vector #' @@ -352,7 +352,7 @@ sum.Series = function(x, ...) x$sum() #' @param mode Not used. #' @export #' @rdname S3_as.vector -as.vector.Series = function(x, mode) x$to_vector() +as.vector.RPolarsSeries = function(x, mode) x$to_vector() #' Convert to a character vector @@ -368,7 +368,7 @@ as.vector.Series = function(x, mode) x$to_vector() #' s = pl$Series(c("foo", "barbaz")) #' as.character(s) #' as.character(s, str_length = 3) -as.character.Series = function(x, ..., str_length = NULL) { +as.character.RPolarsSeries = function(x, ..., str_length = NULL) { if (is.numeric(str_length) && str_length > 0) { .pr$Series$to_fmt_char(x, str_length = str_length) } else { @@ -384,7 +384,7 @@ as.character.Series = function(x, ..., str_length = NULL) { #' #' @rdname S3_print #' @export -print.Series = function(x, ...) { +print.RPolarsSeries = function(x, ...) { cat("polars Series: ") x$print() invisible(x) @@ -401,7 +401,7 @@ print.Series = function(x, ...) { #' @noRd #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.Series = function(x, pattern = "") { +.DollarNames.RPolarsSeries = function(x, pattern = "") { get_method_usages(Series, pattern = pattern) } @@ -419,7 +419,7 @@ print.Series = function(x, ...) { #' s$chunk_lengths() # the series contain three unmerged chunks #' @export #' @rdname S3_c -c.Series = \(x, ...) { +c.RPolarsSeries = \(x, ...) { l = list2(...) x = x$clone() # clone to retain an immutable api, append_mut is not immutable for (i in seq_along(l)) { # append each element of i being either Series or Into diff --git a/R/series__series.R b/R/series__series.R index d14f65642..b88195773 100644 --- a/R/series__series.R +++ b/R/series__series.R @@ -5,7 +5,7 @@ #' the public and private methods/function calls to the polars rust side. The instantiated #' `Series`-object is an `externalptr` to a lowlevel rust polars Series object. The pointer address #' is the only statefullness of the Series object on the R side. Any other state resides on the -#' rust side. The S3 method `.DollarNames.Series` exposes all public `$foobar()`-methods which are callable onto the object. +#' rust side. The S3 method `.DollarNames.RPolarsSeries` exposes all public `$foobar()`-methods which are callable onto the object. #' Most methods return another `Series`-class instance or similar which allows for method chaining. #' This class system in lack of a better name could be called "environment classes" and is the same class #' system extendr provides, except here there is both a public and private set of methods. For implementation @@ -20,7 +20,7 @@ #' #' @keywords Series #' @examples -#' pl$show_all_public_methods("Series") +#' pl$show_all_public_methods("RPolarsSeries") #' #' # see all private methods (not intended for regular use) #' ls(.pr$Series) @@ -47,7 +47,7 @@ Series #' @param x a Series or something-turned-into-Series #' @return Series wrap_s = function(x) { - if (inherits(x, "Series")) x else pl$Series(x) + if (inherits(x, "RPolarsSeries")) x else pl$Series(x) } #' Create new Series @@ -98,7 +98,7 @@ Series_add = function(other) { #' @rdname Series_add #' @param s1 lhs Series #' @param s2 rhs Series or any into Series -"+.Series" = function(s1, s2) wrap_s(s1)$add(s2) +"+.RPolarsSeries" = function(s1, s2) wrap_s(s1)$add(s2) #' sub Series #' @name Series_sub @@ -120,7 +120,7 @@ Series_sub = function(other) { #' @rdname Series_sub #' @param s1 lhs Series #' @param s2 rhs Series or any into Series -"-.Series" = function(s1, s2) wrap_s(s1)$sub(s2) +"-.RPolarsSeries" = function(s1, s2) wrap_s(s1)$sub(s2) #' div Series #' @name Series_div @@ -142,7 +142,7 @@ Series_div = function(other) { #' @rdname Series_div #' @param s1 lhs Series #' @param s2 rhs Series or any into Series -"/.Series" = function(s1, s2) wrap_s(s1)$div(s2) +"/.RPolarsSeries" = function(s1, s2) wrap_s(s1)$div(s2) #' mul Series #' @name Series_mul @@ -164,7 +164,7 @@ Series_mul = function(other) { #' @rdname Series_mul #' @param s1 lhs Series #' @param s2 rhs Series or any into Series -"*.Series" = function(s1, s2) wrap_s(s1)$mul(s2) +"*.RPolarsSeries" = function(s1, s2) wrap_s(s1)$mul(s2) #' rem Series #' @description Series arithmetics, remainder @@ -209,22 +209,22 @@ Series_compare = function(other, op) { #' @rdname Series_compare #' @param s1 lhs Series #' @param s2 rhs Series or any into Series -"==.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "equal")) +"==.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "equal")) #' @export #' @rdname Series_compare -"!=.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "not_equal")) +"!=.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "not_equal")) #' @export #' @rdname Series_compare -"<.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "lt")) +"<.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "lt")) #' @export #' @rdname Series_compare -">.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "gt")) +">.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "gt")) #' @export #' @rdname Series_compare -"<=.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "lt_eq")) +"<=.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "lt_eq")) #' @export #' @rdname Series_compare -">=.Series" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "gt_eq")) +">=.RPolarsSeries" = function(s1, s2) unwrap(wrap_s(s1)$compare(s2, "gt_eq")) #' Shape of series diff --git a/man/RThreadHandle_RThreadHandle_class.Rd b/man/RThreadHandle_RThreadHandle_class.Rd index f9baffce5..3e9096392 100644 --- a/man/RThreadHandle_RThreadHandle_class.Rd +++ b/man/RThreadHandle_RThreadHandle_class.Rd @@ -28,7 +28,7 @@ available to process the R part of the polars query. Native polars query does no session. } \examples{ -prexpr = pl$col("mpg")$map(\(x) { +prexpr = pl$col("mpg")$map_batches(\(x) { Sys.sleep(.1) x * 0.43 }, in_background = TRUE)$alias("kml") diff --git a/man/S3_as.character.Rd b/man/S3_as.character.Rd index 5bc653bfd..df3eb5002 100644 --- a/man/S3_as.character.Rd +++ b/man/S3_as.character.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{as.character.Series} -\alias{as.character.Series} +\name{as.character.RPolarsSeries} +\alias{as.character.RPolarsSeries} \title{Convert to a character vector} \usage{ -\method{as.character}{Series}(x, ..., str_length = NULL) +\method{as.character}{RPolarsSeries}(x, ..., str_length = NULL) } \arguments{ \item{x}{A Polars Series} diff --git a/man/S3_as.vector.Rd b/man/S3_as.vector.Rd index d2b37da9a..072c6250f 100644 --- a/man/S3_as.vector.Rd +++ b/man/S3_as.vector.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{as.vector.Series} -\alias{as.vector.Series} +\name{as.vector.RPolarsSeries} +\alias{as.vector.RPolarsSeries} \title{Convert to a vector} \usage{ -\method{as.vector}{Series}(x, mode) +\method{as.vector}{RPolarsSeries}(x, mode) } \arguments{ \item{x}{A Polars Series} diff --git a/man/S3_c.Rd b/man/S3_c.Rd index 33fca8170..a89af53d0 100644 --- a/man/S3_c.Rd +++ b/man/S3_c.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{c.Series} -\alias{c.Series} +\name{c.RPolarsSeries} +\alias{c.RPolarsSeries} \title{Combine to a Series} \usage{ -\method{c}{Series}(x, ...) +\method{c}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A Polars Series} diff --git a/man/S3_extract.Rd b/man/S3_extract.Rd index 1d9ff7097..3a072626f 100644 --- a/man/S3_extract.Rd +++ b/man/S3_extract.Rd @@ -3,14 +3,14 @@ \name{[.RPolarsDataFrame} \alias{[.RPolarsDataFrame} \alias{[.RPolarsLazyFrame} -\alias{[.Series} +\alias{[.RPolarsSeries} \title{Extract Parts of a Polars Object} \usage{ \method{[}{RPolarsDataFrame}(x, i, j, drop = TRUE) \method{[}{RPolarsLazyFrame}(x, i, j, drop = TRUE) -\method{[}{Series}(x, i) +\method{[}{RPolarsSeries}(x, i) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or \link[=Series_class]{Series}} diff --git a/man/S3_length.Rd b/man/S3_length.Rd index eeaaf271b..05b014283 100644 --- a/man/S3_length.Rd +++ b/man/S3_length.Rd @@ -3,14 +3,14 @@ \name{length.RPolarsDataFrame} \alias{length.RPolarsDataFrame} \alias{length.RPolarsLazyFrame} -\alias{length.Series} +\alias{length.RPolarsSeries} \title{Get the length} \usage{ \method{length}{RPolarsDataFrame}(x) \method{length}{RPolarsLazyFrame}(x) -\method{length}{Series}(x) +\method{length}{RPolarsSeries}(x) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/S3_max.Rd b/man/S3_max.Rd index a772441d0..592c6e4eb 100644 --- a/man/S3_max.Rd +++ b/man/S3_max.Rd @@ -3,14 +3,14 @@ \name{max.RPolarsDataFrame} \alias{max.RPolarsDataFrame} \alias{max.RPolarsLazyFrame} -\alias{max.Series} +\alias{max.RPolarsSeries} \title{Compute the maximum value} \usage{ \method{max}{RPolarsDataFrame}(x, ...) \method{max}{RPolarsLazyFrame}(x, ...) -\method{max}{Series}(x, ...) +\method{max}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/S3_mean.Rd b/man/S3_mean.Rd index a696f949a..9ea9bf8ec 100644 --- a/man/S3_mean.Rd +++ b/man/S3_mean.Rd @@ -3,14 +3,14 @@ \name{mean.RPolarsDataFrame} \alias{mean.RPolarsDataFrame} \alias{mean.RPolarsLazyFrame} -\alias{mean.Series} +\alias{mean.RPolarsSeries} \title{Compute the mean} \usage{ \method{mean}{RPolarsDataFrame}(x, ...) \method{mean}{RPolarsLazyFrame}(x, ...) -\method{mean}{Series}(x, ...) +\method{mean}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/S3_median.Rd b/man/S3_median.Rd index 3155ec65a..801f56467 100644 --- a/man/S3_median.Rd +++ b/man/S3_median.Rd @@ -3,14 +3,14 @@ \name{median.RPolarsDataFrame} \alias{median.RPolarsDataFrame} \alias{median.RPolarsLazyFrame} -\alias{median.Series} +\alias{median.RPolarsSeries} \title{Compute the median} \usage{ \method{median}{RPolarsDataFrame}(x, ...) \method{median}{RPolarsLazyFrame}(x, ...) -\method{median}{Series}(x, ...) +\method{median}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/S3_min.Rd b/man/S3_min.Rd index c30ba976a..7b18af496 100644 --- a/man/S3_min.Rd +++ b/man/S3_min.Rd @@ -3,14 +3,14 @@ \name{min.RPolarsDataFrame} \alias{min.RPolarsDataFrame} \alias{min.RPolarsLazyFrame} -\alias{min.Series} +\alias{min.RPolarsSeries} \title{Compute the minimum value} \usage{ \method{min}{RPolarsDataFrame}(x, ...) \method{min}{RPolarsLazyFrame}(x, ...) -\method{min}{Series}(x, ...) +\method{min}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/S3_print.Rd b/man/S3_print.Rd index 880ac5187..748aa7a31 100644 --- a/man/S3_print.Rd +++ b/man/S3_print.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/s3_methods.R -\name{print.Series} -\alias{print.Series} +\name{print.RPolarsSeries} +\alias{print.RPolarsSeries} \title{Print values} \usage{ -\method{print}{Series}(x, ...) +\method{print}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A Polars Series} diff --git a/man/S3_sum.Rd b/man/S3_sum.Rd index 26a80b173..2a6495566 100644 --- a/man/S3_sum.Rd +++ b/man/S3_sum.Rd @@ -3,14 +3,14 @@ \name{sum.RPolarsDataFrame} \alias{sum.RPolarsDataFrame} \alias{sum.RPolarsLazyFrame} -\alias{sum.Series} +\alias{sum.RPolarsSeries} \title{Compute the sum} \usage{ \method{sum}{RPolarsDataFrame}(x, ...) \method{sum}{RPolarsLazyFrame}(x, ...) -\method{sum}{Series}(x, ...) +\method{sum}{RPolarsSeries}(x, ...) } \arguments{ \item{x}{A \link[=DataFrame_class]{DataFrame}, \link[=LazyFrame_class]{LazyFrame}, or diff --git a/man/Series_add.Rd b/man/Series_add.Rd index eef2d0b88..c460100b6 100644 --- a/man/Series_add.Rd +++ b/man/Series_add.Rd @@ -3,12 +3,12 @@ \name{Series_add} \alias{Series_add} \alias{add} -\alias{+.Series} +\alias{+.RPolarsSeries} \title{add Series} \usage{ Series_add(other) -\method{+}{Series}(s1, s2) +\method{+}{RPolarsSeries}(s1, s2) } \arguments{ \item{other}{Series or into Series} diff --git a/man/Series_class.Rd b/man/Series_class.Rd index 54c09eb3f..66f1eca94 100644 --- a/man/Series_class.Rd +++ b/man/Series_class.Rd @@ -8,7 +8,7 @@ The \code{Series}-class is simply two environments of respectively the public and private methods/function calls to the polars rust side. The instantiated \code{Series}-object is an \code{externalptr} to a lowlevel rust polars Series object. The pointer address is the only statefullness of the Series object on the R side. Any other state resides on the -rust side. The S3 method \code{.DollarNames.Series} exposes all public \verb{$foobar()}-methods which are callable onto the object. +rust side. The S3 method \code{.DollarNames.RPolarsSeries} exposes all public \verb{$foobar()}-methods which are callable onto the object. Most methods return another \code{Series}-class instance or similar which allows for method chaining. This class system in lack of a better name could be called "environment classes" and is the same class system extendr provides, except here there is both a public and private set of methods. For implementation @@ -23,7 +23,7 @@ into pure external functions in after-wrappers.R. In zzz.R (named zzz to be last are removed and replaced by any function prefixed \code{Series_}. } \examples{ -pl$show_all_public_methods("Series") +pl$show_all_public_methods("RPolarsSeries") # see all private methods (not intended for regular use) ls(.pr$Series) diff --git a/man/Series_compare.Rd b/man/Series_compare.Rd index 848aa01af..6af3c900d 100644 --- a/man/Series_compare.Rd +++ b/man/Series_compare.Rd @@ -3,27 +3,27 @@ \name{Series_compare} \alias{Series_compare} \alias{compare} -\alias{==.Series} -\alias{!=.Series} -\alias{<.Series} -\alias{>.Series} -\alias{<=.Series} -\alias{>=.Series} +\alias{==.RPolarsSeries} +\alias{!=.RPolarsSeries} +\alias{<.RPolarsSeries} +\alias{>.RPolarsSeries} +\alias{<=.RPolarsSeries} +\alias{>=.RPolarsSeries} \title{Compare Series} \usage{ Series_compare(other, op) -\method{==}{Series}(s1, s2) +\method{==}{RPolarsSeries}(s1, s2) -\method{!=}{Series}(s1, s2) +\method{!=}{RPolarsSeries}(s1, s2) -\method{<}{Series}(s1, s2) +\method{<}{RPolarsSeries}(s1, s2) -\method{>}{Series}(s1, s2) +\method{>}{RPolarsSeries}(s1, s2) -\method{<=}{Series}(s1, s2) +\method{<=}{RPolarsSeries}(s1, s2) -\method{>=}{Series}(s1, s2) +\method{>=}{RPolarsSeries}(s1, s2) } \arguments{ \item{other}{A Series or something a Series can be created from} diff --git a/man/Series_div.Rd b/man/Series_div.Rd index e3c4632fe..275b8ac09 100644 --- a/man/Series_div.Rd +++ b/man/Series_div.Rd @@ -3,12 +3,12 @@ \name{Series_div} \alias{Series_div} \alias{div} -\alias{/.Series} +\alias{/.RPolarsSeries} \title{div Series} \usage{ Series_div(other) -\method{/}{Series}(s1, s2) +\method{/}{RPolarsSeries}(s1, s2) } \arguments{ \item{other}{Series or into Series} diff --git a/man/Series_mul.Rd b/man/Series_mul.Rd index 39dc6920f..562db9d9a 100644 --- a/man/Series_mul.Rd +++ b/man/Series_mul.Rd @@ -3,12 +3,12 @@ \name{Series_mul} \alias{Series_mul} \alias{mul} -\alias{*.Series} +\alias{*.RPolarsSeries} \title{mul Series} \usage{ Series_mul(other) -\method{*}{Series}(s1, s2) +\method{*}{RPolarsSeries}(s1, s2) } \arguments{ \item{other}{Series or into Series} diff --git a/man/Series_sub.Rd b/man/Series_sub.Rd index 19e5d1892..d8e634cba 100644 --- a/man/Series_sub.Rd +++ b/man/Series_sub.Rd @@ -3,12 +3,12 @@ \name{Series_sub} \alias{Series_sub} \alias{sub} -\alias{-.Series} +\alias{-.RPolarsSeries} \title{sub Series} \usage{ Series_sub(other) -\method{-}{Series}(s1, s2) +\method{-}{RPolarsSeries}(s1, s2) } \arguments{ \item{other}{Series or into Series} diff --git a/man/as_polars_df.Rd b/man/as_polars_df.Rd index b06563d7e..bb36e51ad 100644 --- a/man/as_polars_df.Rd +++ b/man/as_polars_df.Rd @@ -6,7 +6,7 @@ \alias{as_polars_df.data.frame} \alias{as_polars_df.RPolarsDataFrame} \alias{as_polars_df.GroupBy} -\alias{as_polars_df.Series} +\alias{as_polars_df.RPolarsSeries} \alias{as_polars_df.RPolarsLazyFrame} \alias{as_polars_df.LazyGroupBy} \alias{as_polars_df.ArrowTabular} @@ -22,7 +22,7 @@ as_polars_df(x, ...) \method{as_polars_df}{GroupBy}(x, ...) -\method{as_polars_df}{Series}(x, ...) +\method{as_polars_df}{RPolarsSeries}(x, ...) \method{as_polars_df}{RPolarsLazyFrame}( x, diff --git a/src/rust/src/concat.rs b/src/rust/src/concat.rs index c8229f3aa..978c6c1d8 100644 --- a/src/rust/src/concat.rs +++ b/src/rust/src/concat.rs @@ -1,7 +1,7 @@ use crate::rdataframe::{RPolarsDataFrame, RPolarsLazyFrame}; use crate::robj_to; use crate::rpolarserr::*; -use crate::series::Series; +use crate::series::RPolarsSeries; use extendr_api::prelude::*; use polars::lazy::dsl; use polars::prelude as pl; @@ -53,7 +53,7 @@ pub fn concat_df_horizontal(l: Robj) -> RResult { } #[extendr] -pub fn concat_series(l: Robj, rechunk: Robj, to_supertypes: Robj) -> RResult { +pub fn concat_series(l: Robj, rechunk: Robj, to_supertypes: Robj) -> RResult { let to_supertypes = robj_to!(bool, to_supertypes)?; let mut s_vec = robj_to!(Vec, PLSeries, l)?; diff --git a/src/rust/src/concurrent.rs b/src/rust/src/concurrent.rs index 976b4d863..339461341 100644 --- a/src/rust/src/concurrent.rs +++ b/src/rust/src/concurrent.rs @@ -5,7 +5,7 @@ use crate::utils::extendr_concurrent::{concurrent_handler, ThreadCom}; use crate::CONFIG; use polars::prelude as pl; -use crate::rdataframe::Series; +use crate::rdataframe::RPolarsSeries; use crate::rpolarserr::*; use extendr_api::prelude::*; use extendr_api::Conversions; @@ -42,14 +42,14 @@ impl RFnSignature { match self { RFnSignature::FnSeriesToSeries(f, s) => { let s = unpack_rfn(f)? - .call(pairlist!(Series(s))) - .map(Series::any_robj_to_pl_series_result)??; + .call(pairlist!(RPolarsSeries(s))) + .map(RPolarsSeries::any_robj_to_pl_series_result)??; Ok(RFnOutput::Series(s)) } RFnSignature::FnTwoSeriesToSeries(f, s1, s2) => { let s = unpack_rfn(f)? - .call(pairlist!(Series(s1), Series(s2))) - .map(Series::any_robj_to_pl_series_result)??; + .call(pairlist!(RPolarsSeries(s1), RPolarsSeries(s2))) + .map(RPolarsSeries::any_robj_to_pl_series_result)??; Ok(RFnOutput::Series(s)) } RFnSignature::FnF64ToString(f, f64_val) => { diff --git a/src/rust/src/conversion_r_to_s.rs b/src/rust/src/conversion_r_to_s.rs index 86ba93835..9b0d3f061 100644 --- a/src/rust/src/conversion_r_to_s.rs +++ b/src/rust/src/conversion_r_to_s.rs @@ -1,4 +1,4 @@ -use crate::series::Series; +use crate::series::RPolarsSeries; use crate::utils::collect_hinted_result; use extendr_api::prelude::*; /// this file implements any conversion from Robject to polars::Series @@ -58,8 +58,8 @@ fn recursive_robjname2series_tree(x: &Robj, name: &str) -> pl::PolarsResult match () { - _ if x.inherits("Series") => { - let s: Series = unsafe { &mut *x.external_ptr_addr::() }.clone(); + _ if x.inherits("RPolarsSeries") => { + let s: RPolarsSeries = unsafe { &mut *x.external_ptr_addr::() }.clone(); Ok(SeriesTree::Series(s.0)) } _ => Err(pl::PolarsError::InvalidOperation( diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index aac4befe2..2a866c60d 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -6,7 +6,7 @@ use crate::rdatatype::{ use crate::robj_to; use crate::rpolarserr::polars_to_rpolars_err; use crate::rpolarserr::{rerr, rpolars_to_polars_err, RResult, Rctx, WithRctx}; -use crate::series::Series; +use crate::series::RPolarsSeries; use crate::utils::extendr_concurrent::{ParRObj, ThreadCom}; use crate::utils::extendr_helpers::robj_inherits; use crate::utils::parse_fill_null_strategy; @@ -79,7 +79,7 @@ impl RPolarsExpr { let rlen = robj.len(); fn to_series_then_lit(robj: Robj) -> RResult { - Series::any_robj_to_pl_series_result(robj) + RPolarsSeries::any_robj_to_pl_series_result(robj) .map_err(polars_to_rpolars_err) .map(dsl::lit) } @@ -144,8 +144,8 @@ impl RPolarsExpr { } } (Rtype::ExternalPtr, 1) => match () { - _ if robj.inherits("Series") => { - let s: Series = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + _ if robj.inherits("RPolarsSeries") => { + let s: RPolarsSeries = unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(pl::lit(s.0)) } @@ -957,7 +957,7 @@ impl RPolarsExpr { if s.len() == 1 { Ok(Some(s.new_from_index(0, n))) } else { - Series(s).rep_impl(n, rechunk).map(|s| Some(s.0)) + RPolarsSeries(s).rep_impl(n, rechunk).map(|s| Some(s.0)) } }, pl::GetOutput::same_type(), @@ -2635,7 +2635,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { || -> RResult { use crate::utils::unpack_r_eval; - let name = if name.inherits("Series") { + let name = if name.inherits("RPolarsSeries") { unpack_r_eval(R!("polars:::result({{name}}$to_vector())"))? } else { name diff --git a/src/rust/src/rbackground.rs b/src/rust/src/rbackground.rs index 124a36e01..83b4b4653 100644 --- a/src/rust/src/rbackground.rs +++ b/src/rust/src/rbackground.rs @@ -186,7 +186,7 @@ impl RIPCJob { collector, } => { let bits = || { - use crate::series::Series as RSeries; + use crate::series::RPolarsSeries; let func_robj = deserialize_robj(raw_func)?; let series = deserialize_series(&raw_series)?; let func = func_robj @@ -194,8 +194,8 @@ impl RIPCJob { .ok_or(RPolarsErr::new()) .bad_val(rdbg(func_robj)) .mistyped("pure R function")?; - let shared_memory = serialize_series(RSeries::any_robj_to_pl_series_result( - func.call(pairlist!(RSeries(series)))?, + let shared_memory = serialize_series(RPolarsSeries::any_robj_to_pl_series_result( + func.call(pairlist!(RPolarsSeries(series)))?, )?)?; RResult::Ok(ipc::IpcSharedMemory::from_bytes(shared_memory.as_slice())) }; diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index 98bb53880..8b72c4823 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -142,7 +142,7 @@ impl RPolarsDataFrame { } //internal use - pub fn set_column_from_series(&mut self, x: &Series) -> Result<(), String> { + pub fn set_column_from_series(&mut self, x: &RPolarsSeries) -> Result<(), String> { let s: pl::Series = x.into(); //implicit clone, cannot move R objects self.0 .with_column(s) @@ -186,13 +186,13 @@ impl RPolarsDataFrame { let res_series = self .0 .select([name]) - .map(|df| Series(df.iter().next().unwrap().clone())) + .map(|df| RPolarsSeries(df.iter().next().unwrap().clone())) .map_err(|err| format!("in get_column: {:?}", err)); r_result_list(res_series) } pub fn get_columns(&self) -> List { - let mut l = List::from_values(self.0.get_columns().iter().map(|x| Series(x.clone()))); + let mut l = List::from_values(self.0.get_columns().iter().map(|x| RPolarsSeries(x.clone()))); l.set_names(self.0.get_column_names()).unwrap(); l } @@ -281,17 +281,17 @@ impl RPolarsDataFrame { } pub fn select_at_idx(&self, idx: i32) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { self.0 .select_at_idx(idx as usize) - .map(|s| Series(s.clone())) + .map(|s| RPolarsSeries(s.clone())) .ok_or_else(|| format!("select_at_idx: no series found at idx {:?}", idx)) }(); r_result_list(expr_result) } - pub fn drop_in_place(&mut self, names: &str) -> Series { - Series(self.0.drop_in_place(names).unwrap()) + pub fn drop_in_place(&mut self, names: &str) -> RPolarsSeries { + RPolarsSeries(self.0.drop_in_place(names).unwrap()) } pub fn select(&self, exprs: Robj) -> RResult { @@ -321,7 +321,7 @@ impl RPolarsDataFrame { RPolarsLazyFrame(lgb.agg(agg_exprs)).collect() } - pub fn to_struct(&self, name: &str) -> Series { + pub fn to_struct(&self, name: &str) -> RPolarsSeries { use pl::IntoSeries; let s = self.0.clone().into_struct(name); s.into_series().into() diff --git a/src/rust/src/rlib.rs b/src/rust/src/rlib.rs index 29f8f041c..265298ce5 100644 --- a/src/rust/src/rlib.rs +++ b/src/rust/src/rlib.rs @@ -2,7 +2,7 @@ use crate::lazy::dsl::{RPolarsExpr, ProtoExprArray}; use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::{rdbg, RResult}; -use crate::series::Series; +use crate::series::RPolarsSeries; use crate::utils::extendr_concurrent::{ParRObj, ThreadCom}; use crate::utils::robj_to_rchoice; use crate::RFnSignature; @@ -156,7 +156,7 @@ fn arrow_stream_to_df(robj_str: Robj) -> RResult { #[extendr] fn arrow_stream_to_series(robj_str: Robj) -> RResult { let s = crate::arrow_interop::to_rust::arrow_stream_to_series_internal(robj_str)?; - Ok(Series(s).into_robj()) + Ok(RPolarsSeries(s).into_robj()) } #[extendr] diff --git a/src/rust/src/series.rs b/src/rust/src/series.rs index 40d785e87..9698dc7c9 100644 --- a/src/rust/src/series.rs +++ b/src/rust/src/series.rs @@ -30,15 +30,15 @@ use std::convert::TryInto; use std::result::Result; #[derive(Debug, Clone)] -pub struct Series(pub pl::Series); +pub struct RPolarsSeries(pub pl::Series); -impl From for Series { +impl From for RPolarsSeries { fn from(pls: polars::prelude::Series) -> Self { - Series(pls) + RPolarsSeries(pls) } } -impl From<&RPolarsExpr> for pl::PolarsResult { +impl From<&RPolarsExpr> for pl::PolarsResult { fn from(expr: &RPolarsExpr) -> Self { RPolarsDataFrame::default() .lazy() @@ -55,27 +55,27 @@ impl From<&RPolarsExpr> for pl::PolarsResult { } #[extendr] -impl Series { +impl RPolarsSeries { //utility methods - pub fn new(x: Robj, name: Robj) -> RResult { + pub fn new(x: Robj, name: Robj) -> RResult { robjname2series(x, robj_to!(Option, str, name)?.unwrap_or("")) .map_err(polars_to_rpolars_err) - .map(Series) + .map(RPolarsSeries) } // named like this to no collide with clone trait but still export with extendr #[allow(clippy::should_implement_trait)] - pub fn clone(&self) -> Series { - Series(self.0.clone()) + pub fn clone(&self) -> RPolarsSeries { + RPolarsSeries(self.0.clone()) } //function for debugging only - pub fn sleep(&self, millis: i32) -> Series { + pub fn sleep(&self, millis: i32) -> RPolarsSeries { std::thread::sleep(std::time::Duration::from_millis(millis as u64)); self.clone() } - pub fn panic(&self) -> Series { + pub fn panic(&self) -> RPolarsSeries { panic!("somebody panicked on purpose"); } @@ -107,7 +107,7 @@ impl Series { } pub fn sort_mut(&mut self, descending: bool) -> Self { - Series(self.0.sort(descending)) + RPolarsSeries(self.0.sort(descending)) } pub fn value_counts( @@ -150,7 +150,7 @@ impl Series { self.0.is_sorted(options).map_err(polars_to_rpolars_err) } - pub fn series_equal(&self, other: &Series, null_equal: bool, strict: bool) -> bool { + pub fn series_equal(&self, other: &RPolarsSeries, null_equal: bool, strict: bool) -> bool { if strict { self.0.eq(&other.0) } else if null_equal { @@ -192,7 +192,7 @@ impl Series { res } - pub fn compare(&self, other: &Series, op: String) -> List { + pub fn compare(&self, other: &RPolarsSeries, op: String) -> List { //try cast other to self, downcast(dc) to chunkedarray and compare with operator(op) elementwise macro_rules! comp { ($self:expr, $other:expr, $dc:ident, $op:expr) => {{ @@ -210,7 +210,7 @@ impl Series { "lt_eq" => lhs.lt_eq(rhs), _ => panic!("not supported operator"), }; - Ok(Series(ca_bool.into_series())) + Ok(RPolarsSeries(ca_bool.into_series())) }}; } @@ -232,7 +232,7 @@ impl Series { } //names repeat_ as repeat is locked keyword in R - pub fn rep(&self, n: Robj, rechunk: Robj) -> std::result::Result { + pub fn rep(&self, n: Robj, rechunk: Robj) -> std::result::Result { use crate::robj_to; self.rep_impl(robj_to!(usize, n)?, robj_to!(bool, rechunk)?) .map_err(|err| format!("{:?}", err)) @@ -250,14 +250,14 @@ impl Series { self.0.chunk_lengths().map(|val| val as f64).collect() } - pub fn abs(&self) -> RResult { - pl::abs(&self.0).map_err(polars_to_rpolars_err).map(Series) + pub fn abs(&self) -> RResult { + pl::abs(&self.0).map_err(polars_to_rpolars_err).map(RPolarsSeries) } - pub fn alias(&self, name: &str) -> Series { + pub fn alias(&self, name: &str) -> RPolarsSeries { let mut s = self.0.clone(); s.rename(name); - Series(s) + RPolarsSeries(s) } pub fn all(&self) -> List { @@ -298,27 +298,27 @@ impl Series { } } - pub fn add(&self, other: &Series) -> Self { + pub fn add(&self, other: &RPolarsSeries) -> Self { (&self.0 + &other.0).into() } - pub fn sub(&self, other: &Series) -> Self { + pub fn sub(&self, other: &RPolarsSeries) -> Self { (&self.0 - &other.0).into() } - pub fn mul(&self, other: &Series) -> Self { + pub fn mul(&self, other: &RPolarsSeries) -> Self { (&self.0 * &other.0).into() } - pub fn div(&self, other: &Series) -> Self { + pub fn div(&self, other: &RPolarsSeries) -> Self { (&self.0 / &other.0).into() } - pub fn rem(&self, other: &Series) -> Self { + pub fn rem(&self, other: &RPolarsSeries) -> Self { (&self.0 % &other.0).into() } - pub fn append_mut(&mut self, other: &Series) -> List { + pub fn append_mut(&mut self, other: &RPolarsSeries) -> List { r_result_list( self.0 .append(&other.0) @@ -371,7 +371,7 @@ impl Series { let y = ca_list.into_iter().map(|opt_ser| { if let Some(ser) = opt_ser { - rfun.call(pairlist!(Series(ser))).ok() + rfun.call(pairlist!(RPolarsSeries(ser))).ok() } else { unreachable!("internal error: oh it was possible to get a None Series"); } @@ -386,7 +386,7 @@ impl Series { }; //handle any return type from R and collect into Series - let s: extendr_api::Result = || -> extendr_api::Result { + let s: extendr_api::Result = || -> extendr_api::Result { match out_type { Float64 => apply_output!(r_iter, strict, allow_fail_eval, Doubles, Float64Chunked), Int32 => apply_output!(r_iter, strict, allow_fail_eval, Integers, Int32Chunked), @@ -398,7 +398,7 @@ impl Series { let xx = r_iter.map(|opt_r| -> pl::PolarsResult<_> { if let Some(robj) = opt_r { //convert Robj of Series or something "into series" to pl Series - let s = Series::any_robj_to_pl_series_result(robj)?; + let s = RPolarsSeries::any_robj_to_pl_series_result(robj)?; if s.len() > 1 { all_length_one = false; @@ -412,10 +412,10 @@ impl Series { let lc_res: pl::PolarsResult = xx.collect::>(); - let s: extendr_api::Result = lc_res + let s: extendr_api::Result = lc_res .map(|lc| lc.into_series()) .and_then(|s| if all_length_one { s.explode() } else { Ok(s) }) - .map(Series) + .map(RPolarsSeries) .map_err(|e| extendr_api::error::Error::Other(e.to_string())); s @@ -430,43 +430,43 @@ impl Series { x }); - //if ok rename with prefix apply, convert Result in r_result_list + //if ok rename with prefix apply, convert Result in r_result_list r_result_list(s) } pub fn mean(&self) -> Result { - Series(self.0.mean_as_series()).to_r() + RPolarsSeries(self.0.mean_as_series()).to_r() } pub fn median(&self) -> Result { - Series(self.0.median_as_series()).to_r() + RPolarsSeries(self.0.median_as_series()).to_r() } pub fn min(&self) -> Result { - Series(self.0.min_as_series()).to_r() + RPolarsSeries(self.0.min_as_series()).to_r() } pub fn max(&self) -> Result { - Series(self.0.max_as_series()).to_r() + RPolarsSeries(self.0.max_as_series()).to_r() } pub fn sum(&self) -> Result { - Series(self.0.sum_as_series()).to_r() + RPolarsSeries(self.0.sum_as_series()).to_r() } pub fn std(&self, ddof: Robj) -> Result { - Series(self.0.std_as_series(robj_to!(u8, ddof)?)).to_r() + RPolarsSeries(self.0.std_as_series(robj_to!(u8, ddof)?)).to_r() } pub fn var(&self, ddof: Robj) -> Result { - Series(self.0.var_as_series(robj_to!(u8, ddof)?)).to_r() + RPolarsSeries(self.0.var_as_series(robj_to!(u8, ddof)?)).to_r() } pub fn ceil(&self) -> List { r_result_list( self.0 .ceil() - .map(Series) + .map(RPolarsSeries) .map_err(|err| format!("{:?}", err)), ) } @@ -475,7 +475,7 @@ impl Series { r_result_list( self.0 .floor() - .map(Series) + .map(RPolarsSeries) .map_err(|err| format!("{:?}", err)), ) } @@ -484,10 +484,10 @@ impl Series { rprintln!("{:#?}", self.0); } - pub fn cum_sum(&self, reverse: bool) -> RResult { + pub fn cum_sum(&self, reverse: bool) -> RResult { pl::cum_sum(&self.0, reverse) .map_err(polars_to_rpolars_err) - .map(Series) + .map(RPolarsSeries) } pub fn to_frame(&self) -> std::result::Result { @@ -536,10 +536,10 @@ impl Series { } //inner_from_robj only when used within Series, do not have to comply with extendr_api macro supported types -impl Series { +impl RPolarsSeries { pub fn inner_from_robj_clone(robj: &Robj) -> std::result::Result { - if robj.check_external_ptr_type::() { - let x: Series = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + if robj.check_external_ptr_type::() { + let x: RPolarsSeries = unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(x) } else { Err("expected Series") @@ -547,10 +547,10 @@ impl Series { } pub fn any_robj_to_pl_series_result(robj: Robj) -> pl::PolarsResult { - let s = if !robj.inherits("Series") { + let s = if !robj.inherits("RPolarsSeries") { robjname2series(robj, "")? } else { - Series::inner_from_robj_clone(&robj) + RPolarsSeries::inner_from_robj_clone(&robj) .map_err(|err| { //convert any error from R to a polars error pl::PolarsError::ComputeError(err.into()) @@ -562,7 +562,7 @@ impl Series { pub fn rep_impl(&self, n: usize, rechunk: bool) -> pl::PolarsResult { if n == 0 { - return Ok(Series(self.clone().0.slice(0, 0))); + return Ok(RPolarsSeries(self.clone().0.slice(0, 0))); } let mut s = self.0.clone(); for _ in 1..n { @@ -571,7 +571,7 @@ impl Series { if rechunk { s = s.rechunk(); } - Ok(Series(s)) + Ok(RPolarsSeries(s)) } pub fn into_frame(&self) -> RPolarsDataFrame { @@ -579,13 +579,13 @@ impl Series { } } -impl From<&Series> for pl::Series { - fn from(x: &Series) -> Self { +impl From<&RPolarsSeries> for pl::Series { + fn from(x: &RPolarsSeries) -> Self { x.clone().0 } } extendr_module! { mod series; - impl Series; + impl RPolarsSeries; } diff --git a/src/rust/src/utils/mod.rs b/src/rust/src/utils/mod.rs index f8531329e..19ba5c90b 100644 --- a/src/rust/src/utils/mod.rs +++ b/src/rust/src/utils/mod.rs @@ -7,7 +7,7 @@ use crate::conversion_r_to_s::robjname2series; use crate::lazy::dsl::RPolarsExpr; use crate::rdatatype::RPolarsDataType; use crate::rpolarserr::{polars_to_rpolars_err, rdbg, rerr, RPolarsErr, RResult, WithRctx}; -use crate::series::Series; +use crate::series::RPolarsSeries; use std::any::type_name as tn; //use std::intrinsics::read_via_copy; @@ -222,7 +222,7 @@ macro_rules! apply_output { .collect::>() //if all ok collect into serias and rename .map(|ca| { - Series(ca.into_series()) + RPolarsSeries(ca.into_series()) }) }; } @@ -835,11 +835,11 @@ pub fn robj_to_dataframe(robj: extendr_api::Robj) -> RResult { .plain("could not be converted into a DataFrame") } -pub fn robj_to_series(robj: extendr_api::Robj) -> RResult { +pub fn robj_to_series(robj: extendr_api::Robj) -> RResult { let robj = unpack_r_result_list(robj)?; let robj_clone = robj.clone(); robjname2series(robj, "") - .map(Series) + .map(RPolarsSeries) .map_err(polars_to_rpolars_err) .bad_val(rdbg(robj_clone)) .plain("could not be converted into a DataFrame") diff --git a/tests/testthat/test-dataframe.R b/tests/testthat/test-dataframe.R index ba66b8091..e13cad019 100644 --- a/tests/testthat/test-dataframe.R +++ b/tests/testthat/test-dataframe.R @@ -569,7 +569,7 @@ test_that("drop_in_place", { expect_true("Species" %in% dat$columns) x = dat$drop_in_place("Species") expect_false("Species" %in% dat$columns) - expect_s3_class(x, "Series") + expect_s3_class(x, "RPolarsSeries") }) diff --git a/tests/testthat/test-rbackground.R b/tests/testthat/test-rbackground.R index 6a454d560..b6a159e47 100644 --- a/tests/testthat/test-rbackground.R +++ b/tests/testthat/test-rbackground.R @@ -11,7 +11,7 @@ test_that("Test collecting LazyFrame in background", { expect_equal(res_bg$to_data_frame(), compute$collect()$to_data_frame()) }) -test_that("Test using $map() in background", { +test_that("Test using $map_batches() in background", { skip_if_not(Sys.getenv("CI") == "true") # change capacity pl$set_options(rpool_cap = 0) @@ -22,8 +22,8 @@ test_that("Test using $map() in background", { expect_equal(pl$options$rpool_active, 0) - compute = lf$select(pl$col("y")$map(\(x) x * x, in_background = FALSE)) - compute_bg = lf$select(pl$col("y")$map(\(x) { + compute = lf$select(pl$col("y")$map_batches(\(x) x * x, in_background = FALSE)) + compute_bg = lf$select(pl$col("y")$map_batches(\(x) { Sys.sleep(.3) x * x }, in_background = TRUE)) @@ -96,7 +96,7 @@ test_that("reduce cap and active while jobs in queue", { pl$set_options(rpool_cap = 0) pl$set_options(rpool_cap = 3) l_expr = lapply(1:5, \(i) { - pl$lit(i)$map(\(x) { + pl$lit(i)$map_batches(\(x) { Sys.sleep(.4) -i }, in_background = TRUE)$alias(paste0("lit_", i)) diff --git a/tests/testthat/test-s3_methods.R b/tests/testthat/test-s3_methods.R index dea91ae70..fda749eab 100644 --- a/tests/testthat/test-s3_methods.R +++ b/tests/testthat/test-s3_methods.R @@ -73,14 +73,14 @@ make_cases = function() { "sum", "sum", sum, ) } -patrick::with_parameters_test_that("Series", +patrick::with_parameters_test_that("RPolarsSeries", { d = pl$Series(mtcars$mpg) x = base(mtcars$mpg) y = base(d) z = d[[pola]]() - if (inherits(y, "Series")) y <- y$to_vector() - if (inherits(z, "Series")) z <- z$to_vector() + if (inherits(y, "RPolarsSeries")) y <- y$to_vector() + if (inherits(z, "RPolarsSeries")) z <- z$to_vector() expect_equal(x, y, ignore_attr = TRUE) expect_equal(x, z, ignore_attr = TRUE) }, diff --git a/tests/testthat/test-series.R b/tests/testthat/test-series.R index e4d3e32a9..2f85b5022 100644 --- a/tests/testthat/test-series.R +++ b/tests/testthat/test-series.R @@ -94,7 +94,7 @@ test_that("pl$Series_abs", { c(42, 42, NA_real_) ) - expect_s3_class(s$abs(), "Series") + expect_s3_class(s$abs(), "RPolarsSeries") s_int = pl$Series(c(-42L, 42L, NA_integer_)) expect_identical( @@ -155,7 +155,7 @@ test_that("pl$Series_combine_c", { s2$to_vector(), s3$to_vector() ) - expect_s3_class(s2, "Series") + expect_s3_class(s2, "RPolarsSeries") }) @@ -521,7 +521,7 @@ patrick::with_parameters_test_that("mean, median, std, var", s = pl$Series(rnorm(100)) a = s[[.test_name]]() # upstream .std_as_series() does not appear to return Series - if (inherits(a, "Series")) a <- a$to_vector() + if (inherits(a, "RPolarsSeries")) a <- a$to_vector() b = base(s$to_vector()) expect_equal(a, b) }, From 45de20a4f50701b41fc8283834e9a3ebbe80bc95 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:37:19 +0100 Subject: [PATCH 06/32] bump news --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index eeadf685f..f99b9b0fd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ is renamed `$map_batches()`. `$map()` and `$apply()` will be removed in 0.13.0 (#534). - Removed `$days()`, `$hours()`, `$minutes()`, `$seconds()`, `$milliseconds()`, `$microseconds()`, `$nanoseconds()`. Those were deprecated in 0.11.0 (#550). +- The class name of `DataFrame`, `LazyFrame`, `Expr`, and `Series` objects has + changed. They now start with `RPolars`, for example `RPolarsDataFrame`. This + will only break your code if you directly use those class names, such as in + S3 methods (#554). ## What's changed From 4a220c3441e37ca1e22c6ced8550e939ebb7cb0a Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:44:39 +0100 Subject: [PATCH 07/32] cargo fmt --- src/rust/src/concat.rs | 7 +++- src/rust/src/concurrent.rs | 9 +++- src/rust/src/conversion_r_to_s.rs | 3 +- src/rust/src/lazy/dataframe.rs | 7 +++- src/rust/src/lazy/dsl.rs | 68 +++++++++++++++++++------------ src/rust/src/rbackground.rs | 7 ++-- src/rust/src/rdataframe/mod.rs | 11 ++++- src/rust/src/rlib.rs | 10 +++-- src/rust/src/series.rs | 7 +++- 9 files changed, 87 insertions(+), 42 deletions(-) diff --git a/src/rust/src/concat.rs b/src/rust/src/concat.rs index 978c6c1d8..b2c34d765 100644 --- a/src/rust/src/concat.rs +++ b/src/rust/src/concat.rs @@ -10,7 +10,12 @@ use polars_core::functions as pl_functions; use std::result::Result; #[extendr] -fn concat_lf(l: Robj, rechunk: bool, parallel: bool, to_supertypes: bool) -> RResult { +fn concat_lf( + l: Robj, + rechunk: bool, + parallel: bool, + to_supertypes: bool, +) -> RResult { let vlf = robj_to!(Vec, PLLazyFrame, l)?; dsl::concat( vlf, diff --git a/src/rust/src/concurrent.rs b/src/rust/src/concurrent.rs index 339461341..92e195d16 100644 --- a/src/rust/src/concurrent.rs +++ b/src/rust/src/concurrent.rs @@ -126,7 +126,9 @@ pub fn collect_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult RResult<(RPolarsDataFrame, RPolarsDataFrame)> { +pub fn profile_with_r_func_support( + lazy_df: pl::LazyFrame, +) -> RResult<(RPolarsDataFrame, RPolarsDataFrame)> { if ThreadCom::try_from_global(&CONFIG).is_ok() { lazy_df.profile() } else { @@ -146,7 +148,10 @@ pub fn profile_with_r_func_support(lazy_df: pl::LazyFrame) -> RResult<(RPolarsDa .map(|(result_df, profile_df)| (RPolarsDataFrame(result_df), RPolarsDataFrame(profile_df))) } -pub fn fetch_with_r_func_support(lazy_df: pl::LazyFrame, n_rows: usize) -> RResult { +pub fn fetch_with_r_func_support( + lazy_df: pl::LazyFrame, + n_rows: usize, +) -> RResult { if ThreadCom::try_from_global(&CONFIG).is_ok() { lazy_df.fetch(n_rows) } else { diff --git a/src/rust/src/conversion_r_to_s.rs b/src/rust/src/conversion_r_to_s.rs index 9b0d3f061..9eb49faf6 100644 --- a/src/rust/src/conversion_r_to_s.rs +++ b/src/rust/src/conversion_r_to_s.rs @@ -59,7 +59,8 @@ fn recursive_robjname2series_tree(x: &Robj, name: &str) -> pl::PolarsResult match () { _ if x.inherits("RPolarsSeries") => { - let s: RPolarsSeries = unsafe { &mut *x.external_ptr_addr::() }.clone(); + let s: RPolarsSeries = + unsafe { &mut *x.external_ptr_addr::() }.clone(); Ok(SeriesTree::Series(s.0)) } _ => Err(pl::PolarsError::InvalidOperation( diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index 0f8382816..b2c49227c 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -312,7 +312,12 @@ impl RPolarsLazyFrame { } } - fn unique(&self, subset: Robj, keep: Robj, maintain_order: Robj) -> Result { + fn unique( + &self, + subset: Robj, + keep: Robj, + maintain_order: Robj, + ) -> Result { let ke = new_unique_keep_strategy(robj_to!(str, keep)?)?; let maintain_order = robj_to!(bool, maintain_order)?; let subset = robj_to!(Option, Vec, String, subset)?; diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index 2a866c60d..6a62c05b8 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -145,12 +145,14 @@ impl RPolarsExpr { } (Rtype::ExternalPtr, 1) => match () { _ if robj.inherits("RPolarsSeries") => { - let s: RPolarsSeries = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + let s: RPolarsSeries = + unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(pl::lit(s.0)) } _ if robj.inherits("RPolarsExpr") => { - let expr: RPolarsExpr = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + let expr: RPolarsExpr = + unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(expr.0) } @@ -330,7 +332,7 @@ impl RPolarsExpr { } pub fn fill_null_with_strategy(&self, strategy: &str, limit: Nullable) -> List { - let res = || -> Result { + let res = || -> Result { let limit = null_to_opt(limit).map(try_f64_into_usize).transpose()?; let limit: pl::FillNullLimit = limit.map(|x| x as u32); @@ -455,7 +457,7 @@ impl RPolarsExpr { seed_1: Robj, seed_2: Robj, seed_3: Robj, - ) -> Result { + ) -> Result { Ok(RPolarsExpr(self.0.clone().hash( robj_to!(u64, seed)?, robj_to!(u64, seed_1)?, @@ -707,7 +709,7 @@ impl RPolarsExpr { } fn diff(&self, n_float: f64, null_behavior: &str) -> List { - let expr_res = || -> Result { + let expr_res = || -> Result { Ok(RPolarsExpr(self.0.clone().diff( try_f64_into_i64(n_float)?, new_null_behavior(null_behavior)?, @@ -718,7 +720,9 @@ impl RPolarsExpr { } fn pct_change(&self, n_float: Robj) -> RResult { - Ok(RPolarsExpr(self.0.clone().pct_change(robj_to!(PLExpr, n_float)?))) + Ok(RPolarsExpr( + self.0.clone().pct_change(robj_to!(PLExpr, n_float)?), + )) } fn skew(&self, bias: bool) -> Self { @@ -860,7 +864,7 @@ impl RPolarsExpr { } pub fn ewm_mean(&self, alpha: f64, adjust: bool, min_periods: f64, ignore_nulls: bool) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -882,7 +886,7 @@ impl RPolarsExpr { min_periods: f64, ignore_nulls: bool, ) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -904,7 +908,7 @@ impl RPolarsExpr { min_periods: f64, ignore_nulls: bool, ) -> List { - let expr_result = || -> Result { + let expr_result = || -> Result { let min_periods = try_f64_into_usize(min_periods)?; let options = pl::EWMOptions { alpha, @@ -919,7 +923,7 @@ impl RPolarsExpr { } pub fn extend_constant(&self, value: &RPolarsExpr, n: f64) -> List { - let expr_res = || -> Result { + let expr_res = || -> Result { let av = match value.clone().0 { pl::Expr::Literal(ma) => literal_to_any_value(ma), ma => Err(format!("value [{:?}] was not a literal:", ma)), @@ -1093,7 +1097,7 @@ impl RPolarsExpr { } fn list_diff(&self, n: f64, null_behavior: &str) -> List { - let expr_res = || -> Result { + let expr_res = || -> Result { Ok(RPolarsExpr(self.0.clone().list().diff( try_f64_into_i64(n)?, new_null_behavior(null_behavior)?, @@ -1104,7 +1108,7 @@ impl RPolarsExpr { } fn list_shift(&self, periods: Robj) -> List { - let expr_res = || -> Result { + let expr_res = || -> Result { Ok(RPolarsExpr( self.0.clone().list().shift(robj_to!(PLExpr, periods)?), )) @@ -1156,10 +1160,12 @@ impl RPolarsExpr { }; //resolve usize from f64 and stategy from str - let res = || -> Result { + let res = || -> Result { let ub = try_f64_into_usize(upper_bound)?; let strat = new_width_strategy(width_strat)?; - Ok(RPolarsExpr(self.0.clone().list().to_struct(strat, name_gen, ub))) + Ok(RPolarsExpr( + self.0.clone().list().to_struct(strat, name_gen, ub), + )) }(); let res = res.map_err(|err| format!("in to_struct: {}", err)); @@ -1985,7 +1991,7 @@ impl RPolarsExpr { } pub fn str_json_path_match(&self, pat: Robj) -> List { - let res = || -> Result { + let res = || -> Result { use pl::*; let pat: String = robj_to!(String, pat, "in str$json_path_match: {}")?; let function = move |s: Series| { @@ -2068,7 +2074,7 @@ impl RPolarsExpr { } pub fn str_extract(&self, pattern: Robj, group_index: Robj) -> List { - let res = || -> Result { + let res = || -> Result { let pat = robj_to!(String, pattern)?; let gi = robj_to!(usize, group_index)?; Ok(self.0.clone().str().extract(pat.as_str(), gi).into()) @@ -2091,7 +2097,7 @@ impl RPolarsExpr { } //NOTE SHOW CASE all R side argument handling - pub fn str_split(&self, by: Robj, inclusive: Robj) -> Result { + pub fn str_split(&self, by: Robj, inclusive: Robj) -> Result { let by = robj_to!(PLExpr, by)?; let inclusive = robj_to!(bool, inclusive)?; if inclusive { @@ -2103,7 +2109,12 @@ impl RPolarsExpr { //NOTE SHOW CASE all rust side argument handling, n is usize and had to be //handled on rust side anyways - pub fn str_split_exact(&self, by: Robj, n: Robj, inclusive: Robj) -> Result { + pub fn str_split_exact( + &self, + by: Robj, + n: Robj, + inclusive: Robj, + ) -> Result { let by = robj_to!(PLExpr, by)?; let n = robj_to!(usize, n)?; let inclusive = robj_to!(bool, inclusive)?; @@ -2115,7 +2126,7 @@ impl RPolarsExpr { .into()) } - pub fn str_splitn(&self, by: Robj, n: Robj) -> Result { + pub fn str_splitn(&self, by: Robj, n: Robj) -> Result { Ok(self .0 .clone() @@ -2124,7 +2135,12 @@ impl RPolarsExpr { .into()) } - pub fn str_replace(&self, pattern: Robj, value: Robj, literal: Robj) -> Result { + pub fn str_replace( + &self, + pattern: Robj, + value: Robj, + literal: Robj, + ) -> Result { Ok(self .0 .clone() @@ -2142,7 +2158,7 @@ impl RPolarsExpr { pattern: Robj, value: Robj, literal: Robj, - ) -> Result { + ) -> Result { Ok(self .0 .clone() @@ -2155,14 +2171,14 @@ impl RPolarsExpr { .into()) } - pub fn str_slice(&self, offset: Robj, length: Robj) -> Result { + pub fn str_slice(&self, offset: Robj, length: Robj) -> Result { let offset = robj_to!(i64, offset)?; let length = robj_to!(Option, u64, length)?; Ok(self.clone().0.str().slice(offset, length).into()) } - pub fn str_explode(&self) -> Result { + pub fn str_explode(&self) -> Result { Ok(self.0.clone().str().explode().into()) } @@ -2255,7 +2271,7 @@ impl RPolarsExpr { .into() } - pub fn struct_field_by_name(&self, name: Robj) -> Result { + pub fn struct_field_by_name(&self, name: Robj) -> Result { Ok(self .0 .clone() @@ -2268,7 +2284,7 @@ impl RPolarsExpr { // self.0.clone().struct_().field_by_index(index).into() // } - pub fn struct_rename_fields(&self, names: Robj) -> Result { + pub fn struct_rename_fields(&self, names: Robj) -> Result { let string_vec: Vec = robj_to!(Vec, String, names)?; Ok(self.0.clone().struct_().rename_fields(string_vec).into()) } @@ -2328,7 +2344,7 @@ impl RPolarsExpr { Ok(format!("{e}")) } - fn cat_set_ordering(&self, ordering: Robj) -> Result { + fn cat_set_ordering(&self, ordering: Robj) -> Result { let ordering = robj_to!(Map, str, ordering, |s| { Ok(crate::rdatatype::new_categorical_ordering(s).map_err(Rctx::Plain)?) })?; diff --git a/src/rust/src/rbackground.rs b/src/rust/src/rbackground.rs index 83b4b4653..cfc9e4621 100644 --- a/src/rust/src/rbackground.rs +++ b/src/rust/src/rbackground.rs @@ -194,9 +194,10 @@ impl RIPCJob { .ok_or(RPolarsErr::new()) .bad_val(rdbg(func_robj)) .mistyped("pure R function")?; - let shared_memory = serialize_series(RPolarsSeries::any_robj_to_pl_series_result( - func.call(pairlist!(RPolarsSeries(series)))?, - )?)?; + let shared_memory = + serialize_series(RPolarsSeries::any_robj_to_pl_series_result( + func.call(pairlist!(RPolarsSeries(series)))?, + )?)?; RResult::Ok(ipc::IpcSharedMemory::from_bytes(shared_memory.as_slice())) }; collector.send(bits().when( diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index 8b72c4823..66f42b507 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -192,7 +192,12 @@ impl RPolarsDataFrame { } pub fn get_columns(&self) -> List { - let mut l = List::from_values(self.0.get_columns().iter().map(|x| RPolarsSeries(x.clone()))); + let mut l = List::from_values( + self.0 + .get_columns() + .iter() + .map(|x| RPolarsSeries(x.clone())), + ); l.set_names(self.0.get_column_names()).unwrap(); l } @@ -350,7 +355,9 @@ impl RPolarsDataFrame { } pub fn from_arrow_record_batches(rbr: Robj) -> Result { - Ok(RPolarsDataFrame(crate::arrow_interop::to_rust::to_rust_df(rbr)?)) + Ok(RPolarsDataFrame(crate::arrow_interop::to_rust::to_rust_df( + rbr, + )?)) } pub fn estimated_size(&self) -> f64 { diff --git a/src/rust/src/rlib.rs b/src/rust/src/rlib.rs index 265298ce5..4d7dddd42 100644 --- a/src/rust/src/rlib.rs +++ b/src/rust/src/rlib.rs @@ -1,4 +1,4 @@ -use crate::lazy::dsl::{RPolarsExpr, ProtoExprArray}; +use crate::lazy::dsl::{ProtoExprArray, RPolarsExpr}; use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::{rdbg, RResult}; @@ -63,9 +63,11 @@ fn coalesce_exprs(exprs: &ProtoExprArray) -> RPolarsExpr { } #[extendr] -fn concat_list(exprs: &ProtoExprArray) -> Result { +fn concat_list(exprs: &ProtoExprArray) -> Result { let exprs = exprs.to_vec("select"); - Ok(RPolarsExpr(pl::concat_list(exprs).map_err(|err| err.to_string())?)) + Ok(RPolarsExpr( + pl::concat_list(exprs).map_err(|err| err.to_string())?, + )) } #[extendr] @@ -105,7 +107,7 @@ fn r_date_range_lazy( //TODO py-polars have some fancy transmute conversions TOExprs trait, maybe imple that too //for now just use inner directly #[extendr] -fn as_struct(exprs: Robj) -> Result { +fn as_struct(exprs: Robj) -> Result { Ok(pl::as_struct(crate::utils::list_expr_to_vec_pl_expr(exprs, true, true)?).into()) } diff --git a/src/rust/src/series.rs b/src/rust/src/series.rs index 9698dc7c9..4b8b7567f 100644 --- a/src/rust/src/series.rs +++ b/src/rust/src/series.rs @@ -251,7 +251,9 @@ impl RPolarsSeries { } pub fn abs(&self) -> RResult { - pl::abs(&self.0).map_err(polars_to_rpolars_err).map(RPolarsSeries) + pl::abs(&self.0) + .map_err(polars_to_rpolars_err) + .map(RPolarsSeries) } pub fn alias(&self, name: &str) -> RPolarsSeries { @@ -539,7 +541,8 @@ impl RPolarsSeries { impl RPolarsSeries { pub fn inner_from_robj_clone(robj: &Robj) -> std::result::Result { if robj.check_external_ptr_type::() { - let x: RPolarsSeries = unsafe { &mut *robj.external_ptr_addr::() }.clone(); + let x: RPolarsSeries = + unsafe { &mut *robj.external_ptr_addr::() }.clone(); Ok(x) } else { Err("expected Series") From ac6efe64a32328cc6d62af43960c61500ade11a5 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:06:58 +0100 Subject: [PATCH 08/32] update nanoarrow docs --- man/nanoarrow.Rd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man/nanoarrow.Rd b/man/nanoarrow.Rd index 3ecaf02a4..4ff88a261 100644 --- a/man/nanoarrow.Rd +++ b/man/nanoarrow.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/pkg-nanoarrow.R \name{nanoarrow} \alias{nanoarrow} -\alias{as_nanoarrow_array_stream.DataFrame} +\alias{as_nanoarrow_array_stream.RPolarsDataFrame} \alias{array_stream} \alias{arrow} \alias{record_batch_reader} @@ -11,18 +11,18 @@ \alias{more} \alias{at} \alias{\url{https://github.com/apache/arrow-nanoarrow/r}} -\alias{infer_nanoarrow_schema.DataFrame} -\alias{as_arrow_table.DataFrame} -\alias{as_record_batch_reader.DataFrame} +\alias{infer_nanoarrow_schema.RPolarsDataFrame} +\alias{as_arrow_table.RPolarsDataFrame} +\alias{as_record_batch_reader.RPolarsDataFrame} \title{polars to nanoarrow and arrow} \usage{ -\method{as_nanoarrow_array_stream}{DataFrame}(x, ..., schema = NULL) +as_nanoarrow_array_stream.RPolarsDataFrame(x, ..., schema = NULL) -\method{infer_nanoarrow_schema}{DataFrame}(x, ...) +infer_nanoarrow_schema.RPolarsDataFrame(x, ...) -\method{as_arrow_table}{DataFrame}(x, ...) +as_arrow_table.RPolarsDataFrame(x, ...) -\method{as_record_batch_reader}{DataFrame}(x, ..., schema = NULL) +as_record_batch_reader.RPolarsDataFrame(x, ..., schema = NULL) } \arguments{ \item{x}{a polars DataFrame} From 3e3cded2a46f836e080fe04e4e1de90d34993709 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:17:23 +0100 Subject: [PATCH 09/32] forgot some RPolarsLazyFrame --- src/rust/src/sql.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rust/src/sql.rs b/src/rust/src/sql.rs index 87fbf4fa0..b587e3161 100644 --- a/src/rust/src/sql.rs +++ b/src/rust/src/sql.rs @@ -3,7 +3,7 @@ use extendr_api::prelude::*; use polars::sql::SQLContext; -use crate::{rdataframe::LazyFrame, robj_to, rpolarserr::*}; +use crate::{rdataframe::RPolarsLazyFrame, robj_to, rpolarserr::*}; #[derive(Clone)] pub struct RPolarsSQLContext { @@ -33,7 +33,7 @@ impl RPolarsSQLContext { pub fn register(&mut self, name: Robj, lf: Robj) -> RResult<()> { Ok(self .context - .register(&robj_to!(str, name)?, robj_to!(LazyFrame, lf)?.0)) + .register(&robj_to!(str, name)?, robj_to!(RPolarsLazyFrame, lf)?.0)) } pub fn unregister(&mut self, name: Robj) -> RResult<()> { From c2d12e52ece86127888edeed7fc26dc0b8feddab Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:27:07 +0100 Subject: [PATCH 10/32] fix --- src/rust/src/sql.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/src/sql.rs b/src/rust/src/sql.rs index b587e3161..3efe8e231 100644 --- a/src/rust/src/sql.rs +++ b/src/rust/src/sql.rs @@ -33,7 +33,7 @@ impl RPolarsSQLContext { pub fn register(&mut self, name: Robj, lf: Robj) -> RResult<()> { Ok(self .context - .register(&robj_to!(str, name)?, robj_to!(RPolarsLazyFrame, lf)?.0)) + .register(&robj_to!(str, name)?, robj_to!(LazyFrame, lf)?.0)) } pub fn unregister(&mut self, name: Robj) -> RResult<()> { From 2ad5ea703ef547cbd73767090e02ca40c4abebe5 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:32:07 +0100 Subject: [PATCH 11/32] fix --- R/after-wrappers.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index d0e546a49..1c318cd24 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -77,7 +77,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { #' # show all content of .pr #' .pr$print_env(.pr, ".pr the collection of private method calls to rust-polars") .pr = new.env(parent = emptyenv()) -.pr$Series = extendr_method_to_pure_functions(Series) +.pr$Series = extendr_method_to_pure_functions(RPolarsSeries) .pr$DataFrame = extendr_method_to_pure_functions(RPolarsDataFrame) .pr$GroupBy = NULL # derived from DataFrame in R, has no rust calls .pr$LazyFrame = extendr_method_to_pure_functions(RPolarsLazyFrame) From 88083e41d9ca1ac2e373eb628180f752db69a8d1 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:42:00 +0100 Subject: [PATCH 12/32] LazyGroupBy -> RPolarsLazyGroupBy [skip ci] --- NAMESPACE | 10 +++++----- R/after-wrappers.R | 6 +++--- R/as_polars.R | 4 ++-- R/extendr-wrappers.R | 20 ++++++++++++------- R/lazyframe__group_by.R | 2 +- man/as_polars_df.Rd | 4 ++-- man/as_polars_lf.Rd | 4 ++-- ...GroupBy.Rd => print.RPolarsLazyGroupBy.Rd} | 6 +++--- src/rust/src/lazy/dataframe.rs | 12 +++++------ 9 files changed, 37 insertions(+), 31 deletions(-) rename man/{print.LazyGroupBy.Rd => print.RPolarsLazyGroupBy.Rd} (70%) diff --git a/NAMESPACE b/NAMESPACE index 956d88b7c..537055366 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,6 @@ S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) S3method("$",ExprStructNameSpace) S3method("$",GroupBy) -S3method("$",LazyGroupBy) S3method("$",ProtoExprArray) S3method("$",RField) S3method("$",RNullValues) @@ -25,6 +24,7 @@ S3method("$",RPolarsDataType) S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) +S3method("$",RPolarsLazyGroupBy) S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) S3method("$",RPolarsStringCacheHolder) @@ -67,7 +67,6 @@ S3method("[[",ChainedThen) S3method("[[",ChainedWhen) S3method("[[",DataTypeVector) S3method("[[",GroupBy) -S3method("[[",LazyGroupBy) S3method("[[",ProtoExprArray) S3method("[[",RField) S3method("[[",RNullValues) @@ -76,6 +75,7 @@ S3method("[[",RPolarsDataType) S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) +S3method("[[",RPolarsLazyGroupBy) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) S3method("[[",RPolarsStringCacheHolder) @@ -112,14 +112,14 @@ S3method(as.matrix,RPolarsLazyFrame) S3method(as.vector,RPolarsSeries) S3method(as_polars_df,ArrowTabular) S3method(as_polars_df,GroupBy) -S3method(as_polars_df,LazyGroupBy) S3method(as_polars_df,RPolarsDataFrame) S3method(as_polars_df,RPolarsLazyFrame) +S3method(as_polars_df,RPolarsLazyGroupBy) S3method(as_polars_df,RPolarsSeries) S3method(as_polars_df,data.frame) S3method(as_polars_df,default) -S3method(as_polars_lf,LazyGroupBy) S3method(as_polars_lf,RPolarsLazyFrame) +S3method(as_polars_lf,RPolarsLazyGroupBy) S3method(as_polars_lf,default) S3method(as_polars_series,POSIXlt) S3method(as_polars_series,default) @@ -153,7 +153,6 @@ S3method(names,RPolarsLazyFrame) S3method(print,ChainedThen) S3method(print,ChainedWhen) S3method(print,GroupBy) -S3method(print,LazyGroupBy) S3method(print,PTime) S3method(print,RField) S3method(print,RPolarsDataFrame) @@ -161,6 +160,7 @@ S3method(print,RPolarsDataType) S3method(print,RPolarsErr) S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) +S3method(print,RPolarsLazyGroupBy) S3method(print,RPolarsSeries) S3method(print,RThreadHandle) S3method(print,Then) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index 1c318cd24..fc0c1f4c4 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -81,7 +81,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$DataFrame = extendr_method_to_pure_functions(RPolarsDataFrame) .pr$GroupBy = NULL # derived from DataFrame in R, has no rust calls .pr$LazyFrame = extendr_method_to_pure_functions(RPolarsLazyFrame) -.pr$LazyGroupBy = extendr_method_to_pure_functions(LazyGroupBy) +.pr$LazyGroupBy = extendr_method_to_pure_functions(RPolarsLazyGroupBy) .pr$DataType = extendr_method_to_pure_functions(RPolarsDataType) .pr$DataTypeVector = extendr_method_to_pure_functions(DataTypeVector) .pr$RField = extendr_method_to_pure_functions(RField) @@ -267,8 +267,8 @@ DataType = clone_env_one_level_deep(RPolarsDataType) # used for printing public environment pl_class_names = sort( c( - "RPolarsLazyFrame", "RPolarsSeries", "LazyGroupBy", "DataType", "RPolarsExpr", - "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", + "RPolarsLazyFrame", "RPolarsSeries", "RPolarsLazyGroupBy", "RPolarsDataType", + "RPolarsExpr", "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", "RPolarsSQLContext" ) ) # TODO discover all public class automatically diff --git a/R/as_polars.R b/R/as_polars.R index 860b5929a..dabd0076e 100644 --- a/R/as_polars.R +++ b/R/as_polars.R @@ -102,7 +102,7 @@ as_polars_df.RPolarsLazyFrame = function( #' @rdname as_polars_df #' @export -as_polars_df.LazyGroupBy = function(x, ...) { +as_polars_df.RPolarsLazyGroupBy = function(x, ...) { as_polars_df.RPolarsLazyFrame(x$ungroup(), ...) } @@ -160,6 +160,6 @@ as_polars_lf.RPolarsLazyFrame = function(x, ...) { #' @rdname as_polars_lf #' @export -as_polars_lf.LazyGroupBy = function(x, ...) { +as_polars_lf.RPolarsLazyGroupBy = function(x, ...) { x$ungroup() } diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 562a2bb3d..362faa797 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -1129,22 +1129,28 @@ RPolarsLazyFrame <- LazyFrame LazyGroupBy <- new.env(parent = emptyenv()) -LazyGroupBy$print <- function() invisible(.Call(wrap__LazyGroupBy__print, self)) +LazyGroupBy$print <- function() invisible(.Call(wrap__RPolarsLazyGroupBy__print, self)) -LazyGroupBy$clone_in_rust <- function() .Call(wrap__LazyGroupBy__clone_in_rust, self) +LazyGroupBy$clone_in_rust <- function() .Call(wrap__RPolarsLazyGroupBy__clone_in_rust, self) -LazyGroupBy$ungroup <- function() .Call(wrap__LazyGroupBy__ungroup, self) +LazyGroupBy$ungroup <- function() .Call(wrap__RPolarsLazyGroupBy__ungroup, self) -LazyGroupBy$agg <- function(exprs) .Call(wrap__LazyGroupBy__agg, self, exprs) +LazyGroupBy$agg <- function(exprs) .Call(wrap__RPolarsLazyGroupBy__agg, self, exprs) -LazyGroupBy$head <- function(n) .Call(wrap__LazyGroupBy__head, self, n) +LazyGroupBy$head <- function(n) .Call(wrap__RPolarsLazyGroupBy__head, self, n) -LazyGroupBy$tail <- function(n) .Call(wrap__LazyGroupBy__tail, self, n) +LazyGroupBy$tail <- function(n) .Call(wrap__RPolarsLazyGroupBy__tail, self, n) + +RPolarsLazyGroupBy <- LazyGroupBy #' @export -`$.LazyGroupBy` <- function (self, name) { func <- LazyGroupBy[[name]]; environment(func) <- environment(); func } +`$.RPolarsLazyGroupBy` <- function (self, name) { func <- RPolarsLazyGroupBy[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsLazyGroupBy` <- `$.RPolarsLazyGroupBy` + +`$.LazyGroupBy` <- function (self, name) { func <- LazyGroupBy[[name]]; environment(func) <- environment(); func } + `[[.LazyGroupBy` <- `$.LazyGroupBy` Series <- new.env(parent = emptyenv()) diff --git a/R/lazyframe__group_by.R b/R/lazyframe__group_by.R index 86a6adc9b..89f4a83a6 100644 --- a/R/lazyframe__group_by.R +++ b/R/lazyframe__group_by.R @@ -9,7 +9,7 @@ #' @keywords internal #' @export #' -print.LazyGroupBy = function(x, ...) { +print.RPolarsLazyGroupBy = function(x, ...) { cat("polars LazyGroupBy: \n") x$print() } diff --git a/man/as_polars_df.Rd b/man/as_polars_df.Rd index bb36e51ad..48972c4bd 100644 --- a/man/as_polars_df.Rd +++ b/man/as_polars_df.Rd @@ -8,7 +8,7 @@ \alias{as_polars_df.GroupBy} \alias{as_polars_df.RPolarsSeries} \alias{as_polars_df.RPolarsLazyFrame} -\alias{as_polars_df.LazyGroupBy} +\alias{as_polars_df.RPolarsLazyGroupBy} \alias{as_polars_df.ArrowTabular} \title{To polars DataFrame} \usage{ @@ -41,7 +41,7 @@ as_polars_df(x, ...) collect_in_background = FALSE ) -\method{as_polars_df}{LazyGroupBy}(x, ...) +\method{as_polars_df}{RPolarsLazyGroupBy}(x, ...) \method{as_polars_df}{ArrowTabular}(x, ..., rechunk = TRUE, schema = NULL, schema_overrides = NULL) } diff --git a/man/as_polars_lf.Rd b/man/as_polars_lf.Rd index bd7781e4d..364a10d01 100644 --- a/man/as_polars_lf.Rd +++ b/man/as_polars_lf.Rd @@ -4,7 +4,7 @@ \alias{as_polars_lf} \alias{as_polars_lf.default} \alias{as_polars_lf.RPolarsLazyFrame} -\alias{as_polars_lf.LazyGroupBy} +\alias{as_polars_lf.RPolarsLazyGroupBy} \title{To polars LazyFrame} \usage{ as_polars_lf(x, ...) @@ -13,7 +13,7 @@ as_polars_lf(x, ...) \method{as_polars_lf}{RPolarsLazyFrame}(x, ...) -\method{as_polars_lf}{LazyGroupBy}(x, ...) +\method{as_polars_lf}{RPolarsLazyGroupBy}(x, ...) } \arguments{ \item{x}{Object to convert to a polars DataFrame.} diff --git a/man/print.LazyGroupBy.Rd b/man/print.RPolarsLazyGroupBy.Rd similarity index 70% rename from man/print.LazyGroupBy.Rd rename to man/print.RPolarsLazyGroupBy.Rd index 4e1f9736f..ea4057b96 100644 --- a/man/print.LazyGroupBy.Rd +++ b/man/print.RPolarsLazyGroupBy.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/lazyframe__group_by.R -\name{print.LazyGroupBy} -\alias{print.LazyGroupBy} +\name{print.RPolarsLazyGroupBy} +\alias{print.RPolarsLazyGroupBy} \title{print LazyGroupBy} \usage{ -\method{print}{LazyGroupBy}(x, ...) +\method{print}{RPolarsLazyGroupBy}(x, ...) } \arguments{ \item{x}{LazyGroupBy} diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index b2c49227c..43ae79fde 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -329,16 +329,16 @@ impl RPolarsLazyFrame { Ok(lf.into()) } - fn group_by(&self, exprs: Robj, maintain_order: Robj) -> Result { + fn group_by(&self, exprs: Robj, maintain_order: Robj) -> Result { let expr_vec = robj_to!(VecPLExprCol, exprs)?; let maintain_order = robj_to!(Option, bool, maintain_order)?.unwrap_or(false); if maintain_order { - Ok(LazyGroupBy { + Ok(RPolarsLazyGroupBy { lgb: self.0.clone().group_by_stable(expr_vec), opt_state: self.0.get_current_optimizations(), }) } else { - Ok(LazyGroupBy { + Ok(RPolarsLazyGroupBy { lgb: self.0.clone().group_by(expr_vec), opt_state: self.0.get_current_optimizations(), }) @@ -592,13 +592,13 @@ impl RPolarsLazyFrame { } #[derive(Clone)] -pub struct LazyGroupBy { +pub struct RPolarsLazyGroupBy { pub lgb: pl::LazyGroupBy, opt_state: pl::OptState, } #[extendr] -impl LazyGroupBy { +impl RPolarsLazyGroupBy { fn print(&self) { rprintln!("LazyGroupBy (internals are opaque)"); } @@ -640,5 +640,5 @@ impl LazyGroupBy { extendr_module! { mod dataframe; impl RPolarsLazyFrame; - impl LazyGroupBy; + impl RPolarsLazyGroupBy; } From a68afdd8b4fa2ab974af456542ccbcaac15cea1a Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:05:21 +0100 Subject: [PATCH 13/32] rename Then, When, ChainedThen, ChainedWhen --- NAMESPACE | 32 ++++++------- R/after-wrappers.R | 12 ++--- R/extendr-wrappers.R | 46 ++++++++++++++----- R/functions__whenthen.R | 16 +++---- ... => dot-DollarNames.RPolarsChainedThen.Rd} | 6 +-- ... => dot-DollarNames.RPolarsChainedWhen.Rd} | 6 +-- ...Then.Rd => dot-DollarNames.RPolarsThen.Rd} | 6 +-- ...When.Rd => dot-DollarNames.RPolarsWhen.Rd} | 6 +-- man/nanoarrow.Rd | 8 ++-- ...nedThen.Rd => print.RPolarsChainedThen.Rd} | 6 +-- ...nedWhen.Rd => print.RPolarsChainedWhen.Rd} | 6 +-- man/{print.Then.Rd => print.RPolarsThen.Rd} | 6 +-- man/{print.When.Rd => print.RPolarsWhen.Rd} | 6 +-- src/rust/src/lazy/whenthen.rs | 44 +++++++++--------- 14 files changed, 115 insertions(+), 91 deletions(-) rename man/{dot-DollarNames.ChainedThen.Rd => dot-DollarNames.RPolarsChainedThen.Rd} (71%) rename man/{dot-DollarNames.ChainedWhen.Rd => dot-DollarNames.RPolarsChainedWhen.Rd} (71%) rename man/{dot-DollarNames.Then.Rd => dot-DollarNames.RPolarsThen.Rd} (74%) rename man/{dot-DollarNames.When.Rd => dot-DollarNames.RPolarsWhen.Rd} (74%) rename man/{print.ChainedThen.Rd => print.RPolarsChainedThen.Rd} (78%) rename man/{print.ChainedWhen.Rd => print.RPolarsChainedWhen.Rd} (78%) rename man/{print.Then.Rd => print.RPolarsThen.Rd} (79%) rename man/{print.When.Rd => print.RPolarsWhen.Rd} (78%) diff --git a/NAMESPACE b/NAMESPACE index 537055366..d9b5597b7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,8 +4,6 @@ S3method("!",RPolarsExpr) S3method("!=",RPolarsDataType) S3method("!=",RPolarsExpr) S3method("!=",RPolarsSeries) -S3method("$",ChainedThen) -S3method("$",ChainedWhen) S3method("$",DataTypeVector) S3method("$",ExprBinNameSpace) S3method("$",ExprCatNameSpace) @@ -19,6 +17,8 @@ S3method("$",GroupBy) S3method("$",ProtoExprArray) S3method("$",RField) S3method("$",RNullValues) +S3method("$",RPolarsChainedThen) +S3method("$",RPolarsChainedWhen) S3method("$",RPolarsDataFrame) S3method("$",RPolarsDataType) S3method("$",RPolarsErr) @@ -28,10 +28,10 @@ S3method("$",RPolarsLazyGroupBy) S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) S3method("$",RPolarsStringCacheHolder) +S3method("$",RPolarsThen) +S3method("$",RPolarsWhen) S3method("$",RThreadHandle) -S3method("$",Then) S3method("$",VecDataFrame) -S3method("$",When) S3method("$",pl_polars_env) S3method("$",private_polars_env) S3method("$<-",RField) @@ -63,13 +63,13 @@ S3method("[",RPolarsDataFrame) S3method("[",RPolarsLazyFrame) S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) -S3method("[[",ChainedThen) -S3method("[[",ChainedWhen) S3method("[[",DataTypeVector) S3method("[[",GroupBy) S3method("[[",ProtoExprArray) S3method("[[",RField) S3method("[[",RNullValues) +S3method("[[",RPolarsChainedThen) +S3method("[[",RPolarsChainedWhen) S3method("[[",RPolarsDataFrame) S3method("[[",RPolarsDataType) S3method("[[",RPolarsErr) @@ -79,26 +79,26 @@ S3method("[[",RPolarsLazyGroupBy) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) S3method("[[",RPolarsStringCacheHolder) +S3method("[[",RPolarsThen) +S3method("[[",RPolarsWhen) S3method("[[",RThreadHandle) -S3method("[[",Then) S3method("[[",VecDataFrame) -S3method("[[",When) S3method("^",RPolarsExpr) S3method("|",RPolarsExpr) -S3method(.DollarNames,ChainedThen) -S3method(.DollarNames,ChainedWhen) S3method(.DollarNames,GroupBy) S3method(.DollarNames,RField) +S3method(.DollarNames,RPolarsChainedThen) +S3method(.DollarNames,RPolarsChainedWhen) S3method(.DollarNames,RPolarsDataFrame) S3method(.DollarNames,RPolarsErr) S3method(.DollarNames,RPolarsExpr) S3method(.DollarNames,RPolarsLazyFrame) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RPolarsSeries) +S3method(.DollarNames,RPolarsThen) +S3method(.DollarNames,RPolarsWhen) S3method(.DollarNames,RThreadHandle) -S3method(.DollarNames,Then) S3method(.DollarNames,VecDataFrame) -S3method(.DollarNames,When) S3method(.DollarNames,method_environment) S3method(as.character,RPolarsErr) S3method(as.character,RPolarsSeries) @@ -150,11 +150,11 @@ S3method(na.omit,RPolarsDataFrame) S3method(na.omit,RPolarsLazyFrame) S3method(names,RPolarsDataFrame) S3method(names,RPolarsLazyFrame) -S3method(print,ChainedThen) -S3method(print,ChainedWhen) S3method(print,GroupBy) S3method(print,PTime) S3method(print,RField) +S3method(print,RPolarsChainedThen) +S3method(print,RPolarsChainedWhen) S3method(print,RPolarsDataFrame) S3method(print,RPolarsDataType) S3method(print,RPolarsErr) @@ -162,9 +162,9 @@ S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) S3method(print,RPolarsLazyGroupBy) S3method(print,RPolarsSeries) +S3method(print,RPolarsThen) +S3method(print,RPolarsWhen) S3method(print,RThreadHandle) -S3method(print,Then) -S3method(print,When) S3method(print,polars_info) S3method(row.names,RPolarsDataFrame) S3method(sum,RPolarsDataFrame) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index fc0c1f4c4..0811b1cc3 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -87,10 +87,10 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$RField = extendr_method_to_pure_functions(RField) .pr$Expr = extendr_method_to_pure_functions(RPolarsExpr) .pr$ProtoExprArray = extendr_method_to_pure_functions(ProtoExprArray) -.pr$When = extendr_method_to_pure_functions(When) -.pr$Then = extendr_method_to_pure_functions(Then) -.pr$ChainedWhen = extendr_method_to_pure_functions(ChainedWhen) -.pr$ChainedThen = extendr_method_to_pure_functions(ChainedThen) +.pr$When = extendr_method_to_pure_functions(RPolarsWhen) +.pr$Then = extendr_method_to_pure_functions(RPolarsThen) +.pr$ChainedWhen = extendr_method_to_pure_functions(RPolarsChainedWhen) +.pr$ChainedThen = extendr_method_to_pure_functions(RPolarsChainedThen) .pr$VecDataFrame = extendr_method_to_pure_functions(VecDataFrame) .pr$RNullValues = extendr_method_to_pure_functions(RNullValues) .pr$RPolarsErr = extendr_method_to_pure_functions(RPolarsErr) @@ -268,8 +268,8 @@ DataType = clone_env_one_level_deep(RPolarsDataType) pl_class_names = sort( c( "RPolarsLazyFrame", "RPolarsSeries", "RPolarsLazyGroupBy", "RPolarsDataType", - "RPolarsExpr", "RPolarsDataFrame", "When", "Then", "ChainedWhen", "ChainedThen", - "RPolarsSQLContext" + "RPolarsExpr", "RPolarsDataFrame", "RPolarsWhen", "RPolarsThen", + "RPolarsChainedWhen", "RPolarsChainedThen", "RPolarsSQLContext" ) ) # TODO discover all public class automatically diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 362faa797..2be14d753 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -373,48 +373,72 @@ RThreadHandle$thread_description <- function() .Call(wrap__RThreadHandle__thread When <- new.env(parent = emptyenv()) -When$new <- function(condition) .Call(wrap__When__new, condition) +When$new <- function(condition) .Call(wrap__RPolarsWhen__new, condition) -When$then <- function(statement) .Call(wrap__When__then, self, statement) +When$then <- function(statement) .Call(wrap__RPolarsWhen__then, self, statement) + +RPolarsWhen <- When #' @export -`$.When` <- function (self, name) { func <- When[[name]]; environment(func) <- environment(); func } +`$.RPolarsWhen` <- function (self, name) { func <- RPolarsWhen[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsWhen` <- `$.RPolarsWhen` + +`$.When` <- function (self, name) { func <- When[[name]]; environment(func) <- environment(); func } + `[[.When` <- `$.When` Then <- new.env(parent = emptyenv()) -Then$when <- function(condition) .Call(wrap__Then__when, self, condition) +Then$when <- function(condition) .Call(wrap__RPolarsThen__when, self, condition) -Then$otherwise <- function(statement) .Call(wrap__Then__otherwise, self, statement) +Then$otherwise <- function(statement) .Call(wrap__RPolarsThen__otherwise, self, statement) + +RPolarsThen <- Then #' @export -`$.Then` <- function (self, name) { func <- Then[[name]]; environment(func) <- environment(); func } +`$.RPolarsThen` <- function (self, name) { func <- RPolarsThen[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsThen` <- `$.RPolarsThen` + +`$.Then` <- function (self, name) { func <- Then[[name]]; environment(func) <- environment(); func } + `[[.Then` <- `$.Then` ChainedWhen <- new.env(parent = emptyenv()) -ChainedWhen$then <- function(statement) .Call(wrap__ChainedWhen__then, self, statement) +ChainedWhen$then <- function(statement) .Call(wrap__RPolarsChainedWhen__then, self, statement) + +RPolarsChainedWhen <- ChainedWhen #' @export -`$.ChainedWhen` <- function (self, name) { func <- ChainedWhen[[name]]; environment(func) <- environment(); func } +`$.RPolarsChainedWhen` <- function (self, name) { func <- RPolarsChainedWhen[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsChainedWhen` <- `$.RPolarsChainedWhen` + +`$.ChainedWhen` <- function (self, name) { func <- ChainedWhen[[name]]; environment(func) <- environment(); func } + `[[.ChainedWhen` <- `$.ChainedWhen` ChainedThen <- new.env(parent = emptyenv()) -ChainedThen$when <- function(condition) .Call(wrap__ChainedThen__when, self, condition) +ChainedThen$when <- function(condition) .Call(wrap__RPolarsChainedThen__when, self, condition) -ChainedThen$otherwise <- function(statement) .Call(wrap__ChainedThen__otherwise, self, statement) +ChainedThen$otherwise <- function(statement) .Call(wrap__RPolarsChainedThen__otherwise, self, statement) + +RPolarsChainedThen <- ChainedThen #' @export -`$.ChainedThen` <- function (self, name) { func <- ChainedThen[[name]]; environment(func) <- environment(); func } +`$.RPolarsChainedThen` <- function (self, name) { func <- RPolarsChainedThen[[name]]; environment(func) <- environment(); func } #' @export +`[[.RPolarsChainedThen` <- `$.RPolarsChainedThen` + +`$.ChainedThen` <- function (self, name) { func <- ChainedThen[[name]]; environment(func) <- environment(); func } + `[[.ChainedThen` <- `$.ChainedThen` Expr <- new.env(parent = emptyenv()) diff --git a/R/functions__whenthen.R b/R/functions__whenthen.R index b6f2530ef..5e97d8d45 100644 --- a/R/functions__whenthen.R +++ b/R/functions__whenthen.R @@ -94,7 +94,7 @@ ChainedThen_otherwise = function(statement) { #' @export #' @examples #' print(pl$when(pl$col("a") > 2)) -print.When = function(x, ...) { +print.RPolarsWhen = function(x, ...) { print("When") invisible(x) } @@ -107,7 +107,7 @@ print.When = function(x, ...) { #' @export #' @examples #' print(pl$when(pl$col("a") > 2)$then(pl$lit("more than two"))) -print.Then = function(x, ...) { +print.RPolarsThen = function(x, ...) { print("Then") invisible(x) } @@ -122,7 +122,7 @@ print.Then = function(x, ...) { #' @examples #' # #' print(pl$when(pl$col("a") > 2)$then(pl$lit("more than two"))$when(pl$col("b") < 5)) -print.ChainedWhen = function(x, ...) { +print.RPolarsChainedWhen = function(x, ...) { print("ChainedWhen") invisible(x) } @@ -135,7 +135,7 @@ print.ChainedWhen = function(x, ...) { #' @export #' @examples #' print(pl$when(pl$col("a") > 2)$then(pl$lit("more than two"))$when(pl$col("b") < 5)) -print.ChainedThen = function(x, ...) { +print.RPolarsChainedThen = function(x, ...) { print("ChainedThen") invisible(x) } @@ -151,7 +151,7 @@ print.ChainedThen = function(x, ...) { #' @export #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.When = function(x, pattern = "") { +.DollarNames.RPolarsWhen = function(x, pattern = "") { paste0(ls(When, pattern = pattern), "()") } @@ -163,7 +163,7 @@ print.ChainedThen = function(x, ...) { #' @export #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.Then = function(x, pattern = "") { +.DollarNames.RPolarsThen = function(x, pattern = "") { paste0(ls(Then, pattern = pattern), "()") } @@ -175,7 +175,7 @@ print.ChainedThen = function(x, ...) { #' @export #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.ChainedThen = function(x, pattern = "") { +.DollarNames.RPolarsChainedThen = function(x, pattern = "") { paste0(ls(ChainedThen, pattern = pattern), "()") } @@ -187,6 +187,6 @@ print.ChainedThen = function(x, ...) { #' @export #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.ChainedWhen = function(x, pattern = "") { +.DollarNames.RPolarsChainedWhen = function(x, pattern = "") { paste0(ls(ChainedWhen, pattern = pattern), "()") } diff --git a/man/dot-DollarNames.ChainedThen.Rd b/man/dot-DollarNames.RPolarsChainedThen.Rd similarity index 71% rename from man/dot-DollarNames.ChainedThen.Rd rename to man/dot-DollarNames.RPolarsChainedThen.Rd index 601c3ee72..66c1792ec 100644 --- a/man/dot-DollarNames.ChainedThen.Rd +++ b/man/dot-DollarNames.RPolarsChainedThen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{.DollarNames.ChainedThen} -\alias{.DollarNames.ChainedThen} +\name{.DollarNames.RPolarsChainedThen} +\alias{.DollarNames.RPolarsChainedThen} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{ChainedThen}(x, pattern = "") +\method{.DollarNames}{RPolarsChainedThen}(x, pattern = "") } \arguments{ \item{x}{ChainedWhen} diff --git a/man/dot-DollarNames.ChainedWhen.Rd b/man/dot-DollarNames.RPolarsChainedWhen.Rd similarity index 71% rename from man/dot-DollarNames.ChainedWhen.Rd rename to man/dot-DollarNames.RPolarsChainedWhen.Rd index d9bf4969d..57781321e 100644 --- a/man/dot-DollarNames.ChainedWhen.Rd +++ b/man/dot-DollarNames.RPolarsChainedWhen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{.DollarNames.ChainedWhen} -\alias{.DollarNames.ChainedWhen} +\name{.DollarNames.RPolarsChainedWhen} +\alias{.DollarNames.RPolarsChainedWhen} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{ChainedWhen}(x, pattern = "") +\method{.DollarNames}{RPolarsChainedWhen}(x, pattern = "") } \arguments{ \item{x}{ChainedWhen} diff --git a/man/dot-DollarNames.Then.Rd b/man/dot-DollarNames.RPolarsThen.Rd similarity index 74% rename from man/dot-DollarNames.Then.Rd rename to man/dot-DollarNames.RPolarsThen.Rd index c7e363ff0..8db3b4846 100644 --- a/man/dot-DollarNames.Then.Rd +++ b/man/dot-DollarNames.RPolarsThen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{.DollarNames.Then} -\alias{.DollarNames.Then} +\name{.DollarNames.RPolarsThen} +\alias{.DollarNames.RPolarsThen} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{Then}(x, pattern = "") +\method{.DollarNames}{RPolarsThen}(x, pattern = "") } \arguments{ \item{x}{Then} diff --git a/man/dot-DollarNames.When.Rd b/man/dot-DollarNames.RPolarsWhen.Rd similarity index 74% rename from man/dot-DollarNames.When.Rd rename to man/dot-DollarNames.RPolarsWhen.Rd index c74583722..d94b55bcd 100644 --- a/man/dot-DollarNames.When.Rd +++ b/man/dot-DollarNames.RPolarsWhen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{.DollarNames.When} -\alias{.DollarNames.When} +\name{.DollarNames.RPolarsWhen} +\alias{.DollarNames.RPolarsWhen} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{When}(x, pattern = "") +\method{.DollarNames}{RPolarsWhen}(x, pattern = "") } \arguments{ \item{x}{When} diff --git a/man/nanoarrow.Rd b/man/nanoarrow.Rd index 4ff88a261..fa760262b 100644 --- a/man/nanoarrow.Rd +++ b/man/nanoarrow.Rd @@ -16,13 +16,13 @@ \alias{as_record_batch_reader.RPolarsDataFrame} \title{polars to nanoarrow and arrow} \usage{ -as_nanoarrow_array_stream.RPolarsDataFrame(x, ..., schema = NULL) +\method{as_nanoarrow_array_stream}{RPolarsDataFrame}(x, ..., schema = NULL) -infer_nanoarrow_schema.RPolarsDataFrame(x, ...) +\method{infer_nanoarrow_schema}{RPolarsDataFrame}(x, ...) -as_arrow_table.RPolarsDataFrame(x, ...) +\method{as_arrow_table}{RPolarsDataFrame}(x, ...) -as_record_batch_reader.RPolarsDataFrame(x, ..., schema = NULL) +\method{as_record_batch_reader}{RPolarsDataFrame}(x, ..., schema = NULL) } \arguments{ \item{x}{a polars DataFrame} diff --git a/man/print.ChainedThen.Rd b/man/print.RPolarsChainedThen.Rd similarity index 78% rename from man/print.ChainedThen.Rd rename to man/print.RPolarsChainedThen.Rd index f115ff266..093dd935c 100644 --- a/man/print.ChainedThen.Rd +++ b/man/print.RPolarsChainedThen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{print.ChainedThen} -\alias{print.ChainedThen} +\name{print.RPolarsChainedThen} +\alias{print.RPolarsChainedThen} \title{print ChainedThen} \usage{ -\method{print}{ChainedThen}(x, ...) +\method{print}{RPolarsChainedThen}(x, ...) } \arguments{ \item{x}{ChainedThen object} diff --git a/man/print.ChainedWhen.Rd b/man/print.RPolarsChainedWhen.Rd similarity index 78% rename from man/print.ChainedWhen.Rd rename to man/print.RPolarsChainedWhen.Rd index a21c093e0..0e52bc9fd 100644 --- a/man/print.ChainedWhen.Rd +++ b/man/print.RPolarsChainedWhen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{print.ChainedWhen} -\alias{print.ChainedWhen} +\name{print.RPolarsChainedWhen} +\alias{print.RPolarsChainedWhen} \title{print ChainedWhen} \usage{ -\method{print}{ChainedWhen}(x, ...) +\method{print}{RPolarsChainedWhen}(x, ...) } \arguments{ \item{x}{ChainedWhen object} diff --git a/man/print.Then.Rd b/man/print.RPolarsThen.Rd similarity index 79% rename from man/print.Then.Rd rename to man/print.RPolarsThen.Rd index 65e5aedae..1d113d921 100644 --- a/man/print.Then.Rd +++ b/man/print.RPolarsThen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{print.Then} -\alias{print.Then} +\name{print.RPolarsThen} +\alias{print.RPolarsThen} \title{print Then} \usage{ -\method{print}{Then}(x, ...) +\method{print}{RPolarsThen}(x, ...) } \arguments{ \item{x}{When object} diff --git a/man/print.When.Rd b/man/print.RPolarsWhen.Rd similarity index 78% rename from man/print.When.Rd rename to man/print.RPolarsWhen.Rd index 55014143d..6140f131b 100644 --- a/man/print.When.Rd +++ b/man/print.RPolarsWhen.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/functions__whenthen.R -\name{print.When} -\alias{print.When} +\name{print.RPolarsWhen} +\alias{print.RPolarsWhen} \title{print When} \usage{ -\method{print}{When}(x, ...) +\method{print}{RPolarsWhen}(x, ...) } \arguments{ \item{x}{When object} diff --git a/src/rust/src/lazy/whenthen.rs b/src/rust/src/lazy/whenthen.rs index 7110a8617..1b573ef28 100644 --- a/src/rust/src/lazy/whenthen.rs +++ b/src/rust/src/lazy/whenthen.rs @@ -5,44 +5,44 @@ use extendr_api::prelude::*; use polars::lazy::dsl; #[derive(Clone)] -pub struct When { +pub struct RPolarsWhen { inner: dsl::When, } #[derive(Clone)] -pub struct Then { +pub struct RPolarsThen { inner: dsl::Then, } #[derive(Clone)] -pub struct ChainedWhen { +pub struct RPolarsChainedWhen { inner: dsl::ChainedWhen, } #[derive(Clone)] -pub struct ChainedThen { +pub struct RPolarsChainedThen { inner: dsl::ChainedThen, } #[extendr] -impl When { - pub fn new(condition: Robj) -> RResult { - Ok(When { +impl RPolarsWhen { + pub fn new(condition: Robj) -> RResult { + Ok(RPolarsWhen { inner: dsl::when(robj_to!(PLExprCol, condition)?), }) } - fn then(&self, statement: Robj) -> RResult { - Ok(Then { + fn then(&self, statement: Robj) -> RResult { + Ok(RPolarsThen { inner: self.inner.clone().then(robj_to!(PLExprCol, statement)?), }) } } #[extendr] -impl Then { - fn when(&self, condition: Robj) -> RResult { - Ok(ChainedWhen { +impl RPolarsThen { + fn when(&self, condition: Robj) -> RResult { + Ok(RPolarsChainedWhen { inner: self.inner.clone().when(robj_to!(PLExprCol, condition)?), }) } @@ -57,18 +57,18 @@ impl Then { } #[extendr] -impl ChainedWhen { - fn then(&self, statement: Robj) -> RResult { - Ok(ChainedThen { +impl RPolarsChainedWhen { + fn then(&self, statement: Robj) -> RResult { + Ok(RPolarsChainedThen { inner: self.inner.clone().then(robj_to!(PLExprCol, statement)?), }) } } #[extendr] -impl ChainedThen { - fn when(&self, condition: Robj) -> RResult { - Ok(ChainedWhen { +impl RPolarsChainedThen { + fn when(&self, condition: Robj) -> RResult { + Ok(RPolarsChainedWhen { inner: self.inner.clone().when(robj_to!(PLExprCol, condition)?), }) } @@ -84,8 +84,8 @@ impl ChainedThen { extendr_module! { mod whenthen; - impl When; - impl Then; - impl ChainedWhen; - impl ChainedThen; + impl RPolarsWhen; + impl RPolarsThen; + impl RPolarsChainedWhen; + impl RPolarsChainedThen; } From 044d3352eafbeab9272123e851c202237ffdd010 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:06:48 +0100 Subject: [PATCH 14/32] fixes --- tests/testthat/test-groupby.R | 2 +- tests/testthat/test-whenthen.R | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/testthat/test-groupby.R b/tests/testthat/test-groupby.R index b658cf457..0ef6d13c4 100644 --- a/tests/testthat/test-groupby.R +++ b/tests/testthat/test-groupby.R @@ -116,7 +116,7 @@ test_that("LazyGroupBy ungroup", { # tests $ungroup() only changed the class of output, not input (lgb). lgb_ug = lgb$ungroup() expect_identical(class(lgb_ug), "RPolarsLazyFrame") - expect_identical(class(lgb), "LazyGroupBy") + expect_identical(class(lgb), "RPolarsLazyGroupBy") expect_equal( lgb$ungroup()$collect()$to_data_frame(), diff --git a/tests/testthat/test-whenthen.R b/tests/testthat/test-whenthen.R index 4c72e350d..0ff78c241 100644 --- a/tests/testthat/test-whenthen.R +++ b/tests/testthat/test-whenthen.R @@ -1,7 +1,7 @@ test_that("When-class", { - expect_true(inherits(pl$when("columnname"), "When")) - expect_true(inherits(pl$when(TRUE), "When")) - expect_true(inherits(pl$when(1:4), "When")) + expect_true(inherits(pl$when("columnname"), "RPolarsWhen")) + expect_true(inherits(pl$when(TRUE), "RPolarsWhen")) + expect_true(inherits(pl$when(1:4), "RPolarsWhen")) # string "a" is interpreted as column e_actual = pl$when("a")$then("b")$otherwise("c") @@ -24,9 +24,9 @@ test_that("When-class", { test_that("Then-class", { - expect_true(inherits(pl$when("a")$then("b"), "Then")) - expect_true(inherits(pl$when(TRUE)$then(FALSE), "Then")) - expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(NA), "ChainedWhen")) + expect_true(inherits(pl$when("a")$then("b"), "RPolarsThen")) + expect_true(inherits(pl$when(TRUE)$then(FALSE), "RPolarsThen")) + expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(NA), "RPolarsChainedWhen")) expect_true(inherits(pl$when(TRUE)$then(FALSE)$otherwise(NA), "RPolarsExpr")) ctx = result(pl$when("a")$then(complex(2)))$err$contexts() @@ -42,10 +42,10 @@ test_that("Then-class", { test_that("Chained", { - expect_true(inherits(pl$when("a")$then("b")$when("c"), "ChainedWhen")) - expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(TRUE), "ChainedWhen")) + expect_true(inherits(pl$when("a")$then("b")$when("c"), "RPolarsChainedWhen")) + expect_true(inherits(pl$when(TRUE)$then(FALSE)$when(TRUE), "RPolarsChainedWhen")) cw = pl$when("a")$then("b")$when("c") - expect_true(inherits(cw$then("a"), "ChainedThen")) + expect_true(inherits(cw$then("a"), "RPolarsChainedThen")) expect_true(inherits(cw$then("d")$otherwise("e"), "RPolarsExpr")) }) From 3eceb77afeb79cfd07d42de383728208302eae48 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:21:53 +0100 Subject: [PATCH 15/32] use "sql" feature in cargo.toml --- src/rust/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index bd70600ea..c27dfbc93 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -127,6 +127,7 @@ features = [ "search_sorted", "serde-lazy", "sign", + "sql", "strings", "string_encoding", "string_pad", From 5523f66f8301a829ce30e0b72d1fc61975fae566 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:51:13 +0100 Subject: [PATCH 16/32] bump news [skip ci] --- NEWS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index f99b9b0fd..47a278429 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,10 +6,10 @@ is renamed `$map_batches()`. `$map()` and `$apply()` will be removed in 0.13.0 (#534). - Removed `$days()`, `$hours()`, `$minutes()`, `$seconds()`, `$milliseconds()`, `$microseconds()`, `$nanoseconds()`. Those were deprecated in 0.11.0 (#550). -- The class name of `DataFrame`, `LazyFrame`, `Expr`, and `Series` objects has - changed. They now start with `RPolars`, for example `RPolarsDataFrame`. This - will only break your code if you directly use those class names, such as in - S3 methods (#554). +- The class name of all objects created by polars (`DataFrame`, `LazyFrame`, + `Expr`, `Series`, etc.) has changed. They now start with `RPolars`, for example + `RPolarsDataFrame`. This will only break your code if you directly use those + class names, such as in S3 methods (#554). ## What's changed From bcab2662a0e14e420aaed25973f0de16a0b572e8 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:41:06 +0100 Subject: [PATCH 17/32] revert change in cargo.toml --- src/rust/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index c27dfbc93..bd70600ea 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -127,7 +127,6 @@ features = [ "search_sorted", "serde-lazy", "sign", - "sql", "strings", "string_encoding", "string_pad", From 8c44ff1c0e2a787eac176673195ea2d59bb521c5 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:54:08 +0100 Subject: [PATCH 18/32] fix --- R/dataframe__frame.R | 2 +- R/lazyframe__lazy.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index f50b59c9e..5e8d9dff2 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -71,7 +71,7 @@ #' # Try unwrapping an error from polars due to unmatching column lengths #' err_result = .pr$DataFrame$set_column_from_robj(df, 1:10000, "wrong_length") #' tryCatch(unwrap(err_result, call = NULL), error = \(e) cat(as.character(e))) -DataFrame +NULL #' @title auto complete $-access into a polars object diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 279efb14c..3379131f9 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -96,7 +96,7 @@ #' #' # a user might write it as a one-liner like so: #' Pdf_best2 = pl$scan_csv(temp_filepath)$filter(pl$col("Species") == "setosa") -LazyFrame +NULL #' @title auto complete $-access into a polars object From 40280c7c4d52b5637d7e16a3dea6f84fa7eb7a9e Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:59:20 +0100 Subject: [PATCH 19/32] same --- R/series__series.R | 2 +- R/sql.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/series__series.R b/R/series__series.R index b88195773..a9f460c45 100644 --- a/R/series__series.R +++ b/R/series__series.R @@ -36,7 +36,7 @@ #' s_copy = s #' .pr$Series$append_mut(s, pl$Series(5:1)) #' identical(s_copy$to_r(), s$to_r()) # s_copy was modified when s was modified -Series +NULL diff --git a/R/sql.R b/R/sql.R index 9ad59ffeb..378ab57d8 100644 --- a/R/sql.R +++ b/R/sql.R @@ -10,7 +10,7 @@ #' "SELECT b, a*2 AS two_a FROM frame WHERE b IS NOT NULL" #' ) #' res$collect() -RPolarsSQLContext +NULL #' @title auto complete $-access into a polars object From 99254e5e9058c409587664d10f9a292ac2114af8 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:52:28 +0100 Subject: [PATCH 20/32] fix extendr wrappers and zzz --- R/extendr-wrappers.R | 946 ++++++++++++++++++++----------------------- R/zzz.R | 21 +- 2 files changed, 456 insertions(+), 511 deletions(-) diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 2be14d753..a661a9659 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -119,93 +119,91 @@ disable_string_cache <- function() .Call(wrap__disable_string_cache) using_string_cache <- function() .Call(wrap__using_string_cache) -DataFrame <- new.env(parent = emptyenv()) +RPolarsDataFrame <- new.env(parent = emptyenv()) -DataFrame$shape <- function() .Call(wrap__RPolarsDataFrame__shape, self) +RPolarsDataFrame$shape <- function() .Call(wrap__RPolarsDataFrame__shape, self) -DataFrame$n_chunks <- function(strategy) .Call(wrap__RPolarsDataFrame__n_chunks, self, strategy) +RPolarsDataFrame$n_chunks <- function(strategy) .Call(wrap__RPolarsDataFrame__n_chunks, self, strategy) -DataFrame$rechunk <- function() .Call(wrap__RPolarsDataFrame__rechunk, self) +RPolarsDataFrame$rechunk <- function() .Call(wrap__RPolarsDataFrame__rechunk, self) -DataFrame$clone_in_rust <- function() .Call(wrap__RPolarsDataFrame__clone_in_rust, self) +RPolarsDataFrame$clone_in_rust <- function() .Call(wrap__RPolarsDataFrame__clone_in_rust, self) -DataFrame$default <- function() .Call(wrap__RPolarsDataFrame__default) +RPolarsDataFrame$default <- function() .Call(wrap__RPolarsDataFrame__default) -DataFrame$lazy <- function() .Call(wrap__RPolarsDataFrame__lazy, self) +RPolarsDataFrame$lazy <- function() .Call(wrap__RPolarsDataFrame__lazy, self) -DataFrame$drop_all_in_place <- function() invisible(.Call(wrap__RPolarsDataFrame__drop_all_in_place, self)) +RPolarsDataFrame$drop_all_in_place <- function() invisible(.Call(wrap__RPolarsDataFrame__drop_all_in_place, self)) -DataFrame$new_with_capacity <- function(capacity) .Call(wrap__RPolarsDataFrame__new_with_capacity, capacity) +RPolarsDataFrame$new_with_capacity <- function(capacity) .Call(wrap__RPolarsDataFrame__new_with_capacity, capacity) -DataFrame$set_column_from_robj <- function(robj, name) .Call(wrap__RPolarsDataFrame__set_column_from_robj, self, robj, name) +RPolarsDataFrame$set_column_from_robj <- function(robj, name) .Call(wrap__RPolarsDataFrame__set_column_from_robj, self, robj, name) -DataFrame$set_column_from_series <- function(x) .Call(wrap__RPolarsDataFrame__set_column_from_series, self, x) +RPolarsDataFrame$set_column_from_series <- function(x) .Call(wrap__RPolarsDataFrame__set_column_from_series, self, x) -DataFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsDataFrame__with_row_count, self, name, offset) +RPolarsDataFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsDataFrame__with_row_count, self, name, offset) -DataFrame$print <- function() .Call(wrap__RPolarsDataFrame__print, self) +RPolarsDataFrame$print <- function() .Call(wrap__RPolarsDataFrame__print, self) -DataFrame$columns <- function() .Call(wrap__RPolarsDataFrame__columns, self) +RPolarsDataFrame$columns <- function() .Call(wrap__RPolarsDataFrame__columns, self) -DataFrame$set_column_names_mut <- function(names) .Call(wrap__RPolarsDataFrame__set_column_names_mut, self, names) +RPolarsDataFrame$set_column_names_mut <- function(names) .Call(wrap__RPolarsDataFrame__set_column_names_mut, self, names) -DataFrame$get_column <- function(name) .Call(wrap__RPolarsDataFrame__get_column, self, name) +RPolarsDataFrame$get_column <- function(name) .Call(wrap__RPolarsDataFrame__get_column, self, name) -DataFrame$get_columns <- function() .Call(wrap__RPolarsDataFrame__get_columns, self) +RPolarsDataFrame$get_columns <- function() .Call(wrap__RPolarsDataFrame__get_columns, self) -DataFrame$dtypes <- function() .Call(wrap__RPolarsDataFrame__dtypes, self) +RPolarsDataFrame$dtypes <- function() .Call(wrap__RPolarsDataFrame__dtypes, self) -DataFrame$dtype_strings <- function() .Call(wrap__RPolarsDataFrame__dtype_strings, self) +RPolarsDataFrame$dtype_strings <- function() .Call(wrap__RPolarsDataFrame__dtype_strings, self) -DataFrame$schema <- function() .Call(wrap__RPolarsDataFrame__schema, self) +RPolarsDataFrame$schema <- function() .Call(wrap__RPolarsDataFrame__schema, self) -DataFrame$to_list <- function() .Call(wrap__RPolarsDataFrame__to_list, self) +RPolarsDataFrame$to_list <- function() .Call(wrap__RPolarsDataFrame__to_list, self) -DataFrame$to_list_unwind <- function() .Call(wrap__RPolarsDataFrame__to_list_unwind, self) +RPolarsDataFrame$to_list_unwind <- function() .Call(wrap__RPolarsDataFrame__to_list_unwind, self) -DataFrame$to_list_tag_structs <- function() .Call(wrap__RPolarsDataFrame__to_list_tag_structs, self) +RPolarsDataFrame$to_list_tag_structs <- function() .Call(wrap__RPolarsDataFrame__to_list_tag_structs, self) -DataFrame$frame_equal <- function(other) .Call(wrap__RPolarsDataFrame__frame_equal, self, other) +RPolarsDataFrame$frame_equal <- function(other) .Call(wrap__RPolarsDataFrame__frame_equal, self, other) -DataFrame$select_at_idx <- function(idx) .Call(wrap__RPolarsDataFrame__select_at_idx, self, idx) +RPolarsDataFrame$select_at_idx <- function(idx) .Call(wrap__RPolarsDataFrame__select_at_idx, self, idx) -DataFrame$drop_in_place <- function(names) .Call(wrap__RPolarsDataFrame__drop_in_place, self, names) +RPolarsDataFrame$drop_in_place <- function(names) .Call(wrap__RPolarsDataFrame__drop_in_place, self, names) -DataFrame$select <- function(exprs) .Call(wrap__RPolarsDataFrame__select, self, exprs) +RPolarsDataFrame$select <- function(exprs) .Call(wrap__RPolarsDataFrame__select, self, exprs) -DataFrame$with_columns <- function(exprs) .Call(wrap__RPolarsDataFrame__with_columns, self, exprs) +RPolarsDataFrame$with_columns <- function(exprs) .Call(wrap__RPolarsDataFrame__with_columns, self, exprs) -DataFrame$by_agg <- function(group_exprs, agg_exprs, maintain_order) .Call(wrap__RPolarsDataFrame__by_agg, self, group_exprs, agg_exprs, maintain_order) +RPolarsDataFrame$by_agg <- function(group_exprs, agg_exprs, maintain_order) .Call(wrap__RPolarsDataFrame__by_agg, self, group_exprs, agg_exprs, maintain_order) -DataFrame$to_struct <- function(name) .Call(wrap__RPolarsDataFrame__to_struct, self, name) +RPolarsDataFrame$to_struct <- function(name) .Call(wrap__RPolarsDataFrame__to_struct, self, name) -DataFrame$unnest <- function(names) .Call(wrap__RPolarsDataFrame__unnest, self, names) +RPolarsDataFrame$unnest <- function(names) .Call(wrap__RPolarsDataFrame__unnest, self, names) -DataFrame$export_stream <- function(stream_ptr) invisible(.Call(wrap__RPolarsDataFrame__export_stream, self, stream_ptr)) +RPolarsDataFrame$export_stream <- function(stream_ptr) invisible(.Call(wrap__RPolarsDataFrame__export_stream, self, stream_ptr)) -DataFrame$from_arrow_record_batches <- function(rbr) .Call(wrap__RPolarsDataFrame__from_arrow_record_batches, rbr) +RPolarsDataFrame$from_arrow_record_batches <- function(rbr) .Call(wrap__RPolarsDataFrame__from_arrow_record_batches, rbr) -DataFrame$estimated_size <- function() .Call(wrap__RPolarsDataFrame__estimated_size, self) +RPolarsDataFrame$estimated_size <- function() .Call(wrap__RPolarsDataFrame__estimated_size, self) -DataFrame$null_count <- function() .Call(wrap__RPolarsDataFrame__null_count, self) +RPolarsDataFrame$null_count <- function() .Call(wrap__RPolarsDataFrame__null_count, self) -DataFrame$melt <- function(id_vars, value_vars, value_name, variable_name) .Call(wrap__RPolarsDataFrame__melt, self, id_vars, value_vars, value_name, variable_name) +RPolarsDataFrame$melt <- function(id_vars, value_vars, value_name, variable_name) .Call(wrap__RPolarsDataFrame__melt, self, id_vars, value_vars, value_name, variable_name) -DataFrame$pivot_expr <- function(values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) .Call(wrap__RPolarsDataFrame__pivot_expr, self, values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) +RPolarsDataFrame$pivot_expr <- function(values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) .Call(wrap__RPolarsDataFrame__pivot_expr, self, values, index, columns, maintain_order, sort_columns, aggregate_expr, separator) -DataFrame$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_n, self, n, with_replacement, shuffle, seed) +RPolarsDataFrame$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_n, self, n, with_replacement, shuffle, seed) -DataFrame$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_frac, self, frac, with_replacement, shuffle, seed) +RPolarsDataFrame$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsDataFrame__sample_frac, self, frac, with_replacement, shuffle, seed) -DataFrame$transpose <- function(keep_names_as, new_col_names) .Call(wrap__RPolarsDataFrame__transpose, self, keep_names_as, new_col_names) +RPolarsDataFrame$transpose <- function(keep_names_as, new_col_names) .Call(wrap__RPolarsDataFrame__transpose, self, keep_names_as, new_col_names) -DataFrame$write_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__RPolarsDataFrame__write_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) +RPolarsDataFrame$write_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) .Call(wrap__RPolarsDataFrame__write_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style) -DataFrame$write_json <- function(file, pretty, row_oriented) .Call(wrap__RPolarsDataFrame__write_json, self, file, pretty, row_oriented) +RPolarsDataFrame$write_json <- function(file, pretty, row_oriented) .Call(wrap__RPolarsDataFrame__write_json, self, file, pretty, row_oriented) -DataFrame$write_ndjson <- function(file) .Call(wrap__RPolarsDataFrame__write_ndjson, self, file) - -RPolarsDataFrame <- DataFrame +RPolarsDataFrame$write_ndjson <- function(file) .Call(wrap__RPolarsDataFrame__write_ndjson, self, file) #' @export `$.RPolarsDataFrame` <- function (self, name) { func <- RPolarsDataFrame[[name]]; environment(func) <- environment(); func } @@ -213,10 +211,6 @@ RPolarsDataFrame <- DataFrame #' @export `[[.RPolarsDataFrame` <- `$.RPolarsDataFrame` -`$.DataFrame` <- function (self, name) { func <- DataFrame[[name]]; environment(func) <- environment(); func } - -`[[.DataFrame` <- `$.DataFrame` - VecDataFrame <- new.env(parent = emptyenv()) VecDataFrame$with_capacity <- function(n) .Call(wrap__VecDataFrame__with_capacity, n) @@ -371,13 +365,11 @@ RThreadHandle$thread_description <- function() .Call(wrap__RThreadHandle__thread #' @export `[[.RThreadHandle` <- `$.RThreadHandle` -When <- new.env(parent = emptyenv()) - -When$new <- function(condition) .Call(wrap__RPolarsWhen__new, condition) +RPolarsWhen <- new.env(parent = emptyenv()) -When$then <- function(statement) .Call(wrap__RPolarsWhen__then, self, statement) +RPolarsWhen$new <- function(condition) .Call(wrap__RPolarsWhen__new, condition) -RPolarsWhen <- When +RPolarsWhen$then <- function(statement) .Call(wrap__RPolarsWhen__then, self, statement) #' @export `$.RPolarsWhen` <- function (self, name) { func <- RPolarsWhen[[name]]; environment(func) <- environment(); func } @@ -385,17 +377,11 @@ RPolarsWhen <- When #' @export `[[.RPolarsWhen` <- `$.RPolarsWhen` -`$.When` <- function (self, name) { func <- When[[name]]; environment(func) <- environment(); func } - -`[[.When` <- `$.When` - -Then <- new.env(parent = emptyenv()) - -Then$when <- function(condition) .Call(wrap__RPolarsThen__when, self, condition) +RPolarsThen <- new.env(parent = emptyenv()) -Then$otherwise <- function(statement) .Call(wrap__RPolarsThen__otherwise, self, statement) +RPolarsThen$when <- function(condition) .Call(wrap__RPolarsThen__when, self, condition) -RPolarsThen <- Then +RPolarsThen$otherwise <- function(statement) .Call(wrap__RPolarsThen__otherwise, self, statement) #' @export `$.RPolarsThen` <- function (self, name) { func <- RPolarsThen[[name]]; environment(func) <- environment(); func } @@ -403,15 +389,9 @@ RPolarsThen <- Then #' @export `[[.RPolarsThen` <- `$.RPolarsThen` -`$.Then` <- function (self, name) { func <- Then[[name]]; environment(func) <- environment(); func } +RPolarsChainedWhen <- new.env(parent = emptyenv()) -`[[.Then` <- `$.Then` - -ChainedWhen <- new.env(parent = emptyenv()) - -ChainedWhen$then <- function(statement) .Call(wrap__RPolarsChainedWhen__then, self, statement) - -RPolarsChainedWhen <- ChainedWhen +RPolarsChainedWhen$then <- function(statement) .Call(wrap__RPolarsChainedWhen__then, self, statement) #' @export `$.RPolarsChainedWhen` <- function (self, name) { func <- RPolarsChainedWhen[[name]]; environment(func) <- environment(); func } @@ -419,17 +399,11 @@ RPolarsChainedWhen <- ChainedWhen #' @export `[[.RPolarsChainedWhen` <- `$.RPolarsChainedWhen` -`$.ChainedWhen` <- function (self, name) { func <- ChainedWhen[[name]]; environment(func) <- environment(); func } - -`[[.ChainedWhen` <- `$.ChainedWhen` +RPolarsChainedThen <- new.env(parent = emptyenv()) -ChainedThen <- new.env(parent = emptyenv()) +RPolarsChainedThen$when <- function(condition) .Call(wrap__RPolarsChainedThen__when, self, condition) -ChainedThen$when <- function(condition) .Call(wrap__RPolarsChainedThen__when, self, condition) - -ChainedThen$otherwise <- function(statement) .Call(wrap__RPolarsChainedThen__otherwise, self, statement) - -RPolarsChainedThen <- ChainedThen +RPolarsChainedThen$otherwise <- function(statement) .Call(wrap__RPolarsChainedThen__otherwise, self, statement) #' @export `$.RPolarsChainedThen` <- function (self, name) { func <- RPolarsChainedThen[[name]]; environment(func) <- environment(); func } @@ -437,579 +411,573 @@ RPolarsChainedThen <- ChainedThen #' @export `[[.RPolarsChainedThen` <- `$.RPolarsChainedThen` -`$.ChainedThen` <- function (self, name) { func <- ChainedThen[[name]]; environment(func) <- environment(); func } - -`[[.ChainedThen` <- `$.ChainedThen` +RPolarsExpr <- new.env(parent = emptyenv()) -Expr <- new.env(parent = emptyenv()) +RPolarsExpr$col <- function(name) .Call(wrap__RPolarsExpr__col, name) -Expr$col <- function(name) .Call(wrap__RPolarsExpr__col, name) +RPolarsExpr$dtype_cols <- function(dtypes) .Call(wrap__RPolarsExpr__dtype_cols, dtypes) -Expr$dtype_cols <- function(dtypes) .Call(wrap__RPolarsExpr__dtype_cols, dtypes) +RPolarsExpr$cols <- function(names) .Call(wrap__RPolarsExpr__cols, names) -Expr$cols <- function(names) .Call(wrap__RPolarsExpr__cols, names) +RPolarsExpr$lit <- function(robj) .Call(wrap__RPolarsExpr__lit, robj) -Expr$lit <- function(robj) .Call(wrap__RPolarsExpr__lit, robj) +RPolarsExpr$gt <- function(other) .Call(wrap__RPolarsExpr__gt, self, other) -Expr$gt <- function(other) .Call(wrap__RPolarsExpr__gt, self, other) +RPolarsExpr$gt_eq <- function(other) .Call(wrap__RPolarsExpr__gt_eq, self, other) -Expr$gt_eq <- function(other) .Call(wrap__RPolarsExpr__gt_eq, self, other) +RPolarsExpr$lt <- function(other) .Call(wrap__RPolarsExpr__lt, self, other) -Expr$lt <- function(other) .Call(wrap__RPolarsExpr__lt, self, other) +RPolarsExpr$lt_eq <- function(other) .Call(wrap__RPolarsExpr__lt_eq, self, other) -Expr$lt_eq <- function(other) .Call(wrap__RPolarsExpr__lt_eq, self, other) +RPolarsExpr$neq <- function(other) .Call(wrap__RPolarsExpr__neq, self, other) -Expr$neq <- function(other) .Call(wrap__RPolarsExpr__neq, self, other) +RPolarsExpr$neq_missing <- function(other) .Call(wrap__RPolarsExpr__neq_missing, self, other) -Expr$neq_missing <- function(other) .Call(wrap__RPolarsExpr__neq_missing, self, other) +RPolarsExpr$eq <- function(other) .Call(wrap__RPolarsExpr__eq, self, other) -Expr$eq <- function(other) .Call(wrap__RPolarsExpr__eq, self, other) +RPolarsExpr$eq_missing <- function(other) .Call(wrap__RPolarsExpr__eq_missing, self, other) -Expr$eq_missing <- function(other) .Call(wrap__RPolarsExpr__eq_missing, self, other) +RPolarsExpr$and <- function(other) .Call(wrap__RPolarsExpr__and, self, other) -Expr$and <- function(other) .Call(wrap__RPolarsExpr__and, self, other) +RPolarsExpr$or <- function(other) .Call(wrap__RPolarsExpr__or, self, other) -Expr$or <- function(other) .Call(wrap__RPolarsExpr__or, self, other) +RPolarsExpr$xor <- function(other) .Call(wrap__RPolarsExpr__xor, self, other) -Expr$xor <- function(other) .Call(wrap__RPolarsExpr__xor, self, other) +RPolarsExpr$to_physical <- function() .Call(wrap__RPolarsExpr__to_physical, self) -Expr$to_physical <- function() .Call(wrap__RPolarsExpr__to_physical, self) +RPolarsExpr$cast <- function(data_type, strict) .Call(wrap__RPolarsExpr__cast, self, data_type, strict) -Expr$cast <- function(data_type, strict) .Call(wrap__RPolarsExpr__cast, self, data_type, strict) +RPolarsExpr$sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__sort, self, descending, nulls_last) -Expr$sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__sort, self, descending, nulls_last) +RPolarsExpr$arg_sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__arg_sort, self, descending, nulls_last) -Expr$arg_sort <- function(descending, nulls_last) .Call(wrap__RPolarsExpr__arg_sort, self, descending, nulls_last) +RPolarsExpr$top_k <- function(k) .Call(wrap__RPolarsExpr__top_k, self, k) -Expr$top_k <- function(k) .Call(wrap__RPolarsExpr__top_k, self, k) +RPolarsExpr$bottom_k <- function(k) .Call(wrap__RPolarsExpr__bottom_k, self, k) -Expr$bottom_k <- function(k) .Call(wrap__RPolarsExpr__bottom_k, self, k) +RPolarsExpr$arg_max <- function() .Call(wrap__RPolarsExpr__arg_max, self) -Expr$arg_max <- function() .Call(wrap__RPolarsExpr__arg_max, self) +RPolarsExpr$arg_min <- function() .Call(wrap__RPolarsExpr__arg_min, self) -Expr$arg_min <- function() .Call(wrap__RPolarsExpr__arg_min, self) +RPolarsExpr$search_sorted <- function(element) .Call(wrap__RPolarsExpr__search_sorted, self, element) -Expr$search_sorted <- function(element) .Call(wrap__RPolarsExpr__search_sorted, self, element) +RPolarsExpr$gather <- function(idx) .Call(wrap__RPolarsExpr__gather, self, idx) -Expr$gather <- function(idx) .Call(wrap__RPolarsExpr__gather, self, idx) +RPolarsExpr$sort_by <- function(by, descending) .Call(wrap__RPolarsExpr__sort_by, self, by, descending) -Expr$sort_by <- function(by, descending) .Call(wrap__RPolarsExpr__sort_by, self, by, descending) +RPolarsExpr$backward_fill <- function(limit) .Call(wrap__RPolarsExpr__backward_fill, self, limit) -Expr$backward_fill <- function(limit) .Call(wrap__RPolarsExpr__backward_fill, self, limit) +RPolarsExpr$forward_fill <- function(limit) .Call(wrap__RPolarsExpr__forward_fill, self, limit) -Expr$forward_fill <- function(limit) .Call(wrap__RPolarsExpr__forward_fill, self, limit) +RPolarsExpr$shift <- function(periods) .Call(wrap__RPolarsExpr__shift, self, periods) -Expr$shift <- function(periods) .Call(wrap__RPolarsExpr__shift, self, periods) +RPolarsExpr$shift_and_fill <- function(periods, fill_value) .Call(wrap__RPolarsExpr__shift_and_fill, self, periods, fill_value) -Expr$shift_and_fill <- function(periods, fill_value) .Call(wrap__RPolarsExpr__shift_and_fill, self, periods, fill_value) +RPolarsExpr$fill_null <- function(expr) .Call(wrap__RPolarsExpr__fill_null, self, expr) -Expr$fill_null <- function(expr) .Call(wrap__RPolarsExpr__fill_null, self, expr) +RPolarsExpr$fill_null_with_strategy <- function(strategy, limit) .Call(wrap__RPolarsExpr__fill_null_with_strategy, self, strategy, limit) -Expr$fill_null_with_strategy <- function(strategy, limit) .Call(wrap__RPolarsExpr__fill_null_with_strategy, self, strategy, limit) +RPolarsExpr$fill_nan <- function(expr) .Call(wrap__RPolarsExpr__fill_nan, self, expr) -Expr$fill_nan <- function(expr) .Call(wrap__RPolarsExpr__fill_nan, self, expr) +RPolarsExpr$reverse <- function() .Call(wrap__RPolarsExpr__reverse, self) -Expr$reverse <- function() .Call(wrap__RPolarsExpr__reverse, self) +RPolarsExpr$std <- function(ddof) .Call(wrap__RPolarsExpr__std, self, ddof) -Expr$std <- function(ddof) .Call(wrap__RPolarsExpr__std, self, ddof) +RPolarsExpr$var <- function(ddof) .Call(wrap__RPolarsExpr__var, self, ddof) -Expr$var <- function(ddof) .Call(wrap__RPolarsExpr__var, self, ddof) +RPolarsExpr$max <- function() .Call(wrap__RPolarsExpr__max, self) -Expr$max <- function() .Call(wrap__RPolarsExpr__max, self) +RPolarsExpr$min <- function() .Call(wrap__RPolarsExpr__min, self) -Expr$min <- function() .Call(wrap__RPolarsExpr__min, self) +RPolarsExpr$nan_min <- function() .Call(wrap__RPolarsExpr__nan_min, self) -Expr$nan_min <- function() .Call(wrap__RPolarsExpr__nan_min, self) +RPolarsExpr$nan_max <- function() .Call(wrap__RPolarsExpr__nan_max, self) -Expr$nan_max <- function() .Call(wrap__RPolarsExpr__nan_max, self) +RPolarsExpr$mean <- function() .Call(wrap__RPolarsExpr__mean, self) -Expr$mean <- function() .Call(wrap__RPolarsExpr__mean, self) +RPolarsExpr$median <- function() .Call(wrap__RPolarsExpr__median, self) -Expr$median <- function() .Call(wrap__RPolarsExpr__median, self) +RPolarsExpr$sum <- function() .Call(wrap__RPolarsExpr__sum, self) -Expr$sum <- function() .Call(wrap__RPolarsExpr__sum, self) +RPolarsExpr$product <- function() .Call(wrap__RPolarsExpr__product, self) -Expr$product <- function() .Call(wrap__RPolarsExpr__product, self) +RPolarsExpr$n_unique <- function() .Call(wrap__RPolarsExpr__n_unique, self) -Expr$n_unique <- function() .Call(wrap__RPolarsExpr__n_unique, self) +RPolarsExpr$null_count <- function() .Call(wrap__RPolarsExpr__null_count, self) -Expr$null_count <- function() .Call(wrap__RPolarsExpr__null_count, self) +RPolarsExpr$arg_unique <- function() .Call(wrap__RPolarsExpr__arg_unique, self) -Expr$arg_unique <- function() .Call(wrap__RPolarsExpr__arg_unique, self) +RPolarsExpr$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsExpr__quantile, self, quantile, interpolation) -Expr$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsExpr__quantile, self, quantile, interpolation) +RPolarsExpr$filter <- function(predicate) .Call(wrap__RPolarsExpr__filter, self, predicate) -Expr$filter <- function(predicate) .Call(wrap__RPolarsExpr__filter, self, predicate) +RPolarsExpr$explode <- function() .Call(wrap__RPolarsExpr__explode, self) -Expr$explode <- function() .Call(wrap__RPolarsExpr__explode, self) +RPolarsExpr$flatten <- function() .Call(wrap__RPolarsExpr__flatten, self) -Expr$flatten <- function() .Call(wrap__RPolarsExpr__flatten, self) +RPolarsExpr$gather_every <- function(n) .Call(wrap__RPolarsExpr__gather_every, self, n) -Expr$gather_every <- function(n) .Call(wrap__RPolarsExpr__gather_every, self, n) +RPolarsExpr$hash <- function(seed, seed_1, seed_2, seed_3) .Call(wrap__RPolarsExpr__hash, self, seed, seed_1, seed_2, seed_3) -Expr$hash <- function(seed, seed_1, seed_2, seed_3) .Call(wrap__RPolarsExpr__hash, self, seed, seed_1, seed_2, seed_3) +RPolarsExpr$reinterpret <- function(signed) .Call(wrap__RPolarsExpr__reinterpret, self, signed) -Expr$reinterpret <- function(signed) .Call(wrap__RPolarsExpr__reinterpret, self, signed) +RPolarsExpr$interpolate <- function(method) .Call(wrap__RPolarsExpr__interpolate, self, method) -Expr$interpolate <- function(method) .Call(wrap__RPolarsExpr__interpolate, self, method) +RPolarsExpr$rolling_min <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_min, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_min <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_min, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_max <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_max, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_max <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_max, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_mean <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_mean, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_mean <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_mean, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_sum <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_sum, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_sum <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_sum, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_std <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_std, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_std <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_std, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_var <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_var, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_var <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_var, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_median <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_median, self, window_size, weights, min_periods, center, by_null, closed_null) -Expr$rolling_median <- function(window_size, weights, min_periods, center, by_null, closed_null) .Call(wrap__RPolarsExpr__rolling_median, self, window_size, weights, min_periods, center, by_null, closed_null) +RPolarsExpr$rolling_quantile <- function(quantile, interpolation, window_size, weights, min_periods, center, by, closed) .Call(wrap__RPolarsExpr__rolling_quantile, self, quantile, interpolation, window_size, weights, min_periods, center, by, closed) -Expr$rolling_quantile <- function(quantile, interpolation, window_size, weights, min_periods, center, by, closed) .Call(wrap__RPolarsExpr__rolling_quantile, self, quantile, interpolation, window_size, weights, min_periods, center, by, closed) +RPolarsExpr$rolling_skew <- function(window_size_f, bias) .Call(wrap__RPolarsExpr__rolling_skew, self, window_size_f, bias) -Expr$rolling_skew <- function(window_size_f, bias) .Call(wrap__RPolarsExpr__rolling_skew, self, window_size_f, bias) +RPolarsExpr$abs <- function() .Call(wrap__RPolarsExpr__abs, self) -Expr$abs <- function() .Call(wrap__RPolarsExpr__abs, self) +RPolarsExpr$rank <- function(method, descending) .Call(wrap__RPolarsExpr__rank, self, method, descending) -Expr$rank <- function(method, descending) .Call(wrap__RPolarsExpr__rank, self, method, descending) +RPolarsExpr$diff <- function(n_float, null_behavior) .Call(wrap__RPolarsExpr__diff, self, n_float, null_behavior) -Expr$diff <- function(n_float, null_behavior) .Call(wrap__RPolarsExpr__diff, self, n_float, null_behavior) +RPolarsExpr$pct_change <- function(n_float) .Call(wrap__RPolarsExpr__pct_change, self, n_float) -Expr$pct_change <- function(n_float) .Call(wrap__RPolarsExpr__pct_change, self, n_float) +RPolarsExpr$skew <- function(bias) .Call(wrap__RPolarsExpr__skew, self, bias) -Expr$skew <- function(bias) .Call(wrap__RPolarsExpr__skew, self, bias) +RPolarsExpr$kurtosis <- function(fisher, bias) .Call(wrap__RPolarsExpr__kurtosis, self, fisher, bias) -Expr$kurtosis <- function(fisher, bias) .Call(wrap__RPolarsExpr__kurtosis, self, fisher, bias) +RPolarsExpr$clip <- function(min, max) .Call(wrap__RPolarsExpr__clip, self, min, max) -Expr$clip <- function(min, max) .Call(wrap__RPolarsExpr__clip, self, min, max) +RPolarsExpr$clip_min <- function(min) .Call(wrap__RPolarsExpr__clip_min, self, min) -Expr$clip_min <- function(min) .Call(wrap__RPolarsExpr__clip_min, self, min) +RPolarsExpr$clip_max <- function(max) .Call(wrap__RPolarsExpr__clip_max, self, max) -Expr$clip_max <- function(max) .Call(wrap__RPolarsExpr__clip_max, self, max) +RPolarsExpr$lower_bound <- function() .Call(wrap__RPolarsExpr__lower_bound, self) -Expr$lower_bound <- function() .Call(wrap__RPolarsExpr__lower_bound, self) +RPolarsExpr$upper_bound <- function() .Call(wrap__RPolarsExpr__upper_bound, self) -Expr$upper_bound <- function() .Call(wrap__RPolarsExpr__upper_bound, self) +RPolarsExpr$sign <- function() .Call(wrap__RPolarsExpr__sign, self) -Expr$sign <- function() .Call(wrap__RPolarsExpr__sign, self) +RPolarsExpr$sin <- function() .Call(wrap__RPolarsExpr__sin, self) -Expr$sin <- function() .Call(wrap__RPolarsExpr__sin, self) +RPolarsExpr$cos <- function() .Call(wrap__RPolarsExpr__cos, self) -Expr$cos <- function() .Call(wrap__RPolarsExpr__cos, self) +RPolarsExpr$tan <- function() .Call(wrap__RPolarsExpr__tan, self) -Expr$tan <- function() .Call(wrap__RPolarsExpr__tan, self) +RPolarsExpr$arcsin <- function() .Call(wrap__RPolarsExpr__arcsin, self) -Expr$arcsin <- function() .Call(wrap__RPolarsExpr__arcsin, self) +RPolarsExpr$arccos <- function() .Call(wrap__RPolarsExpr__arccos, self) -Expr$arccos <- function() .Call(wrap__RPolarsExpr__arccos, self) +RPolarsExpr$arctan <- function() .Call(wrap__RPolarsExpr__arctan, self) -Expr$arctan <- function() .Call(wrap__RPolarsExpr__arctan, self) +RPolarsExpr$sinh <- function() .Call(wrap__RPolarsExpr__sinh, self) -Expr$sinh <- function() .Call(wrap__RPolarsExpr__sinh, self) +RPolarsExpr$cosh <- function() .Call(wrap__RPolarsExpr__cosh, self) -Expr$cosh <- function() .Call(wrap__RPolarsExpr__cosh, self) +RPolarsExpr$tanh <- function() .Call(wrap__RPolarsExpr__tanh, self) -Expr$tanh <- function() .Call(wrap__RPolarsExpr__tanh, self) +RPolarsExpr$arcsinh <- function() .Call(wrap__RPolarsExpr__arcsinh, self) -Expr$arcsinh <- function() .Call(wrap__RPolarsExpr__arcsinh, self) +RPolarsExpr$arccosh <- function() .Call(wrap__RPolarsExpr__arccosh, self) -Expr$arccosh <- function() .Call(wrap__RPolarsExpr__arccosh, self) +RPolarsExpr$arctanh <- function() .Call(wrap__RPolarsExpr__arctanh, self) -Expr$arctanh <- function() .Call(wrap__RPolarsExpr__arctanh, self) +RPolarsExpr$reshape <- function(dims) .Call(wrap__RPolarsExpr__reshape, self, dims) -Expr$reshape <- function(dims) .Call(wrap__RPolarsExpr__reshape, self, dims) +RPolarsExpr$shuffle <- function(seed) .Call(wrap__RPolarsExpr__shuffle, self, seed) -Expr$shuffle <- function(seed) .Call(wrap__RPolarsExpr__shuffle, self, seed) +RPolarsExpr$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_n, self, n, with_replacement, shuffle, seed) -Expr$sample_n <- function(n, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_n, self, n, with_replacement, shuffle, seed) +RPolarsExpr$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_frac, self, frac, with_replacement, shuffle, seed) -Expr$sample_frac <- function(frac, with_replacement, shuffle, seed) .Call(wrap__RPolarsExpr__sample_frac, self, frac, with_replacement, shuffle, seed) +RPolarsExpr$ewm_mean <- function(alpha, adjust, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_mean, self, alpha, adjust, min_periods, ignore_nulls) -Expr$ewm_mean <- function(alpha, adjust, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_mean, self, alpha, adjust, min_periods, ignore_nulls) +RPolarsExpr$ewm_std <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_std, self, alpha, adjust, bias, min_periods, ignore_nulls) -Expr$ewm_std <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_std, self, alpha, adjust, bias, min_periods, ignore_nulls) +RPolarsExpr$ewm_var <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_var, self, alpha, adjust, bias, min_periods, ignore_nulls) -Expr$ewm_var <- function(alpha, adjust, bias, min_periods, ignore_nulls) .Call(wrap__RPolarsExpr__ewm_var, self, alpha, adjust, bias, min_periods, ignore_nulls) +RPolarsExpr$extend_constant <- function(value, n) .Call(wrap__RPolarsExpr__extend_constant, self, value, n) -Expr$extend_constant <- function(value, n) .Call(wrap__RPolarsExpr__extend_constant, self, value, n) +RPolarsExpr$rep <- function(n, rechunk) .Call(wrap__RPolarsExpr__rep, self, n, rechunk) -Expr$rep <- function(n, rechunk) .Call(wrap__RPolarsExpr__rep, self, n, rechunk) +RPolarsExpr$value_counts <- function(sort, parallel) .Call(wrap__RPolarsExpr__value_counts, self, sort, parallel) -Expr$value_counts <- function(sort, parallel) .Call(wrap__RPolarsExpr__value_counts, self, sort, parallel) +RPolarsExpr$unique_counts <- function() .Call(wrap__RPolarsExpr__unique_counts, self) -Expr$unique_counts <- function() .Call(wrap__RPolarsExpr__unique_counts, self) +RPolarsExpr$entropy <- function(base, normalize) .Call(wrap__RPolarsExpr__entropy, self, base, normalize) -Expr$entropy <- function(base, normalize) .Call(wrap__RPolarsExpr__entropy, self, base, normalize) +RPolarsExpr$cumulative_eval <- function(expr, min_periods, parallel) .Call(wrap__RPolarsExpr__cumulative_eval, self, expr, min_periods, parallel) -Expr$cumulative_eval <- function(expr, min_periods, parallel) .Call(wrap__RPolarsExpr__cumulative_eval, self, expr, min_periods, parallel) +RPolarsExpr$implode <- function() .Call(wrap__RPolarsExpr__implode, self) -Expr$implode <- function() .Call(wrap__RPolarsExpr__implode, self) +RPolarsExpr$shrink_dtype <- function() .Call(wrap__RPolarsExpr__shrink_dtype, self) -Expr$shrink_dtype <- function() .Call(wrap__RPolarsExpr__shrink_dtype, self) +RPolarsExpr$peak_min <- function() .Call(wrap__RPolarsExpr__peak_min, self) -Expr$peak_min <- function() .Call(wrap__RPolarsExpr__peak_min, self) +RPolarsExpr$peak_max <- function() .Call(wrap__RPolarsExpr__peak_max, self) -Expr$peak_max <- function() .Call(wrap__RPolarsExpr__peak_max, self) +RPolarsExpr$list_lengths <- function() .Call(wrap__RPolarsExpr__list_lengths, self) -Expr$list_lengths <- function() .Call(wrap__RPolarsExpr__list_lengths, self) +RPolarsExpr$list_contains <- function(other) .Call(wrap__RPolarsExpr__list_contains, self, other) -Expr$list_contains <- function(other) .Call(wrap__RPolarsExpr__list_contains, self, other) +RPolarsExpr$list_max <- function() .Call(wrap__RPolarsExpr__list_max, self) -Expr$list_max <- function() .Call(wrap__RPolarsExpr__list_max, self) +RPolarsExpr$list_min <- function() .Call(wrap__RPolarsExpr__list_min, self) -Expr$list_min <- function() .Call(wrap__RPolarsExpr__list_min, self) +RPolarsExpr$list_sum <- function() .Call(wrap__RPolarsExpr__list_sum, self) -Expr$list_sum <- function() .Call(wrap__RPolarsExpr__list_sum, self) +RPolarsExpr$list_mean <- function() .Call(wrap__RPolarsExpr__list_mean, self) -Expr$list_mean <- function() .Call(wrap__RPolarsExpr__list_mean, self) +RPolarsExpr$list_sort <- function(descending) .Call(wrap__RPolarsExpr__list_sort, self, descending) -Expr$list_sort <- function(descending) .Call(wrap__RPolarsExpr__list_sort, self, descending) +RPolarsExpr$list_reverse <- function() .Call(wrap__RPolarsExpr__list_reverse, self) -Expr$list_reverse <- function() .Call(wrap__RPolarsExpr__list_reverse, self) +RPolarsExpr$list_unique <- function() .Call(wrap__RPolarsExpr__list_unique, self) -Expr$list_unique <- function() .Call(wrap__RPolarsExpr__list_unique, self) +RPolarsExpr$list_gather <- function(index, null_on_oob) .Call(wrap__RPolarsExpr__list_gather, self, index, null_on_oob) -Expr$list_gather <- function(index, null_on_oob) .Call(wrap__RPolarsExpr__list_gather, self, index, null_on_oob) +RPolarsExpr$list_get <- function(index) .Call(wrap__RPolarsExpr__list_get, self, index) -Expr$list_get <- function(index) .Call(wrap__RPolarsExpr__list_get, self, index) +RPolarsExpr$list_join <- function(separator) .Call(wrap__RPolarsExpr__list_join, self, separator) -Expr$list_join <- function(separator) .Call(wrap__RPolarsExpr__list_join, self, separator) +RPolarsExpr$list_arg_min <- function() .Call(wrap__RPolarsExpr__list_arg_min, self) -Expr$list_arg_min <- function() .Call(wrap__RPolarsExpr__list_arg_min, self) +RPolarsExpr$list_arg_max <- function() .Call(wrap__RPolarsExpr__list_arg_max, self) -Expr$list_arg_max <- function() .Call(wrap__RPolarsExpr__list_arg_max, self) +RPolarsExpr$list_diff <- function(n, null_behavior) .Call(wrap__RPolarsExpr__list_diff, self, n, null_behavior) -Expr$list_diff <- function(n, null_behavior) .Call(wrap__RPolarsExpr__list_diff, self, n, null_behavior) +RPolarsExpr$list_shift <- function(periods) .Call(wrap__RPolarsExpr__list_shift, self, periods) -Expr$list_shift <- function(periods) .Call(wrap__RPolarsExpr__list_shift, self, periods) +RPolarsExpr$list_slice <- function(offset, length) .Call(wrap__RPolarsExpr__list_slice, self, offset, length) -Expr$list_slice <- function(offset, length) .Call(wrap__RPolarsExpr__list_slice, self, offset, length) +RPolarsExpr$list_eval <- function(expr, parallel) .Call(wrap__RPolarsExpr__list_eval, self, expr, parallel) -Expr$list_eval <- function(expr, parallel) .Call(wrap__RPolarsExpr__list_eval, self, expr, parallel) +RPolarsExpr$list_to_struct <- function(width_strat, name_gen, upper_bound) .Call(wrap__RPolarsExpr__list_to_struct, self, width_strat, name_gen, upper_bound) -Expr$list_to_struct <- function(width_strat, name_gen, upper_bound) .Call(wrap__RPolarsExpr__list_to_struct, self, width_strat, name_gen, upper_bound) +RPolarsExpr$str_to_date <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_date, self, format, strict, exact, cache, ambiguous) -Expr$str_to_date <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_date, self, format, strict, exact, cache, ambiguous) +RPolarsExpr$str_to_datetime <- function(format, time_unit, time_zone, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_datetime, self, format, time_unit, time_zone, strict, exact, cache, ambiguous) -Expr$str_to_datetime <- function(format, time_unit, time_zone, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_datetime, self, format, time_unit, time_zone, strict, exact, cache, ambiguous) +RPolarsExpr$str_to_time <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_time, self, format, strict, exact, cache, ambiguous) -Expr$str_to_time <- function(format, strict, exact, cache, ambiguous) .Call(wrap__RPolarsExpr__str_to_time, self, format, strict, exact, cache, ambiguous) +RPolarsExpr$dt_truncate <- function(every, offset) .Call(wrap__RPolarsExpr__dt_truncate, self, every, offset) -Expr$dt_truncate <- function(every, offset) .Call(wrap__RPolarsExpr__dt_truncate, self, every, offset) +RPolarsExpr$dt_round <- function(every, offset) .Call(wrap__RPolarsExpr__dt_round, self, every, offset) -Expr$dt_round <- function(every, offset) .Call(wrap__RPolarsExpr__dt_round, self, every, offset) +RPolarsExpr$dt_time <- function() .Call(wrap__RPolarsExpr__dt_time, self) -Expr$dt_time <- function() .Call(wrap__RPolarsExpr__dt_time, self) +RPolarsExpr$dt_combine <- function(time, tu) .Call(wrap__RPolarsExpr__dt_combine, self, time, tu) -Expr$dt_combine <- function(time, tu) .Call(wrap__RPolarsExpr__dt_combine, self, time, tu) +RPolarsExpr$dt_strftime <- function(fmt) .Call(wrap__RPolarsExpr__dt_strftime, self, fmt) -Expr$dt_strftime <- function(fmt) .Call(wrap__RPolarsExpr__dt_strftime, self, fmt) +RPolarsExpr$dt_year <- function() .Call(wrap__RPolarsExpr__dt_year, self) -Expr$dt_year <- function() .Call(wrap__RPolarsExpr__dt_year, self) +RPolarsExpr$dt_iso_year <- function() .Call(wrap__RPolarsExpr__dt_iso_year, self) -Expr$dt_iso_year <- function() .Call(wrap__RPolarsExpr__dt_iso_year, self) +RPolarsExpr$dt_quarter <- function() .Call(wrap__RPolarsExpr__dt_quarter, self) -Expr$dt_quarter <- function() .Call(wrap__RPolarsExpr__dt_quarter, self) +RPolarsExpr$dt_month <- function() .Call(wrap__RPolarsExpr__dt_month, self) -Expr$dt_month <- function() .Call(wrap__RPolarsExpr__dt_month, self) +RPolarsExpr$dt_week <- function() .Call(wrap__RPolarsExpr__dt_week, self) -Expr$dt_week <- function() .Call(wrap__RPolarsExpr__dt_week, self) +RPolarsExpr$dt_weekday <- function() .Call(wrap__RPolarsExpr__dt_weekday, self) -Expr$dt_weekday <- function() .Call(wrap__RPolarsExpr__dt_weekday, self) +RPolarsExpr$dt_day <- function() .Call(wrap__RPolarsExpr__dt_day, self) -Expr$dt_day <- function() .Call(wrap__RPolarsExpr__dt_day, self) +RPolarsExpr$dt_ordinal_day <- function() .Call(wrap__RPolarsExpr__dt_ordinal_day, self) -Expr$dt_ordinal_day <- function() .Call(wrap__RPolarsExpr__dt_ordinal_day, self) +RPolarsExpr$dt_hour <- function() .Call(wrap__RPolarsExpr__dt_hour, self) -Expr$dt_hour <- function() .Call(wrap__RPolarsExpr__dt_hour, self) +RPolarsExpr$dt_minute <- function() .Call(wrap__RPolarsExpr__dt_minute, self) -Expr$dt_minute <- function() .Call(wrap__RPolarsExpr__dt_minute, self) +RPolarsExpr$dt_second <- function() .Call(wrap__RPolarsExpr__dt_second, self) -Expr$dt_second <- function() .Call(wrap__RPolarsExpr__dt_second, self) +RPolarsExpr$dt_millisecond <- function() .Call(wrap__RPolarsExpr__dt_millisecond, self) -Expr$dt_millisecond <- function() .Call(wrap__RPolarsExpr__dt_millisecond, self) +RPolarsExpr$dt_microsecond <- function() .Call(wrap__RPolarsExpr__dt_microsecond, self) -Expr$dt_microsecond <- function() .Call(wrap__RPolarsExpr__dt_microsecond, self) +RPolarsExpr$dt_nanosecond <- function() .Call(wrap__RPolarsExpr__dt_nanosecond, self) -Expr$dt_nanosecond <- function() .Call(wrap__RPolarsExpr__dt_nanosecond, self) +RPolarsExpr$timestamp <- function(tu) .Call(wrap__RPolarsExpr__timestamp, self, tu) -Expr$timestamp <- function(tu) .Call(wrap__RPolarsExpr__timestamp, self, tu) +RPolarsExpr$dt_epoch_seconds <- function() .Call(wrap__RPolarsExpr__dt_epoch_seconds, self) -Expr$dt_epoch_seconds <- function() .Call(wrap__RPolarsExpr__dt_epoch_seconds, self) +RPolarsExpr$dt_with_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_with_time_unit, self, tu) -Expr$dt_with_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_with_time_unit, self, tu) +RPolarsExpr$dt_cast_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_cast_time_unit, self, tu) -Expr$dt_cast_time_unit <- function(tu) .Call(wrap__RPolarsExpr__dt_cast_time_unit, self, tu) +RPolarsExpr$dt_convert_time_zone <- function(tz) .Call(wrap__RPolarsExpr__dt_convert_time_zone, self, tz) -Expr$dt_convert_time_zone <- function(tz) .Call(wrap__RPolarsExpr__dt_convert_time_zone, self, tz) +RPolarsExpr$dt_replace_time_zone <- function(tz, ambiguous) .Call(wrap__RPolarsExpr__dt_replace_time_zone, self, tz, ambiguous) -Expr$dt_replace_time_zone <- function(tz, ambiguous) .Call(wrap__RPolarsExpr__dt_replace_time_zone, self, tz, ambiguous) +RPolarsExpr$dt_total_days <- function() .Call(wrap__RPolarsExpr__dt_total_days, self) -Expr$dt_total_days <- function() .Call(wrap__RPolarsExpr__dt_total_days, self) +RPolarsExpr$dt_total_hours <- function() .Call(wrap__RPolarsExpr__dt_total_hours, self) -Expr$dt_total_hours <- function() .Call(wrap__RPolarsExpr__dt_total_hours, self) +RPolarsExpr$dt_total_minutes <- function() .Call(wrap__RPolarsExpr__dt_total_minutes, self) -Expr$dt_total_minutes <- function() .Call(wrap__RPolarsExpr__dt_total_minutes, self) +RPolarsExpr$dt_total_seconds <- function() .Call(wrap__RPolarsExpr__dt_total_seconds, self) -Expr$dt_total_seconds <- function() .Call(wrap__RPolarsExpr__dt_total_seconds, self) +RPolarsExpr$dt_total_milliseconds <- function() .Call(wrap__RPolarsExpr__dt_total_milliseconds, self) -Expr$dt_total_milliseconds <- function() .Call(wrap__RPolarsExpr__dt_total_milliseconds, self) +RPolarsExpr$dt_total_microseconds <- function() .Call(wrap__RPolarsExpr__dt_total_microseconds, self) -Expr$dt_total_microseconds <- function() .Call(wrap__RPolarsExpr__dt_total_microseconds, self) +RPolarsExpr$dt_total_nanoseconds <- function() .Call(wrap__RPolarsExpr__dt_total_nanoseconds, self) -Expr$dt_total_nanoseconds <- function() .Call(wrap__RPolarsExpr__dt_total_nanoseconds, self) +RPolarsExpr$dt_offset_by <- function(by) .Call(wrap__RPolarsExpr__dt_offset_by, self, by) -Expr$dt_offset_by <- function(by) .Call(wrap__RPolarsExpr__dt_offset_by, self, by) +RPolarsExpr$repeat_by <- function(by) .Call(wrap__RPolarsExpr__repeat_by, self, by) -Expr$repeat_by <- function(by) .Call(wrap__RPolarsExpr__repeat_by, self, by) +RPolarsExpr$log10 <- function() .Call(wrap__RPolarsExpr__log10, self) -Expr$log10 <- function() .Call(wrap__RPolarsExpr__log10, self) +RPolarsExpr$log <- function(base) .Call(wrap__RPolarsExpr__log, self, base) -Expr$log <- function(base) .Call(wrap__RPolarsExpr__log, self, base) +RPolarsExpr$exp <- function() .Call(wrap__RPolarsExpr__exp, self) -Expr$exp <- function() .Call(wrap__RPolarsExpr__exp, self) +RPolarsExpr$exclude <- function(columns) .Call(wrap__RPolarsExpr__exclude, self, columns) -Expr$exclude <- function(columns) .Call(wrap__RPolarsExpr__exclude, self, columns) +RPolarsExpr$exclude_dtype <- function(columns) .Call(wrap__RPolarsExpr__exclude_dtype, self, columns) -Expr$exclude_dtype <- function(columns) .Call(wrap__RPolarsExpr__exclude_dtype, self, columns) +RPolarsExpr$alias <- function(s) .Call(wrap__RPolarsExpr__alias, self, s) -Expr$alias <- function(s) .Call(wrap__RPolarsExpr__alias, self, s) +RPolarsExpr$drop_nulls <- function() .Call(wrap__RPolarsExpr__drop_nulls, self) -Expr$drop_nulls <- function() .Call(wrap__RPolarsExpr__drop_nulls, self) +RPolarsExpr$drop_nans <- function() .Call(wrap__RPolarsExpr__drop_nans, self) -Expr$drop_nans <- function() .Call(wrap__RPolarsExpr__drop_nans, self) +RPolarsExpr$cum_sum <- function(reverse) .Call(wrap__RPolarsExpr__cum_sum, self, reverse) -Expr$cum_sum <- function(reverse) .Call(wrap__RPolarsExpr__cum_sum, self, reverse) +RPolarsExpr$cum_prod <- function(reverse) .Call(wrap__RPolarsExpr__cum_prod, self, reverse) -Expr$cum_prod <- function(reverse) .Call(wrap__RPolarsExpr__cum_prod, self, reverse) +RPolarsExpr$cum_min <- function(reverse) .Call(wrap__RPolarsExpr__cum_min, self, reverse) -Expr$cum_min <- function(reverse) .Call(wrap__RPolarsExpr__cum_min, self, reverse) +RPolarsExpr$cum_max <- function(reverse) .Call(wrap__RPolarsExpr__cum_max, self, reverse) -Expr$cum_max <- function(reverse) .Call(wrap__RPolarsExpr__cum_max, self, reverse) +RPolarsExpr$cum_count <- function(reverse) .Call(wrap__RPolarsExpr__cum_count, self, reverse) -Expr$cum_count <- function(reverse) .Call(wrap__RPolarsExpr__cum_count, self, reverse) +RPolarsExpr$floor <- function() .Call(wrap__RPolarsExpr__floor, self) -Expr$floor <- function() .Call(wrap__RPolarsExpr__floor, self) +RPolarsExpr$ceil <- function() .Call(wrap__RPolarsExpr__ceil, self) -Expr$ceil <- function() .Call(wrap__RPolarsExpr__ceil, self) +RPolarsExpr$round <- function(decimals) .Call(wrap__RPolarsExpr__round, self, decimals) -Expr$round <- function(decimals) .Call(wrap__RPolarsExpr__round, self, decimals) +RPolarsExpr$dot <- function(other) .Call(wrap__RPolarsExpr__dot, self, other) -Expr$dot <- function(other) .Call(wrap__RPolarsExpr__dot, self, other) +RPolarsExpr$mode <- function() .Call(wrap__RPolarsExpr__mode, self) -Expr$mode <- function() .Call(wrap__RPolarsExpr__mode, self) +RPolarsExpr$first <- function() .Call(wrap__RPolarsExpr__first, self) -Expr$first <- function() .Call(wrap__RPolarsExpr__first, self) +RPolarsExpr$last <- function() .Call(wrap__RPolarsExpr__last, self) -Expr$last <- function() .Call(wrap__RPolarsExpr__last, self) +RPolarsExpr$head <- function(n) .Call(wrap__RPolarsExpr__head, self, n) -Expr$head <- function(n) .Call(wrap__RPolarsExpr__head, self, n) +RPolarsExpr$tail <- function(n) .Call(wrap__RPolarsExpr__tail, self, n) -Expr$tail <- function(n) .Call(wrap__RPolarsExpr__tail, self, n) +RPolarsExpr$unique <- function() .Call(wrap__RPolarsExpr__unique, self) -Expr$unique <- function() .Call(wrap__RPolarsExpr__unique, self) +RPolarsExpr$unique_stable <- function() .Call(wrap__RPolarsExpr__unique_stable, self) -Expr$unique_stable <- function() .Call(wrap__RPolarsExpr__unique_stable, self) +RPolarsExpr$agg_groups <- function() .Call(wrap__RPolarsExpr__agg_groups, self) -Expr$agg_groups <- function() .Call(wrap__RPolarsExpr__agg_groups, self) +RPolarsExpr$all <- function(drop_nulls) .Call(wrap__RPolarsExpr__all, self, drop_nulls) -Expr$all <- function(drop_nulls) .Call(wrap__RPolarsExpr__all, self, drop_nulls) +RPolarsExpr$any <- function(drop_nulls) .Call(wrap__RPolarsExpr__any, self, drop_nulls) -Expr$any <- function(drop_nulls) .Call(wrap__RPolarsExpr__any, self, drop_nulls) +RPolarsExpr$is_duplicated <- function() .Call(wrap__RPolarsExpr__is_duplicated, self) -Expr$is_duplicated <- function() .Call(wrap__RPolarsExpr__is_duplicated, self) +RPolarsExpr$is_finite <- function() .Call(wrap__RPolarsExpr__is_finite, self) -Expr$is_finite <- function() .Call(wrap__RPolarsExpr__is_finite, self) +RPolarsExpr$is_first_distinct <- function() .Call(wrap__RPolarsExpr__is_first_distinct, self) -Expr$is_first_distinct <- function() .Call(wrap__RPolarsExpr__is_first_distinct, self) +RPolarsExpr$is_in <- function(other) .Call(wrap__RPolarsExpr__is_in, self, other) -Expr$is_in <- function(other) .Call(wrap__RPolarsExpr__is_in, self, other) +RPolarsExpr$is_infinite <- function() .Call(wrap__RPolarsExpr__is_infinite, self) -Expr$is_infinite <- function() .Call(wrap__RPolarsExpr__is_infinite, self) +RPolarsExpr$is_last_distinct <- function() .Call(wrap__RPolarsExpr__is_last_distinct, self) -Expr$is_last_distinct <- function() .Call(wrap__RPolarsExpr__is_last_distinct, self) +RPolarsExpr$is_nan <- function() .Call(wrap__RPolarsExpr__is_nan, self) -Expr$is_nan <- function() .Call(wrap__RPolarsExpr__is_nan, self) +RPolarsExpr$is_not_null <- function() .Call(wrap__RPolarsExpr__is_not_null, self) -Expr$is_not_null <- function() .Call(wrap__RPolarsExpr__is_not_null, self) +RPolarsExpr$is_not_nan <- function() .Call(wrap__RPolarsExpr__is_not_nan, self) -Expr$is_not_nan <- function() .Call(wrap__RPolarsExpr__is_not_nan, self) +RPolarsExpr$is_null <- function() .Call(wrap__RPolarsExpr__is_null, self) -Expr$is_null <- function() .Call(wrap__RPolarsExpr__is_null, self) +RPolarsExpr$is_unique <- function() .Call(wrap__RPolarsExpr__is_unique, self) -Expr$is_unique <- function() .Call(wrap__RPolarsExpr__is_unique, self) +RPolarsExpr$not <- function() .Call(wrap__RPolarsExpr__not, self) -Expr$not <- function() .Call(wrap__RPolarsExpr__not, self) +RPolarsExpr$count <- function() .Call(wrap__RPolarsExpr__count, self) -Expr$count <- function() .Call(wrap__RPolarsExpr__count, self) +RPolarsExpr$len <- function() .Call(wrap__RPolarsExpr__len, self) -Expr$len <- function() .Call(wrap__RPolarsExpr__len, self) +RPolarsExpr$slice <- function(offset, length) .Call(wrap__RPolarsExpr__slice, self, offset, length) -Expr$slice <- function(offset, length) .Call(wrap__RPolarsExpr__slice, self, offset, length) +RPolarsExpr$append <- function(other, upcast) .Call(wrap__RPolarsExpr__append, self, other, upcast) -Expr$append <- function(other, upcast) .Call(wrap__RPolarsExpr__append, self, other, upcast) +RPolarsExpr$rechunk <- function() .Call(wrap__RPolarsExpr__rechunk, self) -Expr$rechunk <- function() .Call(wrap__RPolarsExpr__rechunk, self) +RPolarsExpr$add <- function(other) .Call(wrap__RPolarsExpr__add, self, other) -Expr$add <- function(other) .Call(wrap__RPolarsExpr__add, self, other) +RPolarsExpr$floor_div <- function(other) .Call(wrap__RPolarsExpr__floor_div, self, other) -Expr$floor_div <- function(other) .Call(wrap__RPolarsExpr__floor_div, self, other) +RPolarsExpr$rem <- function(other) .Call(wrap__RPolarsExpr__rem, self, other) -Expr$rem <- function(other) .Call(wrap__RPolarsExpr__rem, self, other) +RPolarsExpr$mul <- function(other) .Call(wrap__RPolarsExpr__mul, self, other) -Expr$mul <- function(other) .Call(wrap__RPolarsExpr__mul, self, other) +RPolarsExpr$sub <- function(other) .Call(wrap__RPolarsExpr__sub, self, other) -Expr$sub <- function(other) .Call(wrap__RPolarsExpr__sub, self, other) +RPolarsExpr$div <- function(other) .Call(wrap__RPolarsExpr__div, self, other) -Expr$div <- function(other) .Call(wrap__RPolarsExpr__div, self, other) +RPolarsExpr$pow <- function(exponent) .Call(wrap__RPolarsExpr__pow, self, exponent) -Expr$pow <- function(exponent) .Call(wrap__RPolarsExpr__pow, self, exponent) +RPolarsExpr$over <- function(proto_exprs) .Call(wrap__RPolarsExpr__over, self, proto_exprs) -Expr$over <- function(proto_exprs) .Call(wrap__RPolarsExpr__over, self, proto_exprs) +RPolarsExpr$print <- function() invisible(.Call(wrap__RPolarsExpr__print, self)) -Expr$print <- function() invisible(.Call(wrap__RPolarsExpr__print, self)) +RPolarsExpr$map_batches <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches, self, lambda, output_type, agg_list) -Expr$map_batches <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches, self, lambda, output_type, agg_list) +RPolarsExpr$map_batches_in_background <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches_in_background, self, lambda, output_type, agg_list) -Expr$map_batches_in_background <- function(lambda, output_type, agg_list) .Call(wrap__RPolarsExpr__map_batches_in_background, self, lambda, output_type, agg_list) +RPolarsExpr$map_elements_in_background <- function(lambda, output_type) .Call(wrap__RPolarsExpr__map_elements_in_background, self, lambda, output_type) -Expr$map_elements_in_background <- function(lambda, output_type) .Call(wrap__RPolarsExpr__map_elements_in_background, self, lambda, output_type) +RPolarsExpr$approx_n_unique <- function() .Call(wrap__RPolarsExpr__approx_n_unique, self) -Expr$approx_n_unique <- function() .Call(wrap__RPolarsExpr__approx_n_unique, self) +RPolarsExpr$name_keep <- function() .Call(wrap__RPolarsExpr__name_keep, self) -Expr$name_keep <- function() .Call(wrap__RPolarsExpr__name_keep, self) +RPolarsExpr$name_suffix <- function(suffix) .Call(wrap__RPolarsExpr__name_suffix, self, suffix) -Expr$name_suffix <- function(suffix) .Call(wrap__RPolarsExpr__name_suffix, self, suffix) +RPolarsExpr$name_prefix <- function(prefix) .Call(wrap__RPolarsExpr__name_prefix, self, prefix) -Expr$name_prefix <- function(prefix) .Call(wrap__RPolarsExpr__name_prefix, self, prefix) +RPolarsExpr$name_to_lowercase <- function() .Call(wrap__RPolarsExpr__name_to_lowercase, self) -Expr$name_to_lowercase <- function() .Call(wrap__RPolarsExpr__name_to_lowercase, self) +RPolarsExpr$name_to_uppercase <- function() .Call(wrap__RPolarsExpr__name_to_uppercase, self) -Expr$name_to_uppercase <- function() .Call(wrap__RPolarsExpr__name_to_uppercase, self) +RPolarsExpr$name_map <- function(lambda) .Call(wrap__RPolarsExpr__name_map, self, lambda) -Expr$name_map <- function(lambda) .Call(wrap__RPolarsExpr__name_map, self, lambda) +RPolarsExpr$str_len_bytes <- function() .Call(wrap__RPolarsExpr__str_len_bytes, self) -Expr$str_len_bytes <- function() .Call(wrap__RPolarsExpr__str_len_bytes, self) +RPolarsExpr$str_len_chars <- function() .Call(wrap__RPolarsExpr__str_len_chars, self) -Expr$str_len_chars <- function() .Call(wrap__RPolarsExpr__str_len_chars, self) +RPolarsExpr$str_concat <- function(delimiter, ignore_nulls) .Call(wrap__RPolarsExpr__str_concat, self, delimiter, ignore_nulls) -Expr$str_concat <- function(delimiter, ignore_nulls) .Call(wrap__RPolarsExpr__str_concat, self, delimiter, ignore_nulls) +RPolarsExpr$str_to_uppercase <- function() .Call(wrap__RPolarsExpr__str_to_uppercase, self) -Expr$str_to_uppercase <- function() .Call(wrap__RPolarsExpr__str_to_uppercase, self) +RPolarsExpr$str_to_lowercase <- function() .Call(wrap__RPolarsExpr__str_to_lowercase, self) -Expr$str_to_lowercase <- function() .Call(wrap__RPolarsExpr__str_to_lowercase, self) +RPolarsExpr$str_to_titlecase <- function() .Call(wrap__RPolarsExpr__str_to_titlecase, self) -Expr$str_to_titlecase <- function() .Call(wrap__RPolarsExpr__str_to_titlecase, self) +RPolarsExpr$str_strip_chars <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars, self, matches) -Expr$str_strip_chars <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars, self, matches) +RPolarsExpr$str_strip_chars_end <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_end, self, matches) -Expr$str_strip_chars_end <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_end, self, matches) +RPolarsExpr$str_strip_chars_start <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_start, self, matches) -Expr$str_strip_chars_start <- function(matches) .Call(wrap__RPolarsExpr__str_strip_chars_start, self, matches) +RPolarsExpr$str_zfill <- function(alignment) .Call(wrap__RPolarsExpr__str_zfill, self, alignment) -Expr$str_zfill <- function(alignment) .Call(wrap__RPolarsExpr__str_zfill, self, alignment) +RPolarsExpr$str_pad_end <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_end, self, width, fillchar) -Expr$str_pad_end <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_end, self, width, fillchar) +RPolarsExpr$str_pad_start <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_start, self, width, fillchar) -Expr$str_pad_start <- function(width, fillchar) .Call(wrap__RPolarsExpr__str_pad_start, self, width, fillchar) +RPolarsExpr$str_contains <- function(pat, literal, strict) .Call(wrap__RPolarsExpr__str_contains, self, pat, literal, strict) -Expr$str_contains <- function(pat, literal, strict) .Call(wrap__RPolarsExpr__str_contains, self, pat, literal, strict) +RPolarsExpr$str_ends_with <- function(sub) .Call(wrap__RPolarsExpr__str_ends_with, self, sub) -Expr$str_ends_with <- function(sub) .Call(wrap__RPolarsExpr__str_ends_with, self, sub) +RPolarsExpr$str_starts_with <- function(sub) .Call(wrap__RPolarsExpr__str_starts_with, self, sub) -Expr$str_starts_with <- function(sub) .Call(wrap__RPolarsExpr__str_starts_with, self, sub) +RPolarsExpr$str_json_path_match <- function(pat) .Call(wrap__RPolarsExpr__str_json_path_match, self, pat) -Expr$str_json_path_match <- function(pat) .Call(wrap__RPolarsExpr__str_json_path_match, self, pat) +RPolarsExpr$str_json_extract <- function(dtype, infer_schema_len) .Call(wrap__RPolarsExpr__str_json_extract, self, dtype, infer_schema_len) -Expr$str_json_extract <- function(dtype, infer_schema_len) .Call(wrap__RPolarsExpr__str_json_extract, self, dtype, infer_schema_len) +RPolarsExpr$str_hex_encode <- function() .Call(wrap__RPolarsExpr__str_hex_encode, self) -Expr$str_hex_encode <- function() .Call(wrap__RPolarsExpr__str_hex_encode, self) +RPolarsExpr$str_hex_decode <- function(strict) .Call(wrap__RPolarsExpr__str_hex_decode, self, strict) -Expr$str_hex_decode <- function(strict) .Call(wrap__RPolarsExpr__str_hex_decode, self, strict) +RPolarsExpr$str_base64_encode <- function() .Call(wrap__RPolarsExpr__str_base64_encode, self) -Expr$str_base64_encode <- function() .Call(wrap__RPolarsExpr__str_base64_encode, self) +RPolarsExpr$str_base64_decode <- function(strict) .Call(wrap__RPolarsExpr__str_base64_decode, self, strict) -Expr$str_base64_decode <- function(strict) .Call(wrap__RPolarsExpr__str_base64_decode, self, strict) +RPolarsExpr$str_extract <- function(pattern, group_index) .Call(wrap__RPolarsExpr__str_extract, self, pattern, group_index) -Expr$str_extract <- function(pattern, group_index) .Call(wrap__RPolarsExpr__str_extract, self, pattern, group_index) +RPolarsExpr$str_extract_all <- function(pattern) .Call(wrap__RPolarsExpr__str_extract_all, self, pattern) -Expr$str_extract_all <- function(pattern) .Call(wrap__RPolarsExpr__str_extract_all, self, pattern) +RPolarsExpr$str_count_matches <- function(pattern, literal) .Call(wrap__RPolarsExpr__str_count_matches, self, pattern, literal) -Expr$str_count_matches <- function(pattern, literal) .Call(wrap__RPolarsExpr__str_count_matches, self, pattern, literal) +RPolarsExpr$str_split <- function(by, inclusive) .Call(wrap__RPolarsExpr__str_split, self, by, inclusive) -Expr$str_split <- function(by, inclusive) .Call(wrap__RPolarsExpr__str_split, self, by, inclusive) +RPolarsExpr$str_split_exact <- function(by, n, inclusive) .Call(wrap__RPolarsExpr__str_split_exact, self, by, n, inclusive) -Expr$str_split_exact <- function(by, n, inclusive) .Call(wrap__RPolarsExpr__str_split_exact, self, by, n, inclusive) +RPolarsExpr$str_splitn <- function(by, n) .Call(wrap__RPolarsExpr__str_splitn, self, by, n) -Expr$str_splitn <- function(by, n) .Call(wrap__RPolarsExpr__str_splitn, self, by, n) +RPolarsExpr$str_replace <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace, self, pattern, value, literal) -Expr$str_replace <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace, self, pattern, value, literal) +RPolarsExpr$str_replace_all <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace_all, self, pattern, value, literal) -Expr$str_replace_all <- function(pattern, value, literal) .Call(wrap__RPolarsExpr__str_replace_all, self, pattern, value, literal) +RPolarsExpr$str_slice <- function(offset, length) .Call(wrap__RPolarsExpr__str_slice, self, offset, length) -Expr$str_slice <- function(offset, length) .Call(wrap__RPolarsExpr__str_slice, self, offset, length) +RPolarsExpr$str_explode <- function() .Call(wrap__RPolarsExpr__str_explode, self) -Expr$str_explode <- function() .Call(wrap__RPolarsExpr__str_explode, self) +RPolarsExpr$str_parse_int <- function(radix, strict) .Call(wrap__RPolarsExpr__str_parse_int, self, radix, strict) -Expr$str_parse_int <- function(radix, strict) .Call(wrap__RPolarsExpr__str_parse_int, self, radix, strict) +RPolarsExpr$bin_contains <- function(lit) .Call(wrap__RPolarsExpr__bin_contains, self, lit) -Expr$bin_contains <- function(lit) .Call(wrap__RPolarsExpr__bin_contains, self, lit) +RPolarsExpr$bin_starts_with <- function(sub) .Call(wrap__RPolarsExpr__bin_starts_with, self, sub) -Expr$bin_starts_with <- function(sub) .Call(wrap__RPolarsExpr__bin_starts_with, self, sub) +RPolarsExpr$bin_ends_with <- function(sub) .Call(wrap__RPolarsExpr__bin_ends_with, self, sub) -Expr$bin_ends_with <- function(sub) .Call(wrap__RPolarsExpr__bin_ends_with, self, sub) +RPolarsExpr$bin_encode_hex <- function() .Call(wrap__RPolarsExpr__bin_encode_hex, self) -Expr$bin_encode_hex <- function() .Call(wrap__RPolarsExpr__bin_encode_hex, self) +RPolarsExpr$bin_encode_base64 <- function() .Call(wrap__RPolarsExpr__bin_encode_base64, self) -Expr$bin_encode_base64 <- function() .Call(wrap__RPolarsExpr__bin_encode_base64, self) +RPolarsExpr$bin_decode_hex <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_hex, self, strict) -Expr$bin_decode_hex <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_hex, self, strict) +RPolarsExpr$bin_decode_base64 <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_base64, self, strict) -Expr$bin_decode_base64 <- function(strict) .Call(wrap__RPolarsExpr__bin_decode_base64, self, strict) +RPolarsExpr$struct_field_by_name <- function(name) .Call(wrap__RPolarsExpr__struct_field_by_name, self, name) -Expr$struct_field_by_name <- function(name) .Call(wrap__RPolarsExpr__struct_field_by_name, self, name) +RPolarsExpr$struct_rename_fields <- function(names) .Call(wrap__RPolarsExpr__struct_rename_fields, self, names) -Expr$struct_rename_fields <- function(names) .Call(wrap__RPolarsExpr__struct_rename_fields, self, names) +RPolarsExpr$meta_pop <- function() .Call(wrap__RPolarsExpr__meta_pop, self) -Expr$meta_pop <- function() .Call(wrap__RPolarsExpr__meta_pop, self) +RPolarsExpr$meta_eq <- function(other) .Call(wrap__RPolarsExpr__meta_eq, self, other) -Expr$meta_eq <- function(other) .Call(wrap__RPolarsExpr__meta_eq, self, other) +RPolarsExpr$meta_roots <- function() .Call(wrap__RPolarsExpr__meta_roots, self) -Expr$meta_roots <- function() .Call(wrap__RPolarsExpr__meta_roots, self) +RPolarsExpr$meta_output_name <- function() .Call(wrap__RPolarsExpr__meta_output_name, self) -Expr$meta_output_name <- function() .Call(wrap__RPolarsExpr__meta_output_name, self) +RPolarsExpr$meta_undo_aliases <- function() .Call(wrap__RPolarsExpr__meta_undo_aliases, self) -Expr$meta_undo_aliases <- function() .Call(wrap__RPolarsExpr__meta_undo_aliases, self) +RPolarsExpr$meta_has_multiple_outputs <- function() .Call(wrap__RPolarsExpr__meta_has_multiple_outputs, self) -Expr$meta_has_multiple_outputs <- function() .Call(wrap__RPolarsExpr__meta_has_multiple_outputs, self) +RPolarsExpr$meta_is_regex_projection <- function() .Call(wrap__RPolarsExpr__meta_is_regex_projection, self) -Expr$meta_is_regex_projection <- function() .Call(wrap__RPolarsExpr__meta_is_regex_projection, self) +RPolarsExpr$meta_tree_format <- function() .Call(wrap__RPolarsExpr__meta_tree_format, self) -Expr$meta_tree_format <- function() .Call(wrap__RPolarsExpr__meta_tree_format, self) +RPolarsExpr$cat_set_ordering <- function(ordering) .Call(wrap__RPolarsExpr__cat_set_ordering, self, ordering) -Expr$cat_set_ordering <- function(ordering) .Call(wrap__RPolarsExpr__cat_set_ordering, self, ordering) +RPolarsExpr$cat_get_categories <- function() .Call(wrap__RPolarsExpr__cat_get_categories, self) -Expr$cat_get_categories <- function() .Call(wrap__RPolarsExpr__cat_get_categories, self) +RPolarsExpr$new_count <- function() .Call(wrap__RPolarsExpr__new_count) -Expr$new_count <- function() .Call(wrap__RPolarsExpr__new_count) +RPolarsExpr$new_first <- function() .Call(wrap__RPolarsExpr__new_first) -Expr$new_first <- function() .Call(wrap__RPolarsExpr__new_first) +RPolarsExpr$new_last <- function() .Call(wrap__RPolarsExpr__new_last) -Expr$new_last <- function() .Call(wrap__RPolarsExpr__new_last) +RPolarsExpr$cov <- function(a, b, ddof) .Call(wrap__RPolarsExpr__cov, a, b, ddof) -Expr$cov <- function(a, b, ddof) .Call(wrap__RPolarsExpr__cov, a, b, ddof) +RPolarsExpr$rolling_cov <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_cov, a, b, window_size, min_periods, ddof) -Expr$rolling_cov <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_cov, a, b, window_size, min_periods, ddof) +RPolarsExpr$corr <- function(a, b, method, ddof, propagate_nans) .Call(wrap__RPolarsExpr__corr, a, b, method, ddof, propagate_nans) -Expr$corr <- function(a, b, method, ddof, propagate_nans) .Call(wrap__RPolarsExpr__corr, a, b, method, ddof, propagate_nans) +RPolarsExpr$rolling_corr <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_corr, a, b, window_size, min_periods, ddof) -Expr$rolling_corr <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_corr, a, b, window_size, min_periods, ddof) - -Expr$rolling <- function(index_column, period, offset, closed, check_sorted) .Call(wrap__RPolarsExpr__rolling, self, index_column, period, offset, closed, check_sorted) - -RPolarsExpr <- Expr +RPolarsExpr$rolling <- function(index_column, period, offset, closed, check_sorted) .Call(wrap__RPolarsExpr__rolling, self, index_column, period, offset, closed, check_sorted) #' @export `$.RPolarsExpr` <- function (self, name) { func <- RPolarsExpr[[name]]; environment(func) <- environment(); func } @@ -1017,10 +985,6 @@ RPolarsExpr <- Expr #' @export `[[.RPolarsExpr` <- `$.RPolarsExpr` -`$.Expr` <- function (self, name) { func <- Expr[[name]]; environment(func) <- environment(); func } - -`[[.Expr` <- `$.Expr` - ProtoExprArray <- new.env(parent = emptyenv()) ProtoExprArray$new <- function() .Call(wrap__ProtoExprArray__new) @@ -1037,109 +1001,107 @@ ProtoExprArray$print <- function() invisible(.Call(wrap__ProtoExprArray__print, #' @export `[[.ProtoExprArray` <- `$.ProtoExprArray` -LazyFrame <- new.env(parent = emptyenv()) +RPolarsLazyFrame <- new.env(parent = emptyenv()) -LazyFrame$print <- function() .Call(wrap__RPolarsLazyFrame__print, self) +RPolarsLazyFrame$print <- function() .Call(wrap__RPolarsLazyFrame__print, self) -LazyFrame$describe_plan <- function() invisible(.Call(wrap__RPolarsLazyFrame__describe_plan, self)) +RPolarsLazyFrame$describe_plan <- function() invisible(.Call(wrap__RPolarsLazyFrame__describe_plan, self)) -LazyFrame$debug_plan <- function() .Call(wrap__RPolarsLazyFrame__debug_plan, self) +RPolarsLazyFrame$debug_plan <- function() .Call(wrap__RPolarsLazyFrame__debug_plan, self) -LazyFrame$describe_optimized_plan <- function() .Call(wrap__RPolarsLazyFrame__describe_optimized_plan, self) +RPolarsLazyFrame$describe_optimized_plan <- function() .Call(wrap__RPolarsLazyFrame__describe_optimized_plan, self) -LazyFrame$collect <- function() .Call(wrap__RPolarsLazyFrame__collect, self) +RPolarsLazyFrame$collect <- function() .Call(wrap__RPolarsLazyFrame__collect, self) -LazyFrame$collect_in_background <- function() .Call(wrap__RPolarsLazyFrame__collect_in_background, self) +RPolarsLazyFrame$collect_in_background <- function() .Call(wrap__RPolarsLazyFrame__collect_in_background, self) -LazyFrame$sink_parquet <- function(path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_parquet, self, path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) +RPolarsLazyFrame$sink_parquet <- function(path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_parquet, self, path, compression_method, compression_level, statistics, row_group_size, data_pagesize_limit, maintain_order) -LazyFrame$sink_ipc <- function(path, compression_method, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_ipc, self, path, compression_method, maintain_order) +RPolarsLazyFrame$sink_ipc <- function(path, compression_method, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_ipc, self, path, compression_method, maintain_order) -LazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) +RPolarsLazyFrame$sink_csv <- function(path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) .Call(wrap__RPolarsLazyFrame__sink_csv, self, path, include_bom, include_header, separator, line_terminator, quote, batch_size, datetime_format, date_format, time_format, float_precision, null_value, quote_style, maintain_order) -LazyFrame$first <- function() .Call(wrap__RPolarsLazyFrame__first, self) +RPolarsLazyFrame$first <- function() .Call(wrap__RPolarsLazyFrame__first, self) -LazyFrame$last <- function() .Call(wrap__RPolarsLazyFrame__last, self) +RPolarsLazyFrame$last <- function() .Call(wrap__RPolarsLazyFrame__last, self) -LazyFrame$max <- function() .Call(wrap__RPolarsLazyFrame__max, self) +RPolarsLazyFrame$max <- function() .Call(wrap__RPolarsLazyFrame__max, self) -LazyFrame$min <- function() .Call(wrap__RPolarsLazyFrame__min, self) +RPolarsLazyFrame$min <- function() .Call(wrap__RPolarsLazyFrame__min, self) -LazyFrame$mean <- function() .Call(wrap__RPolarsLazyFrame__mean, self) +RPolarsLazyFrame$mean <- function() .Call(wrap__RPolarsLazyFrame__mean, self) -LazyFrame$median <- function() .Call(wrap__RPolarsLazyFrame__median, self) +RPolarsLazyFrame$median <- function() .Call(wrap__RPolarsLazyFrame__median, self) -LazyFrame$sum <- function() .Call(wrap__RPolarsLazyFrame__sum, self) +RPolarsLazyFrame$sum <- function() .Call(wrap__RPolarsLazyFrame__sum, self) -LazyFrame$std <- function(ddof) .Call(wrap__RPolarsLazyFrame__std, self, ddof) +RPolarsLazyFrame$std <- function(ddof) .Call(wrap__RPolarsLazyFrame__std, self, ddof) -LazyFrame$var <- function(ddof) .Call(wrap__RPolarsLazyFrame__var, self, ddof) +RPolarsLazyFrame$var <- function(ddof) .Call(wrap__RPolarsLazyFrame__var, self, ddof) -LazyFrame$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsLazyFrame__quantile, self, quantile, interpolation) +RPolarsLazyFrame$quantile <- function(quantile, interpolation) .Call(wrap__RPolarsLazyFrame__quantile, self, quantile, interpolation) -LazyFrame$shift <- function(periods) .Call(wrap__RPolarsLazyFrame__shift, self, periods) +RPolarsLazyFrame$shift <- function(periods) .Call(wrap__RPolarsLazyFrame__shift, self, periods) -LazyFrame$shift_and_fill <- function(fill_value, periods) .Call(wrap__RPolarsLazyFrame__shift_and_fill, self, fill_value, periods) +RPolarsLazyFrame$shift_and_fill <- function(fill_value, periods) .Call(wrap__RPolarsLazyFrame__shift_and_fill, self, fill_value, periods) -LazyFrame$reverse <- function() .Call(wrap__RPolarsLazyFrame__reverse, self) +RPolarsLazyFrame$reverse <- function() .Call(wrap__RPolarsLazyFrame__reverse, self) -LazyFrame$drop <- function(columns) .Call(wrap__RPolarsLazyFrame__drop, self, columns) +RPolarsLazyFrame$drop <- function(columns) .Call(wrap__RPolarsLazyFrame__drop, self, columns) -LazyFrame$fill_nan <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_nan, self, fill_value) +RPolarsLazyFrame$fill_nan <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_nan, self, fill_value) -LazyFrame$fill_null <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_null, self, fill_value) +RPolarsLazyFrame$fill_null <- function(fill_value) .Call(wrap__RPolarsLazyFrame__fill_null, self, fill_value) -LazyFrame$slice <- function(offset, length) .Call(wrap__RPolarsLazyFrame__slice, self, offset, length) +RPolarsLazyFrame$slice <- function(offset, length) .Call(wrap__RPolarsLazyFrame__slice, self, offset, length) -LazyFrame$with_columns <- function(exprs) .Call(wrap__RPolarsLazyFrame__with_columns, self, exprs) +RPolarsLazyFrame$with_columns <- function(exprs) .Call(wrap__RPolarsLazyFrame__with_columns, self, exprs) -LazyFrame$unnest <- function(names) .Call(wrap__RPolarsLazyFrame__unnest, self, names) +RPolarsLazyFrame$unnest <- function(names) .Call(wrap__RPolarsLazyFrame__unnest, self, names) -LazyFrame$select <- function(exprs) .Call(wrap__RPolarsLazyFrame__select, self, exprs) +RPolarsLazyFrame$select <- function(exprs) .Call(wrap__RPolarsLazyFrame__select, self, exprs) -LazyFrame$select_str_as_lit <- function(exprs) .Call(wrap__RPolarsLazyFrame__select_str_as_lit, self, exprs) +RPolarsLazyFrame$select_str_as_lit <- function(exprs) .Call(wrap__RPolarsLazyFrame__select_str_as_lit, self, exprs) -LazyFrame$limit <- function(n) .Call(wrap__RPolarsLazyFrame__limit, self, n) +RPolarsLazyFrame$limit <- function(n) .Call(wrap__RPolarsLazyFrame__limit, self, n) -LazyFrame$tail <- function(n) .Call(wrap__RPolarsLazyFrame__tail, self, n) +RPolarsLazyFrame$tail <- function(n) .Call(wrap__RPolarsLazyFrame__tail, self, n) -LazyFrame$filter <- function(expr) .Call(wrap__RPolarsLazyFrame__filter, self, expr) +RPolarsLazyFrame$filter <- function(expr) .Call(wrap__RPolarsLazyFrame__filter, self, expr) -LazyFrame$drop_nulls <- function(subset) .Call(wrap__RPolarsLazyFrame__drop_nulls, self, subset) +RPolarsLazyFrame$drop_nulls <- function(subset) .Call(wrap__RPolarsLazyFrame__drop_nulls, self, subset) -LazyFrame$unique <- function(subset, keep, maintain_order) .Call(wrap__RPolarsLazyFrame__unique, self, subset, keep, maintain_order) +RPolarsLazyFrame$unique <- function(subset, keep, maintain_order) .Call(wrap__RPolarsLazyFrame__unique, self, subset, keep, maintain_order) -LazyFrame$group_by <- function(exprs, maintain_order) .Call(wrap__RPolarsLazyFrame__group_by, self, exprs, maintain_order) +RPolarsLazyFrame$group_by <- function(exprs, maintain_order) .Call(wrap__RPolarsLazyFrame__group_by, self, exprs, maintain_order) -LazyFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsLazyFrame__with_row_count, self, name, offset) +RPolarsLazyFrame$with_row_count <- function(name, offset) .Call(wrap__RPolarsLazyFrame__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__RPolarsLazyFrame__join_asof, self, other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) +RPolarsLazyFrame$join_asof <- function(other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) .Call(wrap__RPolarsLazyFrame__join_asof, self, other, left_on, right_on, left_by, right_by, allow_parallel, force_parallel, suffix, strategy, tolerance, tolerance_str) -LazyFrame$join <- function(other, left_on, right_on, how, suffix, allow_parallel, force_parallel) .Call(wrap__RPolarsLazyFrame__join, self, other, left_on, right_on, how, suffix, allow_parallel, force_parallel) +RPolarsLazyFrame$join <- function(other, left_on, right_on, how, suffix, allow_parallel, force_parallel) .Call(wrap__RPolarsLazyFrame__join, self, other, left_on, right_on, how, suffix, allow_parallel, force_parallel) -LazyFrame$sort_by_exprs <- function(by, dotdotdot, descending, nulls_last, maintain_order) .Call(wrap__RPolarsLazyFrame__sort_by_exprs, self, by, dotdotdot, descending, nulls_last, maintain_order) +RPolarsLazyFrame$sort_by_exprs <- function(by, dotdotdot, descending, nulls_last, maintain_order) .Call(wrap__RPolarsLazyFrame__sort_by_exprs, self, by, dotdotdot, descending, nulls_last, maintain_order) -LazyFrame$melt <- function(id_vars, value_vars, value_name, variable_name, streamable) .Call(wrap__RPolarsLazyFrame__melt, self, id_vars, value_vars, value_name, variable_name, streamable) +RPolarsLazyFrame$melt <- function(id_vars, value_vars, value_name, variable_name, streamable) .Call(wrap__RPolarsLazyFrame__melt, self, id_vars, value_vars, value_name, variable_name, streamable) -LazyFrame$rename <- function(existing, new) .Call(wrap__RPolarsLazyFrame__rename, self, existing, new) +RPolarsLazyFrame$rename <- function(existing, new) .Call(wrap__RPolarsLazyFrame__rename, self, existing, new) -LazyFrame$schema <- function() .Call(wrap__RPolarsLazyFrame__schema, self) +RPolarsLazyFrame$schema <- function() .Call(wrap__RPolarsLazyFrame__schema, self) -LazyFrame$fetch <- function(n_rows) .Call(wrap__RPolarsLazyFrame__fetch, self, n_rows) +RPolarsLazyFrame$fetch <- function(n_rows) .Call(wrap__RPolarsLazyFrame__fetch, self, n_rows) -LazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) .Call(wrap__RPolarsLazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) +RPolarsLazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) .Call(wrap__RPolarsLazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) -LazyFrame$get_optimization_toggle <- function() .Call(wrap__RPolarsLazyFrame__get_optimization_toggle, self) +RPolarsLazyFrame$get_optimization_toggle <- function() .Call(wrap__RPolarsLazyFrame__get_optimization_toggle, self) -LazyFrame$profile <- function() .Call(wrap__RPolarsLazyFrame__profile, self) +RPolarsLazyFrame$profile <- function() .Call(wrap__RPolarsLazyFrame__profile, self) -LazyFrame$explode <- function(dotdotdot) .Call(wrap__RPolarsLazyFrame__explode, self, dotdotdot) +RPolarsLazyFrame$explode <- function(dotdotdot) .Call(wrap__RPolarsLazyFrame__explode, self, dotdotdot) -LazyFrame$clone_in_rust <- function() .Call(wrap__RPolarsLazyFrame__clone_in_rust, self) +RPolarsLazyFrame$clone_in_rust <- function() .Call(wrap__RPolarsLazyFrame__clone_in_rust, self) -LazyFrame$with_context <- function(contexts) .Call(wrap__RPolarsLazyFrame__with_context, self, contexts) - -RPolarsLazyFrame <- LazyFrame +RPolarsLazyFrame$with_context <- function(contexts) .Call(wrap__RPolarsLazyFrame__with_context, self, contexts) #' @export `$.RPolarsLazyFrame` <- function (self, name) { func <- RPolarsLazyFrame[[name]]; environment(func) <- environment(); func } @@ -1147,25 +1109,19 @@ RPolarsLazyFrame <- LazyFrame #' @export `[[.RPolarsLazyFrame` <- `$.RPolarsLazyFrame` -`$.LazyFrame` <- function (self, name) { func <- LazyFrame[[name]]; environment(func) <- environment(); func } - -`[[.LazyFrame` <- `$.LazyFrame` - -LazyGroupBy <- new.env(parent = emptyenv()) +RPolarsLazyGroupBy <- new.env(parent = emptyenv()) -LazyGroupBy$print <- function() invisible(.Call(wrap__RPolarsLazyGroupBy__print, self)) +RPolarsLazyGroupBy$print <- function() invisible(.Call(wrap__RPolarsLazyGroupBy__print, self)) -LazyGroupBy$clone_in_rust <- function() .Call(wrap__RPolarsLazyGroupBy__clone_in_rust, self) +RPolarsLazyGroupBy$clone_in_rust <- function() .Call(wrap__RPolarsLazyGroupBy__clone_in_rust, self) -LazyGroupBy$ungroup <- function() .Call(wrap__RPolarsLazyGroupBy__ungroup, self) +RPolarsLazyGroupBy$ungroup <- function() .Call(wrap__RPolarsLazyGroupBy__ungroup, self) -LazyGroupBy$agg <- function(exprs) .Call(wrap__RPolarsLazyGroupBy__agg, self, exprs) +RPolarsLazyGroupBy$agg <- function(exprs) .Call(wrap__RPolarsLazyGroupBy__agg, self, exprs) -LazyGroupBy$head <- function(n) .Call(wrap__RPolarsLazyGroupBy__head, self, n) +RPolarsLazyGroupBy$head <- function(n) .Call(wrap__RPolarsLazyGroupBy__head, self, n) -LazyGroupBy$tail <- function(n) .Call(wrap__RPolarsLazyGroupBy__tail, self, n) - -RPolarsLazyGroupBy <- LazyGroupBy +RPolarsLazyGroupBy$tail <- function(n) .Call(wrap__RPolarsLazyGroupBy__tail, self, n) #' @export `$.RPolarsLazyGroupBy` <- function (self, name) { func <- RPolarsLazyGroupBy[[name]]; environment(func) <- environment(); func } @@ -1173,111 +1129,105 @@ RPolarsLazyGroupBy <- LazyGroupBy #' @export `[[.RPolarsLazyGroupBy` <- `$.RPolarsLazyGroupBy` -`$.LazyGroupBy` <- function (self, name) { func <- LazyGroupBy[[name]]; environment(func) <- environment(); func } - -`[[.LazyGroupBy` <- `$.LazyGroupBy` - -Series <- new.env(parent = emptyenv()) +RPolarsSeries <- new.env(parent = emptyenv()) -Series$new <- function(x, name) .Call(wrap__RPolarsSeries__new, x, name) +RPolarsSeries$new <- function(x, name) .Call(wrap__RPolarsSeries__new, x, name) -Series$clone <- function() .Call(wrap__RPolarsSeries__clone, self) +RPolarsSeries$clone <- function() .Call(wrap__RPolarsSeries__clone, self) -Series$sleep <- function(millis) .Call(wrap__RPolarsSeries__sleep, self, millis) +RPolarsSeries$sleep <- function(millis) .Call(wrap__RPolarsSeries__sleep, self, millis) -Series$panic <- function() .Call(wrap__RPolarsSeries__panic, self) +RPolarsSeries$panic <- function() .Call(wrap__RPolarsSeries__panic, self) -Series$to_r <- function() .Call(wrap__RPolarsSeries__to_r, self) +RPolarsSeries$to_r <- function() .Call(wrap__RPolarsSeries__to_r, self) -Series$rename_mut <- function(name) invisible(.Call(wrap__RPolarsSeries__rename_mut, self, name)) +RPolarsSeries$rename_mut <- function(name) invisible(.Call(wrap__RPolarsSeries__rename_mut, self, name)) -Series$dtype <- function() .Call(wrap__RPolarsSeries__dtype, self) +RPolarsSeries$dtype <- function() .Call(wrap__RPolarsSeries__dtype, self) -Series$n_unique <- function() .Call(wrap__RPolarsSeries__n_unique, self) +RPolarsSeries$n_unique <- function() .Call(wrap__RPolarsSeries__n_unique, self) -Series$name <- function() .Call(wrap__RPolarsSeries__name, self) +RPolarsSeries$name <- function() .Call(wrap__RPolarsSeries__name, self) -Series$sort_mut <- function(descending) .Call(wrap__RPolarsSeries__sort_mut, self, descending) +RPolarsSeries$sort_mut <- function(descending) .Call(wrap__RPolarsSeries__sort_mut, self, descending) -Series$value_counts <- function(sort, parallel) .Call(wrap__RPolarsSeries__value_counts, self, sort, parallel) +RPolarsSeries$value_counts <- function(sort, parallel) .Call(wrap__RPolarsSeries__value_counts, self, sort, parallel) -Series$arg_min <- function() .Call(wrap__RPolarsSeries__arg_min, self) +RPolarsSeries$arg_min <- function() .Call(wrap__RPolarsSeries__arg_min, self) -Series$arg_max <- function() .Call(wrap__RPolarsSeries__arg_max, self) +RPolarsSeries$arg_max <- function() .Call(wrap__RPolarsSeries__arg_max, self) -Series$is_sorted_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_flag, self) +RPolarsSeries$is_sorted_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_flag, self) -Series$is_sorted_reverse_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_reverse_flag, self) +RPolarsSeries$is_sorted_reverse_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_reverse_flag, self) -Series$is_sorted <- function(descending) .Call(wrap__RPolarsSeries__is_sorted, self, descending) +RPolarsSeries$is_sorted <- function(descending) .Call(wrap__RPolarsSeries__is_sorted, self, descending) -Series$series_equal <- function(other, null_equal, strict) .Call(wrap__RPolarsSeries__series_equal, self, other, null_equal, strict) +RPolarsSeries$series_equal <- function(other, null_equal, strict) .Call(wrap__RPolarsSeries__series_equal, self, other, null_equal, strict) -Series$get_fmt <- function(index, str_length) .Call(wrap__RPolarsSeries__get_fmt, self, index, str_length) +RPolarsSeries$get_fmt <- function(index, str_length) .Call(wrap__RPolarsSeries__get_fmt, self, index, str_length) -Series$to_fmt_char <- function(str_length) .Call(wrap__RPolarsSeries__to_fmt_char, self, str_length) +RPolarsSeries$to_fmt_char <- function(str_length) .Call(wrap__RPolarsSeries__to_fmt_char, self, str_length) -Series$compare <- function(other, op) .Call(wrap__RPolarsSeries__compare, self, other, op) +RPolarsSeries$compare <- function(other, op) .Call(wrap__RPolarsSeries__compare, self, other, op) -Series$rep <- function(n, rechunk) .Call(wrap__RPolarsSeries__rep, self, n, rechunk) +RPolarsSeries$rep <- function(n, rechunk) .Call(wrap__RPolarsSeries__rep, self, n, rechunk) -Series$shape <- function() .Call(wrap__RPolarsSeries__shape, self) +RPolarsSeries$shape <- function() .Call(wrap__RPolarsSeries__shape, self) -Series$len <- function() .Call(wrap__RPolarsSeries__len, self) +RPolarsSeries$len <- function() .Call(wrap__RPolarsSeries__len, self) -Series$chunk_lengths <- function() .Call(wrap__RPolarsSeries__chunk_lengths, self) +RPolarsSeries$chunk_lengths <- function() .Call(wrap__RPolarsSeries__chunk_lengths, self) -Series$abs <- function() .Call(wrap__RPolarsSeries__abs, self) +RPolarsSeries$abs <- function() .Call(wrap__RPolarsSeries__abs, self) -Series$alias <- function(name) .Call(wrap__RPolarsSeries__alias, self, name) +RPolarsSeries$alias <- function(name) .Call(wrap__RPolarsSeries__alias, self, name) -Series$all <- function() .Call(wrap__RPolarsSeries__all, self) +RPolarsSeries$all <- function() .Call(wrap__RPolarsSeries__all, self) -Series$any <- function() .Call(wrap__RPolarsSeries__any, self) +RPolarsSeries$any <- function() .Call(wrap__RPolarsSeries__any, self) -Series$add <- function(other) .Call(wrap__RPolarsSeries__add, self, other) +RPolarsSeries$add <- function(other) .Call(wrap__RPolarsSeries__add, self, other) -Series$sub <- function(other) .Call(wrap__RPolarsSeries__sub, self, other) +RPolarsSeries$sub <- function(other) .Call(wrap__RPolarsSeries__sub, self, other) -Series$mul <- function(other) .Call(wrap__RPolarsSeries__mul, self, other) +RPolarsSeries$mul <- function(other) .Call(wrap__RPolarsSeries__mul, self, other) -Series$div <- function(other) .Call(wrap__RPolarsSeries__div, self, other) +RPolarsSeries$div <- function(other) .Call(wrap__RPolarsSeries__div, self, other) -Series$rem <- function(other) .Call(wrap__RPolarsSeries__rem, self, other) +RPolarsSeries$rem <- function(other) .Call(wrap__RPolarsSeries__rem, self, other) -Series$append_mut <- function(other) .Call(wrap__RPolarsSeries__append_mut, self, other) +RPolarsSeries$append_mut <- function(other) .Call(wrap__RPolarsSeries__append_mut, self, other) -Series$map_elements <- function(robj, rdatatype, strict, allow_fail_eval) .Call(wrap__RPolarsSeries__map_elements, self, robj, rdatatype, strict, allow_fail_eval) +RPolarsSeries$map_elements <- function(robj, rdatatype, strict, allow_fail_eval) .Call(wrap__RPolarsSeries__map_elements, self, robj, rdatatype, strict, allow_fail_eval) -Series$mean <- function() .Call(wrap__RPolarsSeries__mean, self) +RPolarsSeries$mean <- function() .Call(wrap__RPolarsSeries__mean, self) -Series$median <- function() .Call(wrap__RPolarsSeries__median, self) +RPolarsSeries$median <- function() .Call(wrap__RPolarsSeries__median, self) -Series$min <- function() .Call(wrap__RPolarsSeries__min, self) +RPolarsSeries$min <- function() .Call(wrap__RPolarsSeries__min, self) -Series$max <- function() .Call(wrap__RPolarsSeries__max, self) +RPolarsSeries$max <- function() .Call(wrap__RPolarsSeries__max, self) -Series$sum <- function() .Call(wrap__RPolarsSeries__sum, self) +RPolarsSeries$sum <- function() .Call(wrap__RPolarsSeries__sum, self) -Series$std <- function(ddof) .Call(wrap__RPolarsSeries__std, self, ddof) +RPolarsSeries$std <- function(ddof) .Call(wrap__RPolarsSeries__std, self, ddof) -Series$var <- function(ddof) .Call(wrap__RPolarsSeries__var, self, ddof) +RPolarsSeries$var <- function(ddof) .Call(wrap__RPolarsSeries__var, self, ddof) -Series$ceil <- function() .Call(wrap__RPolarsSeries__ceil, self) +RPolarsSeries$ceil <- function() .Call(wrap__RPolarsSeries__ceil, self) -Series$floor <- function() .Call(wrap__RPolarsSeries__floor, self) +RPolarsSeries$floor <- function() .Call(wrap__RPolarsSeries__floor, self) -Series$print <- function() invisible(.Call(wrap__RPolarsSeries__print, self)) +RPolarsSeries$print <- function() invisible(.Call(wrap__RPolarsSeries__print, self)) -Series$cum_sum <- function(reverse) .Call(wrap__RPolarsSeries__cum_sum, self, reverse) +RPolarsSeries$cum_sum <- function(reverse) .Call(wrap__RPolarsSeries__cum_sum, self, reverse) -Series$to_frame <- function() .Call(wrap__RPolarsSeries__to_frame, self) +RPolarsSeries$to_frame <- function() .Call(wrap__RPolarsSeries__to_frame, self) -Series$set_sorted_mut <- function(descending) invisible(.Call(wrap__RPolarsSeries__set_sorted_mut, self, descending)) +RPolarsSeries$set_sorted_mut <- function(descending) invisible(.Call(wrap__RPolarsSeries__set_sorted_mut, self, descending)) -Series$from_arrow <- function(name, array) .Call(wrap__RPolarsSeries__from_arrow, name, array) - -RPolarsSeries <- Series +RPolarsSeries$from_arrow <- function(name, array) .Call(wrap__RPolarsSeries__from_arrow, name, array) #' @export `$.RPolarsSeries` <- function (self, name) { func <- RPolarsSeries[[name]]; environment(func) <- environment(); func } @@ -1285,10 +1235,6 @@ RPolarsSeries <- Series #' @export `[[.RPolarsSeries` <- `$.RPolarsSeries` -`$.Series` <- function (self, name) { func <- Series[[name]]; environment(func) <- environment(); func } - -`[[.Series` <- `$.Series` - RPolarsSQLContext <- new.env(parent = emptyenv()) RPolarsSQLContext$new <- function() .Call(wrap__RPolarsSQLContext__new) diff --git a/R/zzz.R b/R/zzz.R index d6dd64197..5bc81829e 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -9,22 +9,21 @@ if (build_debug_print) { )) } - # modify these Dataframe methods -replace_private_with_pub_methods(DataFrame, "^DataFrame_") +replace_private_with_pub_methods(RPolarsDataFrame, "^DataFrame_") # GroupBy - is special read header info in groupby.R replace_private_with_pub_methods(GroupBy, "^GroupBy_") macro_add_syntax_check_to_class("GroupBy") # not activated automatically as GroupBy is not extendr # LazyFrame -replace_private_with_pub_methods(LazyFrame, "^LazyFrame_") +replace_private_with_pub_methods(RPolarsLazyFrame, "^LazyFrame_") # LazyGroupBy -replace_private_with_pub_methods(LazyGroupBy, "^LazyGroupBy_") +replace_private_with_pub_methods(RPolarsLazyGroupBy, "^LazyGroupBy_") # Expr -replace_private_with_pub_methods(Expr, "^Expr_") +replace_private_with_pub_methods(RPolarsExpr, "^Expr_") # configure subnames spaces of Expr #' @export @@ -59,10 +58,10 @@ expr_cat_make_sub_ns = macro_new_subnamespace("^ExprCat_", "ExprCatNameSpace") `$.ExprBinNameSpace` = sub_name_space_accessor_function expr_bin_make_sub_ns = macro_new_subnamespace("^ExprBin_", "ExprBinNameSpace") -replace_private_with_pub_methods(When, "^When_") -replace_private_with_pub_methods(Then, "^Then_") -replace_private_with_pub_methods(ChainedWhen, "^ChainedWhen_") -replace_private_with_pub_methods(ChainedThen, "^ChainedThen_") +replace_private_with_pub_methods(RPolarsWhen, "^When_") +replace_private_with_pub_methods(RPolarsThen, "^Then_") +replace_private_with_pub_methods(RPolarsChainedWhen, "^ChainedWhen_") +replace_private_with_pub_methods(RPolarsChainedThen, "^ChainedThen_") # any sub-namespace inherits 'method_environment' @@ -95,7 +94,7 @@ replace_private_with_pub_methods(RField, "^RField_") # Series -replace_private_with_pub_methods(Series, "^Series_") +replace_private_with_pub_methods(RPolarsSeries, "^Series_") # RThreadHandle replace_private_with_pub_methods(RThreadHandle, "^RThreadHandle_") @@ -106,7 +105,7 @@ replace_private_with_pub_methods(RPolarsSQLContext, "^SQLContext_") # expression constructors, why not just pl$lit = Expr_lit? -move_env_elements(Expr, pl, c("lit"), remove = FALSE) +move_env_elements(RPolarsExpr, pl, c("lit"), remove = FALSE) #' Get Memory Address From 53ad7e7a02a839ba4a60136291d1c69bab06c0cb Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:57:44 +0100 Subject: [PATCH 21/32] fix --- R/series__series.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/series__series.R b/R/series__series.R index a9f460c45..6bc6e9f91 100644 --- a/R/series__series.R +++ b/R/series__series.R @@ -936,7 +936,7 @@ Series_expr = method_as_property(function() { # loop over each expression function lapply( - Expr, + RPolarsExpr, \(f) { # f is orignial Expr method # point back to env with above defined 'df' and 'self' From b604e4248b3f493cd0dc5c1bf0ef3269e42e2ad5 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:53:07 +0100 Subject: [PATCH 22/32] fix DollarNames --- R/dataframe__frame.R | 2 +- R/expr__expr.R | 2 +- R/functions__whenthen.R | 8 ++++---- R/lazyframe__lazy.R | 2 +- R/s3_methods.R | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 5e8d9dff2..4e8e00ef8 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -83,7 +83,7 @@ NULL #' @return Doesn't return a value. This is used for autocompletion in RStudio. #' @keywords internal .DollarNames.RPolarsDataFrame = function(x, pattern = "") { - get_method_usages(DataFrame, pattern = pattern) + get_method_usages(RPolarsDataFrame, pattern = pattern) } diff --git a/R/expr__expr.R b/R/expr__expr.R index d50c0fc8f..0d5590a53 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -55,7 +55,7 @@ Expr_print = function() { #' @export #' @keywords internal .DollarNames.RPolarsExpr = function(x, pattern = "") { - paste0(ls(Expr, pattern = pattern), "()") + paste0(ls(RPolarsExpr, pattern = pattern), "()") } #' S3 method to convert an Expr to a list diff --git a/R/functions__whenthen.R b/R/functions__whenthen.R index 5e97d8d45..152f4e9a2 100644 --- a/R/functions__whenthen.R +++ b/R/functions__whenthen.R @@ -152,7 +152,7 @@ print.RPolarsChainedThen = function(x, ...) { #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsWhen = function(x, pattern = "") { - paste0(ls(When, pattern = pattern), "()") + paste0(ls(RPolarsWhen, pattern = pattern), "()") } #' @title auto complete $-access into a polars object @@ -164,7 +164,7 @@ print.RPolarsChainedThen = function(x, ...) { #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsThen = function(x, pattern = "") { - paste0(ls(Then, pattern = pattern), "()") + paste0(ls(RPolarsThen, pattern = pattern), "()") } #' @title auto complete $-access into a polars object @@ -176,7 +176,7 @@ print.RPolarsChainedThen = function(x, ...) { #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsChainedThen = function(x, pattern = "") { - paste0(ls(ChainedThen, pattern = pattern), "()") + paste0(ls(RPolarsChainedThen, pattern = pattern), "()") } #' @title auto complete $-access into a polars object @@ -188,5 +188,5 @@ print.RPolarsChainedThen = function(x, ...) { #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsChainedWhen = function(x, pattern = "") { - paste0(ls(ChainedWhen, pattern = pattern), "()") + paste0(ls(RPolarsChainedWhen, pattern = pattern), "()") } diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 3379131f9..1f646f8e4 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -109,7 +109,7 @@ NULL #' @keywords internal .DollarNames.RPolarsLazyFrame = function(x, pattern = "") { - paste0(ls(LazyFrame, pattern = pattern), "()") + paste0(ls(RPolarsLazyFrame, pattern = pattern), "()") } #' Create new LazyFrame diff --git a/R/s3_methods.R b/R/s3_methods.R index 21debba87..9c7961620 100644 --- a/R/s3_methods.R +++ b/R/s3_methods.R @@ -402,7 +402,7 @@ print.RPolarsSeries = function(x, ...) { #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal .DollarNames.RPolarsSeries = function(x, pattern = "") { - get_method_usages(Series, pattern = pattern) + get_method_usages(RPolarsSeries, pattern = pattern) } #' Combine to a Series From 245682619e12ed3526f9c2db7d6c879f90cb39c2 Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:02:34 +0100 Subject: [PATCH 23/32] fix examples --- R/dataframe__frame.R | 2 +- R/lazyframe__lazy.R | 2 +- man/DataFrame_class.Rd | 2 +- man/LazyFrame_class.Rd | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index 4e8e00ef8..e7ef56661 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -32,7 +32,7 @@ #' @examples #' # see all public exported method names (normally accessed via a class #' # instance with $) -#' ls(.pr$env$DataFrame) +#' ls(.pr$env$RPolarsDataFrame) #' #' # see all private methods (not intended for regular use) #' ls(.pr$DataFrame) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 1f646f8e4..2d044f51a 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -37,7 +37,7 @@ #' @keywords LazyFrame #' @examples #' # see all exported methods -#' ls(.pr$env$LazyFrame) +#' ls(.pr$env$RPolarsLazyFrame) #' #' # see all private methods (not intended for regular use) #' ls(.pr$LazyFrame) diff --git a/man/DataFrame_class.Rd b/man/DataFrame_class.Rd index 64e9e9052..df24d5666 100644 --- a/man/DataFrame_class.Rd +++ b/man/DataFrame_class.Rd @@ -35,7 +35,7 @@ replaced by any function prefixed \code{DataFrame_}. \examples{ # see all public exported method names (normally accessed via a class # instance with $) -ls(.pr$env$DataFrame) +ls(.pr$env$RPolarsDataFrame) # see all private methods (not intended for regular use) ls(.pr$DataFrame) diff --git a/man/LazyFrame_class.Rd b/man/LazyFrame_class.Rd index f759fac69..2bac9e14d 100644 --- a/man/LazyFrame_class.Rd +++ b/man/LazyFrame_class.Rd @@ -43,7 +43,7 @@ prefixed \code{LazyFrame_}. } \examples{ # see all exported methods -ls(.pr$env$LazyFrame) +ls(.pr$env$RPolarsLazyFrame) # see all private methods (not intended for regular use) ls(.pr$LazyFrame) From 1d919bec2b7f5e50b03686dc38acb7b2b554ea51 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 10:42:53 +0000 Subject: [PATCH 24/32] auto formatting --- R/expr__expr.R | 3 +-- R/series__series.R | 8 +++++--- tests/testthat/test-dataframe.R | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/R/expr__expr.R b/R/expr__expr.R index 0d5590a53..fca0ba972 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -728,7 +728,6 @@ Expr_map = function(f, output_type = NULL, agg_list = FALSE, in_background = FAL out |> unwrap("in $map():") - } #' Map a custom/user-defined function (UDF) to each element of a column @@ -890,7 +889,7 @@ Expr_map_elements = function(f, return_type = NULL, strict_return_type = TRUE, a } Expr_apply = function(f, return_type = NULL, strict_return_type = TRUE, - allow_fail_eval = FALSE, in_background = FALSE) { + allow_fail_eval = FALSE, in_background = FALSE) { warning("$apply() is deprecated and will be removed in 0.13.0. Use $map_elements() instead.", call. = FALSE) if (in_background) { return(.pr$Expr$map_elements_in_background(self, f, return_type)) diff --git a/R/series__series.R b/R/series__series.R index 6bc6e9f91..880d70d62 100644 --- a/R/series__series.R +++ b/R/series__series.R @@ -366,10 +366,12 @@ Series_map_elements = function( } Series_apply = function(f, datatype = NULL, strict_return_type = TRUE, - allow_fail_eval = FALSE) { + allow_fail_eval = FALSE) { warning("$apply() is deprecated and will be removed in 0.13.0. Use $map_elements() instead.") - Series_map_elements(f, datatype = datatype, strict_return_type = strict_return_type, - allow_fail_eval = allow_fail_eval) + Series_map_elements(f, + datatype = datatype, strict_return_type = strict_return_type, + allow_fail_eval = allow_fail_eval + ) } #' Series_len diff --git a/tests/testthat/test-dataframe.R b/tests/testthat/test-dataframe.R index e13cad019..31cf67afe 100644 --- a/tests/testthat/test-dataframe.R +++ b/tests/testthat/test-dataframe.R @@ -281,7 +281,7 @@ test_that("map_batches unity", { test_that("$map() deprecated", { expect_warning( pl$DataFrame(iris)$select( - pl$col("Sepal.Length")$map(\(s) s) + pl$col("Sepal.Length")$map(\(s) s) ), "map_batches" ) From ed4fa4bee852551ddaedb4ab45a06c555cbd747e Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 10:43:18 +0000 Subject: [PATCH 25/32] bump package version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d718fdc1a..7fc50804d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: polars Title: Lightning-Fast 'DataFrame' Library -Version: 0.11.0.9000 +Version: 0.11.0.9001 Depends: R (>= 4.2) Imports: utils, codetools Authors@R: From 35eebec54a4c11a2a18f768056fbc7cc2f5f5b5b Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 14:33:38 +0000 Subject: [PATCH 26/32] refactor!: RThreadHandle -> RPolarsRThreadHandle --- NAMESPACE | 10 +++++----- R/after-wrappers.R | 2 +- R/extendr-wrappers.R | 12 ++++++------ R/lazyframe__lazy.R | 4 ++-- R/rbackground.R | 19 +++++++++---------- R/zzz.R | 2 +- man/LazyFrame_collect_in_background.Rd | 4 ++-- man/RThreadHandle_RThreadHandle_class.Rd | 7 +++---- ...d => as.character.RPolarsRThreadHandle.Rd} | 6 +++--- ...> dot-DollarNames.RPolarsRThreadHandle.Rd} | 8 ++++---- ...andle.Rd => print.RPolarsRThreadHandle.Rd} | 6 +++--- src/rust/src/lazy/dataframe.rs | 4 ++-- src/rust/src/rbackground.rs | 14 +++++++------- 13 files changed, 48 insertions(+), 50 deletions(-) rename man/{as.character.RThreadHandle.Rd => as.character.RPolarsRThreadHandle.Rd} (66%) rename man/{dot-DollarNames.RThreadHandle.Rd => dot-DollarNames.RPolarsRThreadHandle.Rd} (63%) rename man/{print.RThreadHandle.Rd => print.RPolarsRThreadHandle.Rd} (78%) diff --git a/NAMESPACE b/NAMESPACE index d9b5597b7..b039be7bd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,12 +25,12 @@ S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsLazyGroupBy) +S3method("$",RPolarsRThreadHandle) S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) S3method("$",RPolarsStringCacheHolder) S3method("$",RPolarsThen) S3method("$",RPolarsWhen) -S3method("$",RThreadHandle) S3method("$",VecDataFrame) S3method("$",pl_polars_env) S3method("$",private_polars_env) @@ -76,12 +76,12 @@ S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsLazyGroupBy) +S3method("[[",RPolarsRThreadHandle) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) S3method("[[",RPolarsStringCacheHolder) S3method("[[",RPolarsThen) S3method("[[",RPolarsWhen) -S3method("[[",RThreadHandle) S3method("[[",VecDataFrame) S3method("^",RPolarsExpr) S3method("|",RPolarsExpr) @@ -93,16 +93,16 @@ S3method(.DollarNames,RPolarsDataFrame) S3method(.DollarNames,RPolarsErr) S3method(.DollarNames,RPolarsExpr) S3method(.DollarNames,RPolarsLazyFrame) +S3method(.DollarNames,RPolarsRThreadHandle) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RPolarsSeries) S3method(.DollarNames,RPolarsThen) S3method(.DollarNames,RPolarsWhen) -S3method(.DollarNames,RThreadHandle) S3method(.DollarNames,VecDataFrame) S3method(.DollarNames,method_environment) S3method(as.character,RPolarsErr) +S3method(as.character,RPolarsRThreadHandle) S3method(as.character,RPolarsSeries) -S3method(as.character,RThreadHandle) S3method(as.data.frame,RPolarsDataFrame) S3method(as.data.frame,RPolarsLazyFrame) S3method(as.list,RPolarsExpr) @@ -161,10 +161,10 @@ S3method(print,RPolarsErr) S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) S3method(print,RPolarsLazyGroupBy) +S3method(print,RPolarsRThreadHandle) S3method(print,RPolarsSeries) S3method(print,RPolarsThen) S3method(print,RPolarsWhen) -S3method(print,RThreadHandle) S3method(print,polars_info) S3method(row.names,RPolarsDataFrame) S3method(sum,RPolarsDataFrame) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index 0811b1cc3..b7fdc2f5b 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -94,7 +94,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$VecDataFrame = extendr_method_to_pure_functions(VecDataFrame) .pr$RNullValues = extendr_method_to_pure_functions(RNullValues) .pr$RPolarsErr = extendr_method_to_pure_functions(RPolarsErr) -.pr$RThreadHandle = extendr_method_to_pure_functions(RThreadHandle) +.pr$RThreadHandle = extendr_method_to_pure_functions(RPolarsRThreadHandle) .pr$RPolarsStringCacheHolder = extendr_method_to_pure_functions(RPolarsStringCacheHolder) .pr$RPolarsSQLContext = extendr_method_to_pure_functions(RPolarsSQLContext) diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index a661a9659..e24f521e6 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -351,19 +351,19 @@ RPolarsErr$when <- function(s) .Call(wrap__RPolarsErr__when, self, s) #' @export `[[.RPolarsErr` <- `$.RPolarsErr` -RThreadHandle <- new.env(parent = emptyenv()) +RPolarsRThreadHandle <- new.env(parent = emptyenv()) -RThreadHandle$join <- function() .Call(wrap__RThreadHandle__join, self) +RPolarsRThreadHandle$join <- function() .Call(wrap__RPolarsRThreadHandle__join, self) -RThreadHandle$is_finished <- function() .Call(wrap__RThreadHandle__is_finished, self) +RPolarsRThreadHandle$is_finished <- function() .Call(wrap__RPolarsRThreadHandle__is_finished, self) -RThreadHandle$thread_description <- function() .Call(wrap__RThreadHandle__thread_description, self) +RPolarsRThreadHandle$thread_description <- function() .Call(wrap__RPolarsRThreadHandle__thread_description, self) #' @export -`$.RThreadHandle` <- function (self, name) { func <- RThreadHandle[[name]]; environment(func) <- environment(); func } +`$.RPolarsRThreadHandle` <- function (self, name) { func <- RPolarsRThreadHandle[[name]]; environment(func) <- environment(); func } #' @export -`[[.RThreadHandle` <- `$.RThreadHandle` +`[[.RPolarsRThreadHandle` <- `$.RPolarsRThreadHandle` RPolarsWhen <- new.env(parent = emptyenv()) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 2d044f51a..81bcb1f4e 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -418,8 +418,8 @@ LazyFrame_collect = function( #' #' @details #' This function immediately returns an [RThreadHandle][RThreadHandle_RThreadHandle_class]. -#' Use [`$is_finished()`][RThreadHandle_is_finished] to see if done. -#' Use [`$join()`][RThreadHandle_join] to wait and get the final result. +#' Use [`$is_finished()`][RThreadHandle_is_finished] to see if done. +#' Use [`$join()`][RThreadHandle_join] to wait and get the final result. #' #' It is useful to not block the R session while query executes. If you use #' [`$map_batches()`][Expr_map_batches] or diff --git a/R/rbackground.R b/R/rbackground.R index c77f3e2f3..24a44490b 100644 --- a/R/rbackground.R +++ b/R/rbackground.R @@ -1,11 +1,11 @@ #' @title auto complete $-access into a polars object #' @description called by the interactive R session internally -#' @param x RThreadHandle +#' @param x RPolarsRThreadHandle #' @param pattern code-stump as string to auto-complete #' @export #' @keywords internal -.DollarNames.RThreadHandle = function(x, pattern = "") { - paste0(ls(RThreadHandle, pattern = pattern), "()") +.DollarNames.RPolarsRThreadHandle = function(x, pattern = "") { + paste0(ls(RPolarsRThreadHandle, pattern = pattern), "()") } @@ -15,7 +15,7 @@ #' @param ... not used #' @export #' @keywords internal -as.character.RThreadHandle = function(x, ...) { +as.character.RPolarsRThreadHandle = function(x, ...) { .pr$RThreadHandle$thread_description(x) |> unwrap_or("An exhausted RThreadHandle") } @@ -34,16 +34,16 @@ as.character.RThreadHandle = function(x, ...) { #' print(handle) #' handle$join() #' print(handle) -print.RThreadHandle = function(x, ...) as.character(x) |> cat("\n") +print.RPolarsRThreadHandle = function(x, ...) as.character(x) |> cat("\n") -#' @title The RThreadHandle class +#' @title The RPolarsRThreadHandle class #' @name RThreadHandle_RThreadHandle_class #' @description A handle to some polars query running in a background thread. #' @details #' [`$collect_in_background()`][LazyFrame_collect_in_background] will execute a polars -#' query detached from the R session and return an `RThreadHandle` immediately. This -#' `RThreadHandle`-class has the methods [`is_finished()`][RThreadHandle_is_finished] and +#' query detached from the R session and return an `RPolarsRThreadHandle` immediately. This +#' `RPolarsRThreadHandle`-class has the methods [`is_finished()`][RThreadHandle_is_finished] and #' [`join()`][RThreadHandle_join]. #' #' NOTICE: @@ -72,8 +72,7 @@ print.RThreadHandle = function(x, ...) as.character(x) |> cat("\n") #' if (!handle$is_finished()) print("not done yet") #' df = handle$join() # get result #' df -#' -RThreadHandle +NULL #' Join a RThreadHandle #' @keywords RThreadHandle diff --git a/R/zzz.R b/R/zzz.R index 5bc81829e..1739214c4 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -97,7 +97,7 @@ replace_private_with_pub_methods(RField, "^RField_") replace_private_with_pub_methods(RPolarsSeries, "^Series_") # RThreadHandle -replace_private_with_pub_methods(RThreadHandle, "^RThreadHandle_") +replace_private_with_pub_methods(RPolarsRThreadHandle, "^RThreadHandle_") # SQLContext replace_private_with_pub_methods(RPolarsSQLContext, "^SQLContext_") diff --git a/man/LazyFrame_collect_in_background.Rd b/man/LazyFrame_collect_in_background.Rd index 9d58f5dc5..38aae32a7 100644 --- a/man/LazyFrame_collect_in_background.Rd +++ b/man/LazyFrame_collect_in_background.Rd @@ -15,8 +15,8 @@ a detached thread. This can also be used via \verb{$collect(collect_in_backgroun } \details{ This function immediately returns an \link[=RThreadHandle_RThreadHandle_class]{RThreadHandle}. -Use \code{\link[=RThreadHandle_is_finished]{$is_finished()}} to see if done. -Use \code{\link[=RThreadHandle_join]{$join()}} to wait and get the final result. +Use \code{\link[=RThreadHandle_is_finished]{$is_finished()}} to see if done. +Use \code{\link[=RThreadHandle_join]{$join()}} to wait and get the final result. It is useful to not block the R session while query executes. If you use \code{\link[=Expr_map_batches]{$map_batches()}} or diff --git a/man/RThreadHandle_RThreadHandle_class.Rd b/man/RThreadHandle_RThreadHandle_class.Rd index 3e9096392..ba09a6aad 100644 --- a/man/RThreadHandle_RThreadHandle_class.Rd +++ b/man/RThreadHandle_RThreadHandle_class.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/rbackground.R \name{RThreadHandle_RThreadHandle_class} \alias{RThreadHandle_RThreadHandle_class} -\title{The RThreadHandle class} +\title{The RPolarsRThreadHandle class} \value{ see methods: \code{\link[=RThreadHandle_is_finished]{is_finished()}} @@ -13,8 +13,8 @@ A handle to some polars query running in a background thread. } \details{ \code{\link[=LazyFrame_collect_in_background]{$collect_in_background()}} will execute a polars -query detached from the R session and return an \code{RThreadHandle} immediately. This -\code{RThreadHandle}-class has the methods \code{\link[=RThreadHandle_is_finished]{is_finished()}} and +query detached from the R session and return an \code{RPolarsRThreadHandle} immediately. This +\code{RPolarsRThreadHandle}-class has the methods \code{\link[=RThreadHandle_is_finished]{is_finished()}} and \code{\link[=RThreadHandle_join]{join()}}. NOTICE: @@ -36,7 +36,6 @@ handle = pl$LazyFrame(mtcars)$with_columns(prexpr)$collect_in_background() if (!handle$is_finished()) print("not done yet") df = handle$join() # get result df - } \seealso{ \code{\link[=LazyFrame_collect_in_background]{$collect_in_background()}} diff --git a/man/as.character.RThreadHandle.Rd b/man/as.character.RPolarsRThreadHandle.Rd similarity index 66% rename from man/as.character.RThreadHandle.Rd rename to man/as.character.RPolarsRThreadHandle.Rd index b300aff89..060e1660f 100644 --- a/man/as.character.RThreadHandle.Rd +++ b/man/as.character.RPolarsRThreadHandle.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rbackground.R -\name{as.character.RThreadHandle} -\alias{as.character.RThreadHandle} +\name{as.character.RPolarsRThreadHandle} +\alias{as.character.RPolarsRThreadHandle} \title{RThreadHandle to string} \usage{ -\method{as.character}{RThreadHandle}(x, ...) +\method{as.character}{RPolarsRThreadHandle}(x, ...) } \arguments{ \item{x}{RThreadHandle} diff --git a/man/dot-DollarNames.RThreadHandle.Rd b/man/dot-DollarNames.RPolarsRThreadHandle.Rd similarity index 63% rename from man/dot-DollarNames.RThreadHandle.Rd rename to man/dot-DollarNames.RPolarsRThreadHandle.Rd index 7bddb9a40..e1b08bd9d 100644 --- a/man/dot-DollarNames.RThreadHandle.Rd +++ b/man/dot-DollarNames.RPolarsRThreadHandle.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rbackground.R -\name{.DollarNames.RThreadHandle} -\alias{.DollarNames.RThreadHandle} +\name{.DollarNames.RPolarsRThreadHandle} +\alias{.DollarNames.RPolarsRThreadHandle} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{RThreadHandle}(x, pattern = "") +\method{.DollarNames}{RPolarsRThreadHandle}(x, pattern = "") } \arguments{ -\item{x}{RThreadHandle} +\item{x}{RPolarsRThreadHandle} \item{pattern}{code-stump as string to auto-complete} } diff --git a/man/print.RThreadHandle.Rd b/man/print.RPolarsRThreadHandle.Rd similarity index 78% rename from man/print.RThreadHandle.Rd rename to man/print.RPolarsRThreadHandle.Rd index 956c546e1..17950b5d8 100644 --- a/man/print.RThreadHandle.Rd +++ b/man/print.RPolarsRThreadHandle.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rbackground.R -\name{print.RThreadHandle} -\alias{print.RThreadHandle} +\name{print.RPolarsRThreadHandle} +\alias{print.RPolarsRThreadHandle} \title{s3 method print RThreadHandle} \usage{ -\method{print}{RThreadHandle}(x, ...) +\method{print}{RPolarsRThreadHandle}(x, ...) } \arguments{ \item{x}{RThreadHandle} diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index 43ae79fde..5df2047e8 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -71,10 +71,10 @@ impl RPolarsLazyFrame { collect_with_r_func_support(self.clone().0) } - pub fn collect_in_background(&self) -> crate::rbackground::RThreadHandle> { + pub fn collect_in_background(&self) -> crate::rbackground::RPolarsRThreadHandle> { use crate::rbackground::*; let dup = self.clone(); - RThreadHandle::new(move || { + RPolarsRThreadHandle::new(move || { Ok(RDF::from( dup.0 .collect() diff --git a/src/rust/src/rbackground.rs b/src/rust/src/rbackground.rs index cfc9e4621..5166c8baf 100644 --- a/src/rust/src/rbackground.rs +++ b/src/rust/src/rbackground.rs @@ -16,13 +16,13 @@ use std::collections::VecDeque; use std::sync::{Arc, Mutex}; use std::thread; #[derive(Debug)] -pub struct RThreadHandle { +pub struct RPolarsRThreadHandle { handle: Option>, } -impl RThreadHandle { +impl RPolarsRThreadHandle { pub fn new(compute: impl FnOnce() -> T + Send + 'static) -> Self { - RThreadHandle { + RPolarsRThreadHandle { handle: Some(thread::spawn(compute)), } } @@ -59,7 +59,7 @@ impl RThreadHandle { } #[extendr] -impl RThreadHandle> { +impl RPolarsRThreadHandle> { fn join(&mut self) -> RResult { // Could use *.flatten() when it's stable self.join_generic().and_then(std::convert::identity) @@ -553,8 +553,8 @@ pub fn test_rbackgroundhandler(lambda: Robj, arg: Robj) -> RResult { } #[extendr] -pub fn test_rthreadhandle() -> RThreadHandle> { - RThreadHandle::new(move || { +pub fn test_rthreadhandle() -> RPolarsRThreadHandle> { + RPolarsRThreadHandle::new(move || { println!("Intense sleeping in Rust for 10 seconds!"); let duration = std::time::Duration::from_millis(10000); thread::sleep(duration); @@ -588,7 +588,7 @@ pub fn test_serde_df(df: &RPolarsDataFrame) -> RResult { extendr_module! { mod rbackground; - impl RThreadHandle>; + impl RPolarsRThreadHandle>; fn setup_renv; fn set_global_rpool_cap; fn get_global_rpool_cap; From 48ec87c2dfa2e332ec1cba968fc437be5f792400 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 14:49:41 +0000 Subject: [PATCH 27/32] refactor!: DataTypeVector -> RPolarsDataTypeVector --- NAMESPACE | 4 ++-- R/after-wrappers.R | 2 +- R/csv.R | 2 +- R/expr__expr.R | 2 +- R/extendr-wrappers.R | 14 +++++++------- R/utils.R | 2 +- src/rust/src/lazy/dsl.rs | 6 +++--- src/rust/src/rdataframe/read_csv.rs | 4 ++-- src/rust/src/rdatatype.rs | 10 +++++----- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index b039be7bd..f9ea12aa8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,6 @@ S3method("!",RPolarsExpr) S3method("!=",RPolarsDataType) S3method("!=",RPolarsExpr) S3method("!=",RPolarsSeries) -S3method("$",DataTypeVector) S3method("$",ExprBinNameSpace) S3method("$",ExprCatNameSpace) S3method("$",ExprDTNameSpace) @@ -21,6 +20,7 @@ S3method("$",RPolarsChainedThen) S3method("$",RPolarsChainedWhen) S3method("$",RPolarsDataFrame) S3method("$",RPolarsDataType) +S3method("$",RPolarsDataTypeVector) S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) @@ -63,7 +63,6 @@ S3method("[",RPolarsDataFrame) S3method("[",RPolarsLazyFrame) S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) -S3method("[[",DataTypeVector) S3method("[[",GroupBy) S3method("[[",ProtoExprArray) S3method("[[",RField) @@ -72,6 +71,7 @@ S3method("[[",RPolarsChainedThen) S3method("[[",RPolarsChainedWhen) S3method("[[",RPolarsDataFrame) S3method("[[",RPolarsDataType) +S3method("[[",RPolarsDataTypeVector) S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index b7fdc2f5b..8e2e9e62c 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -83,7 +83,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$LazyFrame = extendr_method_to_pure_functions(RPolarsLazyFrame) .pr$LazyGroupBy = extendr_method_to_pure_functions(RPolarsLazyGroupBy) .pr$DataType = extendr_method_to_pure_functions(RPolarsDataType) -.pr$DataTypeVector = extendr_method_to_pure_functions(DataTypeVector) +.pr$DataTypeVector = extendr_method_to_pure_functions(RPolarsDataTypeVector) .pr$RField = extendr_method_to_pure_functions(RField) .pr$Expr = extendr_method_to_pure_functions(RPolarsExpr) .pr$ProtoExprArray = extendr_method_to_pure_functions(ProtoExprArray) diff --git a/R/csv.R b/R/csv.R index df14a7ab0..6b5f5875a 100644 --- a/R/csv.R +++ b/R/csv.R @@ -295,7 +295,7 @@ list_to_datatype_vector = function(x) { if (!is.list(x) || !is_named(x)) { stop("could not interpret dtypes, must be a named list of DataTypes") } - datatype_vector = DataTypeVector$new() # mutable + datatype_vector = RPolarsDataTypeVector$new() # mutable mapply( name = names(x), type = unname(x), diff --git a/R/expr__expr.R b/R/expr__expr.R index fca0ba972..3a3f2ac63 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -1104,7 +1104,7 @@ Expr_exclude = function(columns) { pcase( is.character(columns), .pr$Expr$exclude(self, columns), - inherits(columns, "DataTypeVector"), .pr$Expr$exclude_dtype(self, columns), + inherits(columns, "RPolarsDataTypeVector"), .pr$Expr$exclude_dtype(self, columns), inherits(columns, "RPolarsDataType"), .pr$Expr$exclude_dtype(self, unwrap(.pr$DataTypeVector$from_rlist(list(columns)))), or_else = pstop(err = paste0("this type is not supported for Expr_exclude: ", columns)) ) diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index e24f521e6..75d696017 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -273,21 +273,21 @@ RPolarsDataType$is_temporal <- function() .Call(wrap__RPolarsDataType__is_tempor #' @export `[[.RPolarsDataType` <- `$.RPolarsDataType` -DataTypeVector <- new.env(parent = emptyenv()) +RPolarsDataTypeVector <- new.env(parent = emptyenv()) -DataTypeVector$new <- function() .Call(wrap__DataTypeVector__new) +RPolarsDataTypeVector$new <- function() .Call(wrap__RPolarsDataTypeVector__new) -DataTypeVector$push <- function(colname, datatype) invisible(.Call(wrap__DataTypeVector__push, self, colname, datatype)) +RPolarsDataTypeVector$push <- function(colname, datatype) invisible(.Call(wrap__RPolarsDataTypeVector__push, self, colname, datatype)) -DataTypeVector$print <- function() invisible(.Call(wrap__DataTypeVector__print, self)) +RPolarsDataTypeVector$print <- function() invisible(.Call(wrap__RPolarsDataTypeVector__print, self)) -DataTypeVector$from_rlist <- function(list) .Call(wrap__DataTypeVector__from_rlist, list) +RPolarsDataTypeVector$from_rlist <- function(list) .Call(wrap__RPolarsDataTypeVector__from_rlist, list) #' @export -`$.DataTypeVector` <- function (self, name) { func <- DataTypeVector[[name]]; environment(func) <- environment(); func } +`$.RPolarsDataTypeVector` <- function (self, name) { func <- RPolarsDataTypeVector[[name]]; environment(func) <- environment(); func } #' @export -`[[.DataTypeVector` <- `$.DataTypeVector` +`[[.RPolarsDataTypeVector` <- `$.RPolarsDataTypeVector` RField <- new.env(parent = emptyenv()) diff --git a/R/utils.R b/R/utils.R index 5ed6ef3e2..43e09073c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -323,7 +323,7 @@ replace_private_with_pub_methods = function(env, class_pattern, keep = c(), remo #' @return extptr to rust vector of RPolarsDataType's #' @keywords internal construct_DataTypeVector = function(l) { - dtv = DataTypeVector$new() + dtv = RPolarsDataTypeVector$new() for (i in seq_along(l)) { if (inherits(l[[i]], "RPolarsDataType")) { dtv$push(names(l)[i], l[[i]]) diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index 6a62c05b8..adbb01089 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -1,7 +1,7 @@ use crate::concurrent::RFnSignature; use crate::rdatatype::{ literal_to_any_value, new_null_behavior, new_rank_method, new_rolling_cov_options, - robj_to_timeunit, DataTypeVector, RPolarsDataType, + robj_to_timeunit, RPolarsDataTypeVector, RPolarsDataType, }; use crate::robj_to; use crate::rpolarserr::polars_to_rpolars_err; @@ -65,7 +65,7 @@ impl RPolarsExpr { } //via col - pub fn dtype_cols(dtypes: &DataTypeVector) -> Self { + pub fn dtype_cols(dtypes: &RPolarsDataTypeVector) -> Self { dsl::dtype_cols(dtypes.dtv_to_vec()).into() } @@ -1498,7 +1498,7 @@ impl RPolarsExpr { self.0.clone().exclude(columns).into() } - pub fn exclude_dtype(&self, columns: &DataTypeVector) -> Self { + pub fn exclude_dtype(&self, columns: &RPolarsDataTypeVector) -> Self { self.0.clone().exclude_dtype(columns.dtv_to_vec()).into() } diff --git a/src/rust/src/rdataframe/read_csv.rs b/src/rust/src/rdataframe/read_csv.rs index 70b885a73..196d8d939 100644 --- a/src/rust/src/rdataframe/read_csv.rs +++ b/src/rust/src/rdataframe/read_csv.rs @@ -1,6 +1,6 @@ //read csv -use crate::rdatatype::DataTypeVector; +use crate::rdatatype::RPolarsDataTypeVector; use crate::lazy::dataframe::RPolarsLazyFrame; use crate::robj_to; @@ -52,7 +52,7 @@ pub fn new_from_csv( comment_char: Robj, quote_char: Robj, skip_rows: Robj, - dtypes: Nullable<&DataTypeVector>, + dtypes: Nullable<&RPolarsDataTypeVector>, null_values: Nullable<&RNullValues>, // missing_utf8_is_empty_string: Robj, ignore_errors: Robj, diff --git a/src/rust/src/rdatatype.rs b/src/rust/src/rdatatype.rs index 3793e016d..ed2583fb4 100644 --- a/src/rust/src/rdatatype.rs +++ b/src/rust/src/rdatatype.rs @@ -205,10 +205,10 @@ impl From for pl::DataType { //if any names are missing will become slice of dtypes and passed to polars_io.csv.csvread.with_dtypes_slice //zero length vector will neither trigger with_dtypes() or with_dtypes_slice() method calls #[derive(Debug, Clone, Default)] -pub struct DataTypeVector(pub Vec<(Option, pl::DataType)>); +pub struct RPolarsDataTypeVector(pub Vec<(Option, pl::DataType)>); #[extendr] -impl DataTypeVector { +impl RPolarsDataTypeVector { pub fn new() -> Self { Self::default() } @@ -221,7 +221,7 @@ impl DataTypeVector { } pub fn from_rlist(list: List) -> List { - let mut dtv = DataTypeVector(Vec::with_capacity(list.len())); + let mut dtv = RPolarsDataTypeVector(Vec::with_capacity(list.len())); let result: std::result::Result<(), String> = list.iter().try_for_each(|(name, robj)| { if !robj.inherits("RPolarsDataType") || robj.rtype() != extendr_api::Rtype::ExternalPtr @@ -240,7 +240,7 @@ impl DataTypeVector { } } -impl DataTypeVector { +impl RPolarsDataTypeVector { pub fn dtv_to_vec(&self) -> Vec { let v: Vec<_> = self.0.iter().map(|(_, dt)| dt.clone()).collect(); v @@ -533,6 +533,6 @@ pub fn robj_to_parallel_strategy(robj: extendr_api::Robj) -> RResult Date: Fri, 1 Dec 2023 14:59:29 +0000 Subject: [PATCH 28/32] refactor!: RField -> RPolarsRField --- NAMESPACE | 10 +++++----- R/Field.R | 8 ++++---- R/after-wrappers.R | 2 +- R/datatype.R | 2 +- R/extendr-wrappers.R | 20 +++++++++---------- R/zzz.R | 2 +- man/Field_print.Rd | 6 +++--- ...ld.Rd => dot-DollarNames.RPolarsRField.Rd} | 8 ++++---- src/rust/src/rdatatype.rs | 14 ++++++------- 9 files changed, 36 insertions(+), 36 deletions(-) rename man/{dot-DollarNames.RField.Rd => dot-DollarNames.RPolarsRField.Rd} (62%) diff --git a/NAMESPACE b/NAMESPACE index f9ea12aa8..e6aee6daa 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,6 @@ S3method("$",ExprStrNameSpace) S3method("$",ExprStructNameSpace) S3method("$",GroupBy) S3method("$",ProtoExprArray) -S3method("$",RField) S3method("$",RNullValues) S3method("$",RPolarsChainedThen) S3method("$",RPolarsChainedWhen) @@ -25,6 +24,7 @@ S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsLazyGroupBy) +S3method("$",RPolarsRField) S3method("$",RPolarsRThreadHandle) S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) @@ -34,8 +34,8 @@ S3method("$",RPolarsWhen) S3method("$",VecDataFrame) S3method("$",pl_polars_env) S3method("$",private_polars_env) -S3method("$<-",RField) S3method("$<-",RPolarsDataFrame) +S3method("$<-",RPolarsRField) S3method("%%",RPolarsExpr) S3method("%/%",RPolarsExpr) S3method("&",RPolarsExpr) @@ -65,7 +65,6 @@ S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) S3method("[[",GroupBy) S3method("[[",ProtoExprArray) -S3method("[[",RField) S3method("[[",RNullValues) S3method("[[",RPolarsChainedThen) S3method("[[",RPolarsChainedWhen) @@ -76,6 +75,7 @@ S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsLazyGroupBy) +S3method("[[",RPolarsRField) S3method("[[",RPolarsRThreadHandle) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) @@ -86,13 +86,13 @@ S3method("[[",VecDataFrame) S3method("^",RPolarsExpr) S3method("|",RPolarsExpr) S3method(.DollarNames,GroupBy) -S3method(.DollarNames,RField) S3method(.DollarNames,RPolarsChainedThen) S3method(.DollarNames,RPolarsChainedWhen) S3method(.DollarNames,RPolarsDataFrame) S3method(.DollarNames,RPolarsErr) S3method(.DollarNames,RPolarsExpr) S3method(.DollarNames,RPolarsLazyFrame) +S3method(.DollarNames,RPolarsRField) S3method(.DollarNames,RPolarsRThreadHandle) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RPolarsSeries) @@ -152,7 +152,6 @@ S3method(names,RPolarsDataFrame) S3method(names,RPolarsLazyFrame) S3method(print,GroupBy) S3method(print,PTime) -S3method(print,RField) S3method(print,RPolarsChainedThen) S3method(print,RPolarsChainedWhen) S3method(print,RPolarsDataFrame) @@ -161,6 +160,7 @@ S3method(print,RPolarsErr) S3method(print,RPolarsExpr) S3method(print,RPolarsLazyFrame) S3method(print,RPolarsLazyGroupBy) +S3method(print,RPolarsRField) S3method(print,RPolarsRThreadHandle) S3method(print,RPolarsSeries) S3method(print,RPolarsThen) diff --git a/R/Field.R b/R/Field.R index 099e445d9..863372628 100644 --- a/R/Field.R +++ b/R/Field.R @@ -30,7 +30,7 @@ pl$Field = function(name, datatype) { #' #' @examples #' print(pl$Field("foo", pl$List(pl$UInt64))) -print.RField = function(x, ...) { +print.RPolarsRField = function(x, ...) { x$print() invisible(x) } @@ -40,12 +40,12 @@ print.RField = function(x, ...) { #' #' Called by the interactive R session internally #' -#' @param x Name of a `RField` object +#' @param x Name of a `RPolarsRField` object #' @param pattern String used to auto-complete #' #' @export #' @keywords internal -.DollarNames.RField = function(x, pattern = "") { +.DollarNames.RPolarsRField = function(x, pattern = "") { get_method_usages(RField, pattern = pattern) } @@ -104,7 +104,7 @@ RField.property_setters$datatype = function(self, value) { } #' @export -"$<-.RField" = function(self, name, value) { +"$<-.RPolarsRField" = function(self, name, value) { name = sub("<-$", "", name) # stop if method is not a setter diff --git a/R/after-wrappers.R b/R/after-wrappers.R index 8e2e9e62c..bb69b1420 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -84,7 +84,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$LazyGroupBy = extendr_method_to_pure_functions(RPolarsLazyGroupBy) .pr$DataType = extendr_method_to_pure_functions(RPolarsDataType) .pr$DataTypeVector = extendr_method_to_pure_functions(RPolarsDataTypeVector) -.pr$RField = extendr_method_to_pure_functions(RField) +.pr$RField = extendr_method_to_pure_functions(RPolarsRField) .pr$Expr = extendr_method_to_pure_functions(RPolarsExpr) .pr$ProtoExprArray = extendr_method_to_pure_functions(ProtoExprArray) .pr$When = extendr_method_to_pure_functions(RPolarsWhen) diff --git a/R/datatype.R b/R/datatype.R index 14f9b9e98..24a6736cd 100644 --- a/R/datatype.R +++ b/R/datatype.R @@ -199,7 +199,7 @@ DataType_constructors = list( if (inherits(arg, "RPolarsDataType")) { return(pl$Field(name, arg)) } - if (inherits(arg, "RField")) { + if (inherits(arg, "RPolarsRField")) { return(arg) } stop( diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 75d696017..bfcc28370 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -289,27 +289,27 @@ RPolarsDataTypeVector$from_rlist <- function(list) .Call(wrap__RPolarsDataTypeVe #' @export `[[.RPolarsDataTypeVector` <- `$.RPolarsDataTypeVector` -RField <- new.env(parent = emptyenv()) +RPolarsRField <- new.env(parent = emptyenv()) -RField$new <- function(name, datatype) .Call(wrap__RField__new, name, datatype) +RPolarsRField$new <- function(name, datatype) .Call(wrap__RPolarsRField__new, name, datatype) -RField$print <- function() invisible(.Call(wrap__RField__print, self)) +RPolarsRField$print <- function() invisible(.Call(wrap__RPolarsRField__print, self)) -RField$clone <- function() .Call(wrap__RField__clone, self) +RPolarsRField$clone <- function() .Call(wrap__RPolarsRField__clone, self) -RField$get_name <- function() .Call(wrap__RField__get_name, self) +RPolarsRField$get_name <- function() .Call(wrap__RPolarsRField__get_name, self) -RField$get_datatype <- function() .Call(wrap__RField__get_datatype, self) +RPolarsRField$get_datatype <- function() .Call(wrap__RPolarsRField__get_datatype, self) -RField$set_name_mut <- function(name) invisible(.Call(wrap__RField__set_name_mut, self, name)) +RPolarsRField$set_name_mut <- function(name) invisible(.Call(wrap__RPolarsRField__set_name_mut, self, name)) -RField$set_datatype_mut <- function(datatype) invisible(.Call(wrap__RField__set_datatype_mut, self, datatype)) +RPolarsRField$set_datatype_mut <- function(datatype) invisible(.Call(wrap__RPolarsRField__set_datatype_mut, self, datatype)) #' @export -`$.RField` <- function (self, name) { func <- RField[[name]]; environment(func) <- environment(); func } +`$.RPolarsRField` <- function (self, name) { func <- RPolarsRField[[name]]; environment(func) <- environment(); func } #' @export -`[[.RField` <- `$.RField` +`[[.RPolarsRField` <- `$.RPolarsRField` RPolarsErr <- new.env(parent = emptyenv()) diff --git a/R/zzz.R b/R/zzz.R index 1739214c4..2115c6e28 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -90,7 +90,7 @@ replace_private_with_pub_methods(RPolarsChainedThen, "^ChainedThen_") # Field -replace_private_with_pub_methods(RField, "^RField_") +replace_private_with_pub_methods(RPolarsRField, "^RField_") # Series diff --git a/man/Field_print.Rd b/man/Field_print.Rd index b05b4fcc1..91eb3d014 100644 --- a/man/Field_print.Rd +++ b/man/Field_print.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Field.R -\name{print.RField} -\alias{print.RField} +\name{print.RPolarsRField} +\alias{print.RPolarsRField} \title{S3 method to print a Field} \usage{ -\method{print}{RField}(x, ...) +\method{print}{RPolarsRField}(x, ...) } \arguments{ \item{x}{An object of type \code{"RField"}} diff --git a/man/dot-DollarNames.RField.Rd b/man/dot-DollarNames.RPolarsRField.Rd similarity index 62% rename from man/dot-DollarNames.RField.Rd rename to man/dot-DollarNames.RPolarsRField.Rd index a03ac2653..68e5887e2 100644 --- a/man/dot-DollarNames.RField.Rd +++ b/man/dot-DollarNames.RPolarsRField.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Field.R -\name{.DollarNames.RField} -\alias{.DollarNames.RField} +\name{.DollarNames.RPolarsRField} +\alias{.DollarNames.RPolarsRField} \title{Auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{RField}(x, pattern = "") +\method{.DollarNames}{RPolarsRField}(x, pattern = "") } \arguments{ -\item{x}{Name of a \code{RField} object} +\item{x}{Name of a \code{RPolarsRField} object} \item{pattern}{String used to auto-complete} } diff --git a/src/rust/src/rdatatype.rs b/src/rust/src/rdatatype.rs index ed2583fb4..bcbc787bf 100644 --- a/src/rust/src/rdatatype.rs +++ b/src/rust/src/rdatatype.rs @@ -10,17 +10,17 @@ use crate::utils::collect_hinted_result; use crate::utils::wrappers::null_to_opt; use std::result::Result; #[derive(Debug, Clone, PartialEq)] -pub struct RField(pub pl::Field); +pub struct RPolarsRField(pub pl::Field); use pl::UniqueKeepStrategy; use polars::prelude::AsofStrategy; use crate::utils::robj_to_rchoice; #[extendr] -impl RField { - fn new(name: String, datatype: &RPolarsDataType) -> RField { +impl RPolarsRField { + fn new(name: String, datatype: &RPolarsDataType) -> RPolarsRField { let name = name.into(); - RField(pl::Field { + RPolarsRField(pl::Field { name, dtype: datatype.0.clone(), }) @@ -32,7 +32,7 @@ impl RField { #[allow(clippy::should_implement_trait)] pub fn clone(&self) -> Self { - RField(self.0.clone()) + RPolarsRField(self.0.clone()) } pub fn get_name(&self) -> String { @@ -112,7 +112,7 @@ impl RPolarsDataType { .ok_or_else(|| "argument [l] is not a list".to_string()) .map(|l| { l.into_iter().enumerate().map(|(i, (name, robj))| { - let res: extendr_api::Result> = robj.try_into(); + let res: extendr_api::Result> = robj.try_into(); res.map_err(|err| { format!( "list element [[{}]] named {} is not a Field: {:?}", @@ -534,5 +534,5 @@ extendr_module! { mod rdatatype; impl RPolarsDataType; impl RPolarsDataTypeVector; - impl RField; + impl RPolarsRField; } From 73013c0c939bf31c5359e5dcec43141429028b4d Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 15:05:53 +0000 Subject: [PATCH 29/32] refactor!: ProtoExprArray -> RPolarsProtoExprArray --- NAMESPACE | 4 ++-- R/after-wrappers.R | 2 +- R/expr__expr.R | 4 ++-- R/extendr-wrappers.R | 14 +++++++------- src/rust/src/lazy/dataframe.rs | 2 +- src/rust/src/lazy/dsl.rs | 19 ++++++++++--------- src/rust/src/rlib.rs | 6 +++--- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e6aee6daa..1449fd574 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,7 +13,6 @@ S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) S3method("$",ExprStructNameSpace) S3method("$",GroupBy) -S3method("$",ProtoExprArray) S3method("$",RNullValues) S3method("$",RPolarsChainedThen) S3method("$",RPolarsChainedWhen) @@ -24,6 +23,7 @@ S3method("$",RPolarsErr) S3method("$",RPolarsExpr) S3method("$",RPolarsLazyFrame) S3method("$",RPolarsLazyGroupBy) +S3method("$",RPolarsProtoExprArray) S3method("$",RPolarsRField) S3method("$",RPolarsRThreadHandle) S3method("$",RPolarsSQLContext) @@ -64,7 +64,6 @@ S3method("[",RPolarsLazyFrame) S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) S3method("[[",GroupBy) -S3method("[[",ProtoExprArray) S3method("[[",RNullValues) S3method("[[",RPolarsChainedThen) S3method("[[",RPolarsChainedWhen) @@ -75,6 +74,7 @@ S3method("[[",RPolarsErr) S3method("[[",RPolarsExpr) S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsLazyGroupBy) +S3method("[[",RPolarsProtoExprArray) S3method("[[",RPolarsRField) S3method("[[",RPolarsRThreadHandle) S3method("[[",RPolarsSQLContext) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index bb69b1420..ff5e665a1 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -86,7 +86,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$DataTypeVector = extendr_method_to_pure_functions(RPolarsDataTypeVector) .pr$RField = extendr_method_to_pure_functions(RPolarsRField) .pr$Expr = extendr_method_to_pure_functions(RPolarsExpr) -.pr$ProtoExprArray = extendr_method_to_pure_functions(ProtoExprArray) +.pr$ProtoExprArray = extendr_method_to_pure_functions(RPolarsProtoExprArray) .pr$When = extendr_method_to_pure_functions(RPolarsWhen) .pr$Then = extendr_method_to_pure_functions(RPolarsThen) .pr$ChainedWhen = extendr_method_to_pure_functions(RPolarsChainedWhen) diff --git a/R/expr__expr.R b/R/expr__expr.R index 3a3f2ac63..368f16f31 100644 --- a/R/expr__expr.R +++ b/R/expr__expr.R @@ -577,11 +577,11 @@ Expr_is_not_null = "use_extendr_wrapper" #' #' @keywords internal #' -#' @return ProtoExprArray object +#' @return RPolarsProtoExprArray object #' #' @examples .pr$env$construct_ProtoExprArray(pl$col("Species"), "Sepal.Width") construct_ProtoExprArray = function(...) { - pra = ProtoExprArray$new() + pra = RPolarsProtoExprArray$new() args = list2(...) # deal with list of expressions diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index bfcc28370..f81e525f7 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -985,21 +985,21 @@ RPolarsExpr$rolling <- function(index_column, period, offset, closed, check_sort #' @export `[[.RPolarsExpr` <- `$.RPolarsExpr` -ProtoExprArray <- new.env(parent = emptyenv()) +RPolarsProtoExprArray <- new.env(parent = emptyenv()) -ProtoExprArray$new <- function() .Call(wrap__ProtoExprArray__new) +RPolarsProtoExprArray$new <- function() .Call(wrap__RPolarsProtoExprArray__new) -ProtoExprArray$push_back_str <- function(s) invisible(.Call(wrap__ProtoExprArray__push_back_str, self, s)) +RPolarsProtoExprArray$push_back_str <- function(s) invisible(.Call(wrap__RPolarsProtoExprArray__push_back_str, self, s)) -ProtoExprArray$push_back_rexpr <- function(r) invisible(.Call(wrap__ProtoExprArray__push_back_rexpr, self, r)) +RPolarsProtoExprArray$push_back_rexpr <- function(r) invisible(.Call(wrap__RPolarsProtoExprArray__push_back_rexpr, self, r)) -ProtoExprArray$print <- function() invisible(.Call(wrap__ProtoExprArray__print, self)) +RPolarsProtoExprArray$print <- function() invisible(.Call(wrap__RPolarsProtoExprArray__print, self)) #' @export -`$.ProtoExprArray` <- function (self, name) { func <- ProtoExprArray[[name]]; environment(func) <- environment(); func } +`$.RPolarsProtoExprArray` <- function (self, name) { func <- RPolarsProtoExprArray[[name]]; environment(func) <- environment(); func } #' @export -`[[.ProtoExprArray` <- `$.ProtoExprArray` +`[[.RPolarsProtoExprArray` <- `$.RPolarsProtoExprArray` RPolarsLazyFrame <- new.env(parent = emptyenv()) diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index 5df2047e8..8e6a7a6e5 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -303,7 +303,7 @@ impl RPolarsLazyFrame { RPolarsLazyFrame(new_df) } - fn drop_nulls(&self, subset: &ProtoExprArray) -> RPolarsLazyFrame { + fn drop_nulls(&self, subset: &RPolarsProtoExprArray) -> RPolarsLazyFrame { if subset.0.is_empty() { RPolarsLazyFrame(self.0.clone().drop_nulls(None)) } else { diff --git a/src/rust/src/lazy/dsl.rs b/src/rust/src/lazy/dsl.rs index adbb01089..63865e1ca 100644 --- a/src/rust/src/lazy/dsl.rs +++ b/src/rust/src/lazy/dsl.rs @@ -1,7 +1,7 @@ use crate::concurrent::RFnSignature; use crate::rdatatype::{ literal_to_any_value, new_null_behavior, new_rank_method, new_rolling_cov_options, - robj_to_timeunit, RPolarsDataTypeVector, RPolarsDataType, + robj_to_timeunit, RPolarsDataType, RPolarsDataTypeVector, }; use crate::robj_to; use crate::rpolarserr::polars_to_rpolars_err; @@ -1701,7 +1701,7 @@ impl RPolarsExpr { } //expr "funnies" - pub fn over(&self, proto_exprs: &ProtoExprArray) -> Self { + pub fn over(&self, proto_exprs: &RPolarsProtoExprArray) -> Self { let ve = pra_to_vec(proto_exprs, "select"); self.0.clone().over(ve).into() } @@ -2500,17 +2500,18 @@ impl ProtoRexpr { //and array of expression or proto expressions. #[derive(Clone, Debug)] -pub struct ProtoExprArray(pub Vec); -impl Default for ProtoExprArray { +pub struct RPolarsProtoExprArray(pub Vec); + +impl Default for RPolarsProtoExprArray { fn default() -> Self { Self::new() } } #[extendr] -impl ProtoExprArray { +impl RPolarsProtoExprArray { pub fn new() -> Self { - ProtoExprArray(Vec::new()) + RPolarsProtoExprArray(Vec::new()) } pub fn push_back_str(&mut self, s: &str) { @@ -2526,7 +2527,7 @@ impl ProtoExprArray { } } -impl ProtoExprArray { +impl RPolarsProtoExprArray { pub fn to_vec(&self, context: &str) -> Vec { self.0.iter().map(|re| re.to_rexpr(context).0).collect() } @@ -2534,7 +2535,7 @@ impl ProtoExprArray { //external function as extendr-api do not allow methods returning unwrapped structs //deprecate use method instead -pub fn pra_to_vec(pra: &ProtoExprArray, context: &str) -> Vec { +pub fn pra_to_vec(pra: &RPolarsProtoExprArray, context: &str) -> Vec { pra.0.iter().map(|re| re.to_rexpr(context).0).collect() } @@ -2702,7 +2703,7 @@ pub fn robj_to_col(name: Robj, dotdotdot: Robj) -> RResult { extendr_module! { mod dsl; impl RPolarsExpr; - impl ProtoExprArray; + impl RPolarsProtoExprArray; fn internal_wrap_e; fn robj_to_col; diff --git a/src/rust/src/rlib.rs b/src/rust/src/rlib.rs index 4d7dddd42..ad207ef6d 100644 --- a/src/rust/src/rlib.rs +++ b/src/rust/src/rlib.rs @@ -1,4 +1,4 @@ -use crate::lazy::dsl::{ProtoExprArray, RPolarsExpr}; +use crate::lazy::dsl::{RPolarsProtoExprArray, RPolarsExpr}; use crate::rdataframe::RPolarsDataFrame; use crate::robj_to; use crate::rpolarserr::{rdbg, RResult}; @@ -57,13 +57,13 @@ fn any_horizontal(dotdotdot: Robj) -> RResult { } #[extendr] -fn coalesce_exprs(exprs: &ProtoExprArray) -> RPolarsExpr { +fn coalesce_exprs(exprs: &RPolarsProtoExprArray) -> RPolarsExpr { let exprs: Vec = exprs.to_vec("select"); pl::coalesce(exprs.as_slice()).into() } #[extendr] -fn concat_list(exprs: &ProtoExprArray) -> Result { +fn concat_list(exprs: &RPolarsProtoExprArray) -> Result { let exprs = exprs.to_vec("select"); Ok(RPolarsExpr( pl::concat_list(exprs).map_err(|err| err.to_string())?, From 8142d0d278709d670d6a070a8e05545e04ead815 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 15:14:51 +0000 Subject: [PATCH 30/32] refactor!: VecDataFrame -> RPolarsVecDataFrame --- NAMESPACE | 6 +++--- R/after-wrappers.R | 2 +- R/dataframe__frame.R | 6 +++--- R/extendr-wrappers.R | 12 ++++++------ R/utils.R | 2 +- ...ame.Rd => dot-DollarNames.RPolarsVecDataFrame.Rd} | 8 ++++---- man/l_to_vdf.Rd | 2 +- src/rust/src/rdataframe/mod.rs | 8 ++++---- 8 files changed, 23 insertions(+), 23 deletions(-) rename man/{dot-DollarNames.VecDataFrame.Rd => dot-DollarNames.RPolarsVecDataFrame.Rd} (65%) diff --git a/NAMESPACE b/NAMESPACE index 1449fd574..96959a3b0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,8 +30,8 @@ S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) S3method("$",RPolarsStringCacheHolder) S3method("$",RPolarsThen) +S3method("$",RPolarsVecDataFrame) S3method("$",RPolarsWhen) -S3method("$",VecDataFrame) S3method("$",pl_polars_env) S3method("$",private_polars_env) S3method("$<-",RPolarsDataFrame) @@ -81,8 +81,8 @@ S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) S3method("[[",RPolarsStringCacheHolder) S3method("[[",RPolarsThen) +S3method("[[",RPolarsVecDataFrame) S3method("[[",RPolarsWhen) -S3method("[[",VecDataFrame) S3method("^",RPolarsExpr) S3method("|",RPolarsExpr) S3method(.DollarNames,GroupBy) @@ -97,8 +97,8 @@ S3method(.DollarNames,RPolarsRThreadHandle) S3method(.DollarNames,RPolarsSQLContext) S3method(.DollarNames,RPolarsSeries) S3method(.DollarNames,RPolarsThen) +S3method(.DollarNames,RPolarsVecDataFrame) S3method(.DollarNames,RPolarsWhen) -S3method(.DollarNames,VecDataFrame) S3method(.DollarNames,method_environment) S3method(as.character,RPolarsErr) S3method(as.character,RPolarsRThreadHandle) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index ff5e665a1..818cb571e 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -91,7 +91,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$Then = extendr_method_to_pure_functions(RPolarsThen) .pr$ChainedWhen = extendr_method_to_pure_functions(RPolarsChainedWhen) .pr$ChainedThen = extendr_method_to_pure_functions(RPolarsChainedThen) -.pr$VecDataFrame = extendr_method_to_pure_functions(VecDataFrame) +.pr$VecDataFrame = extendr_method_to_pure_functions(RPolarsVecDataFrame) .pr$RNullValues = extendr_method_to_pure_functions(RNullValues) .pr$RPolarsErr = extendr_method_to_pure_functions(RPolarsErr) .pr$RThreadHandle = extendr_method_to_pure_functions(RPolarsRThreadHandle) diff --git a/R/dataframe__frame.R b/R/dataframe__frame.R index e7ef56661..2c8c655b9 100644 --- a/R/dataframe__frame.R +++ b/R/dataframe__frame.R @@ -89,14 +89,14 @@ NULL #' @title auto complete $-access into a polars object #' @description called by the interactive R session internally -#' @param x VecDataFrame +#' @param x RPolarsVecDataFrame #' @param pattern code-stump as string to auto-complete #' @return char vec #' @export #' @inherit .DollarNames.RPolarsDataFrame return #' @keywords internal -.DollarNames.VecDataFrame = function(x, pattern = "") { - get_method_usages(VecDataFrame, pattern = pattern) +.DollarNames.RPolarsVecDataFrame = function(x, pattern = "") { + get_method_usages(RPolarsVecDataFrame, pattern = pattern) } diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index f81e525f7..ca0c612f2 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -211,19 +211,19 @@ RPolarsDataFrame$write_ndjson <- function(file) .Call(wrap__RPolarsDataFrame__wr #' @export `[[.RPolarsDataFrame` <- `$.RPolarsDataFrame` -VecDataFrame <- new.env(parent = emptyenv()) +RPolarsVecDataFrame <- new.env(parent = emptyenv()) -VecDataFrame$with_capacity <- function(n) .Call(wrap__VecDataFrame__with_capacity, n) +RPolarsVecDataFrame$with_capacity <- function(n) .Call(wrap__RPolarsVecDataFrame__with_capacity, n) -VecDataFrame$push <- function(df) invisible(.Call(wrap__VecDataFrame__push, self, df)) +RPolarsVecDataFrame$push <- function(df) invisible(.Call(wrap__RPolarsVecDataFrame__push, self, df)) -VecDataFrame$print <- function() invisible(.Call(wrap__VecDataFrame__print, self)) +RPolarsVecDataFrame$print <- function() invisible(.Call(wrap__RPolarsVecDataFrame__print, self)) #' @export -`$.VecDataFrame` <- function (self, name) { func <- VecDataFrame[[name]]; environment(func) <- environment(); func } +`$.RPolarsVecDataFrame` <- function (self, name) { func <- RPolarsVecDataFrame[[name]]; environment(func) <- environment(); func } #' @export -`[[.VecDataFrame` <- `$.VecDataFrame` +`[[.RPolarsVecDataFrame` <- `$.RPolarsVecDataFrame` RNullValues <- new.env(parent = emptyenv()) diff --git a/R/utils.R b/R/utils.R index 43e09073c..8e1a7091d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -185,7 +185,7 @@ move_env_elements = function(from_env, to_env, element_names, remove = TRUE) { #' @description lifecycle: DEPRECATE, imple on rust side as a function #' @param l list of DataFrame #' @keywords internal -#' @return VecDataFrame +#' @return RPolarsVecDataFrame l_to_vdf = function(l) { if (!length(l)) stop("cannot concat empty list l") do_inherit_DataFrame = sapply(l, inherits, "RPolarsDataFrame") diff --git a/man/dot-DollarNames.VecDataFrame.Rd b/man/dot-DollarNames.RPolarsVecDataFrame.Rd similarity index 65% rename from man/dot-DollarNames.VecDataFrame.Rd rename to man/dot-DollarNames.RPolarsVecDataFrame.Rd index b23482d77..6e2f642df 100644 --- a/man/dot-DollarNames.VecDataFrame.Rd +++ b/man/dot-DollarNames.RPolarsVecDataFrame.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dataframe__frame.R -\name{.DollarNames.VecDataFrame} -\alias{.DollarNames.VecDataFrame} +\name{.DollarNames.RPolarsVecDataFrame} +\alias{.DollarNames.RPolarsVecDataFrame} \title{auto complete $-access into a polars object} \usage{ -\method{.DollarNames}{VecDataFrame}(x, pattern = "") +\method{.DollarNames}{RPolarsVecDataFrame}(x, pattern = "") } \arguments{ -\item{x}{VecDataFrame} +\item{x}{RPolarsVecDataFrame} \item{pattern}{code-stump as string to auto-complete} } diff --git a/man/l_to_vdf.Rd b/man/l_to_vdf.Rd index 83a6981f2..8843e1419 100644 --- a/man/l_to_vdf.Rd +++ b/man/l_to_vdf.Rd @@ -10,7 +10,7 @@ l_to_vdf(l) \item{l}{list of DataFrame} } \value{ -VecDataFrame +RPolarsVecDataFrame } \description{ lifecycle: DEPRECATE, imple on rust side as a function diff --git a/src/rust/src/rdataframe/mod.rs b/src/rust/src/rdataframe/mod.rs index 66f42b507..6535dd62b 100644 --- a/src/rust/src/rdataframe/mod.rs +++ b/src/rust/src/rdataframe/mod.rs @@ -544,12 +544,12 @@ impl RPolarsDataFrame { } #[derive(Clone, Debug, Default)] -pub struct VecDataFrame(pub Vec); +pub struct RPolarsVecDataFrame(pub Vec); #[extendr] -impl VecDataFrame { +impl RPolarsVecDataFrame { pub fn with_capacity(n: i32) -> Self { - VecDataFrame(Vec::with_capacity(n as usize)) + RPolarsVecDataFrame(Vec::with_capacity(n as usize)) } pub fn push(&mut self, df: &RPolarsDataFrame) { @@ -570,5 +570,5 @@ extendr_module! { use rdatatype; impl RPolarsDataFrame; - impl VecDataFrame; + impl RPolarsVecDataFrame; } From f5318f29455afc708bdb442950513470b511309e Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 15:23:22 +0000 Subject: [PATCH 31/32] refactor!: RNullValues -> RPolarsRNullValues --- NAMESPACE | 4 ++-- R/after-wrappers.R | 2 +- R/csv.R | 6 +++--- R/extendr-wrappers.R | 12 ++++++------ src/rust/src/rdataframe/read_csv.rs | 19 ++++++++++--------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 96959a3b0..e5af7b476 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,7 +13,6 @@ S3method("$",ExprNameNameSpace) S3method("$",ExprStrNameSpace) S3method("$",ExprStructNameSpace) S3method("$",GroupBy) -S3method("$",RNullValues) S3method("$",RPolarsChainedThen) S3method("$",RPolarsChainedWhen) S3method("$",RPolarsDataFrame) @@ -25,6 +24,7 @@ S3method("$",RPolarsLazyFrame) S3method("$",RPolarsLazyGroupBy) S3method("$",RPolarsProtoExprArray) S3method("$",RPolarsRField) +S3method("$",RPolarsRNullValues) S3method("$",RPolarsRThreadHandle) S3method("$",RPolarsSQLContext) S3method("$",RPolarsSeries) @@ -64,7 +64,6 @@ S3method("[",RPolarsLazyFrame) S3method("[",RPolarsSeries) S3method("[",rpolars_raw_list) S3method("[[",GroupBy) -S3method("[[",RNullValues) S3method("[[",RPolarsChainedThen) S3method("[[",RPolarsChainedWhen) S3method("[[",RPolarsDataFrame) @@ -76,6 +75,7 @@ S3method("[[",RPolarsLazyFrame) S3method("[[",RPolarsLazyGroupBy) S3method("[[",RPolarsProtoExprArray) S3method("[[",RPolarsRField) +S3method("[[",RPolarsRNullValues) S3method("[[",RPolarsRThreadHandle) S3method("[[",RPolarsSQLContext) S3method("[[",RPolarsSeries) diff --git a/R/after-wrappers.R b/R/after-wrappers.R index 818cb571e..a761d2751 100644 --- a/R/after-wrappers.R +++ b/R/after-wrappers.R @@ -92,7 +92,7 @@ extendr_method_to_pure_functions = function(env, class_name = NULL) { .pr$ChainedWhen = extendr_method_to_pure_functions(RPolarsChainedWhen) .pr$ChainedThen = extendr_method_to_pure_functions(RPolarsChainedThen) .pr$VecDataFrame = extendr_method_to_pure_functions(RPolarsVecDataFrame) -.pr$RNullValues = extendr_method_to_pure_functions(RNullValues) +.pr$RNullValues = extendr_method_to_pure_functions(RPolarsRNullValues) .pr$RPolarsErr = extendr_method_to_pure_functions(RPolarsErr) .pr$RThreadHandle = extendr_method_to_pure_functions(RPolarsRThreadHandle) .pr$RPolarsStringCacheHolder = extendr_method_to_pure_functions(RPolarsStringCacheHolder) diff --git a/R/csv.R b/R/csv.R index 6b5f5875a..ebc68f871 100644 --- a/R/csv.R +++ b/R/csv.R @@ -119,17 +119,17 @@ pl$scan_csv = function( RNullValues = (function() { # one string is used as one NULL marker for all columns if (is_string(nullvals)) { - return(RNullValues$new_all_columns(nullvals)) + return(RPolarsRNullValues$new_all_columns(nullvals)) } # many unnamed strings(char vec) is used one mark for each column if (is.character(nullvals) && !is_named(nullvals)) { - return(RNullValues = RNullValues$new_columns(nullvals)) + return(RPolarsRNullValues$new_columns(nullvals)) } # named list is used as column(name) marker(value) pairs if (is.list(nullvals) && is_named(nullvals)) { - return(RNullValues$new_named(unlist(null_values))) + return(RPolarsRNullValues$new_named(unlist(null_values))) } stop("null_values arg must be a string OR unamed char vec OR named char vec") diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index ca0c612f2..34370779c 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -225,19 +225,19 @@ RPolarsVecDataFrame$print <- function() invisible(.Call(wrap__RPolarsVecDataFram #' @export `[[.RPolarsVecDataFrame` <- `$.RPolarsVecDataFrame` -RNullValues <- new.env(parent = emptyenv()) +RPolarsRNullValues <- new.env(parent = emptyenv()) -RNullValues$new_all_columns <- function(x) .Call(wrap__RNullValues__new_all_columns, x) +RPolarsRNullValues$new_all_columns <- function(x) .Call(wrap__RPolarsRNullValues__new_all_columns, x) -RNullValues$new_columns <- function(x) .Call(wrap__RNullValues__new_columns, x) +RPolarsRNullValues$new_columns <- function(x) .Call(wrap__RPolarsRNullValues__new_columns, x) -RNullValues$new_named <- function(robj) .Call(wrap__RNullValues__new_named, robj) +RPolarsRNullValues$new_named <- function(robj) .Call(wrap__RPolarsRNullValues__new_named, robj) #' @export -`$.RNullValues` <- function (self, name) { func <- RNullValues[[name]]; environment(func) <- environment(); func } +`$.RPolarsRNullValues` <- function (self, name) { func <- RPolarsRNullValues[[name]]; environment(func) <- environment(); func } #' @export -`[[.RNullValues` <- `$.RNullValues` +`[[.RPolarsRNullValues` <- `$.RPolarsRNullValues` RPolarsDataType <- new.env(parent = emptyenv()) diff --git a/src/rust/src/rdataframe/read_csv.rs b/src/rust/src/rdataframe/read_csv.rs index 196d8d939..5ea5a9282 100644 --- a/src/rust/src/rdataframe/read_csv.rs +++ b/src/rust/src/rdataframe/read_csv.rs @@ -15,16 +15,17 @@ use std::result::Result; //see param, null_values #[derive(Clone, Debug)] -pub struct RNullValues(pl::NullValues); +pub struct RPolarsRNullValues(pl::NullValues); + use polars::prelude::LazyFileListReader; #[extendr] -impl RNullValues { +impl RPolarsRNullValues { pub fn new_all_columns(x: String) -> Self { - RNullValues(pl::NullValues::AllColumnsSingle(x)) + RPolarsRNullValues(pl::NullValues::AllColumnsSingle(x)) } pub fn new_columns(x: Vec) -> Self { - RNullValues(pl::NullValues::AllColumns(x)) + RPolarsRNullValues(pl::NullValues::AllColumns(x)) } pub fn new_named(robj: Robj) -> Self { let null_markers = robj.as_str_iter().expect("must be str"); @@ -34,11 +35,11 @@ impl RNullValues { .zip(null_markers) .map(|(k, v)| (k.to_owned(), v.to_owned())) .collect(); - RNullValues(pl::NullValues::Named(key_val_pair)) + RPolarsRNullValues(pl::NullValues::Named(key_val_pair)) } } -impl From>> for Option { - fn from(x: Wrap>) -> Self { +impl From>> for Option { + fn from(x: Wrap>) -> Self { null_to_opt(x.0).map(|y| y.clone().0) } } @@ -53,7 +54,7 @@ pub fn new_from_csv( quote_char: Robj, skip_rows: Robj, dtypes: Nullable<&RPolarsDataTypeVector>, - null_values: Nullable<&RNullValues>, + null_values: Nullable<&RPolarsRNullValues>, // missing_utf8_is_empty_string: Robj, ignore_errors: Robj, cache: Robj, @@ -130,5 +131,5 @@ pub fn new_from_csv( extendr_module! { mod read_csv; fn new_from_csv; - impl RNullValues; + impl RPolarsRNullValues; } From f3f8aae4f7547a53872a3bb25a6801a1eb19d99d Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 1 Dec 2023 15:32:27 +0000 Subject: [PATCH 32/32] fix: RField -> RPolarsRField --- R/Field.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Field.R b/R/Field.R index 863372628..17ad1e0d4 100644 --- a/R/Field.R +++ b/R/Field.R @@ -46,7 +46,7 @@ print.RPolarsRField = function(x, ...) { #' @export #' @keywords internal .DollarNames.RPolarsRField = function(x, pattern = "") { - get_method_usages(RField, pattern = pattern) + get_method_usages(RPolarsRField, pattern = pattern) }