From de026261e98cc0c6c2b070e1a1427ef54310782c Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 23 Oct 2019 23:46:15 -0500 Subject: [PATCH] added more parameter alias coverage on R package --- R-package/R/aliases.R | 12 +++++++++++- R-package/R/callback.R | 5 ++--- R-package/tests/testthat/test_parameters.R | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/R-package/R/aliases.R b/R-package/R/aliases.R index 80d411f074b1..8ae11e87c504 100644 --- a/R-package/R/aliases.R +++ b/R-package/R/aliases.R @@ -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" ) )) } diff --git a/R-package/R/callback.R b/R-package/R/callback.R index d6a010b19296..1b5f4f4562a8 100644 --- a/R-package/R/callback.R +++ b/R-package/R/callback.R @@ -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)) { diff --git a/R-package/tests/testthat/test_parameters.R b/R-package/tests/testthat/test_parameters.R index 9d6c75c861e5..beedbe452ba6 100644 --- a/R-package/tests/testthat/test_parameters.R +++ b/R-package/tests/testthat/test_parameters.R @@ -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", {