Unverified Commit f2e1ad6f authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] standardize style for placement of braces (#5240)

parent a4478f7e
......@@ -4,7 +4,9 @@
return(
vapply(
X = df
, FUN = function(x) {paste0(class(x), collapse = ",")}
, FUN = function(x) {
paste0(class(x), collapse = ",")
}
, FUN.VALUE = character(1L)
)
)
......@@ -40,8 +42,12 @@
return(invisible(NULL))
}
.LGB_CONVERT_DEFAULT_FOR_LOGICAL_NA <- function() {return(-1L)}
.LGB_CONVERT_DEFAULT_FOR_NON_LOGICAL_NA <- function() {return(0L)}
.LGB_CONVERT_DEFAULT_FOR_LOGICAL_NA <- function() {
return(-1L)
}
.LGB_CONVERT_DEFAULT_FOR_NON_LOGICAL_NA <- function() {
return(0L)
}
#' @name lgb.convert_with_rules
......
......@@ -69,7 +69,13 @@ lgb.check_interaction_constraints <- function(interaction_constraints, column_na
if (!methods::is(interaction_constraints, "list")) {
stop("interaction_constraints must be a list")
}
if (!all(sapply(interaction_constraints, function(x) {is.character(x) || is.numeric(x)}))) {
constraint_is_character_or_numeric <- sapply(
X = interaction_constraints
, FUN = function(x) {
return(is.character(x) || is.numeric(x))
}
)
if (!all(constraint_is_character_or_numeric)) {
stop("every element in interaction_constraints must be a character vector or numeric vector")
}
......
......@@ -49,7 +49,15 @@ test_that("learning-to-rank with lgb.train() works as expected", {
expect_true(result[["higher_better"]])
expect_identical(result[["data_name"]], "training")
}
expect_identical(sapply(eval_results, function(x) {x$name}), eval_names)
expect_identical(
sapply(
X = eval_results
, FUN = function(x) {
x$name
}
)
, eval_names
)
expect_equal(eval_results[[1L]][["value"]], 0.775)
if (!ON_32_BIT_WINDOWS) {
expect_true(abs(eval_results[[2L]][["value"]] - 0.745986) < TOLERANCE)
......
......@@ -1203,7 +1203,9 @@ test_that("boosters with linear models at leaves work with saveRDS.lgb.Booster a
rm(bst)
# load the booster and make predictions...should be the same
expect_warning({bst2 <- readRDS.lgb.Booster(file = model_file)})
expect_warning({
bst2 <- readRDS.lgb.Booster(file = model_file)
})
preds2 <- predict(bst2, X)
expect_identical(preds, preds2)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment