Skip to content

Commit

Permalink
DS-3563: Protect Sum against NULL in print method (#6)
Browse files Browse the repository at this point in the history
* DS-3563 Simplify and protect against NULL [revdep skip]

Ensure  custom.color set as NULL is handled

Co-authored-by: jrwishart <justin.wishart@displayr.com>
  • Loading branch information
chrisfacer and jrwishart committed Oct 12, 2021
1 parent 87e8430 commit 27dff9f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Remotes: Displayr/flipData,
Displayr/flipU,
Displayr/rhtmlSankeyTree,
Displayr/verbs
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Encoding: UTF-8
2 changes: 1 addition & 1 deletion R/cart.R
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ print.CART <- function(x, ...)
if (x$output == "Sankey")
{
frame <- rPartToTreeFrame(x)
tree.list <- treeFrameToList(frame, attr(x, "xlevels"), x$model, x$where, x$labels)
tree.list <- treeFrameToList(frame, attr(x, "xlevels"), x$model, x$where, x$labels, ...)
plt <- SankeyTree(tree.list, value = "n", nodeHeight = 100, numeric.distribution = TRUE,
tooltip = "tooltip", treeColors = TRUE, terminalDescription = TRUE)
print(plt)
Expand Down
3 changes: 3 additions & 0 deletions R/sankey.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ treeFrameToList <- function(frame, xlevels, model, assigned, labels, max.tooltip
})
}

if (length(custom.color) == 0L)
custom.color <- formals()[["custom.color"]]

if (outcome.is.factor)
{ # Classification tree.
tree.type = "Classification"
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-CART.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test_that("saving variables",
data = bank, subset = bank$ID > 100))
expect_error(predict(z), NA)
expect_error(flipData::Probabilities(z), NA)
expect_error(print(z), NA)
expect_error(print(z, custom.color = NULL), NA)
})


Expand Down

0 comments on commit 27dff9f

Please sign in to comment.