Unverified Commit 1e5049a1 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

fixed cpplint issues (#2756)

parent 3670e476
......@@ -333,7 +333,6 @@ class FeatureGroup {
}
private:
void CreateBinData(int num_data, bool is_multi_val, bool force_dense, bool force_sparse) {
if (is_multi_val) {
multi_bin_data_.clear();
......
......@@ -16,8 +16,8 @@
#include <utility>
#include <vector>
#include "split_info.hpp"
#include "monotone_constraints.hpp"
#include "split_info.hpp"
namespace LightGBM {
......@@ -59,11 +59,11 @@ class FeatureHistogram {
meta_ = meta;
data_ = data;
if (meta_->bin_type == BinType::NumericalBin) {
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdNumerical, this, std::placeholders::_1
, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdNumerical, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
} else {
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdCategorical, this, std::placeholders::_1
, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
find_best_threshold_fun_ = std::bind(&FeatureHistogram::FindBestThresholdCategorical, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
}
rand_ = Random(meta_->config->extra_seed);
}
......@@ -495,9 +495,9 @@ class FeatureHistogram {
* \param sum_hessians
* \return leaf output
*/
static double
CalculateSplittedLeafOutput(double sum_gradients, double sum_hessians,
double l1, double l2, double max_delta_step, const ConstraintEntry& constraints) {
static double CalculateSplittedLeafOutput(double sum_gradients, double sum_hessians,
double l1, double l2, double max_delta_step,
const ConstraintEntry& constraints) {
double ret = CalculateSplittedLeafOutput(sum_gradients, sum_hessians, l1, l2, max_delta_step);
if (ret < constraints.min) {
ret = constraints.min;
......@@ -680,10 +680,10 @@ class FeatureHistogram {
/*! \brief random number generator for extremely randomized trees */
Random rand_;
std::function<void(double, double, data_size_t, const ConstraintEntry&,
SplitInfo*)>
find_best_threshold_fun_;
std::function<void(double, double, data_size_t, const ConstraintEntry&, SplitInfo*)>
find_best_threshold_fun_;
};
class HistogramPool {
public:
/*!
......
#ifndef LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_
#define LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_
/*!
* Copyright (c) 2020 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
#ifndef LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
#define LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
#include <limits>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <limits>
#include <vector>
namespace LightGBM {
......@@ -12,7 +16,7 @@ struct ConstraintEntry {
double min = -std::numeric_limits<double>::max();
double max = std::numeric_limits<double>::max();
ConstraintEntry(){};
ConstraintEntry() {}
void Reset() {
min = -std::numeric_limits<double>::max();
......@@ -22,20 +26,21 @@ struct ConstraintEntry {
void UpdateMin(double new_min) { min = std::max(new_min, min); }
void UpdateMax(double new_max) { max = std::min(new_max, max); }
};
template <typename ConstraintEntry>
class LeafConstraints {
public:
LeafConstraints(int num_leaves) : num_leaves_(num_leaves) {
explicit LeafConstraints(int num_leaves) : num_leaves_(num_leaves) {
entries_.resize(num_leaves_);
}
void Reset() {
for (auto& entry : entries_) {
entry.Reset();
}
}
void UpdateConstraints(bool is_numerical_split, int leaf, int new_leaf,
int8_t monotone_type, double right_output,
double left_output) {
......@@ -59,5 +64,5 @@ class LeafConstraints {
std::vector<ConstraintEntry> entries_;
};
} // namespace LightGBM
#endif // LightGBM_TREELEARNER_MONOTONE_CONSTRAINTS_H_
} // namespace LightGBM
#endif // LIGHTGBM_TREELEARNER_MONOTONE_CONSTRAINTS_HPP_
......@@ -21,8 +21,8 @@
#include "data_partition.hpp"
#include "feature_histogram.hpp"
#include "leaf_splits.hpp"
#include "split_info.hpp"
#include "monotone_constraints.hpp"
#include "split_info.hpp"
#ifdef USE_GPU
// Use 4KBytes aligned allocator for ordered gradients and ordered hessians when GPU is enabled.
......@@ -158,7 +158,7 @@ class SerialTreeLearner: public TreeLearner {
std::vector<SplitInfo> best_split_per_leaf_;
/*! \brief store best split per feature for all leaves */
std::vector<SplitInfo> splits_per_leaf_;
// Stores minimum and maximum constraints for each leaf
/*! \brief stores minimum and maximum constraints for each leaf */
std::unique_ptr<LeafConstraints<ConstraintEntry>> constraints_;
/*! \brief stores best thresholds for all feature for smaller leaf */
......
......@@ -399,7 +399,6 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons
}
if (larger_is_feature_aggregated_[feature_index]) {
// restore from buffer
larger_leaf_histogram_array_global_[feature_index].FromMemory(output_buffer_.data() + larger_buffer_read_start_pos_[feature_index]);
......@@ -409,7 +408,7 @@ void VotingParallelTreeLearner<TREELEARNER_T>::FindBestSplitsFromHistograms(cons
this->ComputeBestSplitForFeature(
larger_leaf_histogram_array_global_.get(), feature_index,
real_feature_index,
real_feature_index,
larger_node_used_features[feature_index],
GetGlobalDataCountInLeaf(larger_leaf_splits_global_->leaf_index()),
larger_leaf_splits_global_.get(),
......
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