Skip to content

Commit

Permalink
pest more things about .recipes_estimate_sparsity()
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Jan 15, 2025
1 parent fc7eda4 commit 9ac6fad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/testthat/test-sparsevctrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,22 @@ test_that(".recipes_toggle_sparse_args works", {
)

rec <- recipe(~., iris) %>%
step_normalize(all_numeric_predictors()) %>%
step_dummy(all_nominal_predictors())

exp <- rec %>% prep() %>% bake(NULL) %>% sparsevctrs::sparsity()

expect_equal(
.recipes_estimate_sparsity(rec),
exp
)

rec <- recipe(~., iris[0, ]) %>%
step_normalize(all_numeric_predictors()) %>%
step_dummy(all_nominal_predictors())

expect_equal(
.recipes_estimate_sparsity(rec),
rec %>% prep() %>% bake(NULL) %>% sparsevctrs::sparsity()
exp
)
})

0 comments on commit 9ac6fad

Please sign in to comment.