Skip to content

Commit af3ff95

Browse files
committed
perform_sanity_checks -> sanitize_args_predictors_trainer
1 parent 4b34428 commit af3ff95

9 files changed

+23
-20
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export(make_shared_grids)
2828
export(make_target_ensemble_grid)
2929
export(make_target_param_grid)
3030
export(overprediction)
31-
export(perform_sanity_checks)
3231
export(read_external_predictions_data)
3332
export(rolling_mean)
3433
export(rolling_sd)
3534
export(run_evaluation_measure)
3635
export(run_workflow_and_format)
36+
export(sanitize_args_predictors_trainer)
3737
export(scaled_pop)
3838
export(sharpness)
3939
export(single_id)

R/data_validation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' include empty strings
1414
#' @param args_list the args list created by [`epipredict::arx_args_list`]
1515
#' @export
16-
perform_sanity_checks <- function(epi_data,
16+
sanitize_args_predictors_trainer <- function(epi_data,
1717
outcome,
1818
predictors,
1919
trainer,

R/forecaster_flatline.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ flatline_fc <- function(epi_data,
4040
args_list <- do.call(flatline_args_list, args_input)
4141
# if you want to ignore extra_sources, setting predictors is the way to do it
4242
predictors <- c(outcome, extra_sources)
43-
argsPredictorsTrainer <- perform_sanity_checks(epi_data, outcome, predictors, NULL, args_list)
44-
args_list <- argsPredictorsTrainer[[1]]
45-
predictors <- argsPredictorsTrainer[[2]]
43+
c(args_list, predictors) %<-% sanitize_args_predictors_trainer(epi_data, outcome, predictors, NULL, args_list)
4644
# end of the copypasta
4745
# finally, any other pre-processing (e.g. smoothing) that isn't performed by
4846
# epipredict

R/forecaster_scaled_pop.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#' @param quantile_levels The quantile levels to predict. Defaults to those required by
3636
#' covidhub.
3737
#' @seealso some utilities for making forecasters: [format_storage],
38-
#' [perform_sanity_checks]
38+
#' [sanitize_args_predictors_trainer]
3939
#' @importFrom epipredict epi_recipe step_population_scaling frosting arx_args_list layer_population_scaling
4040
#' @importFrom tibble tibble
4141
#' @importFrom recipes all_numeric
@@ -76,10 +76,7 @@ scaled_pop <- function(epi_data,
7676
# if you want to hardcode particular predictors in a particular forecaster
7777
predictors <- c(outcome, extra_sources)
7878
# TODO: Partial match quantile_level coming from here (on Dmitry's machine)
79-
argsPredictorsTrainer <- perform_sanity_checks(epi_data, outcome, predictors, trainer, args_list)
80-
args_list <- argsPredictorsTrainer[[1]]
81-
predictors <- argsPredictorsTrainer[[2]]
82-
trainer <- argsPredictorsTrainer[[3]]
79+
c(args_list, predictors, trainer) <- sanitize_args_predictors_trainer(epi_data, outcome, predictors, trainer, args_list)
8380
# end of the copypasta
8481
# finally, any other pre-processing (e.g. smoothing) that isn't performed by
8582
# epipredict

R/forecaster_smoothed_scaled.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#' @param ... any additional arguments as used by [arx_args_list]
4242
#' required by covidhub.
4343
#' @seealso some utilities for making forecasters: [format_storage],
44-
#' [perform_sanity_checks]
44+
#' [sanitize_args_predictors_trainer]
4545
#' @importFrom epipredict epi_recipe step_population_scaling frosting arx_args_list layer_population_scaling
4646
#' @importFrom tibble tibble
4747
#' @importFrom recipes all_numeric
@@ -110,7 +110,7 @@ smoothed_scaled <- function(epi_data,
110110
# and need to make sure we exclude the original variables as predictors
111111
predictors <- update_predictors(epi_data, c(smooth_cols, sd_cols), predictors)
112112
# TODO: Partial match quantile_level coming from here (on Dmitry's machine)
113-
c(args_list, predictors, trainer) %<-% perform_sanity_checks(epi_data, outcome, predictors, trainer, args_list)
113+
c(args_list, predictors, trainer) %<-% sanitize_args_predictors_trainer(epi_data, outcome, predictors, trainer, args_list)
114114
# preprocessing supported by epipredict
115115
preproc <- epi_recipe(epi_data)
116116
if (pop_scaling) {

man/perform_sanity_checks.Rd renamed to man/sanitize_args_predictors_trainer.Rd

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scaled_pop.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/smoothed_scaled.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-forecaster-utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
test_that("perform_sanity_checks", {
1+
test_that("sanitize_args_predictors_trainer", {
22
epi_data <- epipredict::case_death_rate_subset
33
# don't need to test validate_forecaster_inputs as that's inherited
44
# testing args_list inheritance
55
ex_args <- arx_args_list()
6-
expect_error(perform_sanity_checks(epi_data, "case_rate", c("case_rate"), 5, ex_args))
7-
argsPredictors <- perform_sanity_checks(
6+
expect_error(sanitize_args_predictors_trainer(epi_data, "case_rate", c("case_rate"), 5, ex_args))
7+
argsPredictors <- sanitize_args_predictors_trainer(
88
epi_data, "case_rate", c("case_rate", ""), parsnip::linear_reg(), ex_args
99
)
1010
args_list <- argsPredictors[[1]]

0 commit comments

Comments
 (0)