Skip to content

Commit 6140db3

Browse files
committed
pass call through to_sparse_data_frame()
1 parent 91ba6d1 commit 6140db3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

R/sparsevctrs.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
to_sparse_data_frame <- function(x, object) {
1+
to_sparse_data_frame <- function(x, object, call = rlang::caller_env()) {
22
if (is_sparse_matrix(x)) {
33
if (allow_sparse(object)) {
44
x <- sparsevctrs::coerce_to_sparse_data_frame(x)
@@ -8,8 +8,10 @@ to_sparse_data_frame <- function(x, object) {
88
}
99

1010
cli::cli_abort(
11-
"{.arg x} is a sparse matrix, but {.fn {class(object)[1]}} with
12-
engine {.code {object$engine}} doesn't accept that.")
11+
"{.arg x} is a sparse matrix, but {.fn {class(object)[1]}} with
12+
engine {.code {object$engine}} doesn't accept that.",
13+
call = call
14+
)
1315
}
1416
} else if (is.data.frame(x)) {
1517
x <- materialize_sparse_tibble(x, object, "x")

tests/testthat/_snaps/sparsevctrs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Code
2020
lm_fit <- fit_xy(spec, x = hotel_data[1:100, -1], y = hotel_data[1:100, 1])
2121
Condition
22-
Error in `to_sparse_data_frame()`:
22+
Error in `fit_xy()`:
2323
! `x` is a sparse matrix, but `linear_reg()` with engine `lm` doesn't accept that.
2424

2525
# sparse matrices can not be passed to `fit()
@@ -44,7 +44,7 @@
4444
Code
4545
predict(lm_fit, sparse_mtcars)
4646
Condition
47-
Error in `to_sparse_data_frame()`:
47+
Error in `predict()`:
4848
! `x` is a sparse matrix, but `linear_reg()` with engine `lm` doesn't accept that.
4949

5050
# to_sparse_data_frame() is used correctly

0 commit comments

Comments
 (0)