Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 127: Check Stan code is valid syntax #158

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/testthat/test-int-latent_individual.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
prep_obs <- as_latent_individual(sim_obs)
prep_obs_gamma <- as_latent_individual(sim_obs_gamma)

test_that("epidist.epidist_latent_individual Stan code compiles in the default case", { # nolint: line_length_linter.
test_that("epidist.epidist_latent_individual Stan code has no syntax errors and compiles in the default case", { # nolint: line_length_linter.
skip_on_cran()
stancode <- epidist(data = prep_obs, fn = brms::make_stancode)
mod <- cmdstan_model(stan_file = write_stan_file(stancode), compile = FALSE)
expect_true(mod$check_syntax())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the comments here an issue : https://github.com/epinowcast/epinowcast/blob/d957b21af07c7708d8ae28fc248fffe39d453828/.github/workflows/check-cmdstan.yaml#L67

The concern would be that brms has pedantic problems at some point and this then breaks out testing.

expect_no_error(mod$compile())
})

Expand Down Expand Up @@ -50,7 +51,7 @@ test_that("epidist.epidist_latent_individual recovers the simulation settings fo
expect_equal(mean(lognormal_draws$sdlog), sdlog, tolerance = 0.1)
})

test_that("epidist.epidist_latent_individual Stan code compiles in the gamma delay case", { # nolint: line_length_linter.
test_that("epidist.epidist_latent_individual Stan code has no syntax errors and compiles in the gamma delay case", { # nolint: line_length_linter.
skip_on_cran()
stancode_gamma <- epidist(
data = prep_obs_gamma,
Expand All @@ -60,10 +61,11 @@ test_that("epidist.epidist_latent_individual Stan code compiles in the gamma del
mod_gamma <- cmdstan_model(
stan_file = write_stan_file(stancode_gamma), compile = FALSE
)
expect_true(mod_gamma$check_syntax())
expect_no_error(mod_gamma$compile())
})

test_that("epidist.epidist_latent_individual Stan code compiles for an alternative formula", { # nolint: line_length_linter.
test_that("epidist.epidist_latent_individual Stan code has no syntax errors and compiles for an alternative formula", { # nolint: line_length_linter.
skip_on_cran()
prep_obs$sex <- rbinom(n = nrow(prep_obs), size = 1, prob = 0.5)
formula_sex <- epidist_formula(prep_obs, delay_central = ~ 1 + sex,
Expand All @@ -73,6 +75,7 @@ test_that("epidist.epidist_latent_individual Stan code compiles for an alternati
mod_sex <- cmdstan_model(
stan_file = write_stan_file(stancode_sex), compile = FALSE
)
expect_true(mod_sex$check_syntax())
expect_no_error(mod_sex$compile())
})

Expand Down
Loading