Skip to content

Commit

Permalink
use expect_length
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Dec 2, 2024
1 parent 1450571 commit 714b369
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions inst/tinytest/test_add_edge_length.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ tree_unrooted <- allCompat(trees_unrooted, rooted=FALSE)
tree_unrooted_el <- add_edge_length(tree_unrooted, trees_unrooted, rooted=FALSE)

expect_null(tree_ultra$edge.length)
expect_equal(length(tree_ultra_el$edge.length), nrow(tree_ultra_el$edge))
expect_length(tree_ultra_el$edge.length, nrow(tree_ultra_el$edge))
expect_true(is.ultrametric(tree_ultra_el))
expect_null(tree_unrooted$edge.length)
expect_equal(length(tree_unrooted_el$edge.length), nrow(tree_unrooted_el$edge))
expect_length(tree_unrooted_el$edge.length, nrow(tree_unrooted_el$edge))
expect_false(is.ultrametric(tree_unrooted_el))
4 changes: 2 additions & 2 deletions inst/tinytest/test_pmlCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fit <- optim.pml(fit, control=pml.control(trace=0))
sp <- pmlCluster( ~ edge + nni, fit, weight, p=1:3,
control=pml.control(epsilon=1e-08, maxit=10, trace=0))
# expect_equal( sp$Partition, c(1,1,1,2,2))
expect_equal( all(sp$Partition == c(1,1,1,2,2)) ||
all(sp$Partition == c(2,2,2,1,1)) , TRUE)
expect_true(all(sp$Partition == c(1,1,1,2,2)) ||
all(sp$Partition == c(2,2,2,1,1)))


8 changes: 4 additions & 4 deletions inst/tinytest/test_splits.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ expect_true(inherits(Mat, "Matrix"))
expect_equal(spl2tree , tree)
# test generics
c_spl <- c(tree2spl, tree2spl, tree2spl)
expect_equal(length(c_spl) , 3L*length(tree2spl))
expect_equal(length(unique(c_spl)) , length(tree2spl))
expect_equal(length(distinct.splits(c_spl)) , length(tree2spl))
expect_length(c_spl, 3L*length(tree2spl))
expect_length(unique(c_spl), length(tree2spl))
expect_length(distinct.splits(c_spl), length(tree2spl))
spl <- allCircularSplits(6)
spl <- ONEwise(spl)
write.nexus.splits(spl, "tmp.nex")
Expand Down Expand Up @@ -59,7 +59,7 @@ expect_true(inherits(cnet, "networx"))
net1$edge.length <- cnet$edge.length <- cnet$edge.labels <- NULL
attr(cnet, "order") <- NULL
expect_equal(cnet, net1)
expect_equal(nrow(cnet$edge), length(as.splits(cnet)))
expect_length(as.splits(cnet), nrow(cnet$edge))



Expand Down
4 changes: 2 additions & 2 deletions inst/tinytest/test_treeManipulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node_108 <- mrca.phylo(tree, node=desc_108)
expect_equal(mrca.phylo(tree, node=desc_108), 108L)
expect_equal(mrca(tree), mrca.phylo(tree))
kids_108 <- Descendants(tree, 108, "children")
expect_equal(length(Descendants(tree, 101L, "all")), 197L)
expect_length(Descendants(tree, 101L, "all"), 197L)
expect_equal(lengths(Descendants(tree2, 101L:199, "all")),
2 * lengths(prop.part(tree2)) - 2L)
expect_equal(Ancestors(tree, kids_108, "parent"),
Expand Down Expand Up @@ -63,6 +63,6 @@ bs <- bootstrap.phyDat(Laurasiatherian,
FUN = function(x)NJ(dist.hamming(x)), bs=50)
tree <- NJ(dist.hamming(Laurasiatherian))
treeBS <- plotBS(tree, bs, type="none")
expect_equal(length(treeBS$node.label), treeBS$Nnode)
expect_length(treeBS$node.label, treeBS$Nnode)
expect_true(all(treeBS$node.label >=0) )
expect_true(all(treeBS$node.label <= 100) )

0 comments on commit 714b369

Please sign in to comment.