Skip to content

Commit 8fd4334

Browse files
committed
make sure tests for adaptive explicitly call sampler = adaptive_hmc()
1 parent 15d4888 commit 8fd4334

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

tests/testthat/test-adaptive-hmc.R

+30-20
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,47 @@ test_that("bad mcmc proposals are rejected", {
1515
)
1616
expect_match(out, "100% bad")
1717

18-
expect_snapshot(error = TRUE,
19-
draws <- mcmc(m,
20-
chains = 1,
21-
n_samples = 2,
22-
warmup = 0,
23-
verbose = FALSE,
24-
initial_values = initials(z = 1e120)
25-
)
18+
expect_snapshot(
19+
error = TRUE,
20+
draws <- mcmc(
21+
m,
22+
chains = 1,
23+
n_samples = 2,
24+
warmup = 0,
25+
verbose = FALSE,
26+
sampler = adaptive_hmc(),
27+
initial_values = initials(z = 1e120)
28+
)
2629
)
2730

2831
# really bad proposals
2932
x <- rnorm(100000, 1e120, 1)
3033
z <- normal(-1e120, 1e-120)
3134
distribution(x) <- normal(z, 1e-120)
3235
m <- model(z, precision = "single")
33-
expect_snapshot(error = TRUE,
34-
mcmc(m, chains = 1, n_samples = 1, warmup = 0, verbose = FALSE)
36+
expect_snapshot(
37+
error = TRUE,
38+
mcmc(m,
39+
chains = 1,
40+
n_samples = 1,
41+
warmup = 0,
42+
sampler = adaptive_hmc(),
43+
verbose = FALSE)
3544
)
3645

3746
# proposals that are fine, but rejected anyway
3847
z <- normal(0, 1)
3948
m <- model(z, precision = "single")
40-
expect_ok(mcmc(m,
41-
adaptive_hmc(
42-
epsilon = 100,
43-
# Lmin = 1,
44-
# Lmax = 1
45-
),
46-
chains = 1,
47-
n_samples = 5,
48-
warmup = 0,
49-
verbose = FALSE
49+
expect_ok(mcmc(
50+
m,
51+
adaptive_hmc(
52+
epsilon = 100,
53+
# Lmin = 1,
54+
# Lmax = 1
55+
),
56+
chains = 1,
57+
n_samples = 5,
58+
warmup = 0,
59+
verbose = FALSE
5060
))
5161
})

0 commit comments

Comments
 (0)