From 8033833e9b44a63ebf811fb9455c55edc41b3438 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 13 Sep 2023 20:40:08 +0800 Subject: [PATCH 1/2] [R] Fix method name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit r-devel think this is an unregistered s3 method. ``` Mismatches for apparent methods not registered: format: function(x, ...) format.eval.string: function(iter, eval_res, eval_err) See section ‘Registering S3 methods’ in the ‘Writing R Extensions’ manual. ``` --- R-package/R/callbacks.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R-package/R/callbacks.R b/R-package/R/callbacks.R index 7265967b2ad9..58c3205b5853 100644 --- a/R-package/R/callbacks.R +++ b/R-package/R/callbacks.R @@ -70,7 +70,7 @@ cb.print.evaluation <- function(period = 1, showsd = TRUE) { i == env$begin_iteration || i == env$end_iteration) { stdev <- if (showsd) env$bst_evaluation_err else NULL - msg <- format.eval.string(i, env$bst_evaluation, stdev) + msg <- format_eval_string(i, env$bst_evaluation, stdev) cat(msg, '\n') } } @@ -380,7 +380,9 @@ cb.early.stop <- function(stopping_rounds, maximize = FALSE, if ((maximize && score > best_score) || (!maximize && score < best_score)) { - best_msg <<- format.eval.string(i, env$bst_evaluation, env$bst_evaluation_err) + best_msg <<- format_eval_string( + i, env$bst_evaluation, env$bst_evaluation_err + ) best_score <<- score best_iteration <<- i best_ntreelimit <<- best_iteration * env$num_parallel_tree @@ -754,7 +756,7 @@ xgb.gblinear.history <- function(model, class_index = NULL) { # # Format the evaluation metric string -format.eval.string <- function(iter, eval_res, eval_err = NULL) { +format_eval_string <- function(iter, eval_res, eval_err = NULL) { if (length(eval_res) == 0) stop('no evaluation results') enames <- names(eval_res) From 4b9c7afcc90ff6c7ee82fe76a5fa83e4d0b5f6a2 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 13 Sep 2023 21:52:23 +0800 Subject: [PATCH 2/2] convention. --- R-package/R/callbacks.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R-package/R/callbacks.R b/R-package/R/callbacks.R index 58c3205b5853..96bcaef32908 100644 --- a/R-package/R/callbacks.R +++ b/R-package/R/callbacks.R @@ -70,7 +70,7 @@ cb.print.evaluation <- function(period = 1, showsd = TRUE) { i == env$begin_iteration || i == env$end_iteration) { stdev <- if (showsd) env$bst_evaluation_err else NULL - msg <- format_eval_string(i, env$bst_evaluation, stdev) + msg <- .format_eval_string(i, env$bst_evaluation, stdev) cat(msg, '\n') } } @@ -380,7 +380,7 @@ cb.early.stop <- function(stopping_rounds, maximize = FALSE, if ((maximize && score > best_score) || (!maximize && score < best_score)) { - best_msg <<- format_eval_string( + best_msg <<- .format_eval_string( i, env$bst_evaluation, env$bst_evaluation_err ) best_score <<- score @@ -756,7 +756,7 @@ xgb.gblinear.history <- function(model, class_index = NULL) { # # Format the evaluation metric string -format_eval_string <- function(iter, eval_res, eval_err = NULL) { +.format_eval_string <- function(iter, eval_res, eval_err = NULL) { if (length(eval_res) == 0) stop('no evaluation results') enames <- names(eval_res)