-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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] Add tests on lgb.check.eval, lgb.unloader, and lgb.encode.char #3235
Conversation
test_that("lgb.check.eval adds eval to metric in params", { | ||
params <- lgb.check.eval( | ||
params = list(metric = "auc") | ||
, eval = "binary_error" | ||
) | ||
expect_named(params, "metric") | ||
expect_identical(params[["metric"]], list("auc", "binary_error")) | ||
}) | ||
|
||
test_that("lgb.check.eval adds eval to metric in params", { | ||
params <- lgb.check.eval( | ||
params = list(metric = "auc") | ||
, eval = "binary_error" | ||
) | ||
expect_named(params, "metric") | ||
expect_identical(params[["metric"]], list("auc", "binary_error")) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameslamb These two tests look identical. Is it expected or just copy-paste issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes! Must be a copy-paste mistake. This is where I miss Python tests, where each test is a named function and a linter can warn you if you have two with the same name
@@ -311,17 +309,26 @@ lgb.check.obj <- function(params, obj) { | |||
|
|||
} | |||
|
|||
# [description] | |||
# make sure that "metric" is populated on params, | |||
# and add any eval values to itt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to itt
-> to it
In case you will create a PR to remove duplicated test, you can fix this typo at the same time 😃
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
This PR proposes adding a few more tests on R code that isn't currently covered by tests.
It also proposes fixing an inconsistency I found while writing the tests. Today
lgb.check.eval()
sometimes setsmetric
as a character vector, and sometimes sets it as a list. This PR fixes that and guarantees that it always uses a list. Alist
is preferred because it allows for mixing string metric names and custom eval function objects.