Skip to content

Commit

Permalink
added more parameter alias coverage on R package
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Oct 25, 2019
1 parent 6221426 commit de02626
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion R-package/R/aliases.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@
.PARAMETER_ALIASES <- function(){
return(list(
"boosting" = c(
"boosting_type"
"boosting"
, "boost"
, "boosting_type"
)
, "metric" = c(
"metric"
, "metrics"
, "metric_types"
)
, "num_class" = c(
"num_class"
, "num_classes"
)
))
}
5 changes: 2 additions & 3 deletions R-package/R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ cb.reset.parameters <- function(new_params) {
# Some parameters are not allowed to be changed,
# since changing them would simply wreck some chaos
not_allowed <- c(
"num_class"
, "metric"
, "boosting"
.PARAMETER_ALIASES()[["num_class"]]
, .PARAMETER_ALIASES()[["metric"]]
, .PARAMETER_ALIASES()[["boosting"]]
)
if (any(pnames %in% not_allowed)) {
Expand Down
3 changes: 3 additions & 0 deletions R-package/tests/testthat/test_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ expect_true(".PARAMETER_ALIASES() returns a named list", {
param_aliases <- .PARAMETER_ALIASES()
expect_true(is.list(param_aliases))
expect_true(is.character(names(param_aliases)))
expect_true(is.character(param_aliases[["boosting"]]))
expect_true(is.character(param_aliases[["metric"]]))
expect_true(is.character(param_aliases[["num_class"]]))
})

expect_true("training should warn if you use 'dart' boosting, specified with 'boosting' or aliases", {
Expand Down

0 comments on commit de02626

Please sign in to comment.