-
-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathtest-mcmc-combo.R
More file actions
50 lines (45 loc) · 2.29 KB
/
test-mcmc-combo.R
File metadata and controls
50 lines (45 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
source(test_path("data-for-mcmc-tests.R"))
test_that("mcmc_combo returns a gtable object", {
skip_if_not_installed("gridExtra")
expect_gtable(mcmc_combo(arr, regex_pars = "beta"))
expect_gtable(mcmc_combo(arr, regex_pars = "beta",
gg_theme = ggplot2::theme_dark()))
expect_gtable(mcmc_combo(drawsarr, regex_pars = "theta"))
expect_gtable(mcmc_combo(mat, regex_pars = "beta",
binwidth = 1/20, combo = c("dens", "hist"),
facet_args = list(nrow = 2)))
expect_gtable(mcmc_combo(dframe, regex_pars = "Intercept"))
expect_gtable(mcmc_combo(dframe_multiple_chains, regex_pars = "Intercept",
combo = c("trace_highlight", "dens_overlay")))
expect_gtable(mcmc_combo(arr1chain, regex_pars = "Intercept",
combo = c("trace", "hist")))
expect_gtable(mcmc_combo(arr1, pars = "(Intercept)"))
expect_gtable(mcmc_combo(drawsarr1))
expect_gtable(mcmc_combo(mat1))
expect_gtable(mcmc_combo(dframe1))
})
# functions that require multiple chains ----------------------------------
test_that("mcmc_combo throws error if 1 chain but multiple chains required", {
skip_if_not_installed("gridExtra")
expect_error(mcmc_combo(arr1chain, regex_pars = "beta",
combo = c("trace_highlight", "dens")),
"requires multiple chains")
expect_error(mcmc_combo(drawsarr1chain, regex_pars = "theta",
combo = c("trace_highlight", "dens")),
"requires multiple chains")
expect_error(mcmc_combo(mat, regex_pars = "beta",
combo = c("trace_highlight", "hist")),
"requires multiple chains")
expect_error(mcmc_combo(dframe, regex_pars = "beta",
combo = c("dens_overlay", "trace")),
"requires multiple chains")
})
# other errors ------------------------------------------------------------
test_that("mcmc_combo throws errors", {
skip_if_not_installed("gridExtra")
expect_error(mcmc_combo(arr, combo = c("trace_highlight")),
"'combo' should have at least two elements")
expect_error(mcmc_combo(arr, regex_pars = "beta",
combo = c("animal", "hist", "tornado")),
"The following functions were not found: mcmc_animal, mcmc_tornado")
})