1
1
test_that(" layer argument extractor works" , {
2
2
f <- frosting() %> %
3
3
layer_predict() %> %
4
- layer_residual_quantile (probs = c(0.0275 , 0.975 ), symmetrize = FALSE ) %> %
4
+ layer_residual_quantiles (probs = c(0.0275 , 0.975 ), symmetrize = FALSE ) %> %
5
5
layer_naomit(.pred )
6
6
7
7
expect_error(extract_argument(f $ layers [[1 ]], " uhoh" , " bubble" ))
8
8
expect_error(extract_argument(f $ layers [[1 ]], " layer_predict" , " bubble" ))
9
9
expect_identical(
10
- extract_argument(f $ layers [[2 ]], " layer_residual_quantile " , " probs" ),
10
+ extract_argument(f $ layers [[2 ]], " layer_residual_quantiles " , " probs" ),
11
11
c(0.0275 , 0.9750 ))
12
12
13
13
expect_error(extract_argument(f , " layer_thresh" , " probs" ))
14
14
expect_identical(
15
- extract_argument(f , " layer_residual_quantile " , " probs" ),
15
+ extract_argument(f , " layer_residual_quantiles " , " probs" ),
16
16
c(0.0275 , 0.9750 ))
17
17
18
18
wf <- epi_workflow(postprocessor = f )
19
- expect_error(extract_argument(epi_workflow(), " layer_residual_quantile " , " probs" ))
19
+ expect_error(extract_argument(epi_workflow(), " layer_residual_quantiles " , " probs" ))
20
20
expect_identical(
21
- extract_argument(wf , " layer_residual_quantile " , " probs" ),
21
+ extract_argument(wf , " layer_residual_quantiles " , " probs" ),
22
22
c(0.0275 , 0.9750 ))
23
23
24
24
expect_error(extract_argument(wf , " layer_predict" , c(" type" , " opts" )))
25
25
})
26
26
27
27
test_that(" recipe argument extractor works" , {
28
28
jhu <- case_death_rate_subset %> %
29
- filter(time_value > " 2021-08-01" ) %> %
29
+ dplyr :: filter(time_value > " 2021-08-01" ) %> %
30
30
dplyr :: arrange(geo_value , time_value )
31
31
32
32
r <- epi_recipe(jhu ) %> %
@@ -40,21 +40,19 @@ test_that("recipe argument extractor works", {
40
40
41
41
expect_error(extract_argument(r $ steps [[1 ]], " uhoh" , " bubble" ))
42
42
expect_error(extract_argument(r $ steps [[1 ]], " step_epi_lag" , " bubble" ))
43
- # CAREFUL!!
44
- expect_error(extract_argument(r $ steps [[2 ]], " step_epi_ahead" , " ahead" ))
45
- expect_identical(extract_argument(r $ steps [[2 ]], " step_epi_ahead" , " shift" ), - 7 )
43
+ expect_identical(extract_argument(r $ steps [[2 ]], " step_epi_ahead" , " ahead" ), 7 )
46
44
47
45
48
46
expect_error(extract_argument(r , " step_lightly" , " probs" ))
49
47
expect_identical(
50
- extract_argument(r , " step_epi_lag" , " shift " ),
48
+ extract_argument(r , " step_epi_lag" , " lag " ),
51
49
list (c(0 ,7 ,14 ), c(0 ,7 ,14 ))
52
50
)
53
51
54
52
wf <- epi_workflow(preprocessor = r )
55
- expect_error(extract_argument(epi_workflow(), " step_epi_lag" , " shift " ))
53
+ expect_error(extract_argument(epi_workflow(), " step_epi_lag" , " lag " ))
56
54
expect_identical(
57
- extract_argument(wf , " step_epi_lag" , " shift " ),
55
+ extract_argument(wf , " step_epi_lag" , " lag " ),
58
56
list (c(0 ,7 ,14 ), c(0 ,7 ,14 ))
59
57
)
60
58
})
0 commit comments