Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
f2e1ad6f
"vscode:/vscode.git/clone" did not exist on "24786cb498231a441fc8f50400272b8868d3610d"
Unverified
Commit
f2e1ad6f
authored
May 24, 2022
by
James Lamb
Committed by
GitHub
May 24, 2022
Browse files
[R-package] standardize style for placement of braces (#5240)
parent
a4478f7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
R-package/R/lgb.convert_with_rules.R
R-package/R/lgb.convert_with_rules.R
+9
-3
R-package/R/utils.R
R-package/R/utils.R
+7
-1
R-package/tests/testthat/test_learning_to_rank.R
R-package/tests/testthat/test_learning_to_rank.R
+9
-1
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+3
-1
No files found.
R-package/R/lgb.convert_with_rules.R
View file @
f2e1ad6f
...
...
@@ -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
...
...
R-package/R/utils.R
View file @
f2e1ad6f
...
...
@@ -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"
)
}
...
...
R-package/tests/testthat/test_learning_to_rank.R
View file @
f2e1ad6f
...
...
@@ -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
)
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
f2e1ad6f
...
...
@@ -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
)
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment