Skip to content

Commit

Permalink
fix transform_pmf_model_out (#57)
Browse files Browse the repository at this point in the history
* remove `model` parameter from scoringutils call

This change was introduced in
epiforecasts/scoringutils#915 and subsequently
broke our tests.

* hide warnings from tests

A whole bunch of new warnings started popping up because scoringutils
was trying to take the mean of character columns.

Wrapping everything in `suppressWarnings()` helps.

* okay linter
  • Loading branch information
zkamvar authored Oct 17, 2024
1 parent 372977e commit 196bd87
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Authors@R: c(
role = c("aut")),
person(given = "Zhian",
family = "Kamvar",
email = "[email protected] ",
email = "[email protected]",
comment = c(ORCID = "0000-0003-1458-7108"),
role = c("ctb")),
person(given = "Becky",
family = "Sweger",
Expand Down
1 change: 0 additions & 1 deletion R/transform_pmf_model_out.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ transform_pmf_model_out <- function(model_out_tbl, target_observations, output_t
forecast_unit = c("model", task_id_cols),
observed = "observation",
predicted = "value",
model = "model",
predicted_label = "output_type_id"
)

Expand Down
50 changes: 26 additions & 24 deletions tests/testthat/test-score_model_out.R
Original file line number Diff line number Diff line change
Expand Up @@ -393,32 +393,34 @@ test_that("score_model_out works with all kinds of interval levels are requested
regexp = "must be a number between 0 and 100"
)

expect_warning(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_55"
),
"To compute the interval coverage for an interval range of" #scoringutils warning
)
suppressWarnings({
expect_warning(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_55"
),
"To compute the interval coverage for an interval range of" #scoringutils warning
)

expect_error(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_100"
),
regexp = "must be a number between 0 and 100"
)
expect_error(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_100"
),
regexp = "must be a number between 0 and 100"
)

expect_warning(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_5.3"
),
"To compute the interval coverage for an interval range of" #scoringutils warning
)
expect_warning(
score_model_out(
model_out_tbl = forecast_outputs |> dplyr::filter(.data[["output_type"]] == "quantile"),
target_observations = forecast_target_observations,
metrics = "interval_coverage_5.3"
),
"To compute the interval coverage for an interval range of" #scoringutils warning
)
})
})


Expand Down

0 comments on commit 196bd87

Please sign in to comment.