hubverse-org / hubVis

Plotting methods for hub model outputs
https://hubverse-org.github.io/hubVis/
Other
3 stars 0 forks source link

Add a warning if output type id not numeric #20

Closed LucieContamin closed 8 months ago

LucieContamin commented 8 months ago

Add a warning and automatically transform the output_type_id column to numeric if necessary.

Fix issue #18

hub_path <- system.file("example-data/example-simple-forecast-hub",
                        package = "hubEnsembles")
model_outputs <- hubUtils::connect_hub(hub_path) |>
  dplyr::collect()
target_data_path <- file.path(hub_path, "target-data", "covid-hospitalizations.csv")
target_data <- read.csv(target_data_path) |>
  dplyr::mutate(time_idx = as.Date(time_idx))

hubVis::plot_step_ahead_model_output(model_output_data = model_outputs |>
                                       dplyr::filter(location == "US",
                                                     output_type %in% c("quantile"),
                                                     origin_date == "2022-12-12") |>
                                       dplyr::mutate(target_date =  origin_date + horizon),
                                     truth_data = target_data |>
                                       dplyr::filter(location == "US",
                                                     time_idx >= "2022-11-01",
                                                     time_idx <= "2023-03-01"),
                                     facet = "model_id", 
                                     facet_nrow = 1, 
                                     interactive = FALSE,
                                     intervals = 0.5,
                                     one_color = "black",
                                     pal_color = NULL, 
                                     show_legend = FALSE, 
                                     use_median_as_point = TRUE)
#> Warning: ! `model_output_data` must be a `model_out_tbl`. Class applied by
#> default
#> Warning: ! `output_type_id` column must be a numeric. . Class applied by
#> default.

The plot should appear as expected after the warnings (instead of an error stopping the plot)

Created on 2024-01-17 with reprex v2.0.2

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (55a8228) 99.05% compared to head (33ae1e9) 99.06%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #20 +/- ## ========================================== + Coverage 99.05% 99.06% +0.01% ========================================== Files 2 2 Lines 425 430 +5 ========================================== + Hits 421 426 +5 Misses 4 4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.