Skip to content

Commit 1f74625

Browse files
tests
1 parent 167e428 commit 1f74625

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## https://github.com/canmod/macpan2/issues/350
2+
test_that("trajectories and coefficient tables can be collapsed", {
3+
op = options(
4+
macpan2_collapse_traj = TRUE
5+
, macpan2_collapse_coef = TRUE
6+
, macpan2_collapse_default = TRUE
7+
)
8+
9+
spec = test_cache_read("SPEC-sir.rds")
10+
sim = mp_simulator(spec, 50, c("infection", "recovery"))
11+
data = mp_trajectory(sim)
12+
expect_identical(names(data), c("variable", "time", "value"))
13+
cal = mp_tmb_calibrator(
14+
spec
15+
, data
16+
, traj = "infection"
17+
, par = c("beta", "gamma")
18+
, default = list(beta = 0.25, gamma = 0.25)
19+
)
20+
mp_optimize(cal)
21+
coef = mp_tmb_coef(cal, conf.int = TRUE)
22+
expect_identical(
23+
names(coef)
24+
, c("mat", "default", "estimate", "std.error", "conf.low", "conf.high")
25+
)
26+
spec_default = mp_default(spec)
27+
sim_default = mp_default(sim)
28+
expect_identical(spec_default, sim_default)
29+
expect_identical(
30+
names(spec_default)
31+
, c("quantity", "value")
32+
)
33+
34+
options(op)
35+
})

0 commit comments

Comments
 (0)