Skip to content

Commit

Permalink
Add test for adapter interface
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-graham committed Oct 24, 2024
1 parent 400b5e7 commit 05cbe20
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/testthat/test-adaptation.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,24 @@ for (dimension in c(1L, 2L, 5L)) {
}
)
}

test_that("sample_chain works with dummy adapter with required interface", {
dummy_adapter <- list(
initialize = function(proposal, initial_state) {},
update = function(proposal, sample_index, state_and_statistics) {},
finalize = function(proposal) {},
state = function() list()
)
target_distribution <- standard_normal_target_distribution()
proposal <- barker_proposal(target_distribution, scale = 1)
expect_no_error(
sample_chain(
target_distribution = target_distribution,
proposal = proposal,
initial_state = chain_state(0),
n_warm_up_iteration = 1,
n_main_iteration = 0,
adapters = list(dummy_adapter)
)
)
})

0 comments on commit 05cbe20

Please sign in to comment.