Skip to content

Commit

Permalink
refactor: rename pl$polars_info to polars_info (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi authored Jan 4, 2024
1 parent 94f590f commit c87abf8
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 38 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export(is_polars_df)
export(is_polars_lf)
export(is_polars_series)
export(pl)
export(polars_info)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(utils,.DollarNames)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## polars (development version)

### Deprecations

- `pl$polars_info()` is moved to `polars_info()`. `pl$polars_info()` is deprecated
and will be removed in 0.13.0 (#662).

### Rust-polars update

- rust-polars is updated to 0.36.2 (#659). Most of the changes were covered
Expand Down
4 changes: 2 additions & 2 deletions R/expr__string.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ ExprStr_to_lowercase = function() {
#' This method is only available with the feature flag "simd" which can
#' be set via envvar "RPOLARS_FULL_FEATURES" and it requires
#' Rust nightly toolchain to compile.
#' See [`pl$polars_info()`][pl_polars_info] for more details.
#' @examplesIf pl$polars_info()$features$simd
#' See [polars_info] for more details.
#' @examplesIf polars_info()$features$simd
#' 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
9 changes: 7 additions & 2 deletions R/info.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#' - [Number of threads used by Polars][pl_threadpool_size]
#' - Rust feature flags (See `vignette("install", "polars")` for details)
#' @return A list with information of the package
#' @export
#' @examples
#' pl$polars_info()
pl_polars_info = function() {
#' polars_info()
polars_info = function() {
# Similar to arrow::arrow_info()
out = list(
version = utils::packageVersion("polars"),
Expand All @@ -18,6 +19,10 @@ pl_polars_info = function() {
structure(out, class = "polars_info")
}

pl_polars_info = function() {
warning("pl$polars_info() is deprecated and will be removed in 0.13.0. Use polars_info() instead.", call. = FALSE)
polars_info()
}

#' @noRd
#' @export
Expand Down
16 changes: 8 additions & 8 deletions R/sql.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' @title Run SQL queries against DataFrame/LazyFrame data.
#' @description Run SQL queries against DataFrame/LazyFrame data.
#' @details Currently, only available when built with the `full` feature.
#' See [`pl$polars_info()`][pl_polars_info] for more information.
#' See [polars_info] for more information.
#' @name SQLContext_class
#' @keywords SQLContext
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' lf = pl$LazyFrame(a = 1:3, b = c("x", NA, "z"))
#' res = pl$SQLContext(frame = lf)$execute(
#' "SELECT b, a*2 AS two_a FROM frame WHERE b IS NOT NULL"
Expand Down Expand Up @@ -41,7 +41,7 @@ print.RPolarsSQLContext = function(x, ...) {
#' @description Create a new SQLContext and register the given LazyFrames.
#' @param ... Name-value pairs of [LazyFrame][LazyFrame_class] like objects to register.
#' @return RPolarsSQLContext
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' ctx = pl$SQLContext(mtcars = mtcars)
#' ctx
pl_SQLContext = function(...) {
Expand Down Expand Up @@ -71,7 +71,7 @@ pl_SQLContext = function(...) {
#' @param eager A logical flag indicating whether to collect the result immediately.
#' If FALSE (default), a [LazyFrame][LazyFrame_class] is returned. If TRUE, a [DataFrame][DataFrame_class] is returned.
#' @return A [LazyFrame][LazyFrame_class] or [DataFrame][DataFrame_class] depending on the value of `eager`.
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' query = "SELECT * FROM mtcars WHERE cyl = 4"
#' pl$SQLContext(mtcars = mtcars)$execute(query)
#' pl$SQLContext(mtcars = mtcars)$execute(query, eager = TRUE)
Expand All @@ -92,7 +92,7 @@ SQLContext_execute = function(query, eager = FALSE) {
#' @param name A string name to register the frame as.
#' @param frame A [LazyFrame][LazyFrame_class] like object to register.
#' @return Returns the [SQLContext_class] object invisibly.
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' ctx = pl$SQLContext()
#' ctx$register("mtcars", mtcars)
#'
Expand All @@ -108,7 +108,7 @@ SQLContext_register = function(name, frame) {
#' @description Register multiple frames as tables.
#' @param ... Name-value pairs of [LazyFrame][LazyFrame_class] like objects to register.
#' @return Returns the [SQLContext_class] object invisibly.
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' ctx = pl$SQLContext()
#' r_df = mtcars
#' pl_df = pl$DataFrame(mtcars)
Expand Down Expand Up @@ -145,7 +145,7 @@ SQLContext_register_many = function(...) {
#' @description Unregister tables by name.
#' @param names A character vector of table names to unregister.
#' @return Returns the [SQLContext_class] object invisibly.
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' # Initialise a new SQLContext and register the given tables.
#' ctx = pl$SQLContext(x = mtcars, y = mtcars, z = mtcars)
#' ctx$tables()
Expand All @@ -165,7 +165,7 @@ SQLContext_unregister = function(names) {
#' @title List registered tables
#' @description Return a character vector of the registered table names.
#' @return A character vector of the registered table names.
#' @examplesIf pl$polars_info()$features$sql
#' @examplesIf polars_info()$features$sql
#' ctx = pl$SQLContext()
#' ctx$tables()
#' ctx$register("df1", mtcars)
Expand Down
11 changes: 7 additions & 4 deletions dev/generate-lib-sums.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ desc::desc_set(paste0("Config/", package_name, "/LibVersion"), current_lib_versi

if (identical(current_lib_version, latest_released_lib_version)) {
message("Current lib version is available via the binary release.")
write_bin_lib_data(
lib_data_file_path,
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/sha256sums.txt"),
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/")
try(
write_bin_lib_data(
lib_data_file_path,
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/sha256sums.txt"),
glue::glue("{base_url}{tag_prefix }{latest_released_lib_version}/")
),
silent = TRUE
)
} else {
message("Current lib version is not available via binary releases.")
Expand Down
4 changes: 2 additions & 2 deletions man/ExprStr_to_titlecase.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/SQLContext_class.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/SQLContext_execute.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/SQLContext_register.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/SQLContext_register_many.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/SQLContext_tables.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/SQLContext_unregister.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_SQLContext.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/pl_polars_info.Rd → man/polars_info.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/info.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# print pl$polars_info()
# print polars_info()

Code
info
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-expr_string.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test_that("to_uppercase, to_lowercase", {
})

test_that("to_titlecase - enabled via the simd feature", {
skip_if_not(pl$polars_info()$features$simd)
skip_if_not(polars_info()$features$simd)
df2 = pl$DataFrame(foo = c("hi there", "HI, THERE", NA))
expect_identical(
df2$select(pl$col("foo")$str$to_titlecase())$to_list()$foo,
Expand All @@ -194,7 +194,7 @@ test_that("to_titlecase - enabled via the simd feature", {
})

test_that("to_titlecase - enabled via the simd feature", {
skip_if(pl$polars_info()$features$simd)
skip_if(polars_info()$features$simd)
expect_error(pl$col("foo")$str$to_titlecase())
})

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-info.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ patrick::with_parameters_test_that("polars_info() features are logical",
expect_type(feature, "logical")
expect_length(feature, 1)
},
feature = pl$polars_info()$features
feature = polars_info()$features
)

test_that("print pl$polars_info()", {
info = pl$polars_info()
test_that("print polars_info()", {
info = polars_info()

# Ensure static version for snapshot test
info$version = package_version("999.999.999")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-sql.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("Intialize SQLContext with LazyFrame like objects", {
skip_if_not(pl$polars_info()$features$sql)
skip_if_not(polars_info()$features$sql)

ctx = pl$SQLContext(
r_df = mtcars,
Expand All @@ -23,7 +23,7 @@ test_that("Intialize SQLContext with LazyFrame like objects", {
})

test_that("SQLContext_register, register_many, unregister", {
skip_if_not(pl$polars_info()$features$sql)
skip_if_not(polars_info()$features$sql)

ctx = pl$SQLContext()
ctx$register("mtcars", mtcars)
Expand Down

0 comments on commit c87abf8

Please sign in to comment.