File tree Expand file tree Collapse file tree 2 files changed +19
-24
lines changed Expand file tree Collapse file tree 2 files changed +19
-24
lines changed Original file line number Diff line number Diff line change @@ -174,18 +174,8 @@ fit.model_spec <-
174
174
eval_env $ formula <- formula
175
175
eval_env $ weights <- wts
176
176
177
- if ((! allow_sparse(object )) && is_sparse_tibble(data )) {
178
- cli :: cli_warn(
179
- " {.arg data} is a sparse tibble, but {.fn {class(object)[1]}} with
180
- engine {.code {object$engine}} doesn't accept that. Converting to
181
- non-sparse."
182
- )
183
- for (i in seq_along(ncol(data ))) {
184
- # materialize with []
185
- data [[i ]] <- data [[i ]][]
186
- }
187
- }
188
-
177
+ data <- materialize_sparse_tibble(data , object , " data" )
178
+
189
179
fit_interface <-
190
180
check_interface(eval_env $ formula , eval_env $ data , cl , object )
191
181
Original file line number Diff line number Diff line change @@ -8,21 +8,26 @@ to_sparse_data_frame <- function(x, object) {
8
8
engine {.code {object$engine}} doesn't accept that." )
9
9
}
10
10
} else if (is.data.frame(x )) {
11
- if ((! allow_sparse(object )) && is_sparse_tibble(x )) {
12
- cli :: cli_warn(
13
- " {.arg x} is a sparse tibble, but {.fn {class(object)[1]}} with
14
- engine {.code {object$engine}} doesn't accept that. Converting to
15
- non-sparse."
16
- )
17
- for (i in seq_along(ncol(x ))) {
18
- # materialize with []
19
- x [[i ]] <- x [[i ]][]
20
- }
21
- }
11
+ x <- materialize_sparse_tibble(x , object , " x" )
22
12
}
23
13
x
24
14
}
25
15
26
16
is_sparse_tibble <- function (x ) {
27
17
any(vapply(x , sparsevctrs :: is_sparse_vector , logical (1 )))
28
- }
18
+ }
19
+
20
+ materialize_sparse_tibble <- function (x , object , input ) {
21
+ if ((! allow_sparse(object )) && is_sparse_tibble(x )) {
22
+ cli :: cli_warn(
23
+ " {.arg {input}} is a sparse tibble, but {.fn {class(object)[1]}} with
24
+ engine {.code {object$engine}} doesn't accept that. Converting to
25
+ non-sparse."
26
+ )
27
+ for (i in seq_along(ncol(x ))) {
28
+ # materialize with []
29
+ x [[i ]] <- x [[i ]][]
30
+ }
31
+ }
32
+ x
33
+ }
You can’t perform that action at this time.
0 commit comments