cmu-delphi / epipredict

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

feat: add snaphot tests of canned forecasters #307

Closed dshemetov closed 2 months ago

dshemetov commented 3 months ago

Checklist

Please:

Change explanations for reviewer

Adds snapshot tests. Could add more snapshots with different parameter settings, but I went with a few for now.

Magic GitHub syntax to mark associated Issue(s) as resolved when this is merged into the default branch

dshemetov commented 3 months ago

Ran into an issue where the CI and my local snapshots disagreed. Ran renv::update() locally, updated packages, and it seemed to fix it by updating the snapshots. A little concerning that our canned forecasts can change in the 3rd decimal place based on updated dependencies. But at least these snapshots will help us identify when such changes come from our work or from an upstream dependency.

dshemetov commented 2 months ago

So for each of our canned forecasters, I included the forecast outputs of a few (~default) forecaster (using included JHU data) as snapshots in the tests. Now these tests will compare the output of those forecasts on developer branches and will give us (at least some) confidence we have not altered these forecaster outputs with our code changes. And if the forecasts have changed, you can run testthat::snapshot_review() to get a nice diff interface, where you can decide whether to accept or reject the new snapshots.

dajmcdon commented 2 months ago

Cool! And it runs on R CMD Check?

dshemetov commented 2 months ago

Yup, it's part of the tests, so it runs with devtools::test() too.