Skip to content

Commit

Permalink
[R-package] fix learning-to-rank tests on Solaris (#3534)
Browse files Browse the repository at this point in the history
* [R-package] fix learning-to-rank tests on Solaris

* Update R-package/tests/testthat/test_learning_to_rank.R

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
  • Loading branch information
jameslamb and StrikerRUS authored Nov 8, 2020
1 parent c0ffb71 commit 71a1a4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R-package/tests/testthat/test_learning_to_rank.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context("Learning to rank")
# numerical tolerance to use when checking metric values
TOLERANCE <- 1e-06

ON_SOLARIS <- Sys.info()["sysname"] == "SunOS"

test_that("learning-to-rank with lgb.train() works as expected", {
set.seed(708L)
data(agaricus.train, package = "lightgbm")
Expand Down Expand Up @@ -46,11 +48,14 @@ test_that("learning-to-rank with lgb.train() works as expected", {
}
expect_identical(sapply(eval_results, function(x) {x$name}), eval_names)
expect_equal(eval_results[[1L]][["value"]], 0.775)
expect_true(abs(eval_results[[2L]][["value"]] - 0.745986) < TOLERANCE)
expect_true(abs(eval_results[[3L]][["value"]] - 0.7351959) < TOLERANCE)
if (!ON_SOLARIS) {
expect_true(abs(eval_results[[2L]][["value"]] - 0.745986) < TOLERANCE)
expect_true(abs(eval_results[[3L]][["value"]] - 0.7351959) < TOLERANCE)
}
})

test_that("learning-to-rank with lgb.cv() works as expected", {
testthat::skip_if(ON_SOLARIS, message = "Skipping on Solaris")
set.seed(708L)
data(agaricus.train, package = "lightgbm")
# just keep a few features,to generate an model with imperfect fit
Expand Down

0 comments on commit 71a1a4f

Please sign in to comment.