[R] [CI] use lintr 3.1.0 (#9456)

This commit is contained in:
James Lamb
2023-08-10 17:49:16 +08:00
committed by GitHub
parent 1caa93221a
commit 4359356d46
5 changed files with 16 additions and 8 deletions
+1 -2
View File
@@ -86,8 +86,7 @@ xgb.model.dt.tree <- function(feature_names = NULL, model = NULL, text = NULL,
text <- xgb.dump(model = model, with_stats = TRUE)
}
if (length(text) < 2 ||
sum(grepl('leaf=(\\d+)', text)) < 1) {
if (length(text) < 2 || !any(grepl('leaf=(\\d+)', text))) {
stop("Non-tree model detected! This function can only be used with tree models.")
}
+1 -1
View File
@@ -136,7 +136,7 @@ get.leaf.depth <- function(dt_tree) {
# list of paths to each leaf in a tree
paths <- lapply(paths_tmp$vpath, names)
# combine into a resulting path lengths table for a tree
data.table(Depth = sapply(paths, length), ID = To[Leaf == TRUE])
data.table(Depth = lengths(paths), ID = To[Leaf == TRUE])
}, by = Tree]
}