Skip to content

Commit

Permalink
Merge pull request #345 from tlverse/disable_lightgbm_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nhejazi authored Apr 22, 2021
2 parents 5cddc6c + ad43f25 commit db8447c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
9 changes: 9 additions & 0 deletions man/Lrnr_haldensify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions tests/testthat/test-lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,36 @@ test_learner <- function(learner, task, ...) {
# with only default arguments. Not sure if this is a reasonable requirement
learner_obj <- learner$new(...)
print(sprintf("Testing Learner: %s", learner_obj$name))

# test learner training
fit_obj <- learner_obj$train(task)
test_that("Learner can be trained on data", {
skip_on_os("windows")
fit_obj <- learner_obj$train(task)
expect_true(fit_obj$is_trained)
})

# test learner prediction
train_preds <- fit_obj$predict()
test_that("Learner can generate training set predictions", {
skip_on_os("windows")
fit_obj <- learner_obj$train(task)
train_preds <- fit_obj$predict()
expect_equal(
sl3:::safe_dim(train_preds)[1], length(task$Y)
)
})

# test learner chaining
chained_task <- fit_obj$chain()
test_that("Chaining returns a task", {
skip_on_os("windows")
fit_obj <- learner_obj$train(task)
chained_task <- fit_obj$chain()
expect_true(is(chained_task, "sl3_Task"))
})

test_that("Chaining returns the correct number of rows", {
skip_on_os("windows")
fit_obj <- learner_obj$train(task)
chained_task <- fit_obj$chain()
expect_equal(nrow(chained_task$X), nrow(task$X))
})
}
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-screeners.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@ test_importance_screener <- function(learner) {
}

test_that("Lrnr_screener_importance tests", {
# get all learners supporting variable importance
importance_learners <- sl3::sl3_list_learners("importance")

# remove LightGBM on Windows
if (Sys.info()["sysname"] == "Windows") {
importance_learners <-
importance_learners[!(importance_learners == "Lrnr_lightgbm")]
}

# test all learners supporting variable importance
lapply(importance_learners, test_importance_screener)
})

Expand Down

0 comments on commit db8447c

Please sign in to comment.