Skip to content

Commit 4ffe7a1

Browse files
committed
test translate() for PH models
1 parent de88664 commit 4ffe7a1

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/testthat/_snaps/translate.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,24 @@
15271527
min_rows(5, data, 5)
15281528
15291529

1530+
# arguments (proportional_hazards)
1531+
1532+
Code
1533+
basic %>% translate_args()
1534+
Output
1535+
list()
1536+
1537+
---
1538+
1539+
Code
1540+
basic_incomplete %>% translate_args()
1541+
Condition
1542+
Error in `.check_glmnet_penalty_fit()`:
1543+
! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
1544+
* There are 0 values for `penalty`.
1545+
* To try multiple values for total regularization, use the tune package.
1546+
* To predict multiple penalties, use `multi_predict()`
1547+
15301548
# arguments (rand_forest)
15311549

15321550
Code

tests/testthat/test_translate.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ test_that("arguments (nearest_neighbor)", {
199199
expect_snapshot(translate_args(dist_power %>% set_engine("kknn")))
200200
})
201201

202+
203+
# translate.proportional_hazards ------------------------------------------
204+
test_that("arguments (proportional_hazards)", {
205+
suppressMessages({
206+
basic <- proportional_hazards(penalty = 0.1) %>% set_engine("glmnet")
207+
basic_incomplete <- proportional_hazards() %>% set_engine("glmnet")
208+
})
209+
210+
# this is empty because the engines are not defined in parsnip
211+
expect_snapshot(basic %>% translate_args())
212+
# but we can check for the error if there is no penalty for glmnet
213+
expect_snapshot(error = TRUE,
214+
basic_incomplete %>% translate_args()
215+
)
216+
})
217+
202218
# translate.rand_forest --------------------------------------------------------
203219
test_that("arguments (rand_forest)", {
204220
basic <- rand_forest(mode = "regression")

0 commit comments

Comments
 (0)