Skip to content

tests: snapshot rest of the errors #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,12 @@ importFrom(rlang,caller_arg)
importFrom(rlang,caller_env)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
importFrom(rlang,env_get_list)
importFrom(rlang,expr)
importFrom(rlang,global_env)
importFrom(rlang,inject)
importFrom(rlang,is_call)
importFrom(rlang,is_character)
importFrom(rlang,is_closure)
importFrom(rlang,is_environment)
importFrom(rlang,is_formula)
importFrom(rlang,is_function)
importFrom(rlang,is_list)
importFrom(rlang,is_logical)
importFrom(rlang,is_missing)
importFrom(rlang,is_null)
importFrom(rlang,is_string)
importFrom(rlang,is_symbol)
importFrom(rlang,is_true)
importFrom(rlang,is_vector)
importFrom(rlang,set_names)
importFrom(rlang,sym)
importFrom(stats,as.formula)
Expand Down
8 changes: 4 additions & 4 deletions R/epipredict-package.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## usethis namespace: start
#' @import epiprocess parsnip
#' @importFrom checkmate assert assert_character assert_int assert_scalar
#' @importFrom checkmate assert_logical assert_numeric assert_number
#' @importFrom checkmate assert_integer assert_integerish
#' @importFrom checkmate assert_date assert_function assert_class
#' @importFrom checkmate assert_class assert_numeric
#' @importFrom checkmate test_character test_date test_function
#' @importFrom checkmate test_integerish test_logical
#' @importFrom checkmate test_numeric test_scalar
#' @importFrom cli cli_abort cli_warn
#' @importFrom dplyr arrange across all_of any_of bind_cols bind_rows group_by
#' @importFrom dplyr summarize filter mutate select left_join rename ungroup
Expand Down
2 changes: 0 additions & 2 deletions man/autoplot-epipred.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

152 changes: 152 additions & 0 deletions tests/testthat/_snaps/arx_args_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# arx_args checks inputs

Code
arx_args_list(ahead = c(0, 4))
Condition
Error in `arx_args_list()`:
! `ahead` must be a scalar.

---

Code
arx_args_list(n_training = c(28, 65))
Condition
Error in `arx_args_list()`:
! `n_training` must be a scalar.

---

Code
arx_args_list(ahead = -1)
Condition
Error in `arx_args_list()`:
! `ahead` must be a non-negative integer.

---

Code
arx_args_list(ahead = 1.5)
Condition
Error in `arx_args_list()`:
! `ahead` must be a non-negative integer.

---

Code
arx_args_list(n_training = -1)
Condition
Error in `arx_args_list()`:
! `n_training` must be a strictly positive number.

---

Code
arx_args_list(n_training = 1.5)
Condition
Error in `arx_args_list()`:
! `n_training` must be a positive integer.

---

Code
arx_args_list(lags = c(-1, 0))
Condition
Error in `arx_args_list()`:
! `lags` must be non-negative integers.

---

Code
arx_args_list(lags = list(c(1:5, 6.5), 2:8))
Condition
Error in `arx_args_list()`:
! `lags` must be non-negative integers.

---

Code
arx_args_list(symmetrize = 4)
Condition
Error in `arx_args_list()`:
! `symmetrize` must be of type <logical>.

---

Code
arx_args_list(nonneg = 4)
Condition
Error in `arx_args_list()`:
! `nonneg` must be of type <logical>.

---

Code
arx_args_list(quantile_levels = -0.1)
Condition
Error in `arx_args_list()`:
! `quantile_levels` must lie in [0, 1].

---

Code
arx_args_list(quantile_levels = 1.1)
Condition
Error in `arx_args_list()`:
! `quantile_levels` must lie in [0, 1].

---

Code
arx_args_list(target_date = "2022-01-01")
Condition
Error in `arx_args_list()`:
! `target_date` must be a date.

---

Code
arx_args_list(n_training_min = "de")
Condition
Error in `arx_args_list()`:
! `...` must be empty.
x Problematic argument:
* n_training_min = "de"

---

Code
arx_args_list(epi_keys = 1)
Condition
Error in `arx_args_list()`:
! `...` must be empty.
x Problematic argument:
* epi_keys = 1

# arx forecaster disambiguates quantiles

Code
compare_quantile_args(alist, tlist)
Condition
Error in `compare_quantile_args()`:
! You have specified different, non-default, quantiles in the trainier and `arx_args` options.
i Please only specify quantiles in one location.

# arx_lags_validator handles named & unnamed lists as expected

Code
arx_lags_validator(pred_vec, lags_finit_fn_switch2)
Condition
Error in `arx_lags_validator()`:
! You have requested 2 predictor(s) but 3 different lags.
i Lags must be a vector or a list with length == number of predictors.

---

Code
arx_lags_validator(pred_vec, lags_init_other_name)
Condition
Error in `arx_lags_validator()`:
! If lags is a named list, then all predictors must be present.
i The predictors are `death_rate` and `case_rate`.
i So lags is missing `case_rate`'.

92 changes: 92 additions & 0 deletions tests/testthat/_snaps/arx_cargs_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# arx_class_args checks inputs

Code
arx_class_args_list(ahead = c(0, 4))
Condition
Error in `arx_class_args_list()`:
! `ahead` must be a scalar.

---

Code
arx_class_args_list(n_training = c(28, 65))
Condition
Error in `arx_class_args_list()`:
! `n_training` must be a scalar.

---

Code
arx_class_args_list(ahead = -1)
Condition
Error in `arx_class_args_list()`:
! `ahead` must be a non-negative integer.

---

Code
arx_class_args_list(ahead = 1.5)
Condition
Error in `arx_class_args_list()`:
! `ahead` must be a non-negative integer.

---

Code
arx_class_args_list(n_training = -1)
Condition
Error in `arx_class_args_list()`:
! `n_training` must be a strictly positive number.

---

Code
arx_class_args_list(n_training = 1.5)
Condition
Error in `arx_class_args_list()`:
! `n_training` must be a positive integer.

---

Code
arx_class_args_list(lags = c(-1, 0))
Condition
Error in `arx_class_args_list()`:
! `lags` must be non-negative integers.

---

Code
arx_class_args_list(lags = list(c(1:5, 6.5), 2:8))
Condition
Error in `arx_class_args_list()`:
! `lags` must be non-negative integers.

---

Code
arx_class_args_list(target_date = "2022-01-01")
Condition
Error in `arx_class_args_list()`:
! `target_date` must be a date.

---

Code
arx_class_args_list(n_training_min = "de")
Condition
Error in `arx_class_args_list()`:
! `...` must be empty.
x Problematic argument:
* n_training_min = "de"

---

Code
arx_class_args_list(epi_keys = 1)
Condition
Error in `arx_class_args_list()`:
! `...` must be empty.
x Problematic argument:
* epi_keys = 1

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/bake-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# bake method works in all cases

Code
bake(prep(r, edf), NULL, composition = "matrix")
Condition
Error in `hardhat::recompose()`:
! `data` must only contain numeric columns.
i These columns aren't numeric: "geo_value" and "time_value".

20 changes: 20 additions & 0 deletions tests/testthat/_snaps/check-training-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# training set validation works

Code
validate_meta_match(t1, template, "geo_type", "abort")
Condition
Error in `validate_meta_match()`:
! The `geo_type` of the training data appears to be different from that
used to construct the recipe. This may result in unexpected consequences.
i Training `geo_type` is 'county'.
i Originally, it was 'state'.

---

Code
epi_check_training_set(t4, rec)
Condition
Error in `epi_check_training_set()`:
! The recipe specifies keys which are not in the training data.
i The training set is missing columns for missing_col.

46 changes: 46 additions & 0 deletions tests/testthat/_snaps/check_enough_train_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# check_enough_train_data works on pooled data

Code
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n + 1,
drop_na = FALSE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
Condition
Error in `prep()`:
! The following columns don't have enough data to predict: x and y.

---

Code
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n - 1,
drop_na = TRUE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
Condition
Error in `prep()`:
! The following columns don't have enough data to predict: x and y.

# check_enough_train_data works on unpooled data

Code
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = n + 1, epi_keys = "geo_value",
drop_na = FALSE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
Condition
Error in `prep()`:
! The following columns don't have enough data to predict: x and y.

---

Code
epi_recipe(toy_epi_df) %>% check_enough_train_data(x, y, n = 2 * n - 3,
epi_keys = "geo_value", drop_na = TRUE) %>% prep(toy_epi_df) %>% bake(new_data = NULL)
Condition
Error in `prep()`:
! The following columns don't have enough data to predict: x and y.

# check_enough_train_data works with all_predictors() downstream of constructed terms

Code
epi_recipe(toy_epi_df) %>% step_epi_lag(x, lag = c(1, 2)) %>%
check_enough_train_data(all_predictors(), y, n = 2 * n - 5) %>% prep(
toy_epi_df) %>% bake(new_data = NULL)
Condition
Error in `prep()`:
! The following columns don't have enough data to predict: lag_1_x, lag_2_x, and y.

Loading
Loading