From 9ac6fadbb72e9c0fb02461eb8464bddfc1ba36ad Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Wed, 15 Jan 2025 08:31:37 -0800 Subject: [PATCH] pest more things about .recipes_estimate_sparsity() --- tests/testthat/test-sparsevctrs.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-sparsevctrs.R b/tests/testthat/test-sparsevctrs.R index 77f2189e0..67e5124cc 100644 --- a/tests/testthat/test-sparsevctrs.R +++ b/tests/testthat/test-sparsevctrs.R @@ -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 ) }) \ No newline at end of file