Skip to content

Commit

Permalink
add test for auto thinning draws
Browse files Browse the repository at this point in the history
  • Loading branch information
n-kall committed Dec 11, 2023
1 parent 3530c99 commit c84fa37
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testthat/test-thin_draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ test_that("thin_draws works on rvars", {

expect_equal(thin_draws(as_draws_rvars(x)$theta, 10L), as_draws_rvars(thin_draws(x, 10L))$theta)
})

test_that("automatic thinning works as expected", {
x <- as_draws_array(example_draws())
mu_1 <- subset_draws(x, variable = "mu", chain = 1)

ess_tail_mu_1 <- ess_tail(mu_1)
ess_bulk_mu_1 <- ess_bulk(mu_1)

thin_by <- round(ndraws(mu_1) / min(ess_tail_mu_1, ess_bulk_mu_1))
expect_equal(thin_draws(mu_1), thin_draws(mu_1, thin = thin_by))

})

0 comments on commit c84fa37

Please sign in to comment.