Skip to content

Commit

Permalink
add importFrom(utils, modifyList) in NAMESPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Aug 23, 2021
1 parent e8232fa commit 799bd01
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ importFrom(graphics,par)
importFrom(jsonlite,fromJSON)
importFrom(methods,is)
importFrom(stats,quantile)
importFrom(utils,modifyList)
importFrom(utils,read.delim)
useDynLib(lib_lightgbm , .registration = TRUE)
12 changes: 7 additions & 5 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @importFrom R6 R6Class
#' @importFrom utils modifyList
Booster <- R6::R6Class(
classname = "lgb.Booster",
cloneable = FALSE,
Expand Down Expand Up @@ -38,7 +39,7 @@ Booster <- R6::R6Class(
stop("lgb.Booster: Can only use lgb.Dataset as training data")
}
train_set_handle <- train_set$.__enclos_env__$private$get_handle()
params <- modifyList(params, train_set$get_params())
params <- utils::modifyList(params, train_set$get_params())
params_str <- lgb.params2str(params = params)
# Store booster handle
handle <- .Call(
Expand Down Expand Up @@ -187,10 +188,10 @@ Booster <- R6::R6Class(
}

if (methods::is(self$params, "list")) {
params <- modifyList(self$params, params)
params <- utils::modifyList(self$params, params)
}

params <- modifyList(params, additional_params)
params <- utils::modifyList(params, additional_params)
params_str <- lgb.params2str(params = params)

.Call(
Expand Down Expand Up @@ -501,7 +502,7 @@ Booster <- R6::R6Class(
}

# Predict on new data
params <- modifyList(params, additional_params)
params <- utils::modifyList(params, additional_params)
predictor <- Predictor$new(
modelfile = private$handle
, params = params
Expand Down Expand Up @@ -762,6 +763,7 @@ Booster <- R6::R6Class(
#' )
#' )
#' }
#' @importFrom utils modifyList
#' @export
predict.lgb.Booster <- function(object,
data,
Expand Down Expand Up @@ -799,7 +801,7 @@ predict.lgb.Booster <- function(object,
, predcontrib = predcontrib
, header = header
, reshape = reshape
, params = modifyList(params, additional_params)
, params = utils::modifyList(params, additional_params)
)
)
}
Expand Down
5 changes: 3 additions & 2 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#' @importFrom methods is
#' @importFrom R6 R6Class
#' @importFrom utils modifyList
Dataset <- R6::R6Class(

classname = "lgb.Dataset",
Expand Down Expand Up @@ -535,7 +536,7 @@ Dataset <- R6::R6Class(
return(invisible(self))
}
if (lgb.is.null.handle(x = private$handle)) {
private$params <- modifyList(private$params, params)
private$params <- utils::modifyList(private$params, params)
} else {
tryCatch({
.Call(
Expand All @@ -552,7 +553,7 @@ Dataset <- R6::R6Class(

# If updating failed but raw data is available, modify the params
# on the R side and re-set ("deconstruct") the Dataset
private$params <- modifyList(private$params, params)
private$params <- utils::modifyList(private$params, params)
self$finalize()
})
}
Expand Down
14 changes: 7 additions & 7 deletions R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ test_that("lgb.cv() fit on linearly-relatead data improves when using linear lea
cv_bst_linear <- lgb.cv(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
, nfold = 5L
)
expect_is(cv_bst_linear, "lgb.CVBooster")
Expand Down Expand Up @@ -1767,7 +1767,7 @@ test_that("lgb.train() fit on linearly-relatead data improves when using linear
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
, valids = list("train" = dtrain)
)
expect_true(lgb.is.Booster(bst_linear))
Expand Down Expand Up @@ -1798,7 +1798,7 @@ test_that("lgb.train() w/ linear learner fails already-constructed dataset with
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
)
}, regexp = "Cannot change linear_tree after constructed Dataset handle")
})
Expand Down Expand Up @@ -1839,7 +1839,7 @@ test_that("lgb.train() works with linear learners even if Dataset has missing va
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
, valids = list("train" = dtrain)
)
expect_true(lgb.is.Booster(bst_linear))
Expand Down Expand Up @@ -1887,7 +1887,7 @@ test_that("lgb.train() works with linear learners, bagging, and a Dataset that h
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
, valids = list("train" = dtrain)
)
expect_true(lgb.is.Booster(bst_linear))
Expand Down Expand Up @@ -1925,7 +1925,7 @@ test_that("lgb.train() works with linear learners and data where a feature has o
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
)
expect_true(lgb.is.Booster(bst_linear))
})
Expand Down Expand Up @@ -1964,7 +1964,7 @@ test_that("lgb.train() works with linear learners when Dataset has categorical f
bst_linear <- lgb.train(
data = dtrain
, nrounds = 10L
, params = modifyList(params, list(linear_tree = TRUE))
, params = utils::modifyList(params, list(linear_tree = TRUE))
, valids = list("train" = dtrain)
)
expect_true(lgb.is.Booster(bst_linear))
Expand Down

0 comments on commit 799bd01

Please sign in to comment.