Skip to content

Commit ce557ad

Browse files
committed
add tests showing failure of inv_metric for 1 parameter
1 parent 3d95a90 commit ce557ad

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/testthat/test-model-sample-metric.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,42 @@ test_that("sample() method works with provided inv_metrics", {
5454
})
5555

5656

57+
test_that("sample() method works with inv_metrics extracted from previous fit", {
58+
expect_sample_output(fit_r <- mod$sample(data = data_list,
59+
chains = 2,
60+
seed = 123))
61+
inv_metric_vector <- fit_r$inv_metric(matrix = FALSE)
62+
inv_metric_matrix <- fit_r$inv_metric()
63+
64+
expect_equal(dim(inv_metric_vector[[1]]), 1)
65+
expect_equal(dim(inv_metric_matrix[[1]]), c(1, 1))
66+
67+
expect_silent(expect_sample_output(fit_r <- mod$sample(data = data_list,
68+
chains = 1,
69+
metric = "diag_e",
70+
inv_metric = inv_metric_vector[[1]],
71+
seed = 123)))
72+
73+
expect_silent(expect_sample_output(fit_r <- mod$sample(data = data_list,
74+
chains = 1,
75+
metric = "dense_e",
76+
inv_metric = inv_metric_matrix[[1]],
77+
seed = 123)))
78+
79+
expect_silent(expect_sample_output(fit_r <- mod$sample(data = data_list,
80+
chains = 2,
81+
metric = "diag_e",
82+
inv_metric = inv_metric_vector,
83+
seed = 123)))
84+
85+
expect_silent(expect_sample_output(fit_r <- mod$sample(data = data_list,
86+
chains = 2,
87+
metric = "dense_e",
88+
inv_metric = inv_metric_matrix,
89+
seed = 123)))
90+
})
91+
92+
5793
test_that("sample() method works with lists of inv_metrics", {
5894
inv_metric_vector <- array(1, dim = c(1))
5995
inv_metric_vector_json <- test_path("resources", "metric", "bernoulli.inv_metric.diag_e.json")

0 commit comments

Comments
 (0)