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
1b43214f
Unverified
Commit
1b43214f
authored
Jun 24, 2022
by
CuriousCorrelation
Committed by
GitHub
Jun 23, 2022
Browse files
[ci] [R-package] Add string_boundary_linter (#5324)
parent
eb13f39a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
+22
-21
.ci/lint_r_code.R
.ci/lint_r_code.R
+1
-0
R-package/tests/testthat/test_basic.R
R-package/tests/testthat/test_basic.R
+3
-3
R-package/tests/testthat/test_lgb.Booster.R
R-package/tests/testthat/test_lgb.Booster.R
+17
-17
build_r.R
build_r.R
+1
-1
No files found.
.ci/lint_r_code.R
View file @
1b43214f
...
...
@@ -58,6 +58,7 @@ LINTERS_TO_USE <- list(
,
"spaces_inside"
=
lintr
::
spaces_inside_linter
()
,
"spaces_left_parens"
=
lintr
::
spaces_left_parentheses_linter
()
,
"sprintf"
=
lintr
::
sprintf_linter
()
,
"string_boundary"
=
lintr
::
string_boundary_linter
()
,
"todo_comments"
=
lintr
::
todo_comment_linter
(
c
(
"todo"
,
"fixme"
,
"to-do"
))
,
"trailing_blank"
=
lintr
::
trailing_blank_lines_linter
()
,
"trailing_white"
=
lintr
::
trailing_whitespace_linter
()
...
...
R-package/tests/testthat/test_basic.R
View file @
1b43214f
...
...
@@ -4,9 +4,9 @@ VERBOSITY <- as.integer(
ON_WINDOWS
<-
.Platform
$
OS.type
==
"windows"
UTF8_LOCALE
<-
all
(
grepl
(
pattern
=
"UTF-8$"
,
x
=
Sys.getlocale
(
category
=
"LC_CTYPE"
)
UTF8_LOCALE
<-
all
(
endsWith
(
Sys.getlocale
(
category
=
"LC_CTYPE"
)
,
"UTF-8"
))
data
(
agaricus.train
,
package
=
"lightgbm"
)
...
...
R-package/tests/testthat/test_lgb.Booster.R
View file @
1b43214f
...
...
@@ -787,20 +787,20 @@ test_that("all parameters are stored correctly with save_model_to_string()", {
params_in_file
<-
.params_from_model_string
(
model_str
=
model_str
)
# parameters should match what was passed from the R package
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[metric\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[metric:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
"[metric: l2]"
),
1L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[num_iterations\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[num_iterations:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
"[num_iterations: 4]"
),
1L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[objective\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[objective:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
"[objective: regression]"
),
1L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[verbosity\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[verbosity:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
sprintf
(
"[verbosity: %i]"
,
VERBOSITY
)),
1L
)
# early stopping should be off by default
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[early_stopping_round\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[early_stopping_round:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
"[early_stopping_round: 0]"
),
1L
)
})
...
...
@@ -851,15 +851,15 @@ test_that("early_stopping, num_iterations are stored correctly in model string e
# parameters should match what was passed from the R package, and the "main" (non-alias)
# params values in `params` should be preferred to keyword argumentts or aliases
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[num_iterations\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[num_iterations:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
sprintf
(
"[num_iterations: %s]"
,
num_iterations
)),
1L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[early_stopping_round\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[early_stopping_round:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
sprintf
(
"[early_stopping_round: %s]"
,
early_stopping_round
)),
1L
)
# none of the aliases shouold have been written to the model file
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[num_boost_round\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[n_iter\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[n_iter_no_change\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[num_boost_round:"
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[n_iter:"
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[n_iter_no_change:"
)),
0L
)
})
...
...
@@ -1079,15 +1079,15 @@ test_that("lgb.cv() correctly handles passing through params to the model file",
# parameters should match what was passed from the R package, and the "main" (non-alias)
# params values in `params` should be preferred to keyword argumentts or aliases
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[num_iterations\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[num_iterations:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
sprintf
(
"[num_iterations: %s]"
,
num_iterations
)),
1L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[early_stopping_round\\:"
,
x
=
params_in_file
)),
1L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[early_stopping_round:"
)),
1L
)
expect_equal
(
sum
(
params_in_file
==
sprintf
(
"[early_stopping_round: %s]"
,
early_stopping_round
)),
1L
)
# none of the aliases shouold have been written to the model file
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[num_boost_round\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[n_iter\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
grepl
(
pattern
=
"^\\[n_iter_no_change\\:"
,
x
=
params_in_file
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[num_boost_round:"
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[n_iter:"
)),
0L
)
expect_equal
(
sum
(
startsWith
(
params_in_file
,
"[n_iter_no_change:"
)),
0L
)
}
})
...
...
@@ -1268,8 +1268,8 @@ test_that("Booster's print, show, and summary work correctly", {
}
.has_expected_content_for_fitted_model
<-
function
(
printed_txt
)
{
expect_true
(
any
(
grepl
(
"^
LightGBM Model"
,
printed_txt
)))
expect_true
(
any
(
grepl
(
"^
Fitted to dataset"
,
printed_txt
)))
expect_true
(
any
(
startsWith
(
printed_txt
,
"
LightGBM Model"
)))
expect_true
(
any
(
startsWith
(
printed_txt
,
"
Fitted to dataset"
)))
}
.has_expected_content_for_finalized_model
<-
function
(
printed_txt
)
{
...
...
build_r.R
View file @
1b43214f
...
...
@@ -404,7 +404,7 @@ dynlib_line <- grep(
)
c_api_contents
<-
readLines
(
file.path
(
TEMP_SOURCE_DIR
,
"src"
,
"lightgbm_R.h"
))
c_api_contents
<-
c_api_contents
[
grepl
(
"^
LIGHTGBM_C_EXPORT"
,
c_api_contents
)]
c_api_contents
<-
c_api_contents
[
startsWith
(
c_api_contents
,
"
LIGHTGBM_C_EXPORT"
)]
c_api_contents
<-
gsub
(
pattern
=
"LIGHTGBM_C_EXPORT SEXP "
,
replacement
=
""
...
...
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