Skip to content

Commit

Permalink
Merge branch 'main' into prepare-altdoc-0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher authored Dec 16, 2023
2 parents d4ae4fc + c74a2b8 commit 1039828
Show file tree
Hide file tree
Showing 32 changed files with 95 additions and 269 deletions.
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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).
- `pl$concat_list()`: elements being strings are now interpreted as column names.
- `pl$concat_list()`: elements being strings are now interpreted as column names.
Use `pl$lit` to concat with a string.
- `<RPolarsExpr>$lit_to_s()` is renamed to `<RPolarsExpr>$to_series()` (#582).
- `<RPolarsExpr>$lit_to_df()` is removed (#582).
- Change class names and function names associated with class names.
- The class name of all objects created by polars (`DataFrame`, `LazyFrame`,
`Expr`, `Series`, etc.) has changed. They now start with `RPolars`, for example
Expand All @@ -24,7 +26,7 @@
the row.names attribute to a column.
This option is inspired by the `tibble::as_tibble()` function (#561).
- `as_polars_df()` for `data.frame` has a new argument `make_names_unique` (#561).
- New methods `$str$to_date()`, `$str$to_time()`, `$str$to_datetime()` as
- New methods `$str$to_date()`, `$str$to_time()`, `$str$to_datetime()` as
alternatives to `$str$strptime()` (#558).
- The `dim()` function for DataFrame and LazyFrame correctly returns integer instead of
double (#577).
Expand Down
2 changes: 1 addition & 1 deletion R/PTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ time_unit_conv_factor = c(
#'
#'
#' pl$Series(pl$PTime(runif(5) * 3600 * 24 * 1E0, tu = "s"))
#' pl$lit(pl$PTime("23:59:59"))$lit_to_s()
#' pl$lit(pl$PTime("23:59:59"))$to_series()
#'
#' pl$lit(pl$PTime("23:59:59"))$to_r()
pl$PTime = function(x, tu = c("s", "ms", "us", "ns"), format = "%H:%M:%S") {
Expand Down
2 changes: 1 addition & 1 deletion R/autocompletion.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#' # polars has experimental auto completion for chain of methods if all on the same line
#' pl$extra_auto_completion() # first activate feature (this will 'annoy' the Rstudio auto-completer)
#' pl$lit(42)$lit_to_s() # add a $ and press tab 1-3 times
#' pl$lit(42)$to_series() # add a $ and press tab 1-3 times
#' pl$extra_auto_completion(activate = FALSE) # deactivate
pl$extra_auto_completion = function(activate = TRUE) {
# load this function into custom.completer setting to activate
Expand Down
4 changes: 2 additions & 2 deletions R/construction.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ arrow_to_rseries_result = function(name, values, rechunk = TRUE) {
is_arrow_dictonary(array) &&
array$type$value_type %in_list% list(arrow::utf8(), arrow::large_utf8())
) {
return(Ok(pl$lit(c())$cast(pl$Categorical)$lit_to_s()))
return(Ok(pl$lit(c())$cast(pl$Categorical)$to_series()))
}

# rechunk immediately before import
Expand All @@ -162,6 +162,6 @@ arrow_to_rseries_result = function(name, values, rechunk = TRUE) {
}

rseries_result |> map(\(s) {
if (rechunk) wrap_e(s)$rechunk()$lit_to_s() else s
if (rechunk) wrap_e(s)$rechunk()$to_series() else s
})
}
16 changes: 8 additions & 8 deletions R/expr__datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ ExprDT_round = function(every, offset = NULL) {
#' @aliases (Expr)$dt$combine
#' @examples
#' # Using pl$PTime
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime("02:34:12"))$lit_to_s()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime(3600 * 1.5, tu = "s"))$lit_to_s()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime(3600 * 1.5E6 + 123, tu = "us"))$lit_to_s()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime("02:34:12"))$to_series()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime(3600 * 1.5, tu = "s"))$to_series()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(pl$PTime(3600 * 1.5E6 + 123, tu = "us"))$to_series()
#'
#' # pass double and set tu manually
#' pl$lit(as.Date("2021-01-01"))$dt$combine(3600 * 1.5E6 + 123, tu = "us")$lit_to_s()
#' pl$lit(as.Date("2021-01-01"))$dt$combine(3600 * 1.5E6 + 123, tu = "us")$to_series()
#'
#' # if needed to convert back to R it is more intuitive to set a specific time zone
#' expr = pl$lit(as.Date("2021-01-01"))$dt$combine(3600 * 1.5E6 + 123, tu = "us")
Expand Down Expand Up @@ -582,10 +582,10 @@ ExprDT_nanosecond = function() {
#' @usage NULL
#' @aliases (Expr)$dt$epoch
#' @examples
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("ns")$lit_to_s()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("ms")$lit_to_s()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("s")$lit_to_s()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("d")$lit_to_s()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("ns")$to_series()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("ms")$to_series()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("s")$to_series()
#' pl$date_range(as.Date("2022-1-1"), eager = FALSE)$dt$epoch("d")$to_series()
ExprDT_epoch = function(tu = c("us", "ns", "ms", "s", "d")) {
tu = tu[1]

Expand Down
19 changes: 5 additions & 14 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ Expr_apply = function(f, return_type = NULL, strict_return_type = TRUE,
#' pl$select(pl$lit(1:4))
#'
#' # r vector to literal to Series
#' pl$lit(1:4)$lit_to_s()
#' pl$lit(1:4)$to_series()
#'
#' # vectors to literal implicitly
#' (pl$lit(2) + 1:4) / 4:1
Expand Down Expand Up @@ -1036,12 +1036,12 @@ Expr_to_physical = "use_extendr_wrapper"
#' )
#'
#' # strict FALSE, inserts null for any cast failure
#' pl$lit(c(100, 200, 300))$cast(pl$dtypes$UInt8, strict = FALSE)$lit_to_s()
#' pl$lit(c(100, 200, 300))$cast(pl$dtypes$UInt8, strict = FALSE)$to_series()
#'
#' # strict TRUE, raise any failure as an error when query is executed.
#' tryCatch(
#' {
#' pl$lit("a")$cast(pl$dtypes$Float64, strict = TRUE)$lit_to_s()
#' pl$lit("a")$cast(pl$dtypes$Float64, strict = TRUE)$to_series()
#' },
#' error = function(e) e
#' )
Expand Down Expand Up @@ -3436,20 +3436,11 @@ Expr_to_struct = function() {
#' Collect an expression based on literals into a Series.
#' @return Series
#' @examples
#' pl$lit(1:5)$lit_to_s()
Expr_lit_to_s = function() {
#' pl$lit(1:5)$to_series()
Expr_to_series = function() {
pl$select(self)$to_series(0)
}

#' Convert Literal to DataFrame
#'
#' Collect an expression based on literals into a DataFrame.
#' @return Series
#' @examples
#' pl$lit(1:5)$lit_to_df()
Expr_lit_to_df = function() {
pl$select(self)
}

#' Find local minima
#'
Expand Down
8 changes: 4 additions & 4 deletions R/expr__string.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#' pl$lit(txt_datetimes)$str$strptime(
#' pl$Datetime("ns"),
#' format = "%Y-%m-%d %H:%M:%S %z", strict = FALSE,
#' )$lit_to_s()
#' )$to_series()
ExprStr_strptime = function(
datatype,
format,
Expand Down Expand Up @@ -244,7 +244,7 @@ ExprStr_concat = function(delimiter = "-", ignore_nulls = TRUE) {
#' @keywords ExprStr
#' @return Expr of Utf8 uppercase chars
#' @examples
#' pl$lit(c("A", "b", "c", "1", NA))$str$to_uppercase()$lit_to_s()
#' pl$lit(c("A", "b", "c", "1", NA))$str$to_uppercase()$to_series()
ExprStr_to_uppercase = function() {
.pr$Expr$str_to_uppercase(self)
}
Expand All @@ -255,7 +255,7 @@ ExprStr_to_uppercase = function() {
#' @keywords ExprStr
#' @return Expr of Utf8 lowercase chars
#' @examples
#' pl$lit(c("A", "b", "c", "1", NA))$str$to_lowercase()$lit_to_s()
#' pl$lit(c("A", "b", "c", "1", NA))$str$to_lowercase()$to_series()
ExprStr_to_lowercase = function() {
.pr$Expr$str_to_lowercase(self)
}
Expand All @@ -271,7 +271,7 @@ ExprStr_to_lowercase = function() {
#' Rust nightly toolchain to compile.
#' See [`pl$polars_info()`][polars_info] for more details.
#' @examplesIf pl$polars_info()$features$simd
#' pl$lit(c("hello there", "HI, THERE", NA))$str$to_titlecase()$lit_to_s()
#' pl$lit(c("hello there", "HI, THERE", NA))$str$to_titlecase()$to_series()
ExprStr_to_titlecase = function() {
check_feature("simd", "in $to_titlecase():")

Expand Down
2 changes: 1 addition & 1 deletion R/functions__eager.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pl$date_range = function(

f_eager_eval = \(lit) {
if (isTRUE(eager)) {
result(lit$lit_to_s())
result(lit$to_series())
} else {
Ok(lit)
}
Expand Down
6 changes: 3 additions & 3 deletions R/functions__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ pl$n_unique = function(column) { #-> int or Expr
#'
#' # comparison with n_unique for 2 million integers. (try change example to 20 million ints)
#' lit_series = pl$lit(c(1:1E6, 1E6:1, 1:1E6))
#' system.time(pl$approx_n_unique(lit_series)$lit_to_s()$print())
#' system.time(pl$n_unique(lit_series)$lit_to_s()$print())
#' system.time(pl$approx_n_unique(lit_series)$to_series()$print())
#' system.time(pl$n_unique(lit_series)$to_series()$print())
pl$approx_n_unique = function(column) { #-> int or Expr
pcase(
inherits(column, "RPolarsExpr"), result(column$approx_n_unique()),
Expand Down Expand Up @@ -682,7 +682,7 @@ pl$var = function(column, ddof = 1) {
#' pl$lit(1:5),
#' pl$Series(5:1),
#' rep(0L, 5)
#' ))$alias("alice")$lit_to_s()
#' ))$alias("alice")$to_series()
#'
pl$concat_list = function(exprs) {
concat_list(as.list(exprs)) |>
Expand Down
2 changes: 1 addition & 1 deletion R/series__series.R
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ Series_expr = method_as_property(function() {
#' $list$lengths()
#' $sum()
#' $cast(pl$dtypes$Int8)
#' $lit_to_s()
#' $to_series()
#' )
Series_to_lit = function() {
pl$lit(self)
Expand Down
8 changes: 4 additions & 4 deletions man/ExprDT_combine.Rd

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

8 changes: 4 additions & 4 deletions man/ExprDT_epoch.Rd

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

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

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

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

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

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

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

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

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

4 changes: 2 additions & 2 deletions man/Expr_cast.Rd

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

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

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

17 changes: 0 additions & 17 deletions man/Expr_lit_to_df.Rd

This file was deleted.

8 changes: 4 additions & 4 deletions man/Expr_lit_to_s.Rd → man/Expr_to_series.Rd

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

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

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

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

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

4 changes: 2 additions & 2 deletions man/pl_approx_n_unique.Rd

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

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

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

Loading

0 comments on commit 1039828

Please sign in to comment.