Skip to content

Commit 36c4c0a

Browse files
authored
Merge pull request #393 from cmu-delphi/ds/snapshots
tests: snapshot rest of the errors
2 parents 0bb8a35 + f588f0a commit 36c4c0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1098
-120
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# arx_args checks inputs
2+
3+
Code
4+
arx_args_list(ahead = c(0, 4))
5+
Condition
6+
Error in `arx_args_list()`:
7+
! `ahead` must be a scalar.
8+
9+
---
10+
11+
Code
12+
arx_args_list(n_training = c(28, 65))
13+
Condition
14+
Error in `arx_args_list()`:
15+
! `n_training` must be a scalar.
16+
17+
---
18+
19+
Code
20+
arx_args_list(ahead = -1)
21+
Condition
22+
Error in `arx_args_list()`:
23+
! `ahead` must be a non-negative integer.
24+
25+
---
26+
27+
Code
28+
arx_args_list(ahead = 1.5)
29+
Condition
30+
Error in `arx_args_list()`:
31+
! `ahead` must be a non-negative integer.
32+
33+
---
34+
35+
Code
36+
arx_args_list(n_training = -1)
37+
Condition
38+
Error in `arx_args_list()`:
39+
! `n_training` must be a strictly positive number.
40+
41+
---
42+
43+
Code
44+
arx_args_list(n_training = 1.5)
45+
Condition
46+
Error in `arx_args_list()`:
47+
! `n_training` must be a positive integer.
48+
49+
---
50+
51+
Code
52+
arx_args_list(lags = c(-1, 0))
53+
Condition
54+
Error in `arx_args_list()`:
55+
! `lags` must be non-negative integers.
56+
57+
---
58+
59+
Code
60+
arx_args_list(lags = list(c(1:5, 6.5), 2:8))
61+
Condition
62+
Error in `arx_args_list()`:
63+
! `lags` must be non-negative integers.
64+
65+
---
66+
67+
Code
68+
arx_args_list(symmetrize = 4)
69+
Condition
70+
Error in `arx_args_list()`:
71+
! `symmetrize` must be of type <logical>.
72+
73+
---
74+
75+
Code
76+
arx_args_list(nonneg = 4)
77+
Condition
78+
Error in `arx_args_list()`:
79+
! `nonneg` must be of type <logical>.
80+
81+
---
82+
83+
Code
84+
arx_args_list(quantile_levels = -0.1)
85+
Condition
86+
Error in `arx_args_list()`:
87+
! `quantile_levels` must lie in [0, 1].
88+
89+
---
90+
91+
Code
92+
arx_args_list(quantile_levels = 1.1)
93+
Condition
94+
Error in `arx_args_list()`:
95+
! `quantile_levels` must lie in [0, 1].
96+
97+
---
98+
99+
Code
100+
arx_args_list(target_date = "2022-01-01")
101+
Condition
102+
Error in `arx_args_list()`:
103+
! `target_date` must be a date.
104+
105+
---
106+
107+
Code
108+
arx_args_list(n_training_min = "de")
109+
Condition
110+
Error in `arx_args_list()`:
111+
! `...` must be empty.
112+
x Problematic argument:
113+
* n_training_min = "de"
114+
115+
---
116+
117+
Code
118+
arx_args_list(epi_keys = 1)
119+
Condition
120+
Error in `arx_args_list()`:
121+
! `...` must be empty.
122+
x Problematic argument:
123+
* epi_keys = 1
124+
125+
# arx forecaster disambiguates quantiles
126+
127+
Code
128+
compare_quantile_args(alist, tlist)
129+
Condition
130+
Error in `compare_quantile_args()`:
131+
! You have specified different, non-default, quantiles in the trainier and `arx_args` options.
132+
i Please only specify quantiles in one location.
133+
134+
# arx_lags_validator handles named & unnamed lists as expected
135+
136+
Code
137+
arx_lags_validator(pred_vec, lags_finit_fn_switch2)
138+
Condition
139+
Error in `arx_lags_validator()`:
140+
! You have requested 2 predictor(s) but 3 different lags.
141+
i Lags must be a vector or a list with length == number of predictors.
142+
143+
---
144+
145+
Code
146+
arx_lags_validator(pred_vec, lags_init_other_name)
147+
Condition
148+
Error in `arx_lags_validator()`:
149+
! If lags is a named list, then all predictors must be present.
150+
i The predictors are `death_rate` and `case_rate`.
151+
i So lags is missing `case_rate`'.
152+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# arx_class_args checks inputs
2+
3+
Code
4+
arx_class_args_list(ahead = c(0, 4))
5+
Condition
6+
Error in `arx_class_args_list()`:
7+
! `ahead` must be a scalar.
8+
9+
---
10+
11+
Code
12+
arx_class_args_list(n_training = c(28, 65))
13+
Condition
14+
Error in `arx_class_args_list()`:
15+
! `n_training` must be a scalar.
16+
17+
---
18+
19+
Code
20+
arx_class_args_list(ahead = -1)
21+
Condition
22+
Error in `arx_class_args_list()`:
23+
! `ahead` must be a non-negative integer.
24+
25+
---
26+
27+
Code
28+
arx_class_args_list(ahead = 1.5)
29+
Condition
30+
Error in `arx_class_args_list()`:
31+
! `ahead` must be a non-negative integer.
32+
33+
---
34+
35+
Code
36+
arx_class_args_list(n_training = -1)
37+
Condition
38+
Error in `arx_class_args_list()`:
39+
! `n_training` must be a strictly positive number.
40+
41+
---
42+
43+
Code
44+
arx_class_args_list(n_training = 1.5)
45+
Condition
46+
Error in `arx_class_args_list()`:
47+
! `n_training` must be a positive integer.
48+
49+
---
50+
51+
Code
52+
arx_class_args_list(lags = c(-1, 0))
53+
Condition
54+
Error in `arx_class_args_list()`:
55+
! `lags` must be non-negative integers.
56+
57+
---
58+
59+
Code
60+
arx_class_args_list(lags = list(c(1:5, 6.5), 2:8))
61+
Condition
62+
Error in `arx_class_args_list()`:
63+
! `lags` must be non-negative integers.
64+
65+
---
66+
67+
Code
68+
arx_class_args_list(target_date = "2022-01-01")
69+
Condition
70+
Error in `arx_class_args_list()`:
71+
! `target_date` must be a date.
72+
73+
---
74+
75+
Code
76+
arx_class_args_list(n_training_min = "de")
77+
Condition
78+
Error in `arx_class_args_list()`:
79+
! `...` must be empty.
80+
x Problematic argument:
81+
* n_training_min = "de"
82+
83+
---
84+
85+
Code
86+
arx_class_args_list(epi_keys = 1)
87+
Condition
88+
Error in `arx_class_args_list()`:
89+
! `...` must be empty.
90+
x Problematic argument:
91+
* epi_keys = 1
92+

tests/testthat/_snaps/bake-method.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# bake method works in all cases
2+
3+
Code
4+
bake(prep(r, edf), NULL, composition = "matrix")
5+
Condition
6+
Error in `hardhat::recompose()`:
7+
! `data` must only contain numeric columns.
8+
i These columns aren't numeric: "geo_value" and "time_value".
9+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# training set validation works
2+
3+
Code
4+
validate_meta_match(t1, template, "geo_type", "abort")
5+
Condition
6+
Error in `validate_meta_match()`:
7+
! The `geo_type` of the training data appears to be different from that
8+
used to construct the recipe. This may result in unexpected consequences.
9+
i Training `geo_type` is 'county'.
10+
i Originally, it was 'state'.
11+
12+
---
13+
14+
Code
15+
epi_check_training_set(t4, rec)
16+
Condition
17+
Error in `epi_check_training_set()`:
18+
! The recipe specifies keys which are not in the training data.
19+
i The training set is missing columns for missing_col.
20+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# check_enough_train_data works on pooled data
2+
3+
Code
4+
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n + 1,
5+
drop_na = FALSE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
6+
Condition
7+
Error in `prep()`:
8+
! The following columns don't have enough data to predict: x and y.
9+
10+
---
11+
12+
Code
13+
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n - 1,
14+
drop_na = TRUE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
15+
Condition
16+
Error in `prep()`:
17+
! The following columns don't have enough data to predict: x and y.
18+
19+
# check_enough_train_data works on unpooled data
20+
21+
Code
22+
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = n + 1, epi_keys = "geo_value",
23+
drop_na = FALSE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
24+
Condition
25+
Error in `prep()`:
26+
! The following columns don't have enough data to predict: x and y.
27+
28+
---
29+
30+
Code
31+
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n - 3,
32+
epi_keys = "geo_value", drop_na = TRUE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
33+
Condition
34+
Error in `prep()`:
35+
! The following columns don't have enough data to predict: x and y.
36+
37+
# check_enough_train_data works with all_predictors() downstream of constructed terms
38+
39+
Code
40+
epi_recipe(toy_epi_df) %>% step_epi_lag(x, lag = c(1, 2)) %>%
41+
check_enough_train_data(all_predictors(), y, n = 2 * n - 5) %>% prep(
42+
toy_epi_df) %>% bake(new_data = NULL)
43+
Condition
44+
Error in `prep()`:
45+
! The following columns don't have enough data to predict: lag_1_x, lag_2_x, and y.
46+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# constructor returns reasonable quantiles
2+
3+
Code
4+
new_quantiles(rnorm(5), rnorm(5))
5+
Condition
6+
Error in `new_quantiles()`:
7+
! `quantile_levels` must lie in [0, 1].
8+
9+
---
10+
11+
Code
12+
new_quantiles(sort(rnorm(5)), sort(runif(2)))
13+
Condition
14+
Error in `new_quantiles()`:
15+
! length(values) == length(quantile_levels) is not TRUE
16+
17+
---
18+
19+
Code
20+
new_quantiles(c(2, 1, 3, 4, 5), c(0.1, 0.1, 0.2, 0.5, 0.8))
21+
Condition
22+
Error in `new_quantiles()`:
23+
! !vctrs::vec_duplicate_any(quantile_levels) is not TRUE
24+
25+
---
26+
27+
Code
28+
new_quantiles(c(2, 1, 3, 4, 5), c(0.1, 0.15, 0.2, 0.5, 0.8))
29+
Condition
30+
Error in `new_quantiles()`:
31+
! `values[order(quantile_levels)]` produces unsorted quantiles.
32+
33+
---
34+
35+
Code
36+
new_quantiles(c(1, 2, 3), c(0.1, 0.2, 3))
37+
Condition
38+
Error in `new_quantiles()`:
39+
! `quantile_levels` must lie in [0, 1].
40+
41+
# arithmetic works on quantiles
42+
43+
Code
44+
sum(dstn)
45+
Condition
46+
Error in `mapply()`:
47+
! You can't perform arithmetic between two distributions like this.
48+
49+
---
50+
51+
Code
52+
suppressWarnings(dstn + distributional::dist_normal())
53+
Condition
54+
Error:
55+
! non-numeric argument to binary operator
56+

0 commit comments

Comments
 (0)