From c84fa37bfbe70418a88981fd4a46a94cda98718d Mon Sep 17 00:00:00 2001 From: n-kall Date: Mon, 11 Dec 2023 12:30:54 +0200 Subject: [PATCH] add test for auto thinning draws --- tests/testthat/test-thin_draws.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/testthat/test-thin_draws.R b/tests/testthat/test-thin_draws.R index 7b16abeb..aec7c40c 100644 --- a/tests/testthat/test-thin_draws.R +++ b/tests/testthat/test-thin_draws.R @@ -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)) + +})