Skip to content

Commit 6035560

Browse files
committed
is_sparse_tibble -> sparsevctrs::has_sparse_ele
1 parent bb361a2 commit 6035560

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

R/convert_data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949
}
5050

51-
if (is_sparse_tibble(data)) {
51+
if (sparsevctrs::has_sparse_elements(data)) {
5252
cli::cli_abort(
5353
"Sparse data cannot be used with formula interface. Please use
5454
{.fn fit_xy} instead."
@@ -417,7 +417,7 @@ maybe_sparse_matrix <- function(x) {
417417
return(x)
418418
}
419419

420-
if (is_sparse_tibble(x)) {
420+
if (sparsevctrs::has_sparse_elements(x)) {
421421
res <- sparsevctrs::coerce_to_sparse_matrix(x)
422422
} else {
423423
res <- as.matrix(x)

R/fit_helpers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ form_xy <- function(object, control, env,
131131
remove_intercept <- encoding_info %>% dplyr::pull(remove_intercept)
132132
allow_sparse_x <- encoding_info %>% dplyr::pull(allow_sparse_x)
133133

134-
if (allow_sparse_x && is_sparse_tibble(env$data)) {
134+
if (allow_sparse_x && sparsevctrs::has_sparse_elements(env$data)) {
135135
target <- "dgCMatrix"
136136
}
137137

R/predict.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ prepare_data <- function(object, new_data) {
470470
if (allow_sparse(object) && inherits(new_data, "dgCMatrix")) {
471471
return(new_data)
472472
}
473-
if (allow_sparse(object) && is_sparse_tibble(new_data)) {
473+
if (allow_sparse(object) && sparsevctrs::has_sparse_elements(new_data)) {
474474
new_data <- sparsevctrs::coerce_to_sparse_matrix(new_data)
475475
return(new_data)
476476
}

R/sparsevctrs.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ to_sparse_data_frame <- function(x, object, call = rlang::caller_env()) {
3737
x
3838
}
3939

40-
is_sparse_tibble <- function(x) {
40+
sparsevctrs::has_sparse_elements <- function(x) {
4141
any(vapply(x, sparsevctrs::is_sparse_vector, logical(1)))
4242
}
4343

@@ -46,7 +46,7 @@ is_sparse_matrix <- function(x) {
4646
}
4747

4848
materialize_sparse_tibble <- function(x, object, input) {
49-
if (is_sparse_tibble(x) && (!allow_sparse(object))) {
49+
if (sparsevctrs::has_sparse_elements(x) && (!allow_sparse(object))) {
5050
if (inherits(object, "model_fit")) {
5151
object <- object$spec
5252
}

tests/testthat/test-sparsevctrs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ test_that("maybe_sparse_matrix() is used correctly", {
282282

283283
local_mocked_bindings(
284284
maybe_sparse_matrix = function(x) {
285-
if (is_sparse_tibble(x)) {
285+
if (sparsevctrs::has_sparse_elements(x)) {
286286
stop("sparse vectors detected")
287287
} else {
288288
stop("no sparse vectors detected")

0 commit comments

Comments
 (0)