1- test_that(" sparse tibble can be passed to `fit()" , {
1+ test_that(" sparse tibble can be passed to `fit() - supported " , {
22 skip_if_not_installed(" xgboost" )
33 withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
44
@@ -12,19 +12,21 @@ test_that("sparse tibble can be passed to `fit()", {
1212 error = TRUE ,
1313 lm_fit <- fit(spec , avg_price_per_room ~ . , data = hotel_data )
1414 )
15+ })
16+
17+ test_that(" sparse tibble can be passed to `fit() - unsupported" , {
18+ hotel_data <- sparse_hotel_rates(tibble = TRUE )
1519
1620 spec <- linear_reg() %> %
1721 set_mode(" regression" ) %> %
1822 set_engine(" lm" )
1923
20- withr :: local_options(" sparsevctrs.verbose_materialize" = NULL )
21-
2224 expect_snapshot(
2325 lm_fit <- fit(spec , avg_price_per_room ~ . , data = hotel_data [1 : 100 , ])
2426 )
2527})
2628
27- test_that(" sparse matrix can be passed to `fit()" , {
29+ test_that(" sparse matrix can be passed to `fit() - supported " , {
2830 skip_if_not_installed(" xgboost" )
2931 withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
3032
@@ -39,7 +41,10 @@ test_that("sparse matrix can be passed to `fit()", {
3941 lm_fit <- fit(spec , avg_price_per_room ~ . , data = hotel_data )
4042 )
4143
42- withr :: local_options(" sparsevctrs.verbose_materialize" = NULL )
44+ })
45+
46+ test_that(" sparse matrix can be passed to `fit() - unsupported" , {
47+ hotel_data <- sparse_hotel_rates()
4348
4449 spec <- linear_reg() %> %
4550 set_mode(" regression" ) %> %
@@ -50,12 +55,11 @@ test_that("sparse matrix can be passed to `fit()", {
5055 )
5156})
5257
53- test_that(" sparse tibble can be passed to `fit_xy()" , {
58+ test_that(" sparse tibble can be passed to `fit_xy() - supported " , {
5459 skip_if_not_installed(" xgboost" )
60+ withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
5561
5662 hotel_data <- sparse_hotel_rates(tibble = TRUE )
57-
58- withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
5963
6064 spec <- boost_tree() %> %
6165 set_mode(" regression" ) %> %
@@ -64,8 +68,10 @@ test_that("sparse tibble can be passed to `fit_xy()", {
6468 expect_no_error(
6569 lm_fit <- fit_xy(spec , x = hotel_data [, - 1 ], y = hotel_data [, 1 ])
6670 )
71+ })
6772
68- withr :: local_options(" sparsevctrs.verbose_materialize" = NULL )
73+ test_that(" sparse tibble can be passed to `fit_xy() - unsupported" , {
74+ hotel_data <- sparse_hotel_rates(tibble = TRUE )
6975
7076 spec <- linear_reg() %> %
7177 set_mode(" regression" ) %> %
@@ -76,7 +82,7 @@ test_that("sparse tibble can be passed to `fit_xy()", {
7682 )
7783})
7884
79- test_that(" sparse matrices can be passed to `fit_xy()" , {
85+ test_that(" sparse matrices can be passed to `fit_xy() - supported " , {
8086 skip_if_not_installed(" xgboost" )
8187 withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
8288
@@ -89,6 +95,10 @@ test_that("sparse matrices can be passed to `fit_xy()", {
8995 expect_no_error(
9096 lm_fit <- fit_xy(spec , x = hotel_data [, - 1 ], y = hotel_data [, 1 ])
9197 )
98+ })
99+
100+ test_that(" sparse matrices can be passed to `fit_xy() - unsupported" , {
101+ hotel_data <- sparse_hotel_rates()
92102
93103 spec <- linear_reg() %> %
94104 set_mode(" regression" ) %> %
@@ -100,12 +110,11 @@ test_that("sparse matrices can be passed to `fit_xy()", {
100110 )
101111})
102112
103- test_that(" sparse tibble can be passed to `predict()" , {
113+ test_that(" sparse tibble can be passed to `predict() - supported " , {
104114 skip_if_not_installed(" ranger" )
115+ withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
105116
106117 hotel_data <- sparse_hotel_rates(tibble = TRUE )
107-
108- withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
109118
110119 spec <- rand_forest(trees = 10 ) %> %
111120 set_mode(" regression" ) %> %
@@ -116,8 +125,10 @@ test_that("sparse tibble can be passed to `predict()", {
116125 expect_no_error(
117126 predict(tree_fit , hotel_data )
118127 )
128+ })
119129
120- withr :: local_options(" sparsevctrs.verbose_materialize" = NULL )
130+ test_that(" sparse tibble can be passed to `predict() - unsupported" , {
131+ hotel_data <- sparse_hotel_rates(tibble = TRUE )
121132
122133 spec <- linear_reg() %> %
123134 set_mode(" regression" ) %> %
@@ -134,7 +145,7 @@ test_that("sparse tibble can be passed to `predict()", {
134145 )
135146})
136147
137- test_that(" sparse matrices can be passed to `predict()" , {
148+ test_that(" sparse matrices can be passed to `predict() - supported " , {
138149 skip_if_not_installed(" ranger" )
139150 withr :: local_options(" sparsevctrs.verbose_materialize" = 3 )
140151
@@ -149,6 +160,10 @@ test_that("sparse matrices can be passed to `predict()", {
149160 expect_no_error(
150161 predict(tree_fit , hotel_data )
151162 )
163+ })
164+
165+ test_that(" sparse matrices can be passed to `predict() - unsupported" , {
166+ hotel_data <- sparse_hotel_rates()
152167
153168 spec <- linear_reg() %> %
154169 set_mode(" regression" ) %> %
0 commit comments