Skip to content

Commit 4bb4019

Browse files
committed
tests pass
1 parent 49271da commit 4bb4019

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

DESCRIPTION

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: epipredict
22
Title: Basic epidemiology forecasting methods
3-
Version: 0.1.8
3+
Version: 0.1.9
44
Authors@R: c(
55
person("Daniel J.", "McDonald", , "[email protected]", role = c("aut", "cre")),
66
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
@@ -25,7 +25,7 @@ URL: https://github.com/cmu-delphi/epipredict/,
2525
BugReports: https://github.com/cmu-delphi/epipredict/issues/
2626
Depends:
2727
epidatasets,
28-
epiprocess (>= 0.9.0),
28+
epiprocess (>= 0.10.4),
2929
parsnip (>= 1.0.0),
3030
R (>= 3.5.0)
3131
Imports:
@@ -73,7 +73,6 @@ Remotes:
7373
cmu-delphi/epidatasets,
7474
cmu-delphi/epidatr,
7575
cmu-delphi/epiprocess,
76-
cmu-delphi/epidatasets,
7776
dajmcdon/smoothqr
7877
Config/Needs/website: cmu-delphi/delphidocs
7978
Config/testthat/edition: 3

R/arx_classifier.R

+12-23
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ arx_classifier <- function(
5858
if (args_list$adjust_latency == "none") {
5959
forecast_date_default <- max(epi_data$time_value)
6060
if (!is.null(args_list$forecast_date) && args_list$forecast_date != forecast_date_default) {
61-
cli_warn("The specified forecast date {args_list$forecast_date} doesn't match the date from which the forecast is occurring {forecast_date}.")
61+
cli_warn(
62+
"The specified forecast date {args_list$forecast_date} doesn't match the
63+
date from which the forecast is occurring {forecast_date}."
64+
)
6265
}
6366
} else {
6467
forecast_date_default <- attributes(epi_data)$metadata$as_of
@@ -101,7 +104,7 @@ arx_classifier <- function(
101104
#'
102105
#' @return An unfit `epi_workflow`.
103106
#' @export
104-
#' @seealso [arx_classifier()]
107+
#' @seealso [arx_classifier()] [arx_class_args_list()]
105108
#' @examples
106109
#' library(dplyr)
107110
#' jhu <- covid_case_death_rates %>%
@@ -154,12 +157,13 @@ arx_class_epi_workflow <- function(
154157
role = "grp",
155158
horizon = args_list$horizon,
156159
method = args_list$method,
157-
log_scale = args_list$log_scale,
158-
additional_gr_args_list = args_list$additional_gr_args
160+
log_scale = args_list$log_scale
159161
)
160162
for (l in seq_along(lags)) {
161163
pred_names <- predictors[l]
162-
pred_names <- as.character(glue::glue_data(args_list, "gr_{horizon}_{method}_{pred_names}"))
164+
pred_names <- as.character(glue::glue_data(
165+
args_list, "gr_{horizon}_{method}_{pred_names}"
166+
))
163167
r <- step_epi_lag(r, !!pred_names, lag = lags[[l]])
164168
}
165169
# ------- outcome
@@ -185,8 +189,7 @@ arx_class_epi_workflow <- function(
185189
role = "pre-outcome",
186190
horizon = args_list$horizon,
187191
method = args_list$method,
188-
log_scale = args_list$log_scale,
189-
additional_gr_args_list = args_list$additional_gr_args
192+
log_scale = args_list$log_scale
190193
)
191194
}
192195
}
@@ -270,9 +273,6 @@ arx_class_epi_workflow <- function(
270273
#' @param method Character. Options available for growth rate calculation.
271274
#' @param log_scale Scalar logical. Whether to compute growth rates on the
272275
#' log scale.
273-
#' @param additional_gr_args List. Optional arguments controlling growth rate
274-
#' calculation. See [epiprocess::growth_rate()] and the related Vignette for
275-
#' more details.
276276
#' @param check_enough_data_n Integer. A lower limit for the number of rows per
277277
#' epi_key that are required for training. If `NULL`, this check is ignored.
278278
#' @param check_enough_data_epi_keys Character vector. A character vector of
@@ -301,7 +301,6 @@ arx_class_args_list <- function(
301301
horizon = 7L,
302302
method = c("rel_change", "linear_reg"),
303303
log_scale = FALSE,
304-
additional_gr_args = list(),
305304
check_enough_data_n = NULL,
306305
check_enough_data_epi_keys = NULL,
307306
...) {
@@ -320,23 +319,14 @@ arx_class_args_list <- function(
320319
arg_is_lgl(log_scale)
321320
arg_is_pos(n_training)
322321
if (is.finite(n_training)) arg_is_pos_int(n_training)
323-
if (!is.list(additional_gr_args)) {
324-
cli_abort(c(
325-
"`additional_gr_args` must be a {.cls list}.",
326-
"!" = "This is a {.cls {class(additional_gr_args)}}.",
327-
i = "See `?epiprocess::growth_rate` for available arguments."
328-
))
329-
}
330322
arg_is_pos(check_enough_data_n, allow_null = TRUE)
331323
arg_is_chr(check_enough_data_epi_keys, allow_null = TRUE)
332324

333325
if (!is.null(forecast_date) && !is.null(target_date)) {
334326
if (forecast_date + ahead != target_date) {
335327
cli_warn(
336-
paste0(
337-
"`forecast_date` {.val {forecast_date}} +",
338-
" `ahead` {.val {ahead}} must equal `target_date` {.val {target_date}}."
339-
),
328+
"`forecast_date` {.val {forecast_date}} +
329+
`ahead` {.val {ahead}} must equal `target_date` {.val {target_date}}.",
340330
class = "epipredict__arx_args__inconsistent_target_ahead_forecaste_date"
341331
)
342332
}
@@ -362,7 +352,6 @@ arx_class_args_list <- function(
362352
horizon,
363353
method,
364354
log_scale,
365-
additional_gr_args,
366355
check_enough_data_n,
367356
check_enough_data_epi_keys
368357
),

tests/testthat/test-snapshots.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ test_that("arx_forecaster output format snapshots", {
148148
test_that("arx_classifier snapshots", {
149149
train <- covid_case_death_rates %>%
150150
filter(geo_value %nin% c("as", "gu", "mp", "vi"))
151-
arc1 <- arx_classifier(
151+
expect_warning(arc1 <- arx_classifier(
152152
train %>%
153153
dplyr::filter(time_value >= as.Date("2021-11-01")),
154154
"death_rate",
155155
c("case_rate", "death_rate")
156-
)
156+
), "fitted probabilities numerically")
157157
expect_snapshot_tibble(arc1$predictions)
158158
max_date <- train$time_value %>% max()
159159
arc2 <- arx_classifier(

0 commit comments

Comments
 (0)