Skip to content

Commit

Permalink
test: re add tests for as_polars_df(<ArrowTabular>)
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed May 7, 2024
1 parent 2fde92a commit 303ea0b
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions tests/testthat/test-as_polars.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,33 @@ test_that("from arrow Table and ChunkedArray", {
unname(as.list(at))
)

# no rechunk no longer works
# expect_identical(
# lapply(at$columns, \(x) length(as_polars_series.ChunkedArray(x, rechunk = FALSE)$chunk_lengths())),
# lapply(at$columns, \(x) x$num_chunks)
# )
# expect_grepl_error(expect_identical(
# lapply(at$columns, \(x) length(as_polars_series.ChunkedArray(x, rechunk = TRUE)$chunk_lengths())),
# lapply(at$columns, \(x) x$num_chunks)
# ))
# expect_identical(
# as_polars_df.ArrowTabular(at, rechunk = FALSE)$
# select(pl$all()$map_batches(\(s) s$chunk_lengths()))$
# to_list() |>
# lapply(length) |>
# unname(),
# lapply(at$columns, \(x) x$num_chunks)
# )

# expect_identical(
# as_polars_df.ArrowTabular(at, rechunk = TRUE)$
# select(pl$all()$map_batches(\(s) s$chunk_lengths()))$
# to_list() |>
# lapply(length) |>
# unname(),
# lapply(at$columns, \(x) x$num_chunks)
# )


# #not supported yet
expect_identical(
lapply(at$columns, \(x) length(as_polars_series.ChunkedArray(x, rechunk = FALSE)$chunk_lengths())),
lapply(at$columns, \(x) x$num_chunks)
)
expect_grepl_error(expect_identical(
lapply(at$columns, \(x) length(as_polars_series.ChunkedArray(x, rechunk = TRUE)$chunk_lengths())),
lapply(at$columns, \(x) x$num_chunks)
))
expect_identical(
as_polars_df.ArrowTabular(at, rechunk = FALSE)$
select(pl$all()$map_batches(\(s) s$chunk_lengths()))$
to_list() |>
lapply(length) |>
unname(),
lapply(at$columns, \(x) x$num_chunks)
)

expect_identical(
as_polars_df.ArrowTabular(at, rechunk = TRUE)$
select(pl$all()$map_batches(\(s) s$chunk_lengths()))$
to_list() |>
lapply(length) |>
unname(),
lapply(at$columns, \(x) x$num_chunks)
)

#not supported yet
# #chunked data with factors
l = list(
df1 = data.frame(factor = factor(c("apple", "apple", "banana"))),
Expand Down

0 comments on commit 303ea0b

Please sign in to comment.