CDCgov / ww-inference-model

An in-development R package and a Bayesian hierarchical model jointly fitting multiple "local" wastewater data streams and "global" case count data to produce nowcasts and forecasts of both observations
https://cdcgov.github.io/ww-inference-model/
Apache License 2.0
17 stars 2 forks source link

Fix `test_get_stan_data` so random failure doesn't occur #142

Closed kaitejohnson closed 2 months ago

kaitejohnson commented 2 months ago

Problem

Every so often this test fails despite setting the seed for reproducibility. I believe is because we are using rnorm() to generate concentration values and then checking for outliers, and then checking for the number of rows in the final dataset. Have seen it a few times in CI. My inclination is that the test is hard coded and should be made more robust.

dylanhmorris commented 2 months ago

It doesn't look to me as though the seed is actually set? A variable named seed is defined but it will do nothing to affect the rnorm calls below it

https://github.com/CDCgov/ww-inference-model/blob/03c903010169dc4d96852ec618651591bb7ec9e5/tests/testthat/test_get_stan_data.R#L1-L15

kaitejohnson commented 2 months ago

Oh wow yep I thought that was set.seed this now makes sense