Skip to content

Commit

Permalink
Change default value for strategy in $n_chunks() (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Jun 6, 2024
1 parent 2936638 commit f4b0d8d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Polars R Package (development version)

### Breaking changes

- In `$n_chunks()`, the default value of `strategy` now is `"first"` (#1137).

### New features

- New method `$has_nulls()` (#1133).
Expand Down
2 changes: 1 addition & 1 deletion R/dataframe__frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ DataFrame_first = function() {
#' str(z)
#' z = rechunk(z)
#' str(z)
DataFrame_n_chunks = function(strategy = "all") {
DataFrame_n_chunks = function(strategy = "first") {
.pr$DataFrame$n_chunks(self, strategy) |>
unwrap("in n_chunks():")
}
Expand Down
2 changes: 1 addition & 1 deletion man/DataFrame_n_chunks.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/test-concat.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ test_that("concat dataframe", {
)

# check rechunk works
expect_identical(pl$concat(mtcars, mtcars, rechunk = TRUE)$n_chunks(), rep(1, 11))
expect_identical(pl$concat(mtcars, mtcars, rechunk = FALSE)$n_chunks(), rep(2, 11))
expect_identical(pl$concat(mtcars, mtcars, rechunk = TRUE)$n_chunks("all"), rep(1, 11))
expect_identical(pl$concat(mtcars, mtcars, rechunk = FALSE)$n_chunks("all"), rep(2, 11))



Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,15 @@ test_that("n_chunks", {
how = "horizontal"
)

expect_identical(df$n_chunks(), c(1, 2))
expect_identical(df$n_chunks("first"), c(1))
expect_identical(df$n_chunks("all"), c(1, 2))
expect_identical(df$n_chunks(), 1)
expect_identical(pl$DataFrame()$n_chunks("all"), numeric())
expect_identical(pl$DataFrame()$n_chunks(), numeric())
expect_identical(pl$DataFrame()$n_chunks("first"), numeric())

pl$DataFrame()$n_chunks("wrong strat") |>
get_err_ctx("Plain") |>
grepl(pat = "strategy") |>
expect_true()
expect_grepl_error(
pl$DataFrame()$n_chunks("wrong strat"),
"strategy not recognized"
)
})


Expand Down

0 comments on commit f4b0d8d

Please sign in to comment.