Skip to content

Commit 357aaf8

Browse files
Add some unit tests
1 parent 6b49954 commit 357aaf8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/testthat/test-bwlist.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
context("black/white lists")
2+
3+
dat <- generate_fixed_data_frame()
4+
sbdata <- suppressMessages(sparsebnData(dat, type = "c"))
5+
6+
### Get all blocks at once
7+
nodes <- names(sbdata$data)
8+
blocks <- lapply(nodes, function(x){
9+
# Allow all off-diagonal entries since we are no longer using the block decomposition
10+
row <- (nodes)[nodes != x]
11+
col <- rep(x, length(col))
12+
cbind(row, col)
13+
})
14+
blocks <- do.call("rbind", blocks)
15+
16+
pp <- ncol(dat)
17+
len_saturate <- pp*(pp-1)/2
18+
nlambda <- 20
19+
20+
test_that("White lists work OK", {
21+
dags <- ccdr.run(sbdata, lambdas.length = nlambda, whitelist = blocks)
22+
expect_equal(num.edges(dags), rep(len_saturate, nlambda))
23+
})
24+
25+
test_that("Black lists work OK", {
26+
dags <- ccdr.run(sbdata, lambdas.length = nlambda, blacklist = blocks)
27+
expect_equal(num.edges(dags), rep(0, nlambda))
28+
})

0 commit comments

Comments
 (0)