Skip to content

Commit 01168ca

Browse files
authored
Merge pull request #484 from tidymodels/multi-predict-error
Fix error message for `multi_predict()`
2 parents b1cb0bd + 917fdf3 commit 01168ca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

R/aaa_multi_predict.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ multi_predict.default <- function(object, ...)
3131
rlang::abort(
3232
glue::glue(
3333
"No `multi_predict` method exists for objects with classes ",
34-
glue::glue_collapse(glue::glue("'{class()}'"), sep = ", ")
34+
glue::glue_collapse(glue::glue("'{class(object)}'"), sep = ", ")
3535
)
3636
)
3737

tests/testthat/test_misc.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@ test_that('parsnip objects', {
1414
lm_fit <- fit(lm_idea, mpg ~ ., data = mtcars)
1515
expect_false(has_multi_predict(lm_fit))
1616
expect_false(has_multi_predict(lm_fit$fit))
17+
expect_error(
18+
multi_predict(lm_fit, mtcars),
19+
"No `multi_predict` method exists"
20+
)
1721

1822
mars_fit <-
1923
mars(mode = "regression") %>%
2024
set_engine("earth") %>%
2125
fit(mpg ~ ., data = mtcars)
2226
expect_true(has_multi_predict(mars_fit))
2327
expect_false(has_multi_predict(mars_fit$fit))
28+
expect_error(
29+
multi_predict(mars_fit$fit, mtcars),
30+
"No `multi_predict` method exists"
31+
)
32+
2433
})
2534

2635
test_that('other objects', {

0 commit comments

Comments
 (0)