Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
651375d5
Unverified
Commit
651375d5
authored
Mar 21, 2020
by
James Lamb
Committed by
GitHub
Mar 21, 2020
Browse files
[R-package] added test on uncovered line of lgb.plot.importance() (#2903)
parent
3e540eac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
R-package/tests/testthat/test_lgb.plot.importance.R
R-package/tests/testthat/test_lgb.plot.importance.R
+21
-11
No files found.
R-package/tests/testthat/test_lgb.plot.importance.R
View file @
651375d5
...
@@ -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
())
}
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment