Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test_that("train and predict binary classification", {
num_leaves = 5L
, objective = "binary"
, metric = "binary_error"
, verbose = VERBOSITY
)
, nrounds = nrounds
, valids = list(
Expand Down Expand Up @@ -118,6 +119,7 @@ test_that("train and predict softmax", {
, objective = "multiclass"
, metric = "multi_error"
, num_class = 3L
, verbose = VERBOSITY
)
, nrounds = 20L
, valids = list(
Expand Down Expand Up @@ -147,6 +149,7 @@ test_that("use of multiple eval metrics works", {
, learning_rate = 1.0
, objective = "binary"
, metric = metrics
, verbose = VERBOSITY
)
, nrounds = 10L
, valids = list(
Expand Down Expand Up @@ -298,6 +301,7 @@ test_that("lightgbm() performs evaluation on validation sets if they are provide
"binary_error"
, "auc"
)
, verbose = VERBOSITY
)
, nrounds = nrounds
, valids = list(
Expand Down
33 changes: 29 additions & 4 deletions R-package/tests/testthat/test_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ test_label <- agaricus.test$label[1L:100L]

test_that("lgb.Dataset: basic construction, saving, loading", {
# 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
dtest2 <- lgb.Dataset(as.matrix(test_data), label = test_label)
expect_equal(get_field(dtest1, "label"), get_field(dtest2, "label"))
Expand All @@ -21,7 +27,12 @@ test_that("lgb.Dataset: basic construction, saving, loading", {
tmp_file <- tempfile("lgb.Dataset_")
lgb.Dataset.save(dtest1, tmp_file)
# read from a local file
dtest3 <- lgb.Dataset(tmp_file)
dtest3 <- lgb.Dataset(
tmp_file
, params = list(
verbose = VERBOSITY
)
)
lgb.Dataset.construct(dtest3)
unlink(tmp_file)
expect_equal(get_field(dtest1, "label"), get_field(dtest3, "label"))
Expand Down Expand Up @@ -358,6 +369,9 @@ test_that("lgb.Dataset: should be able to run lgb.train() immediately after usin
dtest <- lgb.Dataset(
data = test_data
, label = test_label
, params = list(
verbose = VERBOSITY
)
)
tmp_file <- tempfile(pattern = "lgb.Dataset_")
lgb.Dataset.save(
Expand Down Expand Up @@ -389,6 +403,9 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
dtest <- lgb.Dataset(
data = test_data
, label = test_label
, params = list(
verbosity = VERBOSITY
)
)
tmp_file <- tempfile(pattern = "lgb.Dataset_")
lgb.Dataset.save(
Expand All @@ -404,6 +421,8 @@ test_that("lgb.Dataset: should be able to run lgb.cv() immediately after using l
, metric = "binary_logloss"
, num_leaves = 5L
, learning_rate = 1.0
, num_iterations = 5L
jmoralez marked this conversation as resolved.
Show resolved Hide resolved
, verbosity = VERBOSITY
)

# should be able to train right away
Expand Down Expand Up @@ -446,7 +465,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with

dtrain <- lgb.Dataset(
data = train_file
, params = list(header = TRUE)
, params = list(
header = TRUE
, verbosity = VERBOSITY
)
)
dtrain$construct()
expect_identical(dtrain$get_colnames(), c("x1", "x2"))
Expand All @@ -467,7 +489,10 @@ test_that("lgb.Dataset: should be able to create a Dataset from a text file with

dtrain <- lgb.Dataset(
data = train_file
, params = list(header = FALSE)
, params = list(
header = FALSE
, verbosity = VERBOSITY
)
)
dtrain$construct()
expect_identical(dtrain$get_colnames(), c("Column_0", "Column_1"))
Expand Down