/
test-SingularV.R
38 lines (27 loc) · 1.17 KB
/
test-SingularV.R
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
library(PCMBaseCpp)
if(PCMBaseCppIsADevRelease()) {
library(testthat)
library(PCMBase)
context("Test singular matrix V")
load("testobjects.RData")
phyltree <- tree.a
phyltree$part.regime <- NULL
phyltree$edge.regime <- NULL
modelBM <- PCM(model = "BM", k = 1)
mTraits <- matrix(0,ncol=PCMTreeNumTips(phyltree),nrow=1)
metaI <- PCMInfo(mTraits, phyltree, modelBM)
metaICpp <- PCMInfoCpp(mTraits, phyltree, modelBM)
test_that(
"Singular V matrix raises a warning (PCMBase.Errors.As.Warnings=TRUE):", {
options(PCMBase.Errors.As.Warnings = TRUE)
expect_warning(loglik_PCMBase <- PCMLik(mTraits, phyltree, modelBM, metaI = metaI))
expect_warning(loglik_PCMBaseCpp <- PCMLik(mTraits, phyltree, modelBM, metaI = metaICpp))
expect_true(is.na(loglik_PCMBase) && is.na(loglik_PCMBaseCpp))
})
test_that(
"Singular V matrix raises an error (PCMBase.Errors.As.Warnings=FALSE):", {
options(PCMBase.Errors.As.Warnings = FALSE)
expect_error(loglik_PCMBase <- PCMLik(mTraits, phyltree, modelBM, metaI = metaI))
expect_error(loglik_PCMBaseCpp <- PCMLik(mTraits, phyltree, modelBM, metaI = metaICpp))
})
}