Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: monty
Title: Monte Carlo Models
Version: 0.4.8
Version: 0.4.9
Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"),
email = "[email protected]"),
person("Wes", "Hinsley", role = "aut"),
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-model-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ test_that("can directly sample from a model", {
m$direct_sample(r2))
expect_equal(monty_model_direct_sample(m, r1, named = TRUE),
c(gamma = m$direct_sample(r2)))

m <- monty_example("banana")
r1 <- monty_rng_create(n_streams = 3, seed = 42)
r2 <- monty_rng_create(n_streams = 3, seed = 42)

expect_equal(monty_model_direct_sample(m, r1),
m$direct_sample(r2))
expect_equal(monty_model_direct_sample(m, r1, named = TRUE),
m$direct_sample(r2))
})


Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-packer.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ test_that("can't used process with array unpacking", {
})


test_that("can't used fixed with array unpacking", {
p <- monty_packer(c("x", "y"), fixed = list(z = 3))
expect_equal(p$unpack(1:2), list(x = 1, y = 2, z = 3))
expect_error(
p$unpack(matrix(1:6, 2)),
"Can't unpack a matrix where the unpacker uses 'fixed'")
})


test_that("Properly unpack scalars stored as zero-length arrays", {
p <- monty_packer(array = list(a = integer(0), b = 1L))
expect_equal(p$unpack(1:2), list(a = 1, b = 2))
Expand Down
Loading