Skip to content

Commit 95f3a58

Browse files
committed
one test set per method
1 parent 29e8e27 commit 95f3a58

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

test/MarkovChainMonteCarlo/runtests.jl

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ end
185185
mcmc_params =
186186
Dict(:mcmc_alg => RWMHSampling(), :obs_sample => obs_sample, :init_params => [3.0], :step => 0.5, :rng => rng)
187187

188+
188189
@testset "Constructor: standardize" begin
189190
em = test_gp_1(y, σ2_y, iopairs)
190191
test_obs = MarkovChainMonteCarlo.to_decorrelated(obs_sample, em)
@@ -281,40 +282,37 @@ end
281282

282283
end
283284

284-
@testset "Sine GP & ForwardDiff-based variants" begin
285285

286286

287-
mcmc_params =
288-
Dict(:obs_sample => obs_sample, :init_params => [3.0], :step => 0.1, :rng => rng, :target_acc => 0.6) # the target is usually higher in grad-based MCMC
289287

290-
em_1, em_1b = test_gp_and_agp_1(y, σ2_y, iopairs)
291-
# em_1 cannot be used here
292-
293-
mcmc_algs = [
294-
BarkerSampling(), # robust
295-
# MALASampling(), # very sensitive to :step in mcmc
296-
# infMALASampling(), # very sensitive to :step
297-
InfmMALASampling(), # more robust but incorrect posterior mean
298-
BarkerSampling(), # robust
299-
# HMCSampling(), # NaNs?
300-
# infHMCSampling(), # NaNs?
301-
InfmHMCSampling(), # NaNs?
302-
]
303-
304-
# GPJL doesnt support ForwardDiff
305-
@test_throws ErrorException new_step, posterior_mean, chain =
306-
mcmc_test_template(prior, σ2_y, em_1; mcmc_alg = mcmc_algs[1], mcmc_params...)
307-
308-
for alg in mcmc_algs
309-
@info "testing algorithm: $(alg)"
310-
new_step, posterior_mean, chain = mcmc_test_template(prior, σ2_y, em_1b; mcmc_alg = alg, mcmc_params...)
311-
esjd_tmp = esjd(chain)
312-
@info "ESJD = $esjd_tmp"
313-
@info posterior_mean
314-
@test isapprox(posterior_mean, π / 2; atol = 4e-1)
288+
mcmc_params = Dict(:obs_sample => obs_sample, :init_params => [3.0], :step => 0.01, :rng => rng, :target_acc => 0.6) # the target is usually higher in grad-based MCMC
315289

316-
end
290+
em_1, em_1b = test_gp_and_agp_1(y, σ2_y, iopairs)
291+
# em_1 cannot be used here
317292

293+
mcmc_algs = [
294+
BarkerSampling(), #
295+
MALASampling(), #
296+
InfMALASampling(), #
297+
InfmMALASampling(), #
298+
HMCSampling(), #
299+
InfHMCSampling(), #
300+
InfmHMCSampling(), #
301+
]
302+
303+
# GPJL doesnt support ForwardDiff
304+
@test_throws ErrorException new_step, posterior_mean, chain =
305+
mcmc_test_template(prior, σ2_y, em_1; mcmc_alg = mcmc_algs[1], mcmc_params...)
306+
307+
for alg in mcmc_algs
308+
@info "testing algorithm: $(nameof(typeof(alg)))"
309+
new_step, posterior_mean, chain = mcmc_test_template(prior, σ2_y, em_1b; mcmc_alg = alg, mcmc_params...)
310+
esjd_tmp = esjd(chain)
311+
@info "ESJD = $esjd_tmp"
312+
@info posterior_mean
313+
@testset "Sine GP & ForwardDiff variant:$(nameof(typeof(alg)))" begin
314+
@test isapprox(posterior_mean, π / 2; atol = 4e-1)
315+
end
318316

319317
end
320318

0 commit comments

Comments
 (0)