Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/RoguePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ RoguePlot <- function(trees, tip, p = 1, plot = TRUE,
if (isTRUE(sort)) {
cons <- DropTip(cons, dummyRoot, preorder = FALSE, check = FALSE)
} else {
stopifnot(attr(cons, "order") == "preorder")
stopifnot(identical(attr(cons, "order"), "preorder"))
# We promise to return `cons` in preorder
cons <- DropTip(cons, dummyRoot, preorder = TRUE, check = FALSE)
}
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-RoguePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ test_that("RoguePlot(sort = TRUE)", {
expect_equal(sorted$atNode, unsorted$atNode)
})

test_that("RoguePlot() errors cleanly if cons loses its preorder attribute", {
skip_if_not_installed("testthat", "3.1.7") # for local_mocked_bindings()
trees <- list(read.tree(text = "(a, (b, (c, (rogue, (d, e)))));"),
read.tree(text = "(a, (b, (c, ((d, e), rogue))));"))
local_mocked_bindings(
Preorder = function(tree, ...) {
attr(tree, "order") <- NULL
tree
},
.package = "TreeTools"
)
expect_error(RoguePlot(trees, tip = "rogue", plot = FALSE),
"preorder")
})

test_that("polytomy id", {
trees <- list(read.tree(text = "(a,(((b,(c,d)),e),rogue));"),
read.tree(text = "(a,((((c,d),e),rogue),b));"),
Expand Down
Loading