Skip to content

Commit

Permalink
replace .lgb_params2str() with .params2str()
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Nov 9, 2023
1 parent 743c372 commit eb0ae49
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Booster <- R6::R6Class(
}
train_set_handle <- train_set$.__enclos_env__$private$get_handle()
params <- utils::modifyList(params, train_set$get_params())
params_str <- .lgb_params2str(params = params)
params_str <- .params2str(params = params)
# Store booster handle
handle <- .Call(
LGBM_BoosterCreate_R
Expand Down Expand Up @@ -167,7 +167,7 @@ Booster <- R6::R6Class(
params <- utils::modifyList(self$params, params)
}

params_str <- .lgb_params2str(params = params)
params_str <- .params2str(params = params)

self$restore_handle()

Expand Down Expand Up @@ -586,7 +586,7 @@ Booster <- R6::R6Class(
, predcontrib
, start_iteration
, num_iteration
, .lgb_params2str(params = params)
, .params2str(params = params)
)

private$fast_predict_config <- list(
Expand Down
6 changes: 3 additions & 3 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Dataset <- R6::R6Class(
}

# Generate parameter str
params_str <- .lgb_params2str(params = private$params)
params_str <- .params2str(params = private$params)

# Get handle of reference dataset
ref_handle <- NULL
Expand Down Expand Up @@ -589,8 +589,8 @@ Dataset <- R6::R6Class(
tryCatch({
.Call(
LGBM_DatasetUpdateParamChecking_R
, .lgb_params2str(params = private$params)
, .lgb_params2str(params = new_params)
, .params2str(params = private$params)
, .params2str(params = new_params)
)
private$params <- new_params
}, error = function(e) {
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.Predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Predictor <- R6::R6Class(

# Initialize will create a starter model
initialize = function(modelfile, params = list(), fast_predict_config = list()) {
private$params <- .lgb_params2str(params = params)
private$params <- .params2str(params = params)
handle <- NULL

if (is.character(modelfile)) {
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
}

.lgb_params2str <- function(params) {
.params2str <- function(params) {

if (!identical(class(params), "list")) {
stop("params must be a list")
Expand Down
2 changes: 1 addition & 1 deletion R-package/tests/testthat/test_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ test_that("lgb.Dataset: Dataset should be able to construct from matrix and retu
, rawData
, nrow(rawData)
, ncol(rawData)
, lightgbm:::.lgb_params2str(params = list())
, lightgbm:::.params2str(params = list())
, ref_handle
)
expect_true(methods::is(handle, "externalptr"))
Expand Down
12 changes: 6 additions & 6 deletions R-package/tests/testthat/test_utils.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
test_that(".lgb_params2str() works as expected for empty lists", {
out_str <- .lgb_params2str(
test_that(".params2str() works as expected for empty lists", {
out_str <- .params2str(
params = list()
)
expect_identical(class(out_str), "character")
expect_equal(out_str, "")
})

test_that(".lgb_params2str() works as expected for a key in params with multiple different-length elements", {
test_that(".params2str() works as expected for a key in params with multiple different-length elements", {
metrics <- c("a", "ab", "abc", "abcdefg")
params <- list(
objective = "magic"
, metric = metrics
, nrounds = 10L
, learning_rate = 0.0000001
)
out_str <- .lgb_params2str(
out_str <- .params2str(
params = params
)
expect_identical(class(out_str), "character")
Expand All @@ -24,8 +24,8 @@ test_that(".lgb_params2str() works as expected for a key in params with multiple
)
})

test_that(".lgb_params2str() passes through duplicated params", {
out_str <- .lgb_params2str(
test_that(".params2str() passes through duplicated params", {
out_str <- .params2str(
params = list(
objective = "regression"
, bagging_fraction = 0.8
Expand Down

0 comments on commit eb0ae49

Please sign in to comment.