Skip to content

Commit

Permalink
Test new trees in sq_trees
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Smith committed Mar 6, 2019
1 parent 14be9ae commit dc9e88a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/test-PartitionDistance.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ context("PartitionDistance.R")
data('sq_trees')

test_that("SplitStatus works", {
expect_equal(c(15, 8), dim(SplitStatus(sq_trees)))
expect_equal(c(15, 8), dim(SplitStatus(sq_trees, sq_trees$opposite_tree)))
expect_equal(c(length(sq_trees), 8), dim(SplitStatus(sq_trees)))
expect_equal(c(length(sq_trees), 8), dim(SplitStatus(sq_trees, sq_trees$opposite_tree)))
expect_equal(SplitStatus(sq_trees, sq_trees$ref_tree), SplitStatus(sq_trees))
})

Expand Down
21 changes: 11 additions & 10 deletions tests/testthat/test-TernaryPoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@ data('sq_trees')
test_that("Splits comparisons are correct", {


expect_equal(c(15, 3), dim(BipartitionPoints(sq_trees)))
expect_equal(c(length(sq_trees), 3), dim(BipartitionPoints(sq_trees)))
expect_identical(8, unique(rowSums(BipartitionPoints(sq_trees))))
expect_equal(c(15, 3), dim(BipartitionPoints(sq_trees, cf=sq_trees$collapse_some)))
expect_equal(c(length(sq_trees), 3), dim(BipartitionPoints(sq_trees, cf=sq_trees$collapse_some)))
expect_equal(c(0,0,8, 0,1,7, 0,3,5, 0,4,4, 0,1,7, 0,2,6, 0,3,5,
1,0,7, 5,0,3, 1,3,4, 3,3,2, 1,2,5, 5,0,3, 0,8,0, 0,8,0),
1,0,7, 5,0,3, 1,3,4, 3,3,2, 1,2,5, 5,0,3, 0,8,0,
0,4,4, rep(c(0,8,0), 3)),
as.integer(unlist(t(SplitPoints(sq_trees)))))

splitsVsOne <- SplitPoints(sq_trees, cf=sq_trees$collapse_one)
expect_equal(rownames(splitsVsOne), names(sq_trees))
# Numbers lazily copied from output, rather than calculated;
# independent verification could be valuable.
expect_equal(c(rep(0, 8),4,0,2,0,4,0,0), splitsVsOne$Unresolved)
expect_equal(c(0,1,3,4,1,2,3,0,0,3,3,2,0,7,7), splitsVsOne$Contradicted)
expect_equal(c(7,6,4,3,6,5,4,7,3,4,2,5,3,0,0), splitsVsOne$Consistent)
expect_equal(c(rep(0, 8),4,0,2,0,4,rep(0, 5)), splitsVsOne$Unresolved)
expect_equal(c(0,1,3,4,1,2,3,0,0,3,3,2,0,7,3,7,7,7), splitsVsOne$Contradicted)
expect_equal(c(7,6,4,3,6,5,4,7,3,4,2,5,3,0,4,0,0,0), splitsVsOne$Consistent)
expect_equal(as.integer(data.frame(Unresolved=0, Contradicted=0, Consistent=3)),
as.integer(SplitPoints(sq_trees$collapse_one, cf=sq_trees$collapse_some)))
}
)

test_that("Quartet comparisons are correct", {
expect_equal(c(15, 3), dim(QuartetPoints(sq_trees)))
expect_equal(c(length(sq_trees), 3), dim(QuartetPoints(sq_trees)))
expect_identical(330, unique(rowSums(QuartetPoints(sq_trees))))
# Numbers lazily copied from output, rather than calculated;
# independent verification could be valuable.
cfCollapseOne <- QuartetPoints(sq_trees, cf=sq_trees$collapse_one)
expect_equal(c(rep(0, 8), 115, 0, 57, 0, 197, 0, 0), cfCollapseOne$Unresolved)
expect_equal(c(0, 8, 52, 76, 24, 78, 92, 0, 0, 52, 52, 78, 0, 237, 219),
cfCollapseOne$Contradicted)
expect_equal(c(rep(0, 8), 115, 0, 57, 0, 197, rep(0, 5)), cfCollapseOne$Unresolved)
expect_equal(c(0, 8, 52, 76, 24, 78, 92, 0, 0, 52, 52, 78, 0, 237,
84, 206, 240, 219), cfCollapseOne$Contradicted)
})

test_that("Line ends are correct", {
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-ZZZ-Metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ test_that("Quartets are counted correctly", {
quartet_matches <- QuartetStatus(sq_trees)

expected_identical <- c(330L, 322L, 278L, 254L, 306L, 252L, 238L,
322L, 207L, 270L, 213L, 244L, 125L, 86L, 104L)
expected_ambiguous <- c(rep(0L, 7), 8L, 123L, 8L, 65L, 8L, 205L, 0L, 0L)
322L, 207L, 270L, 213L, 244L, 125L, 86L,
244L, 122L, 85L, # Values for these three new trees copied without checking
104L)
expected_ambiguous <- c(rep(0L, 7), 8L, 123L, 8L, 65L, 8L, 205L, rep(0L, 5L))
names(expected_identical) <- names(expected_ambiguous) <- names(sq_trees)

expect_identical(expected_identical, quartet_matches[, 's'])
Expand Down

0 comments on commit dc9e88a

Please sign in to comment.