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] Add tests on lgb.check.eval, lgb.unloader, and lgb.encode.char #3235

Merged
merged 3 commits into from
Jul 22, 2020

Conversation

jameslamb
Copy link
Collaborator

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 sets metric as a character vector, and sometimes sets it as a list. This PR fixes that and guarantees that it always uses a list. A list is preferred because it allows for mixing string metric names and custom eval function objects.

@jameslamb jameslamb requested a review from guolinke July 17, 2020 05:20
@jameslamb jameslamb requested a review from Laurae2 as a code owner July 17, 2020 05:20
@jameslamb jameslamb merged commit 952e23a into microsoft:master Jul 22, 2020
Comment on lines +92 to +108
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"))
})
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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 😃

@jameslamb jameslamb deleted the r/more-tests branch October 11, 2020 04:37
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants