Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: move to the latest polars #1117

Merged
merged 10 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Breaking changes

- Updated rust-polars to unreleased version (> 0.40.0) (#1104, #1110):
- Updated rust-polars to unreleased version (> 0.40.0) (#1104, #1110, #1117):
- In `$join()`, there is a new argument `coalesce` and the `how` options now
accept `"full"` instead of `"outer"` and `"outer_coalesce"`.
- `$top_k()` and `$bottom_k()` gain three arguments `nulls_last`,
Expand All @@ -26,7 +26,10 @@
- In all functions accepting optimization parameter (such as
`projection_pushdown`), there is a new parameter `cluster_with_columns` to
combine sequential independent calls to `$with_columns()`.

- `$str$expload()` is removed.
eitsupi marked this conversation as resolved.
Show resolved Hide resolved
- The `check_sorted` argument is removed from `$rolling()` and `$group_by_dynamic()`.
Sortedness is now verified in a quick manner, so this argument is no longer needed
(pola-rs/polars#16494).
- As warned in v0.16.0, the order of arguments in `pl$Series` is changed (#1071).
The first argument is now `name`, and the second argument is `values`.
- `$to_struct()` on an Expr is removed. This method is now only available for
Expand Down
10 changes: 4 additions & 6 deletions R/dataframe__frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -2127,11 +2127,10 @@ DataFrame_rolling = function(
period,
offset = NULL,
closed = "right",
group_by = NULL,
check_sorted = TRUE) {
group_by = NULL) {
period = parse_as_polars_duration_string(period)
offset = parse_as_polars_duration_string(offset) %||% negate_duration_string(period)
construct_rolling_group_by(self, index_column, period, offset, closed, group_by, check_sorted)
construct_rolling_group_by(self, index_column, period, offset, closed, group_by)
}

#' @inherit LazyFrame_group_by_dynamic title description details params
Expand Down Expand Up @@ -2211,14 +2210,13 @@ DataFrame_group_by_dynamic = function(
closed = "left",
label = "left",
group_by = NULL,
start_by = "window",
check_sorted = TRUE) {
start_by = "window") {
every = parse_as_polars_duration_string(every)
offset = parse_as_polars_duration_string(offset) %||% negate_duration_string(every)
period = parse_as_polars_duration_string(period) %||% every
construct_group_by_dynamic(
self, index_column, every, period, offset, include_boundaries, closed, label,
group_by, start_by, check_sorted
group_by, start_by
)
}

Expand Down
9 changes: 2 additions & 7 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3282,10 +3282,6 @@ Expr_peak_max = function() {
#' See the `Polars duration string language` section for details.
#' @param closed Define which sides of the temporal interval are closed
#' (inclusive). This can be either `"left"`, `"right"`, `"both"` or `"none"`.
#' @param check_sorted Check whether data is actually sorted. Checking it is
#' expensive so if you are sure the data within the `index_column` is sorted, you
#' can set this to `FALSE` but note that if the data actually is unsorted, it
#' will lead to incorrect output.
#'
#' @inheritSection polars_duration_string Polars duration string language
#' @return Expr
Expand Down Expand Up @@ -3319,11 +3315,10 @@ Expr_rolling = function(
...,
period,
offset = NULL,
closed = "right",
check_sorted = TRUE) {
closed = "right") {
period = parse_as_polars_duration_string(period)
offset = parse_as_polars_duration_string(offset) %||% negate_duration_string(period)
.pr$Expr$rolling(self, index_column, period, offset, closed, check_sorted) |>
.pr$Expr$rolling(self, index_column, period, offset, closed) |>
unwrap("in $rolling():")
}

Expand Down
12 changes: 0 additions & 12 deletions R/expr__string.R
Original file line number Diff line number Diff line change
Expand Up @@ -853,18 +853,6 @@ ExprStr_slice = function(offset, length = NULL) {
unwrap("in $str$slice():")
}

#' Returns a column with a separate row for every string character
#'
#' @keywords ExprStr
#' @return Expr: Series of dtype String.
#' @examples
#' df = pl$DataFrame(a = c("foo", "bar"))
#' df$select(pl$col("a")$str$explode())
ExprStr_explode = function() {
.pr$Expr$str_explode(self) |>
unwrap("in $str$explode():")
}


#' Convert a String column into an Int64 column with base radix
#'
Expand Down
8 changes: 3 additions & 5 deletions R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,6 @@ RPolarsExpr$str_replace_all <- function(pat, value, literal) .Call(wrap__RPolars

RPolarsExpr$str_slice <- function(offset, length) .Call(wrap__RPolarsExpr__str_slice, self, offset, length)

RPolarsExpr$str_explode <- function() .Call(wrap__RPolarsExpr__str_explode, self)

RPolarsExpr$str_to_integer <- function(base, strict) .Call(wrap__RPolarsExpr__str_to_integer, self, base, strict)

RPolarsExpr$str_reverse <- function() .Call(wrap__RPolarsExpr__str_reverse, self)
Expand Down Expand Up @@ -1154,7 +1152,7 @@ RPolarsExpr$corr <- function(a, b, method, ddof, propagate_nans) .Call(wrap__RPo

RPolarsExpr$rolling_corr <- function(a, b, window_size, min_periods, ddof) .Call(wrap__RPolarsExpr__rolling_corr, a, b, window_size, min_periods, ddof)

RPolarsExpr$rolling <- function(index_column, period, offset, closed, check_sorted) .Call(wrap__RPolarsExpr__rolling, self, index_column, period, offset, closed, check_sorted)
RPolarsExpr$rolling <- function(index_column, period, offset, closed) .Call(wrap__RPolarsExpr__rolling, self, index_column, period, offset, closed)

#' @export
`$.RPolarsExpr` <- function (self, name) { func <- RPolarsExpr[[name]]; environment(func) <- environment(); func }
Expand Down Expand Up @@ -1270,9 +1268,9 @@ RPolarsLazyFrame$clone_in_rust <- function() .Call(wrap__RPolarsLazyFrame__clone

RPolarsLazyFrame$with_context <- function(contexts) .Call(wrap__RPolarsLazyFrame__with_context, self, contexts)

RPolarsLazyFrame$rolling <- function(index_column, period, offset, closed, group_by, check_sorted) .Call(wrap__RPolarsLazyFrame__rolling, self, index_column, period, offset, closed, group_by, check_sorted)
RPolarsLazyFrame$rolling <- function(index_column, period, offset, closed, group_by) .Call(wrap__RPolarsLazyFrame__rolling, self, index_column, period, offset, closed, group_by)

RPolarsLazyFrame$group_by_dynamic <- function(index_column, every, period, offset, label, include_boundaries, closed, by, start_by, check_sorted) .Call(wrap__RPolarsLazyFrame__group_by_dynamic, self, index_column, every, period, offset, label, include_boundaries, closed, by, start_by, check_sorted)
RPolarsLazyFrame$group_by_dynamic <- function(index_column, every, period, offset, label, include_boundaries, closed, by, start_by) .Call(wrap__RPolarsLazyFrame__group_by_dynamic, self, index_column, every, period, offset, label, include_boundaries, closed, by, start_by)

RPolarsLazyFrame$to_dot <- function(optimized) .Call(wrap__RPolarsLazyFrame__to_dot, self, optimized)

Expand Down
8 changes: 3 additions & 5 deletions R/group_by_dynamic.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RPolarsDynamicGroupBy = new.env(parent = emptyenv())
#' @noRd
construct_group_by_dynamic = function(
df, index_column, every, period, offset, include_boundaries, closed, label,
group_by, start_by, check_sorted) {
group_by, start_by) {
if (!inherits(df, "RPolarsDataFrame")) {
stop("internal error: construct_group called not on DataFrame")
}
Expand All @@ -58,8 +58,7 @@ construct_group_by_dynamic = function(
closed = closed,
label = label,
group_by = group_by,
start_by = start_by,
check_sorted = check_sorted
start_by = start_by
)
class(out) = "RPolarsDynamicGroupBy"
out
Expand Down Expand Up @@ -96,8 +95,7 @@ DynamicGroupBy_agg = function(...) {
closed = prv$closed,
label = prv$label,
group_by = prv$group_by,
start_by = prv$start_by,
check_sorted = prv$check_sorted
start_by = prv$start_by
)$
agg(unpack_list(..., .context = "in $agg():"))$
collect(no_optimization = TRUE)
Expand Down
8 changes: 3 additions & 5 deletions R/group_by_rolling.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RPolarsRollingGroupBy = new.env(parent = emptyenv())
#' The internal RollingGroupBy constructor
#' @return The input as grouped DataFrame
#' @noRd
construct_rolling_group_by = function(df, index_column, period, offset, closed, group_by, check_sorted) {
construct_rolling_group_by = function(df, index_column, period, offset, closed, group_by) {
if (!inherits(df, "RPolarsDataFrame")) {
stop("internal error: construct_group called not on DataFrame")
}
Expand All @@ -50,8 +50,7 @@ construct_rolling_group_by = function(df, index_column, period, offset, closed,
period = period,
offset = offset,
closed = closed,
group_by = group_by,
check_sorted = check_sorted
group_by = group_by
)
class(out) = "RPolarsRollingGroupBy"
out
Expand Down Expand Up @@ -96,8 +95,7 @@ RollingGroupBy_agg = function(...) {
period = prv$period,
offset = prv$offset,
closed = prv$closed,
group_by = prv$group_by,
check_sorted = prv$check_sorted
group_by = prv$group_by
)$
agg(unpack_list(..., .context = "in $agg():"))$
collect(no_optimization = TRUE)
Expand Down
10 changes: 4 additions & 6 deletions R/lazyframe__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -1924,13 +1924,12 @@ LazyFrame_rolling = function(
period,
offset = NULL,
closed = "right",
group_by = NULL,
check_sorted = TRUE) {
group_by = NULL) {
period = parse_as_polars_duration_string(period)
offset = parse_as_polars_duration_string(offset) %||% negate_duration_string(period)
.pr$LazyFrame$rolling(
self, index_column, period, offset, closed,
wrap_elist_result(group_by, str_to_lit = FALSE), check_sorted
wrap_elist_result(group_by, str_to_lit = FALSE)
) |>
unwrap("in $rolling():")
}
Expand Down Expand Up @@ -2034,15 +2033,14 @@ LazyFrame_group_by_dynamic = function(
closed = "left",
label = "left",
group_by = NULL,
start_by = "window",
check_sorted = TRUE) {
start_by = "window") {
every = parse_as_polars_duration_string(every)
offset = parse_as_polars_duration_string(offset) %||% negate_duration_string(every)
period = parse_as_polars_duration_string(period) %||% every

.pr$LazyFrame$group_by_dynamic(
self, index_column, every, period, offset, label, include_boundaries, closed,
wrap_elist_result(group_by, str_to_lit = FALSE), start_by, check_sorted
wrap_elist_result(group_by, str_to_lit = FALSE), start_by
) |>
unwrap("in $group_by_dynamic():")
}
Expand Down
8 changes: 1 addition & 7 deletions man/DataFrame_group_by_dynamic.Rd

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

8 changes: 1 addition & 7 deletions man/DataFrame_rolling.Rd

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

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

This file was deleted.

14 changes: 1 addition & 13 deletions man/Expr_rolling.Rd

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

8 changes: 1 addition & 7 deletions man/LazyFrame_group_by_dynamic.Rd

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

8 changes: 1 addition & 7 deletions man/LazyFrame_rolling.Rd

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

Loading
Loading