[R] replace uses of T and F with TRUE and FALSE (#5778)
* [R-package] replace uses of T and F with TRUE and FALSE * enable linting * Remove skip Co-authored-by: Philip Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -12,7 +12,7 @@ flag_32bit = .Machine$sizeof.pointer != 8
|
||||
|
||||
set.seed(1982)
|
||||
data(Arthritis)
|
||||
df <- data.table(Arthritis, keep.rownames = F)
|
||||
df <- data.table(Arthritis, keep.rownames = FALSE)
|
||||
df[,AgeDiscret := as.factor(round(Age / 10,0))]
|
||||
df[,AgeCat := as.factor(ifelse(Age > 30, "Old", "Young"))]
|
||||
df[,ID := NULL]
|
||||
@@ -47,7 +47,7 @@ test_that("xgb.dump works", {
|
||||
if (!flag_32bit)
|
||||
expect_length(xgb.dump(bst.Tree), 200)
|
||||
dump_file = file.path(tempdir(), 'xgb.model.dump')
|
||||
expect_true(xgb.dump(bst.Tree, dump_file, with_stats = T))
|
||||
expect_true(xgb.dump(bst.Tree, dump_file, with_stats = TRUE))
|
||||
expect_true(file.exists(dump_file))
|
||||
expect_gt(file.size(dump_file), 8000)
|
||||
|
||||
@@ -160,7 +160,7 @@ test_that("SHAPs sum to predictions, with or without DART", {
|
||||
objective = "reg:squarederror",
|
||||
eval_metric = "rmse"),
|
||||
if (booster == "dart")
|
||||
list(rate_drop = .01, one_drop = T)),
|
||||
list(rate_drop = .01, one_drop = TRUE)),
|
||||
data = d,
|
||||
label = y,
|
||||
nrounds = nrounds)
|
||||
@@ -168,8 +168,8 @@ test_that("SHAPs sum to predictions, with or without DART", {
|
||||
pr <- function(...)
|
||||
predict(fit, newdata = d, ...)
|
||||
pred <- pr()
|
||||
shap <- pr(predcontrib = T)
|
||||
shapi <- pr(predinteraction = T)
|
||||
shap <- pr(predcontrib = TRUE)
|
||||
shapi <- pr(predinteraction = TRUE)
|
||||
tol = 1e-5
|
||||
|
||||
expect_equal(rowSums(shap), pred, tol = tol)
|
||||
|
||||
@@ -107,7 +107,7 @@ test_that("SHAP contribution values are not NAN", {
|
||||
|
||||
shaps <- as.data.frame(predict(fit,
|
||||
newdata = as.matrix(subset(d, fold == 1)[, ivs]),
|
||||
predcontrib = T))
|
||||
predcontrib = TRUE))
|
||||
result <- cbind(shaps, sum = rowSums(shaps), pred = predict(fit,
|
||||
newdata = as.matrix(subset(d, fold == 1)[, ivs])))
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
context("Code is of high quality and lint free")
|
||||
test_that("Code Lint", {
|
||||
skip_on_cran()
|
||||
skip_on_travis()
|
||||
skip_if_not_installed("lintr")
|
||||
my_linters <- list(
|
||||
absolute_paths_linter=lintr::absolute_paths_linter,
|
||||
assignment_linter=lintr::assignment_linter,
|
||||
@@ -21,7 +19,8 @@ test_that("Code Lint", {
|
||||
spaces_inside_linter=lintr::spaces_inside_linter,
|
||||
spaces_left_parentheses_linter=lintr::spaces_left_parentheses_linter,
|
||||
trailing_blank_lines_linter=lintr::trailing_blank_lines_linter,
|
||||
trailing_whitespace_linter=lintr::trailing_whitespace_linter
|
||||
trailing_whitespace_linter=lintr::trailing_whitespace_linter,
|
||||
true_false=lintr::T_and_F_symbol_linter
|
||||
)
|
||||
# lintr::expect_lint_free(linters=my_linters) # uncomment this if you want to check code quality
|
||||
lintr::expect_lint_free(linters=my_linters) # uncomment this if you want to check code quality
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user