Skip to content

Commit 0b6b85f

Browse files
authored
Merge pull request #854 from tidymodels/test-poisson_reg
Tests for `poisson_reg()`
2 parents dcb00db + 6540ce2 commit 0b6b85f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# updating
2+
3+
Code
4+
poisson_reg(penalty = 1) %>% set_engine("glmnet", lambda.min.ratio = 0.001) %>%
5+
update(mixture = tune())
6+
Message
7+
! parsnip could not locate an implementation for `poisson_reg` model specifications using the `glmnet` engine.
8+
i The parsnip extension package poissonreg implements support for this specification.
9+
i Please install (if needed) and load to continue.
10+
Output
11+
Poisson Regression Model Specification (regression)
12+
13+
Main Arguments:
14+
penalty = 1
15+
mixture = tune()
16+
17+
Engine-Specific Arguments:
18+
lambda.min.ratio = 0.001
19+
20+
Computational engine: glmnet
21+
22+
23+
# bad input
24+
25+
Code
26+
poisson_reg(mode = "bogus")
27+
Condition
28+
Error in `poisson_reg()`:
29+
! 'bogus' is not a known mode for model `poisson_reg()`.
30+
31+
---
32+
33+
Code
34+
translate(poisson_reg(mode = "regression"), engine = NULL)
35+
Condition
36+
Error in `translate.default()`:
37+
! Please set an engine.
38+
39+
---
40+
41+
Code
42+
poisson_reg(formula = y ~ x)
43+
Condition
44+
Error in `poisson_reg()`:
45+
! unused argument (formula = y ~ x)
46+

tests/testthat/test-poisson_reg.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
test_that("updating", {
2+
expect_snapshot(
3+
poisson_reg(penalty = 1) %>%
4+
set_engine("glmnet", lambda.min.ratio = 0.001) %>%
5+
update(mixture = tune())
6+
)
7+
})
8+
9+
test_that("bad input", {
10+
expect_snapshot(error = TRUE, poisson_reg(mode = "bogus"))
11+
expect_snapshot(error = TRUE, translate(poisson_reg(mode = "regression"), engine = NULL))
12+
expect_snapshot(error = TRUE, poisson_reg(formula = y ~ x))
13+
})

0 commit comments

Comments
 (0)