"vscode:/vscode.git/clone" did not exist on "a1a4103797fd320f5379f9ad399affd34e50c6a5"
Commit 90127b52 authored by Nikita Titov's avatar Nikita Titov Committed by Guolin Ke
Browse files

cpplint whitespaces and new lines (#1986)

parent 6f548ada
......@@ -298,9 +298,9 @@ def gen_parameter_code(config_hpp, config_out_cpp):
name = y["name"][0]
if "vector" in param_type:
if "int8" in param_type:
str_to_write += " str_buf << \"[%s: \" << Common::Join(Common::ArrayCast<int8_t, int>(%s),\",\") << \"]\\n\";\n" % (name, name)
str_to_write += " str_buf << \"[%s: \" << Common::Join(Common::ArrayCast<int8_t, int>(%s), \",\") << \"]\\n\";\n" % (name, name)
else:
str_to_write += " str_buf << \"[%s: \" << Common::Join(%s,\",\") << \"]\\n\";\n" % (name, name)
str_to_write += " str_buf << \"[%s: \" << Common::Join(%s, \",\") << \"]\\n\";\n" % (name, name)
else:
str_to_write += " str_buf << \"[%s: \" << %s << \"]\\n\";\n" % (name, name)
# tails
......
......@@ -33,7 +33,6 @@ public:
inline void Run();
private:
/*! \brief Load parameters from command line and config file*/
void LoadParameters(int argc, char** argv);
......
......@@ -291,7 +291,6 @@ public:
* \return The boosting object
*/
static Boosting* CreateBoosting(const std::string& type, const char* filename);
};
class GBDTBase : public Boosting {
......
......@@ -771,6 +771,7 @@ public:
LIGHTGBM_EXPORT void Set(const std::unordered_map<std::string, std::string>& params);
static std::unordered_map<std::string, std::string> alias_table;
static std::unordered_set<std::string> parameter_set;
private:
void CheckParamConflict();
void GetMembersFromString(const std::unordered_map<std::string, std::string>& params);
......
......@@ -117,8 +117,7 @@ public:
* \param idx Index of this record
* \param value Label value of this record
*/
inline void SetLabelAt(data_size_t idx, label_t value)
{
inline void SetLabelAt(data_size_t idx, label_t value) {
label_[idx] = value;
}
......@@ -127,8 +126,7 @@ public:
* \param idx Index of this record
* \param value Weight value of this record
*/
inline void SetWeightAt(data_size_t idx, label_t value)
{
inline void SetWeightAt(data_size_t idx, label_t value) {
weights_[idx] = value;
}
......@@ -137,8 +135,7 @@ public:
* \param idx Index of this record
* \param value Query Id value of this record
*/
inline void SetQueryAt(data_size_t idx, data_size_t value)
{
inline void SetQueryAt(data_size_t idx, data_size_t value) {
queries_[idx] = static_cast<data_size_t>(value);
}
......@@ -251,7 +248,6 @@ private:
/*! \brief Interface for Parser */
class Parser {
public:
/*! \brief virtual destructor */
virtual ~Parser() {}
......@@ -550,13 +546,13 @@ public:
feature_names_ = std::vector<std::string>(feature_names);
// replace ' ' in feature_names with '_'
bool spaceInFeatureName = false;
for (auto& feature_name: feature_names_){
if (feature_name.find(' ') != std::string::npos){
for (auto& feature_name : feature_names_) {
if (feature_name.find(' ') != std::string::npos) {
spaceInFeatureName = true;
std::replace(feature_name.begin(), feature_name.end(), ' ', '_');
}
}
if (spaceInFeatureName){
if (spaceInFeatureName) {
Log::Warning("Find whitespaces in feature_names, replace with underlines");
}
}
......
......@@ -7,7 +7,6 @@ namespace LightGBM {
class DatasetLoader {
public:
LIGHTGBM_EXPORT DatasetLoader(const Config& io_config, const PredictFunction& predict_fun, int num_class, const char* filename);
LIGHTGBM_EXPORT ~DatasetLoader();
......@@ -30,7 +29,6 @@ public:
DatasetLoader(const DatasetLoader&) = delete;
private:
Dataset* LoadFromBinFile(const char* data_filename, const char* bin_filename, int rank, int num_machines, int* num_global_data, std::vector<data_size_t>* used_data_indices);
void SetHeader(const char* filename);
......
......@@ -176,7 +176,6 @@ public:
} else {
return bin_data_->SplitCategorical(min_bin, max_bin, default_bin, threshold, num_threshold, data_indices, num_data, lte_indices, gt_indices);
}
}
/*!
* \brief From bin to feature value
......
......@@ -51,7 +51,6 @@ public:
* \param config Config for metric
*/
LIGHTGBM_EXPORT static Metric* CreateMetric(const std::string& type, const Config& config);
};
/*!
......@@ -59,7 +58,6 @@ public:
*/
class DCGCalculator {
public:
static void DefaultEvalAt(std::vector<int>* eval_at);
static void DefaultLabelGain(std::vector<double>* label_gain);
/*!
......
......@@ -257,7 +257,6 @@ public:
}
private:
static void AllgatherBruck(char* input, const comm_size_t* block_start, const comm_size_t* block_len, char* output, comm_size_t all_size);
static void AllgatherRecursiveDoubling(char* input, const comm_size_t* block_start, const comm_size_t* block_len, char* output, comm_size_t all_size);
......
......@@ -204,7 +204,6 @@ public:
void RecomputeMaxDepth();
private:
std::string NumericalDecisionIfElse(int node) const;
std::string CategoricalDecisionIfElse(int node) const;
......@@ -332,7 +331,7 @@ private:
PathElement(int i, double z, double o, double w) : feature_index(i), zero_fraction(z), one_fraction(o), pweight(w) {}
};
/*! \brief Polynomial time algorithm for SHAP values (https://arxiv.org/abs/1706.06060) */
/*! \brief Polynomial time algorithm for SHAP values (https://arxiv.org/abs/1706.06060)*/
void TreeSHAP(const double *feature_values, double *phi,
int node, int unique_depth,
PathElement *parent_unique_path, double parent_zero_fraction,
......
......@@ -22,7 +22,7 @@ public:
}
int step = std::max(1, (static_cast<int>(array.size()) + num_threads - 1) / num_threads);
std::vector<size_t> arg_maxs(num_threads, 0);
#pragma omp parallel for schedule(static,1)
#pragma omp parallel for schedule(static, 1)
for (int i = 0; i < num_threads; ++i) {
size_t start = step * i;
if (start >= array.size()) { continue; }
......@@ -124,7 +124,7 @@ public:
for (int k = end - 2; k >= q; k--, i++) { std::swap(ref[i], ref[k]); }
*l = j;
*r = i;
};
}
// Note: k refer to index here. e.g. k=0 means get the max number.
inline static int ArgMaxAtK(std::vector<VAL_T>* arr, int start, int end, int k) {
......@@ -184,7 +184,6 @@ public:
}
return true;
}
};
} // namespace LightGBM
......
......@@ -317,16 +317,16 @@ inline static unsigned CountDecimalDigit32(uint32_t n) {
inline static void Uint32ToStr(uint32_t value, char* buffer) {
const char kDigitsLut[200] = {
'0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',
'1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',
'2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',
'3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',
'4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',
'5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',
'6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',
'7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',
'8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',
'9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
'1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
'2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
'3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
'4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
'5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
'6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
'7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
'8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
'9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'
};
unsigned digit = CountDecimalDigit32(value);
buffer += digit;
......@@ -395,7 +395,7 @@ inline static std::vector<T2> ArrayCast(const std::vector<T>& arr) {
template<typename T, bool is_float, bool is_unsign>
struct __TToStringHelperFast {
void operator()(T value, char* buffer, size_t ) const {
void operator()(T value, char* buffer, size_t) const {
Int32ToStr(value, buffer);
}
};
......@@ -417,7 +417,7 @@ struct __TToStringHelperFast<T, true, false> {
template<typename T>
struct __TToStringHelperFast<T, false, true> {
void operator()(T value, char* buffer, size_t ) const {
void operator()(T value, char* buffer, size_t) const {
Uint32ToStr(value, buffer);
}
};
......@@ -512,7 +512,7 @@ struct __StringToTHelperFast<T, true> {
const char* operator()(const char*p, T* out) const {
double tmp = 0.0f;
auto ret = Atof(p, &tmp);
*out= static_cast<T>(tmp);
*out = static_cast<T>(tmp);
return ret;
}
};
......@@ -637,7 +637,6 @@ inline static void SortForPair(std::vector<T1>& keys, std::vector<T2>& values, s
keys[i] = arr[i].first;
values[i] = arr[i].second;
}
}
template <typename T>
......@@ -661,7 +660,7 @@ inline static std::vector<int> VectorSize(const std::vector<std::vector<T>>& dat
inline static double AvoidInf(double x) {
if (x >= 1e300) {
return 1e300;
} else if(x <= -1e300) {
} else if (x <= -1e300) {
return -1e300;
} else {
return x;
......@@ -700,7 +699,7 @@ static void ParallelSort(_RanIt _First, _RanIt _Last, _Pr _Pred, _VTRanIt*) {
size_t inner_size = (len + num_threads - 1) / num_threads;
inner_size = std::max(inner_size, kMinInnerLen);
num_threads = static_cast<int>((len + inner_size - 1) / inner_size);
#pragma omp parallel for schedule(static,1)
#pragma omp parallel for schedule(static, 1)
for (int i = 0; i < num_threads; ++i) {
size_t left = inner_size*i;
size_t right = left + inner_size;
......@@ -716,7 +715,7 @@ static void ParallelSort(_RanIt _First, _RanIt _Last, _Pr _Pred, _VTRanIt*) {
// Recursive merge
while (s < len) {
int loop_size = static_cast<int>((len + s * 2 - 1) / (s * 2));
#pragma omp parallel for schedule(static,1)
#pragma omp parallel for schedule(static, 1)
for (int i = 0; i < loop_size; ++i) {
size_t left = i * 2 * s;
size_t mid = left + s;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment