Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed May 14, 2024
1 parent 864fb56 commit 1e3bc94
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/testthat/test-likelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ test_that("likelihood() works with epichains and epichains_summary objects", {
),
-23.538997
)
# Use default stat_max = NULL
expect_equal(
likelihood(
chains = chains_summary_eg,
statistic = "size",
offspring_dist = rpois,
lambda = 0.9
),
-23.538997
)
# Use default stat_max = NULL
expect_equal(
likelihood(
chains = chains_tree_eg,
statistic = "size",
offspring_dist = rpois,
lambda = 0.9
),
-23.538997
)
})

test_that("Likelihoods are numerically correct", {
Expand Down Expand Up @@ -251,4 +271,24 @@ test_that("Errors are thrown", {
),
"Must be of type"
)
expect_error(
likelihood(
chains = chains, # Inf in data is not allowed
statistic = "size",
offspring_dist = rpois,
lambda = 0.5,
stat_max = NULL
),
"must be an integer"
)
expect_error(
likelihood(
chains = c(1:2, Inf), # Inf in data is not allowed
statistic = "size",
offspring_dist = rpois,
lambda = 0.5,
stat_max = Inf
),
"must only contain finite values"
)
})

0 comments on commit 1e3bc94

Please sign in to comment.