File tree 2 files changed +38
-5
lines changed
2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 36
36
# ' wf <- epi_workflow(r, linear_reg())
37
37
# '
38
38
# ' wf
39
- epi_workflow <- function (preprocessor = NULL , spec = NULL ,
40
- postprocessor = NULL ) {
39
+ epi_workflow <- function (preprocessor = NULL , spec = NULL , postprocessor = NULL ) {
41
40
out <- workflows :: workflow(spec = spec )
42
41
class(out ) <- c(" epi_workflow" , class(out ))
43
42
44
43
if (is_epi_recipe(preprocessor )) {
45
- return (add_epi_recipe(out , preprocessor ))
46
- }
47
- if (! is_null(preprocessor )) {
44
+ out <- add_epi_recipe(out , preprocessor )
45
+ }else if (! is_null(preprocessor )) {
48
46
out <- workflows ::: add_preprocessor(out , preprocessor )
49
47
}
50
48
if (! is_null(postprocessor )) {
Original file line number Diff line number Diff line change
1
+
2
+ test_that(" postprocesser was evaluated" , {
3
+ r <- epi_recipe(case_death_rate_subset )
4
+ s <- parsnip :: linear_reg()
5
+ f <- frosting()
6
+
7
+ ef <- epi_workflow(r , s , f )
8
+ ef2 <- epi_workflow(r , s ) %> % add_frosting(f )
9
+
10
+ expect_true(epipredict ::: has_postprocessor(ef ))
11
+ expect_true(epipredict ::: has_postprocessor(ef2 ))
12
+ })
13
+
14
+
15
+ test_that(" outcome of the two methods are the same" , {
16
+ jhu <- case_death_rate_subset
17
+
18
+ r <- epi_recipe(jhu ) %> %
19
+ step_epi_lag(death_rate , lag = c(0 , 7 )) %> %
20
+ step_epi_ahead(death_rate , ahead = 7 ) %> %
21
+ step_epi_lag(case_rate , lag = c(7 )) %> %
22
+ step_naomit(all_predictors()) %> %
23
+ step_naomit(all_outcomes())
24
+
25
+ s <- parsnip :: linear_reg()
26
+ f <- frosting() %> %
27
+ layer_predict() %> %
28
+ layer_naomit(.pred ) %> %
29
+ layer_residual_quantile()
30
+
31
+ ef <- epi_workflow(r , s , f )
32
+ ef2 <- epi_workflow(r , s ) %> % add_frosting(f )
33
+
34
+ expect_equal(ef ,ef2 )
35
+ })
You can’t perform that action at this time.
0 commit comments