@@ -14,9 +14,11 @@ test_that("Testing default behaviour of ccdr.run", {
1414 expect_is(final , " list" )
1515
1616 # ## Check output types
17- for (i in seq_along(final )){
18- expect_is(final [[i ]], " sparsebnFit" )
19- }
17+ check_sbf <- check_list_class(final , " sparsebnFit" )
18+ expect_true(check_sbf )
19+ # for(i in seq_along(final)){
20+ # expect_is(final[[i]], "sparsebnFit")
21+ # }
2022
2123 # ## Check consistency of nedge
2224 for (i in seq_along(final )){
@@ -33,9 +35,11 @@ test_that("Testing ccdr.run with manual settings", {
3335 expect_is(final , " list" )
3436
3537 # ## Check output types
36- for (i in seq_along(final )){
37- expect_is(final [[i ]], " sparsebnFit" )
38- }
38+ check_sbf <- check_list_class(final , " sparsebnFit" )
39+ expect_true(check_sbf )
40+ # for(i in seq_along(final)){
41+ # expect_is(final[[i]], "sparsebnFit")
42+ # }
3943
4044 # ## Check consistency of nedge
4145 for (i in seq_along(final )){
@@ -45,38 +49,12 @@ test_that("Testing ccdr.run with manual settings", {
4549 }
4650})
4751
48- # ## OLD TEST CODE
49- # source('~/Dropbox/PhD Research/Programming Projects/bncompare_dev/bncompare/R/bncompare-generate.R')
50- # # depends on
51- # source('~/Dropbox/PhD Research/Programming Projects/bncompare_dev/bncompare/R/s3-trueGraph.R')
52- # # depends on
53- # source('~/Dropbox/PhD Research/Programming Projects/bncompare_dev/bncompare/R/bncompare-utils.R')
54- # # depends on
55- # source('~/Dropbox/PhD Research/Programming Projects/bncompare_dev/bncompare/R/bncompare-functions.R')
56- #
57- # R_DEBUG_ON <<- FALSE # This is just a hack since we aren't using load_bncompare.R to load the package
58- #
59- # ### Generate some random data
60- # pp <- 10
61- # nn <- 100
62- # ss <- 2
63- #
64- # g <- generate_ordered_dag(pp, ss)
65- # d <- generate_data(g, nn)
66- # final <- ccdr.run(data = d$dat, lambdas.length = 20, alpha = 3, verbose = FALSE)
67- #
68- # test_that("Testing default behaviour of ccdr.gridR", {
69- # expect_is(final, "list")
70- #
71- # ### Check output types
72- # for(i in seq_along(final)){
73- # expect_is(final[[i]], "sparsebnFit")
74- # }
75- #
76- # ### Check consistency of nedge
77- # for(i in seq_along(final)){
78- # matrix.nedge <- sum(as.matrix(final[[i]]$sbm) != 0)
79- # sbm.nedge <- .num_edges(final[[i]]$sbm)
80- # expect_equal(final[[i]]$nedge, sbm.nedge, matrix.nedge)
81- # }
82- # })
52+ test_that(" Bugfix: ccdr.run returns the correct number of solutions" , {
53+ # ## Edge threshold not met, return all solutions
54+ final <- ccdr.run(data = data , lambdas.length = 5 )
55+ expect_equal(length(final ), 5 )
56+
57+ # ## Edge threshold met, only return subpath of complete solutions
58+ final <- ccdr.run(data = data , lambdas.length = 5 , alpha = 0.1 )
59+ expect_equal(length(final ), 1 )
60+ })
0 commit comments