Skip to content

Commit

Permalink
[R-package] remove support for '...' in create_valid() (#4865)
Browse files Browse the repository at this point in the history
* [R-package] remove support for '...' in create_valid()

* remove importFrom
  • Loading branch information
jameslamb authored Dec 7, 2021
1 parent 3ede5fa commit 431556a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
35 changes: 3 additions & 32 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,7 @@ Dataset <- R6::R6Class(
weight = NULL,
group = NULL,
init_score = NULL,
params = list(),
...) {

additional_params <- list(...)
if (length(additional_params) > 0L) {
warning(paste0(
"Dataset$create_valid(): Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. "
, "See ?lgb.Dataset.create.valid for documentation on how to call this function."
))
}

# anything passed into '...' should be overwritten by things passed to 'params'
params <- modifyList(additional_params, params)
params = list()) {

# the Dataset's existing parameters should be overwritten by any passed in to this call
params <- modifyList(self$get_params(), params)
Expand Down Expand Up @@ -863,8 +848,6 @@ lgb.Dataset <- function(data,
#' The "Dataset Parameters" section of the documentation} for a list of parameters
#' and valid values. If this is an empty list (the default), the validation Dataset
#' will have the same parameters as the Dataset passed to argument \code{dataset}.
#' @param ... additional \code{lgb.Dataset} parameters.
#' NOTE: As of v3.3.0, use of \code{...} is deprecated. Add parameters to \code{params} directly.
#'
#' @return constructed dataset
#'
Expand Down Expand Up @@ -912,31 +895,19 @@ lgb.Dataset <- function(data,
#' )
#' dvalid$construct()
#' }
#' @importFrom utils modifyList
#' @export
lgb.Dataset.create.valid <- function(dataset,
data,
label = NULL,
weight = NULL,
group = NULL,
init_score = NULL,
params = list(),
...) {
params = list()) {

if (!lgb.is.Dataset(x = dataset)) {
stop("lgb.Dataset.create.valid: input data should be an lgb.Dataset object")
}

additional_params <- list(...)
if (length(additional_params) > 0L) {
warning(paste0(
"lgb.Dataset.create.valid: Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. See ?lgb.Dataset.create.valid for documentation on how to call this function."
))
}

# Create validation dataset
return(invisible(
dataset$create_valid(
Expand All @@ -945,7 +916,7 @@ lgb.Dataset.create.valid <- function(dataset,
, weight = weight
, group = group
, init_score = init_score
, params = utils::modifyList(params, additional_params)
, params = params
)
))

Expand Down
6 changes: 1 addition & 5 deletions R-package/man/lgb.Dataset.create.valid.Rd

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

0 comments on commit 431556a

Please sign in to comment.