Skip to content

Commit 65cd9b4

Browse files
committed
smoothed_scaled data tests
1 parent e2353b7 commit 65cd9b4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/testthat/test-forecasters-data.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ forecasters <- tibble::tribble(
66
~forecaster, ~extra_params, ~extra_params_names, ~fc_name,
77
scaled_pop, list(1, TRUE), list("ahead", "pop_scaling"), "scaled_pop",
88
scaled_pop, list(1, FALSE), list("ahead", "pop_scaling"), "scaled_pop",
9-
flatline_fc, list(1), list("ahead"), "flatline_fc"
9+
flatline_fc, list(1), list("ahead"), "flatline_fc",
10+
smoothed_scaled, list(1), list("ahead"), "smoothed_scaled"
1011
)
12+
expects_nonequal <- c("scaled_pop", "smoothed_scaled")
1113
synth_mean <- 25
1214
synth_sd <- 2
1315
tiny_sd <- 1.0e-5
@@ -49,7 +51,7 @@ different_constants <- epiprocess::as_epi_archive(rbind(
4951
))
5052
for (ii in 1:nrow(forecasters)) {
5153
test_that(paste(forecasters$fc_name[[ii]], " predicts a constant median for constant data"), {
52-
if (forecasters$fc_name[[ii]] == "scaled_pop") {
54+
if (any(forecasters$fc_name[[ii]] %in% expects_nonequal)) {
5355
suppressWarnings(expect_warning(res <- get_pred(different_constants, ii), regexp = "prediction from rank-deficient fit"))
5456
} else {
5557
res <- get_pred(different_constants, ii)
@@ -126,7 +128,7 @@ missing_state <- epiprocess::as_epi_archive(rbind(
126128
))
127129
for (ii in seq_len(nrow(forecasters))) {
128130
test_that(paste(forecasters$fc_name[[ii]], "predicts well in the presence of only one state with variably delayed data"), {
129-
if (forecasters$fc_name[[ii]] == "scaled_pop") {
131+
if (any(forecasters$fc_name[[ii]] %in% expects_nonequal)) {
130132
suppressWarnings(expect_warning(res <- get_pred(missing_state, ii), regexp = "prediction from rank-deficient fit"))
131133
} else {
132134
res <- get_pred(missing_state, ii)
@@ -171,7 +173,7 @@ for (ii in seq_len(nrow(forecasters))) {
171173
test_that(paste(forecasters$fc_name[[ii]], "predicts a linear increasing slope correctly"), {
172174
# flatline will definitely fail this, so it's exempt
173175
if (!identical(forecasters$forecaster[[ii]], flatline_fc)) {
174-
if (forecasters$fc_name[[ii]] == "scaled_pop") {
176+
if (any(forecasters$fc_name[[ii]] %in% expects_nonequal)) {
175177
suppressWarnings(expect_warning(res <- get_pred(linear, ii), regexp = "prediction from rank-deficient fit"))
176178
} else {
177179
res <- get_pred(linear, ii)

0 commit comments

Comments
 (0)