[dfe06d]: / tests / testthat / test_find_imports.R

Download this file

49 lines (38 with data), 1.7 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
context("Test detection of imported cases")
## test various movements ##
test_that("Test detection of imported cases", {
## skip on CRAN
skip_on_cran()
## generate inputs
data(fake_outbreak)
data <- with(fake_outbreak,
outbreaker_data(dates = onset,
w_dens = w,
ctd = ctd,
dna = dna))
config <- create_config(data = data)
data <- add_convolutions(data = data, config = config)
temp <- create_param(data = data, config = config)
param_current <- temp$current
param_store <- temp$store
ll <- custom_likelihoods()
priors <- custom_priors()
moves <- custom_moves()
moves <- bind_moves(moves = moves,
config = config,
data = data,
likelihoods = ll,
priors = priors)
## detect imported cases
out <- outbreaker_find_imports(moves = moves, data = data,
param_current = param_current,
param_store = param_store,
config = config,
likelihoods = ll)
## tests ##
expect_identical(which(!out$config$move_alpha), which(!out$config$move_kappa))
expect_identical(out$param_store$alpha[[1]], out$param_current$alpha)
expect_identical(out$param_store$kappa[[1]], out$param_current$kappa)
expect_equal(which(is.na(out$param_current$alpha)), c(1,4,28))
expect_true(all(config$move_alpha==!is.na(param_current$alpha)))
})