cmu-delphi / epipredict

Tools for building predictive models in epidemiology.
https://cmu-delphi.github.io/epipredict/
Other
8 stars 8 forks source link

fix: minimize `suppressWarnings` calls #323

Open dshemetov opened 2 months ago

dshemetov commented 2 months ago

From discussions in #319.

flatline_forecaster

When I remove suppressWarnings here, that makes the tests here fail. The warning is:

Detected an unexpected many-to-many relationship between `x` and `y`.
i Row 1 of `x` matches multiple rows in `y`.
i Row 1 of `y` matches multiple rows in `x`.
i If a many-to-many relationship is expected, set `relationship = "many-to-many"` to silence this warning.

cdc_baseline_forecaster

If you remove the suppressWarnings there, you get the following in the tests

Using an external vector in selections was deprecated in tidyselect 1.1.0.
i Please use `all_of()` or `any_of()` instead.
  # Was:
  data %>% select(col_names)

  # Now:
  data %>% select(all_of(col_names))

Backtrace:
     ▆
  1. ├─epipredict::cdc_baseline_forecaster(...) at test-snapshots.R:39:3
  2. │ ├─... %>% ... at epipredict/R/cdc_baseline_forecaster.R:105:3
  3. │ ├─stats::predict(wf, new_data = latest)
  4. │ └─epipredict:::predict.epi_workflow(wf, new_data = latest)
  5. │   ├─epipredict::apply_frosting(object, components, new_data, ...) at epipredict/R/epi_workflow.R:272:3
  6. │   └─epipredict:::apply_frosting.epi_workflow(...) at epipredict/R/frosting.R:337:3
  7. │     ├─epipredict::slather(la, components, workflow, new_data) at epipredict/R/frosting.R:403:7
  8. │     └─epipredict:::slather.layer_unnest(la, components, workflow, new_data) at epipredict/R/layers.R:206:3
  9. │       └─components$predictions %>% tidyr::unnest(col_names) at epipredict/R/layer_unnest.R:34:5
 10. ├─dplyr::mutate(., target_date = forecast_date + ahead * args_list$data_frequency)
 11. ├─dplyr::select(., -time_value)
 12. ├─tibble::as_tibble(.)
 13. ├─tidyr::unnest(., col_names)
 14. ├─epiprocess:::unnest.epi_df(., col_names)
 15. │ └─dplyr::dplyr_reconstruct(NextMethod(), data) at cmu-delphi-epiprocess-00c0a85/R/methods-epi_df.R:239:3
 16. │   └─dplyr:::dplyr_new_data_frame(data)
 17. │     ├─row.names %||% .row_names_info(x, type = 0L)
 18. │     └─base::.row_names_info(x, type = 0L)
 19. ├─base::NextMethod() at cmu-delphi-epiprocess-00c0a85/R/methods-epi_df.R:239:3
 20. └─tidyr:::unnest.data.frame(., col_names)
 21.   └─tidyselect::eval_select(expr = enquo(cols), data = data, allow_rename = FALSE)
 22.     └─tidyselect:::eval_select_impl(...)
 23.       ├─tidyselect:::with_subscript_errors(...)
 24.       │ └─base::withCallingHandlers(...)
 25.       └─tidyselect:::vars_select_eval(...)
 26.         └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 27.           └─tidyselect:::eval_sym(expr, data_mask, context_mask)

dist_quantiles

Removing this one gave no warnings or errors in tests, but I'm not sure what this was intended to suppress, so I'm not comfortable removing that.