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
a55ff183
Unverified
Commit
a55ff183
authored
Dec 29, 2021
by
James Lamb
Committed by
GitHub
Dec 29, 2021
Browse files
[R-package] remove uses of testthat::context() in tests (#4915)
parent
ab788291
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
0 additions
and
64 deletions
+0
-64
R-package/tests/testthat/test_Predictor.R
R-package/tests/testthat/test_Predictor.R
+0
-2
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+0
-15
R-package/tests/testthat/test_custom_objective.R
R-package/tests/testthat/test_custom_objective.R
+0
-2
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+0
-2
R-package/tests/testthat/test_learning_to_rank.R
R-package/tests/testthat/test_learning_to_rank.R
+0
-2
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+0
-14
R-package/tests/testthat/test_lgb.convert_with_rules.R
R-package/tests/testthat/test_lgb.convert_with_rules.R
+0
-2
R-package/tests/testthat/test_lgb.importance.R
R-package/tests/testthat/test_lgb.importance.R
+0
-2
R-package/tests/testthat/test_lgb.interprete.R
R-package/tests/testthat/test_lgb.interprete.R
+0
-2
R-package/tests/testthat/test_lgb.plot.importance.R
R-package/tests/testthat/test_lgb.plot.importance.R
+0
-2
R-package/tests/testthat/test_lgb.plot.interpretation.R
R-package/tests/testthat/test_lgb.plot.interpretation.R
+0
-2
R-package/tests/testthat/test_lgb.unloader.R
R-package/tests/testthat/test_lgb.unloader.R
+0
-2
R-package/tests/testthat/test_metrics.R
R-package/tests/testthat/test_metrics.R
+0
-2
R-package/tests/testthat/test_parameters.R
R-package/tests/testthat/test_parameters.R
+0
-5
R-package/tests/testthat/test_utils.R
R-package/tests/testthat/test_utils.R
+0
-6
R-package/tests/testthat/test_weighted_loss.R
R-package/tests/testthat/test_weighted_loss.R
+0
-2
No files found.
R-package/tests/testthat/test_Predictor.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"Predictor"
)
test_that
(
"Predictor$finalize() should not fail"
,
{
X
<-
as.matrix
(
as.integer
(
iris
[,
"Species"
]),
ncol
=
1L
)
y
<-
iris
[[
"Sepal.Length"
]]
...
...
R-package/tests/testthat/test_basic.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"lightgbm()"
)
ON_WINDOWS
<-
.Platform
$
OS.type
==
"windows"
UTF8_LOCALE
<-
all
(
grepl
(
...
...
@@ -326,9 +324,6 @@ test_that("lightgbm() does not write model to disk if save_name=NULL", {
expect_equal
(
files_before
,
files_after
)
})
context
(
"training continuation"
)
test_that
(
"training continuation works"
,
{
dtrain
<-
lgb.Dataset
(
train
$
data
...
...
@@ -360,8 +355,6 @@ test_that("training continuation works", {
expect_lt
(
abs
(
err_bst
-
err_bst2
),
0.01
)
})
context
(
"lgb.cv()"
)
test_that
(
"cv works"
,
{
dtrain
<-
lgb.Dataset
(
train
$
data
,
label
=
train
$
label
)
params
<-
list
(
...
...
@@ -593,8 +586,6 @@ test_that("lgb.cv() respects eval_train_metric argument", {
)
})
context
(
"lgb.train()"
)
test_that
(
"lgb.train() works as expected with multiple eval metrics"
,
{
metrics
<-
c
(
"binary_error"
,
"auc"
,
"binary_logloss"
)
bst
<-
lgb.train
(
...
...
@@ -2139,8 +2130,6 @@ test_that("lgb.cv() updates params based on keyword arguments", {
})
context
(
"linear learner"
)
test_that
(
"lgb.train() fit on linearly-relatead data improves when using linear learners"
,
{
set.seed
(
708L
)
.new_dataset
<-
function
()
{
...
...
@@ -2380,8 +2369,6 @@ test_that("lgb.train() works with linear learners when Dataset has categorical f
expect_true
(
bst_lin_last_mse
<
bst_last_mse
)
})
context
(
"interaction constraints"
)
test_that
(
"lgb.train() throws an informative error if interaction_constraints is not a list"
,
{
dtrain
<-
lgb.Dataset
(
train
$
data
,
label
=
train
$
label
)
params
<-
list
(
objective
=
"regression"
,
interaction_constraints
=
"[1,2],[3]"
)
...
...
@@ -2482,8 +2469,6 @@ test_that(paste0("lgb.train() gives same results when using interaction_constrai
})
context
(
"monotone constraints"
)
.generate_trainset_for_monotone_constraints_tests
<-
function
(
x3_to_categorical
)
{
n_samples
<-
3000L
x1_positively_correlated_with_y
<-
runif
(
n
=
n_samples
,
min
=
0.0
,
max
=
1.0
)
...
...
R-package/tests/testthat/test_custom_objective.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"Test models with custom objective"
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
data
(
agaricus.test
,
package
=
"lightgbm"
)
dtrain
<-
lgb.Dataset
(
agaricus.train
$
data
,
label
=
agaricus.train
$
label
)
...
...
R-package/tests/testthat/test_dataset.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"testing lgb.Dataset functionality"
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
train_data
<-
agaricus.train
$
data
[
seq_len
(
1000L
),
]
train_label
<-
agaricus.train
$
label
[
seq_len
(
1000L
)]
...
...
R-package/tests/testthat/test_learning_to_rank.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"Learning to rank"
)
# numerical tolerance to use when checking metric values
TOLERANCE
<-
1e-06
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"Booster"
)
ON_WINDOWS
<-
.Platform
$
OS.type
==
"windows"
TOLERANCE
<-
1e-6
...
...
@@ -31,8 +29,6 @@ test_that("Booster$finalize() should not fail", {
expect_true
(
lgb.is.null.handle
(
bst
$
.__enclos_env__
$
private
$
handle
))
})
context
(
"lgb.get.eval.result"
)
test_that
(
"lgb.get.eval.result() should throw an informative error if booster is not an lgb.Booster"
,
{
bad_inputs
<-
list
(
matrix
(
1.0
:
10.0
,
2L
,
5L
)
...
...
@@ -124,8 +120,6 @@ test_that("lgb.get.eval.result() should throw an informative error for incorrect
},
regexp
=
"Only the following eval_names exist for dataset.*\\: \\[l2\\]"
,
fixed
=
FALSE
)
})
context
(
"lgb.load()"
)
test_that
(
"lgb.load() gives the expected error messages given different incorrect inputs"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
@@ -394,8 +388,6 @@ test_that("If a string and a file are both passed to lgb.load() the file is used
expect_identical
(
pred
,
pred2
)
})
context
(
"Booster"
)
test_that
(
"Creating a Booster from a Dataset should work"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
@@ -692,8 +684,6 @@ test_that("Booster$params should include dataset params, before and after Booste
expect_identical
(
bst
$
params
,
expected_params
)
})
context
(
"save_model"
)
test_that
(
"Saving a model with different feature importance types works"
,
{
set.seed
(
708L
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
@@ -1032,8 +1022,6 @@ test_that("lgb.cv() correctly handles passing through params to the model file",
})
context
(
"saveRDS.lgb.Booster() and readRDS.lgb.Booster()"
)
test_that
(
"params (including dataset params) should be stored in .rds file for Booster"
,
{
data
(
agaricus.train
,
package
=
"lightgbm"
)
dtrain
<-
lgb.Dataset
(
...
...
@@ -1069,8 +1057,6 @@ test_that("params (including dataset params) should be stored in .rds file for B
)
})
context
(
"saveRDS and readRDS work on Booster"
)
test_that
(
"params (including dataset params) should be stored in .rds file for Booster"
,
{
data
(
agaricus.train
,
package
=
"lightgbm"
)
dtrain
<-
lgb.Dataset
(
...
...
R-package/tests/testthat/test_lgb.convert_with_rules.R
View file @
a55ff183
context
(
"lgb.convert_with_rules()"
)
test_that
(
"lgb.convert_with_rules() rejects inputs that are not a data.table or data.frame"
,
{
bad_inputs
<-
list
(
matrix
(
1.0
:
10.0
,
2L
,
5L
)
...
...
R-package/tests/testthat/test_lgb.importance.R
View file @
a55ff183
context
(
"lgb.importance"
)
test_that
(
"lgb.importance() should reject bad inputs"
,
{
bad_inputs
<-
list
(
.Machine
$
integer.max
...
...
R-package/tests/testthat/test_lgb.interprete.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"lgb.interpete"
)
.sigmoid
<-
function
(
x
)
{
1.0
/
(
1.0
+
exp
(
-
x
))
}
...
...
R-package/tests/testthat/test_lgb.plot.importance.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"lgb.plot.importance()"
)
test_that
(
"lgb.plot.importance() should run without error for well-formed inputs"
,
{
data
(
agaricus.train
,
package
=
"lightgbm"
)
train
<-
agaricus.train
...
...
R-package/tests/testthat/test_lgb.plot.interpretation.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"lgb.plot.interpretation"
)
.sigmoid
<-
function
(
x
)
{
1.0
/
(
1.0
+
exp
(
-
x
))
}
...
...
R-package/tests/testthat/test_lgb.unloader.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"lgb.unloader"
)
test_that
(
"lgb.unloader works as expected"
,
{
data
(
agaricus.train
,
package
=
"lightgbm"
)
train
<-
agaricus.train
...
...
R-package/tests/testthat/test_metrics.R
View file @
a55ff183
context
(
".METRICS_HIGHER_BETTER()"
)
test_that
(
".METRICS_HIGHER_BETTER() should be well formed"
,
{
metrics
<-
.METRICS_HIGHER_BETTER
()
metric_names
<-
names
(
.METRICS_HIGHER_BETTER
())
...
...
R-package/tests/testthat/test_parameters.R
View file @
a55ff183
context
(
"feature penalties"
)
data
(
agaricus.train
,
package
=
"lightgbm"
)
data
(
agaricus.test
,
package
=
"lightgbm"
)
train
<-
agaricus.train
...
...
@@ -47,8 +44,6 @@ test_that("Feature penalties work properly", {
expect_length
(
var_gain
[[
length
(
var_gain
)]],
0L
)
})
context
(
"parameter aliases"
)
test_that
(
".PARAMETER_ALIASES() returns a named list of character vectors, where names are unique"
,
{
param_aliases
<-
.PARAMETER_ALIASES
()
expect_identical
(
class
(
param_aliases
),
"list"
)
...
...
R-package/tests/testthat/test_utils.R
View file @
a55ff183
context
(
"lgb.params2str"
)
test_that
(
"lgb.params2str() works as expected for empty lists"
,
{
out_str
<-
lgb.params2str
(
params
=
list
()
...
...
@@ -37,8 +35,6 @@ test_that("lgb.params2str() passes through duplicated params", {
expect_equal
(
out_str
,
"objective=regression bagging_fraction=0.8 bagging_fraction=0.5"
)
})
context
(
"lgb.check.eval"
)
test_that
(
"lgb.check.eval works as expected with no metric"
,
{
params
<-
lgb.check.eval
(
params
=
list
(
device
=
"cpu"
)
...
...
@@ -84,8 +80,6 @@ test_that("lgb.check.eval drops duplicate metrics and preserves order", {
expect_identical
(
params
[[
"metric"
]],
list
(
"l1"
,
"l2"
,
"rmse"
))
})
context
(
"lgb.check.wrapper_param"
)
test_that
(
"lgb.check.wrapper_param() uses passed-in keyword arg if no alias found in params"
,
{
kwarg_val
<-
sample
(
seq_len
(
100L
),
size
=
1L
)
params
<-
lgb.check.wrapper_param
(
...
...
R-package/tests/testthat/test_weighted_loss.R
View file @
a55ff183
...
...
@@ -2,8 +2,6 @@ VERBOSITY <- as.integer(
Sys.getenv
(
"LIGHTGBM_TEST_VERBOSITY"
,
"-1"
)
)
context
(
"Case weights are respected"
)
test_that
(
"Gamma regression reacts on 'weight'"
,
{
n
<-
100L
set.seed
(
87L
)
...
...
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