Skip to content

Commit

Permalink
Issue 286: Allow family to be set to a string (#297)
Browse files Browse the repository at this point in the history
* Clean up merge conflict

* Fix bug with epdist_prior accepting family as string

* Correction to string test

* Lint package
  • Loading branch information
athowes authored Sep 12, 2024
1 parent 32511ba commit 5558929
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/prior.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' @export
epidist_prior <- function(data, family, formula, prior) {
epidist_validate(data)
family <- brms:::validate_family(family)
class(family) <- c(class(family), family$family)
default <- brms::default_prior(formula, data = data)
model <- epidist_model_prior(data, formula)
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test-int-latent_individual.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ test_that("epidist.epidist_latent_individual fit and the MCMC converges when set
expect_convergence(fit_constant)
})

test_that("epidist.epidist_latent_individual Stan code has no syntax errors and compiles with lognormal family as a string", { # nolint: line_length_linter.
# Note: this test is stochastic. See note at the top of this script
skip_on_cran()
set.seed(1)
stancode_string <- epidist(
data = prep_obs,
family = "lognormal",
seed = 1,
silent = 2,
output_dir = fs::dir_create(tempfile()),
fn = brms::make_stancode
)
mod_string <- cmdstanr::cmdstan_model(
stan_file = cmdstanr::write_stan_file(stancode_string), compile = FALSE
)
expect_true(mod_string$check_syntax())
expect_no_error(mod_string$compile())
})

test_that("epidist.epidist_latent_individual recovers the simulation settings for the delay distribution in the default case", { # nolint: line_length_linter.
# Note: this test is stochastic. See note at the top of this script
skip_on_cran()
Expand Down

0 comments on commit 5558929

Please sign in to comment.