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

[R-package] silence more logs in unit tests (#5227)

parent 0ebbf1e4
...@@ -78,6 +78,7 @@ test_that("train and predict binary classification", { ...@@ -78,6 +78,7 @@ test_that("train and predict binary classification", {
num_leaves = 5L num_leaves = 5L
, objective = "binary" , objective = "binary"
, metric = "binary_error" , metric = "binary_error"
, verbose = VERBOSITY
) )
, nrounds = nrounds , nrounds = nrounds
, valids = list( , valids = list(
...@@ -118,6 +119,7 @@ test_that("train and predict softmax", { ...@@ -118,6 +119,7 @@ test_that("train and predict softmax", {
, objective = "multiclass" , objective = "multiclass"
, metric = "multi_error" , metric = "multi_error"
, num_class = 3L , num_class = 3L
, verbose = VERBOSITY
) )
, nrounds = 20L , nrounds = 20L
, valids = list( , valids = list(
...@@ -147,6 +149,7 @@ test_that("use of multiple eval metrics works", { ...@@ -147,6 +149,7 @@ test_that("use of multiple eval metrics works", {
, learning_rate = 1.0 , learning_rate = 1.0
, objective = "binary" , objective = "binary"
, metric = metrics , metric = metrics
, verbose = VERBOSITY
) )
, nrounds = 10L , nrounds = 10L
, valids = list( , valids = list(
...@@ -298,6 +301,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide ...@@ -298,6 +301,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
"binary_error" "binary_error"
, "auc" , "auc"
) )
, verbose = VERBOSITY
) )
, nrounds = nrounds , nrounds = nrounds
, valids = list( , valids = list(
......
...@@ -12,7 +12,13 @@ test_label <- agaricus.test$label[1L:100L] ...@@ -12,7 +12,13 @@ test_label <- agaricus.test$label[1L:100L]
test_that("lgb.Dataset: basic construction, saving, loading", { test_that("lgb.Dataset: basic construction, saving, loading", {
# from sparse matrix # from sparse matrix
dtest1 <- lgb.Dataset(test_data, label = test_label) dtest1 <- lgb.Dataset(
test_data
, label = test_label
, params = list(
verbose = VERBOSITY
)
)
# from dense matrix # from dense matrix
dtest2 <- lgb.Dataset(as.matrix(test_data), label = test_label) dtest2 <- lgb.Dataset(as.matrix(test_data), label = test_label)
expect_equal(get_field(dtest1, "label"), get_field(dtest2, "label")) expect_equal(get_field(dtest1, "label"), get_field(dtest2, "label"))
...@@ -21,7 +27,12 @@ test_that("lgb.Dataset: basic construction, saving, loading", { ...@@ -21,7 +27,12 @@ test_that("lgb.Dataset: basic construction, saving, loading", {
tmp_file <- tempfile("lgb.Dataset_") tmp_file <- tempfile("lgb.Dataset_")
lgb.Dataset.save(dtest1, tmp_file) lgb.Dataset.save(dtest1, tmp_file)
# read from a local file # read from a local file
dtest3 <- lgb.Dataset(tmp_file) dtest3 <- lgb.Dataset(
tmp_file
, params = list(
verbose = VERBOSITY
)
)
lgb.Dataset.construct(dtest3) lgb.Dataset.construct(dtest3)
unlink(tmp_file) unlink(tmp_file)
expect_equal(get_field(dtest1, "label"), get_field(dtest3, "label")) expect_equal(get_field(dtest1, "label"), get_field(dtest3, "label"))
...@@ -358,6 +369,9 @@ test_that("lgb.Dataset: should be able to run lgb.train() immediately after usin ...@@ -358,6 +369,9 @@ test_that("lgb.Dataset: should be able to run lgb.train() immediately after usin
dtest <- lgb.Dataset( dtest <- lgb.Dataset(
data = test_data data = test_data
, label = test_label , label = test_label
, params = list(
verbose = VERBOSITY
)
) )
tmp_file <- tempfile(pattern = "lgb.Dataset_") tmp_file <- tempfile(pattern = "lgb.Dataset_")
lgb.Dataset.save( lgb.Dataset.save(
...@@ -389,6 +403,9 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l ...@@ -389,6 +403,9 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
dtest <- lgb.Dataset( dtest <- lgb.Dataset(
data = test_data data = test_data
, label = test_label , label = test_label
, params = list(
verbosity = VERBOSITY
)
) )
tmp_file <- tempfile(pattern = "lgb.Dataset_") tmp_file <- tempfile(pattern = "lgb.Dataset_")
lgb.Dataset.save( lgb.Dataset.save(
...@@ -404,6 +421,8 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l ...@@ -404,6 +421,8 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
, metric = "binary_logloss" , metric = "binary_logloss"
, num_leaves = 5L , num_leaves = 5L
, learning_rate = 1.0 , learning_rate = 1.0
, num_iterations = 5L
, verbosity = VERBOSITY
) )
# should be able to train right away # should be able to train right away
...@@ -446,7 +465,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with ...@@ -446,7 +465,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
dtrain <- lgb.Dataset( dtrain <- lgb.Dataset(
data = train_file data = train_file
, params = list(header = TRUE) , params = list(
header = TRUE
, verbosity = VERBOSITY
)
) )
dtrain$construct() dtrain$construct()
expect_identical(dtrain$get_colnames(), c("x1", "x2")) expect_identical(dtrain$get_colnames(), c("x1", "x2"))
...@@ -467,7 +489,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with ...@@ -467,7 +489,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with
dtrain <- lgb.Dataset( dtrain <- lgb.Dataset(
data = train_file data = train_file
, params = list(header = FALSE) , params = list(
header = FALSE
, verbosity = VERBOSITY
)
) )
dtrain$construct() dtrain$construct()
expect_identical(dtrain$get_colnames(), c("Column_0", "Column_1")) expect_identical(dtrain$get_colnames(), c("Column_0", "Column_1"))
......
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