Skip to content

Commit

Permalink
Merge pull request #1372 from tidymodels/stricter-sparsevctrs-tests
Browse files Browse the repository at this point in the history
Stricter sparsevctrs tests
  • Loading branch information
EmilHvitfeldt authored Sep 16, 2024
2 parents 377f7d5 + a18b7f9 commit a56d6f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Imports:
Matrix,
purrr (>= 1.0.0),
rlang (>= 1.1.0),
sparsevctrs (>= 0.1.0.9000),
sparsevctrs (>= 0.1.0.9001),
stats,
tibble,
tidyr (>= 1.0.0),
Expand Down
2 changes: 2 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ n_complete_rows <- function(x) {
x[[pos_list_col]] <- purrr::map_lgl(x[[pos_list_col]], flatten_na)
}

x <- x[, vapply(x, anyNA, logical(1))]

sum(vec_detect_complete(x))
}

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-sparsevctrs.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("recipe() accepts sparse tibbles", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()
hotel_data <- sparsevctrs::coerce_to_sparse_tibble(hotel_data)
Expand Down Expand Up @@ -31,6 +32,7 @@ test_that("recipe() accepts sparse tibbles", {

test_that("prep() accepts sparse tibbles", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()
hotel_data <- sparsevctrs::coerce_to_sparse_tibble(hotel_data)
Expand All @@ -56,6 +58,7 @@ test_that("prep() accepts sparse tibbles", {

test_that("bake() accepts sparse tibbles", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()
hotel_data <- sparsevctrs::coerce_to_sparse_tibble(hotel_data)
Expand All @@ -82,6 +85,7 @@ test_that("bake() accepts sparse tibbles", {

test_that("recipe() accepts sparse matrices", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()

Expand Down Expand Up @@ -112,6 +116,7 @@ test_that("recipe() accepts sparse matrices", {

test_that("prep() accepts sparse matrices", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()

Expand All @@ -136,6 +141,7 @@ test_that("prep() accepts sparse matrices", {

test_that("bake() accepts sparse matrices", {
skip_if_not_installed("modeldata")
withr::local_options("sparsevctrs.verbose_materialize" = 3)

hotel_data <- sparse_hotel_rates()

Expand Down

0 comments on commit a56d6f3

Please sign in to comment.