Unverified Commit 651375d5 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] added test on uncovered line of lgb.plot.importance() (#2903)

parent 3e540eac
...@@ -17,21 +17,31 @@ test_that("lgb.plot.importance() should run without error for well-formed inputs ...@@ -17,21 +17,31 @@ test_that("lgb.plot.importance() should run without error for well-formed inputs
# Check that there are no plots present before plotting # Check that there are no plots present before plotting
expect_null(dev.list()) expect_null(dev.list())
resDT <- lgb.plot.importance(
tree_imp = tree_imp args_no_cex <- list(
"tree_imp" = tree_imp
, top_n = 10L , top_n = 10L
, measure = "Gain" , measure = "Gain"
, cex = 0.75
) )
args_cex <- args_no_cex
args_cex[["cex"]] <- 0.75
# Check that lgb.plot.importance() returns the data.table of the plotted data for (arg_list in list(args_no_cex, args_cex)) {
expect_true(data.table::is.data.table(resDT))
expect_named(resDT, c("Feature", "Gain", "Cover", "Frequency"))
# Check that a plot was produced resDT <- do.call(
expect_false(is.null(dev.list())) what = lgb.plot.importance
, args = arg_list
)
# remove all plots # Check that lgb.plot.importance() returns the data.table of the plotted data
dev.off() expect_true(data.table::is.data.table(resDT))
expect_null(dev.list()) expect_named(resDT, c("Feature", "Gain", "Cover", "Frequency"))
# Check that a plot was produced
expect_false(is.null(dev.list()))
# remove all plots
dev.off()
expect_null(dev.list())
}
}) })
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment