Skip to content

Commit

Permalink
Merge branch 'master' into arrow-support
Browse files Browse the repository at this point in the history
  • Loading branch information
borchero committed Aug 5, 2023
2 parents ab2d5e2 + 20975ba commit 570ca64
Show file tree
Hide file tree
Showing 23 changed files with 278 additions and 354 deletions.
20 changes: 15 additions & 5 deletions .ci/lint_r_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,37 @@ LINTERS_TO_USE <- list(
, "any_duplicated" = lintr::any_duplicated_linter()
, "any_is_na" = lintr::any_is_na_linter()
, "assignment" = lintr::assignment_linter()
, "boolean_arithmetic" = lintr::boolean_arithmetic_linter()
, "braces" = lintr::brace_linter()
, "class_equals" = lintr::class_equals_linter()
, "commas" = lintr::commas_linter()
, "duplicate_argument" = lintr::duplicate_argument_linter()
, "empty_assignment" = lintr::empty_assignment_linter()
, "equals_na" = lintr::equals_na_linter()
, "for_loop_index" = lintr::for_loop_index_linter()
, "function_left" = lintr::function_left_parentheses_linter()
, "implicit_integers" = lintr::implicit_integer_linter()
, "infix_spaces" = lintr::infix_spaces_linter()
, "inner_combine" = lintr::inner_combine_linter()
, "is_numeric" = lintr::is_numeric_linter()
, "fixed_regex" = lintr::fixed_regex_linter()
, "function_return" = lintr::function_return_linter()
, "lengths" = lintr::lengths_linter()
, "literal_coercion" = lintr::literal_coercion_linter()
, "long_lines" = lintr::line_length_linter(length = 120L)
, "matrix" = lintr::matrix_apply_linter()
, "missing_argument" = lintr::missing_argument_linter()
, "no_tabs" = lintr::no_tab_linter()
, "non_portable_path" = lintr::nonportable_path_linter()
, "numeric_leading_zero" = lintr::numeric_leading_zero_linter()
, "outer_negation" = lintr::outer_negation_linter()
, "package_hooks" = lintr::package_hooks_linter()
, "paste" = lintr::paste_linter()
, "quotes" = lintr::quotes_linter()
, "redundant_equals" = lintr::redundant_equals_linter()
, "regex_subset" = lintr::regex_subset_linter()
, "routine_registration" = lintr::routine_registration_linter()
, "semicolon" = lintr::semicolon_linter()
, "seq" = lintr::seq_linter()
, "single_quotes" = lintr::single_quotes_linter()
, "spaces_inside" = lintr::spaces_inside_linter()
, "spaces_left_parens" = lintr::spaces_left_parentheses_linter()
, "sprintf" = lintr::sprintf_linter()
Expand Down Expand Up @@ -96,9 +104,11 @@ LINTERS_TO_USE <- list(
, "??" = interactive_text
)
)
, "unneeded_concatenation" = lintr::unneeded_concatenation_linter()
, "unreachable_code" = lintr::unreachable_code_linter()
, "vector_logic" = lintr::vector_logic_linter()
, "unnecessary_concatenation" = lintr::unnecessary_concatenation_linter()
, "unnecessary_lambda" = lintr::unnecessary_lambda_linter()
, "unreachable_code" = lintr::unreachable_code_linter()
, "vector_logic" = lintr::vector_logic_linter()
, "whitespace" = lintr::whitespace_linter()
)

noquote(paste0(length(FILES_TO_LINT), " R files need linting"))
Expand Down
2 changes: 1 addition & 1 deletion .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if [[ $TASK == "lint" ]]; then
cpplint \
isort \
mypy \
'r-lintr>=3.0' \
'r-lintr>=3.1' \
ruff
source activate $CONDA_ENV
echo "Linting Python code"
Expand Down
2 changes: 1 addition & 1 deletion .ci/test_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if (($env:TASK -eq "regular") -or (($env:APPVEYOR -eq "true") -and ($env:TASK -e
cd $env:BUILD_SOURCESDIRECTORY/examples/python-guide
@("import matplotlib", "matplotlib.use('Agg')") + (Get-Content "plot_example.py") | Set-Content "plot_example.py"
(Get-Content "plot_example.py").replace('graph.render(view=True)', 'graph.render(view=False)') | Set-Content "plot_example.py" # prevent interactive window mode
conda install -q -y -n $env:CONDA_ENV h5py ipywidgets notebook
conda install -q -y -n $env:CONDA_ENV "h5py>3.0" ipywidgets notebook
foreach ($file in @(Get-ChildItem *.py)) {
@("import sys, warnings", "warnings.showwarning = lambda message, category, filename, lineno, file=None, line=None: sys.stdout.write(warnings.formatwarning(message, category, filename, lineno, line))") + (Get-Content $file) | Set-Content $file
python $file ; Check-Output $?
Expand Down
54 changes: 1 addition & 53 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,4 @@
# offer a reasonable automatic best-guess

# catch-all rule (this only gets matched if no rules below match)
* @guolinke @StrikerRUS @jameslamb @shiyu1994

# other catch-alls that will get matched if specific rules below are not matched
*.R @jameslamb @jmoralez
*.py @StrikerRUS @jmoralez @jameslamb @shiyu1994
*.cpp @guolinke @shiyu1994
*.h @guolinke @shiyu1994

# main C++ code
include/ @guolinke @shiyu1994
src/ @guolinke @shiyu1994
CMakeLists.txt @guolinke @jameslamb @StrikerRUS @shiyu1994
tests/c_api_test/ @guolinke @shiyu1994
tests/cpp_tests/ @guolinke @shiyu1994
tests/data/ @guolinke @shiyu1994
windows/ @guolinke @StrikerRUS @shiyu1994

# R code
build_r.R @jameslamb @StrikerRUS @jmoralez
build-cran-package.sh @jameslamb @StrikerRUS @jmoralez
R-package/ @jameslamb @jmoralez

# Python code
python-package/ @StrikerRUS @shiyu1994 @jameslamb @jmoralez

# Dask integration
python-package/lightgbm/dask.py @jameslamb @jmoralez
tests/python_package_test/test_dask.py @jameslamb @jmoralez

# helpers
helpers/ @StrikerRUS @guolinke

# CI administrative stuff
.ci/ @StrikerRUS @jameslamb
docs/ @StrikerRUS @jameslamb
examples/ @StrikerRUS @jameslamb @guolinke @jmoralez
*.yml @StrikerRUS @jameslamb
.vsts-ci.yml @StrikerRUS @jameslamb

# docker setup
docker/ @StrikerRUS @jameslamb
docker/dockerfile-cli @guolinke @shiyu1994 @StrikerRUS @jameslamb
docker/gpu/ @StrikerRUS @jameslamb
docker/dockerfile-python @StrikerRUS @shiyu1994 @jameslamb @jmoralez
docker/dockerfile-r @jameslamb @jmoralez

# GPU code
docs/GPU-*.rst @shiyu1994 @guolinke
src/treelearner/gpu_tree_learner.cpp @guolinke @shiyu1994
src/treelearner/tree_learner.cpp @guolinke @shiyu1994

# JAVA code
swig/ @guolinke @shiyu1994
* @guolinke @jameslamb @shiyu1994 @jmoralez
7 changes: 3 additions & 4 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,10 @@ Dataset <- R6::R6Class(
if (info_len > 0L) {

# Get back fields
ret <- NULL
ret <- if (field_name == "group") {
integer(info_len)
if (field_name == "group") {
ret <- integer(info_len)
} else {
numeric(info_len)
ret <- numeric(info_len)
}

.Call(
Expand Down
2 changes: 0 additions & 2 deletions R-package/R/lgb.Predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ Predictor <- R6::R6Class(
start_iteration <- 0L
}

num_row <- 0L

# Check if data is a file name and not a matrix
if (identical(class(data), "character") && length(data) == 1L) {

Expand Down
4 changes: 0 additions & 4 deletions R-package/R/lgb.convert_with_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ lgb.convert_with_rules <- function(data, rules = NULL) {

column_classes <- .get_column_classes(df = data)

is_char <- which(column_classes == "character")
is_factor <- which(column_classes == "factor")
is_logical <- which(column_classes == "logical")

is_data_table <- data.table::is.data.table(x = data)
is_data_frame <- is.data.frame(data)

Expand Down
2 changes: 0 additions & 2 deletions R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ lgb.cv <- function(params = list()
stop(sQuote("folds"), " must be a list with 2 or more elements that are vectors of indices for each CV-fold")
}

nfold <- length(folds)

} else {

if (nfold <= 1L) {
Expand Down
4 changes: 3 additions & 1 deletion R-package/R/lgb.interprete.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ lgb.interprete <- function(model,
leaf_index_dt <- data.table::as.data.table(x = pred_mat)
leaf_index_mat_list <- lapply(
X = leaf_index_dt
, FUN = function(x) matrix(x, ncol = num_class, byrow = TRUE)
, FUN = matrix
, ncol = num_class
, byrow = TRUE
)

# Get list of trees
Expand Down
8 changes: 3 additions & 5 deletions R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ lgb.train <- function(params = list(),

# Construct datasets, if needed
data$update_params(params = params)
if (!is.null(categorical_feature)) {
data$set_categorical_feature(categorical_feature)
}
data$construct()

# Check interaction constraints
Expand All @@ -179,11 +182,6 @@ lgb.train <- function(params = list(),
data$set_colnames(colnames)
}

# Write categorical features
if (!is.null(categorical_feature)) {
data$set_categorical_feature(categorical_feature)
}

valid_contain_train <- FALSE
train_data_name <- "train"
reduced_valid_sets <- list()
Expand Down
19 changes: 19 additions & 0 deletions R-package/tests/testthat/helper.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ref for this file:
#
# * https://r-pkgs.org/testing-design.html#testthat-helper-files
# * https://r-pkgs.org/testing-design.html#testthat-setup-files

# LightGBM-internal fix to comply with CRAN policy of only using up to 2 threads in tests and example.
Expand All @@ -10,3 +11,21 @@
# the check farm is a shared resource and will typically be running many checks simultaneously.
#
.LGB_MAX_THREADS <- 2L

# by default, how much should results in tests be allowed to differ from hard-coded expected numbers?
.LGB_NUMERIC_TOLERANCE <- 1e-6

# are the tests running on Windows?
.LGB_ON_WINDOWS <- .Platform$OS.type == "windows"
.LGB_ON_32_BIT_WINDOWS <- .LGB_ON_WINDOWS && .Machine$sizeof.pointer != 8L

# are the tests running in a UTF-8 locale?
.LGB_UTF8_LOCALE <- all(endsWith(
Sys.getlocale(category = "LC_CTYPE")
, "UTF-8"
))

# control how many loud LightGBM's logger is in tests
.LGB_VERBOSITY <- as.integer(
Sys.getenv("LIGHTGBM_TEST_VERBOSITY", "-1")
)
Loading

0 comments on commit 570ca64

Please sign in to comment.