Skip to content

Commit

Permalink
Merge branch 'master' into ci/cran-asan
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Oct 22, 2021
2 parents eddfffd + a2b60e8 commit 8ab7e25
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 19 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ if(BUILD_CPP_TEST)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
GIT_TAG release-1.11.0
)
FetchContent_MakeAvailable(googletest)
add_library(GTest::GTest ALIAS gtest)
Expand Down
6 changes: 6 additions & 0 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Booster <- R6::R6Class(
stop("lgb.Booster: Can only use a string as model file path")
}

modelfile <- path.expand(modelfile)

# Create booster from model
handle <- .Call(
LGBM_BoosterCreateFromModelfile_R
Expand Down Expand Up @@ -425,6 +427,8 @@ Booster <- R6::R6Class(
num_iteration <- self$best_iter
}

filename <- path.expand(filename)

.Call(
LGBM_BoosterSaveModel_R
, private$handle
Expand Down Expand Up @@ -857,6 +861,7 @@ lgb.load <- function(filename = NULL, model_str = NULL) {
if (!is.character(filename)) {
stop("lgb.load: filename should be character")
}
filename <- path.expand(filename)
if (!file.exists(filename)) {
stop(sprintf("lgb.load: file '%s' passed to filename does not exist", filename))
}
Expand Down Expand Up @@ -917,6 +922,7 @@ lgb.save <- function(booster, filename, num_iteration = NULL) {
if (!(is.character(filename) && length(filename) == 1L)) {
stop("lgb.save: filename should be a string")
}
filename <- path.expand(filename)

# Store booster
return(
Expand Down
4 changes: 2 additions & 2 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Dataset <- R6::R6Class(

handle <- .Call(
LGBM_DatasetCreateFromFile_R
, private$raw_data
, path.expand(private$raw_data)
, params_str
, ref_handle
)
Expand Down Expand Up @@ -742,7 +742,7 @@ Dataset <- R6::R6Class(
.Call(
LGBM_DatasetSaveBinary_R
, private$handle
, fname
, path.expand(fname)
)
return(invisible(self))
}
Expand Down
4 changes: 3 additions & 1 deletion R-package/R/lgb.Predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Predictor <- R6::R6Class(
# Create handle on it
handle <- .Call(
LGBM_BoosterCreateFromModelfile_R
, modelfile
, path.expand(modelfile)
)
private$need_free_handle <- TRUE

Expand Down Expand Up @@ -96,6 +96,8 @@ Predictor <- R6::R6Class(
# Check if data is a file name and not a matrix
if (identical(class(data), "character") && length(data) == 1L) {

data <- path.expand(data)

# Data is a filename, create a temporary file with a "lightgbm_" pattern in it
tmp_filename <- tempfile(pattern = "lightgbm_")
on.exit(unlink(tmp_filename), add = TRUE)
Expand Down
11 changes: 7 additions & 4 deletions R-package/pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ development:
mode: unreleased

authors:
Yu Shi:
href: https://github.com/shiyu1994
html: <img src="https://avatars.githubusercontent.com/u/14541765?s=400&v=4" height="48" /> Yu Shi
Guolin Ke:
href: https://github.com/guolinke
html: <img src="https://avatars0.githubusercontent.com/u/16040950?s=400&v=4" height="48" /> Guolin Ke
html: <img src="https://avatars.githubusercontent.com/u/16040950?s=400&v=4" height="48" /> Guolin Ke
Damien Soukhavong:
href: https://github.com/Laurae2
html: <img src="https://avatars1.githubusercontent.com/u/9083669?s=460&v=4" height="48" /> Damien Soukhavong
html: <img src="https://avatars.githubusercontent.com/u/9083669?s=400&v=4" height="48" /> Damien Soukhavong
Yachen Yan:
href: https://github.com/yanyachen
html: <img src="https://avatars1.githubusercontent.com/u/6893682?s=460&v=4" height="48" /> Yachen Yan
html: <img src="https://avatars.githubusercontent.com/u/6893682?s=400&v=4" height="48" /> Yachen Yan
James Lamb:
href: https://github.com/jameslamb
html: <img src="https://avatars1.githubusercontent.com/u/7608904?s=400&v=4" height="48" /> James Lamb
html: <img src="https://avatars.githubusercontent.com/u/7608904?s=400&v=4" height="48" /> James Lamb

navbar:
title: LightGBM
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def generate_doxygen_xml(app: Sphinx) -> None:
"MACRO_EXPANSION=YES",
"EXPAND_ONLY_PREDEF=NO",
"SKIP_FUNCTION_MACROS=NO",
"PREDEFINED=__cplusplus",
"SORT_BRIEF_DOCS=YES",
"WARN_AS_ERROR=YES",
]
Expand Down
18 changes: 12 additions & 6 deletions include/LightGBM/c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1329,19 +1329,25 @@ LIGHTGBM_C_EXPORT int LGBM_NetworkInitWithFunctions(int num_machines,
void* allgather_ext_fun);

#if !defined(__cplusplus) && (!defined(__STDC__) || (__STDC_VERSION__ < 199901L))
#define INLINE_FUNCTION /*!< \brief inline specifier no-op in C using standards before C99. */
/*! \brief Inline specifier no-op in C using standards before C99. */
#define INLINE_FUNCTION
#else
#define INLINE_FUNCTION inline /*!< \brief Inline specifier. */
/*! \brief Inline specifier. */
#define INLINE_FUNCTION inline
#endif

#if !defined(__cplusplus) && (!defined(__STDC__) || (__STDC_VERSION__ < 201112L))
#define THREAD_LOCAL /*!< \brief Thread local specifier no-op in C using standards before C11. */
/*! \brief Thread local specifier no-op in C using standards before C11. */
#define THREAD_LOCAL
#elif !defined(__cplusplus)
#define THREAD_LOCAL _Thread_local /*!< \brief Thread local specifier. */
/*! \brief Thread local specifier. */
#define THREAD_LOCAL _Thread_local
#elif defined(_MSC_VER)
#define THREAD_LOCAL __declspec(thread) /*!< \brief Thread local specifier. */
/*! \brief Thread local specifier. */
#define THREAD_LOCAL __declspec(thread)
#else
#define THREAD_LOCAL thread_local /*!< \brief Thread local specifier. */
/*! \brief Thread local specifier. */
#define THREAD_LOCAL thread_local
#endif

/*!
Expand Down
2 changes: 1 addition & 1 deletion include/LightGBM/dataset_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DatasetLoader {
/*! \brief Random generator*/
Random random_;
/*! \brief prediction function for initial model */
const PredictFunction& predict_fun_;
const PredictFunction predict_fun_;
/*! \brief number of classes */
int num_class_;
/*! \brief index of label column */
Expand Down
3 changes: 1 addition & 2 deletions python-package/lightgbm/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ def train(

if num_boost_round <= 0:
raise ValueError("num_boost_round should be greater than zero.")
predictor: Optional[_InnerPredictor] = None
if isinstance(init_model, (str, Path)):
predictor = _InnerPredictor(model_file=init_model, pred_parameter=params)
elif isinstance(init_model, Booster):
predictor = init_model._to_predictor(dict(init_model.params, **params))
else:
predictor = None
init_iteration = predictor.num_total_iteration if predictor is not None else 0
# check dataset
if not isinstance(train_set, Dataset):
Expand Down
4 changes: 2 additions & 2 deletions src/io/dataset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
double tmp_label = 0.0f;
auto& ref_text_data = *text_data;
std::vector<float> feature_row(dataset->num_features_);
if (predict_fun_ == nullptr) {
if (!predict_fun_) {
OMP_INIT_EX();
// if doesn't need to prediction with initial model
#pragma omp parallel for schedule(static) private(oneline_features) firstprivate(tmp_label, feature_row)
Expand Down Expand Up @@ -1262,7 +1262,7 @@ void DatasetLoader::ExtractFeaturesFromMemory(std::vector<std::string>* text_dat
void DatasetLoader::ExtractFeaturesFromFile(const char* filename, const Parser* parser,
const std::vector<data_size_t>& used_data_indices, Dataset* dataset) {
std::vector<double> init_score;
if (predict_fun_ != nullptr) {
if (predict_fun_) {
init_score = std::vector<double>(dataset->num_data_ * num_class_);
}
std::function<void(data_size_t, const std::vector<std::string>&)> process_fun =
Expand Down

0 comments on commit 8ab7e25

Please sign in to comment.