Skip to content

Commit

Permalink
Test stochasticity
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Jun 28, 2024
1 parent 56ea94b commit e3f7d70
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/testthat/test-tree_distance_spr.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,22 @@ test_that("SPR deOliveira2008 calculation looks valid", {

errors <- biggerThyNeighbour < 0
# We may see a few "errors" due to chance, but expect these to be rare
rare <- 6
rare <- nSPR
expect_lt(sum(errors), rare)
if (interactive() && any(errors)) {
testDist[colSums(errors) > 0, ]
}

overShot <- as.matrix(testDist) > as.matrix(simDist)
overs <- colSums(overShot) > 0
overShot[overs, overs]
expect_lt(sum(overShot) / length(overShot), rare / 100)
# We may overshoot where there are "knots" in trees and the optimal SPR
# path is not equivalent to just pruning shared subtrees; these cases
# ought to be rare.
rare <- 0.10
expect_lt(sum(overShot) / length(overShot), rare)

if (interactive()) {
# View these cases:
overs <- colSums(overShot) > 0
overShot[overs, overs]
}
})

0 comments on commit e3f7d70

Please sign in to comment.