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

refactor!: change the polars_info() output structure #791

Merged
merged 2 commits into from
Feb 8, 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: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
Their behaviour doesn't change.
- `include_bounds` is renamed `closed` and must be one of `"left"`,
`"right"`, `"both"`, or `"none"`.
- `polars_info()` returns a slightly changed list.
- `$threadpool_size`, which means the number of threads used by Polars,
is changed to `$thread_pool_size` (#784)
- `$version`, which indicates the version of this package,
is changed to `$versions$r_package` (#791).
- `$rust_polars`, which indicates the version of the dependent Rust Polars,
is changed to `$versions$rust_crate` (#791).

### Deprecations

Expand Down
12 changes: 7 additions & 5 deletions R/polars_info.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Report information of the package
#'
#' This function reports the following information:
#' - Package versions (the R package version and the dependent Rust Polars version)
#' - Package versions (the Polars R package version and the dependent Rust Polars crate version)
#' - [Number of threads used by Polars][pl_thread_pool_size]
#' - Rust feature flags (See `vignette("install", "polars")` for details)
#' @return A list with information of the package
Expand All @@ -15,8 +15,10 @@
polars_info = function() {
# Similar to arrow::arrow_info()
out = list(
version = utils::packageVersion("polars"),
rust_polars = rust_polars_version(),
versions = list(
r_package = utils::packageVersion("polars"),
rust_crate = rust_polars_version()
),
thread_pool_size = thread_pool_size(),
features = cargo_rpolars_feature_info()
)
Expand All @@ -38,8 +40,8 @@ print.polars_info = function(x, ...) {
cat("\n")
}

cat("r-polars package version : ", format(x$version), "\n", sep = "")
cat("rust-polars crate version: ", format(x$rust_polars), "\n", sep = "")
cat("Polars R package version : ", format(x$versions$r_package), "\n", sep = "")
cat("Rust Polars crate version: ", format(x$versions$rust_crate), "\n", sep = "")
cat("\n")
cat("Thread pool size:", x$thread_pool_size, "\n")
cat("\n")
Expand Down
2 changes: 1 addition & 1 deletion man/polars_info.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/polars_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Code
info
Output
r-polars package version : 999.999.999
rust-polars crate version: 999.999.999
Polars R package version : 999.999.999
Rust Polars crate version: 999.999.999

Thread pool size: 1

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-polars_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ test_that("print polars_info()", {
info = polars_info()

# Ensure static version for snapshot test
info$version = package_version("999.999.999")
info$rust_polars = package_version("999.999.999")
info$versions$r_package = package_version("999.999.999")
info$versions$rust_crate = package_version("999.999.999")

# Ensure the thread_pool_size is 1 for snapshot test
info$thread_pool_size = 1
Expand Down
Loading