Skip to content

Commit

Permalink
check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Nov 20, 2024
1 parent 4145681 commit 62a9e78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests/testthat/test-gen.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("epidist_gen_posterior_predict returns a function that outputs positiv

# Test gamma
prep_gamma <- brms::prepare_predictions(fit_gamma)
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
predict_fn_gamma <- epidist_gen_posterior_predict(family_gamma)
pred_i_gamma <- predict_fn_gamma(i = i, prep_gamma)
expect_identical(floor(pred_i_gamma), pred_i_gamma)
Expand All @@ -32,7 +32,7 @@ test_that("epidist_gen_posterior_predict returns a function that errors for i ou
# Test gamma
prep_gamma <- brms::prepare_predictions(fit_gamma)
i_out_of_bounds_gamma <- length(prep_gamma$data$Y) + 1
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
predict_fn_gamma <- epidist_gen_posterior_predict(family_gamma)
expect_error(predict_fn_gamma(i = i_out_of_bounds_gamma, prep_gamma))
})
Expand All @@ -50,7 +50,7 @@ test_that("epidist_gen_posterior_predict returns a function that can generate pr
expect_true(all(abs(pred - round(pred)) > .Machine$double.eps^0.5))

# Test gamma
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
predict_fn_gamma <- epidist_gen_posterior_predict(family_gamma)
draws_gamma <- data.frame(
relative_obs_time = 1000, pwindow = 0, swindow = 0
Expand Down Expand Up @@ -87,7 +87,7 @@ test_that("epidist_gen_posterior_predict returns a function that predicts delays
# Test gamma
prep_gamma <- brms::prepare_predictions(fit_gamma)
prep_gamma$ndraws <- 1000
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
predict_fn_gamma <- epidist_gen_posterior_predict(family_gamma)
q_gamma <- purrr::map_vec(seq_along(prep_gamma$data$Y), function(i) {
y <- predict_fn_gamma(i, prep_gamma)
Expand Down Expand Up @@ -117,7 +117,7 @@ test_that("epidist_gen_posterior_epred returns a function that creates arrays wi

# Test gamma
prep_gamma <- brms::prepare_predictions(fit_gamma)
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
epred_fn_gamma <- epidist_gen_posterior_epred(family_gamma)
epred_gamma <- epred_fn_gamma(prep_gamma)
expect_setequal(class(epred_gamma), c("matrix", "array"))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-latent_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test_that("epidist_gen_log_lik_latent returns a function that produces valid log

# Test gamma
prep_gamma <- brms::prepare_predictions(fit_gamma)
family_gamma <- epidist_family(data = prep_obs, family = gamma())
family_gamma <- epidist_family(data = prep_obs, family = Gamma())
log_lik_fn_gamma <- epidist_gen_log_lik_latent(family_gamma)
log_lik_gamma <- log_lik_fn_gamma(i = i, prep_gamma)
expect_length(log_lik_gamma, prep_gamma$ndraws)
Expand Down

0 comments on commit 62a9e78

Please sign in to comment.