-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Note: some tests in this script are stochastic. As such, test failure may be | ||
# bad luck rather than indicate an issue with the code. However, as these tests | ||
# are reproducible, the distribution of test failures may be investigated by | ||
# varying the input seed. Test failure at an unusually high rate does suggest | ||
# a potential code issue. | ||
|
||
test_that("epidist.epidist_marginal_model Stan code has no syntax errors in the default case", { # nolint: line_length_linter. | ||
skip_on_cran() | ||
stancode <- epidist( | ||
data = prep_marginal_obs, | ||
fn = brms::make_stancode | ||
) | ||
mod <- cmdstanr::cmdstan_model( | ||
stan_file = cmdstanr::write_stan_file(stancode), compile = FALSE | ||
) | ||
expect_true(mod$check_syntax()) | ||
}) | ||
|
||
test_that("epidist.epidist_marginal_model fits and the MCMC converges in the default case", { # nolint: line_length_linter. | ||
# Note: this test is stochastic. See note at the top of this script | ||
skip_on_cran() | ||
set.seed(1) | ||
fit <- epidist( | ||
data = prep_marginal_obs, | ||
seed = 1, | ||
silent = 2, refresh = 0, | ||
cores = 2, | ||
chains = 2, | ||
backend = "cmdstanr" | ||
) | ||
expect_s3_class(fit, "brmsfit") | ||
expect_s3_class(fit, "epidist_fit") | ||
expect_convergence(fit) | ||
}) |