Commit 8425fbea authored by Tony-Y's avatar Tony-Y Committed by Qiwei Ye
Browse files

Fix coding style (#969) (#970)

Function names must be in the "Pascal Case" style.

* check_elements_interval_closed to CheckElementsIntervalClosed

* obtain_min_max_sum to ObtainMinMaxSum
parent d3e88ef5
...@@ -580,7 +580,7 @@ static void ParallelSort(_RanIt _First, _RanIt _Last, _Pr _Pred) { ...@@ -580,7 +580,7 @@ static void ParallelSort(_RanIt _First, _RanIt _Last, _Pr _Pred) {
} }
// Check that all y[] are in interval [ymin, ymax] (end points included); throws error if not // Check that all y[] are in interval [ymin, ymax] (end points included); throws error if not
inline void check_elements_interval_closed(const float *y, float ymin, float ymax, int ny, const char *callername) { inline void CheckElementsIntervalClosed(const float *y, float ymin, float ymax, int ny, const char *callername) {
for (int i = 0; i < ny; ++i) { for (int i = 0; i < ny; ++i) {
if (y[i] < ymin || y[i] > ymax) { if (y[i] < ymin || y[i] > ymax) {
Log::Fatal("[%s]: does not tolerate element [#%i = %f] outside [%f, %f]", callername, i, y[i], ymin, ymax); Log::Fatal("[%s]: does not tolerate element [#%i = %f] outside [%f, %f]", callername, i, y[i], ymin, ymax);
...@@ -590,7 +590,7 @@ inline void check_elements_interval_closed(const float *y, float ymin, float yma ...@@ -590,7 +590,7 @@ inline void check_elements_interval_closed(const float *y, float ymin, float yma
// One-pass scan over array w with nw elements: find min, max and sum of elements; // One-pass scan over array w with nw elements: find min, max and sum of elements;
// this is useful for checking weight requirements. // this is useful for checking weight requirements.
inline void obtain_min_max_sum(const float *w, int nw, float *mi, float *ma, double *su) { inline void ObtainMinMaxSum(const float *w, int nw, float *mi, float *ma, double *su) {
float minw = w[0]; float minw = w[0];
float maxw = w[0]; float maxw = w[0];
double sumw = static_cast<double>(w[0]); double sumw = static_cast<double>(w[0]);
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
CHECK_NOTNULL(label_); CHECK_NOTNULL(label_);
// ensure that labels are in interval [0, 1], interval ends included // ensure that labels are in interval [0, 1], interval ends included
Common::check_elements_interval_closed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str()); Common::CheckElementsIntervalClosed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str());
Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__); Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__);
// check that weights are non-negative and sum is positive // check that weights are non-negative and sum is positive
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
sum_weights_ = static_cast<double>(num_data_); sum_weights_ = static_cast<double>(num_data_);
} else { } else {
float minw; float minw;
Common::obtain_min_max_sum(weights_, num_data_, &minw, nullptr, &sum_weights_); Common::ObtainMinMaxSum(weights_, num_data_, &minw, nullptr, &sum_weights_);
if (minw < 0.0f) { if (minw < 0.0f) {
Log::Fatal("[%s:%s]: (metric) weights not allowed to be negative", GetName()[0].c_str(), __func__); Log::Fatal("[%s:%s]: (metric) weights not allowed to be negative", GetName()[0].c_str(), __func__);
} }
...@@ -172,13 +172,13 @@ public: ...@@ -172,13 +172,13 @@ public:
weights_ = metadata.weights(); weights_ = metadata.weights();
CHECK_NOTNULL(label_); CHECK_NOTNULL(label_);
Common::check_elements_interval_closed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str()); Common::CheckElementsIntervalClosed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str());
Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__); Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__);
// check all weights are strictly positive; throw error if not // check all weights are strictly positive; throw error if not
if (weights_ != nullptr) { if (weights_ != nullptr) {
float minw; float minw;
Common::obtain_min_max_sum(weights_, num_data_, &minw, nullptr, nullptr); Common::ObtainMinMaxSum(weights_, num_data_, &minw, nullptr, nullptr);
if (minw <= 0.0f) { if (minw <= 0.0f) {
Log::Fatal("[%s:%s]: (metric) all weights must be positive", GetName()[0].c_str(), __func__); Log::Fatal("[%s:%s]: (metric) all weights must be positive", GetName()[0].c_str(), __func__);
} }
...@@ -256,14 +256,14 @@ public: ...@@ -256,14 +256,14 @@ public:
weights_ = metadata.weights(); weights_ = metadata.weights();
CHECK_NOTNULL(label_); CHECK_NOTNULL(label_);
Common::check_elements_interval_closed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str()); Common::CheckElementsIntervalClosed(label_, 0.0f, 1.0f, num_data_, GetName()[0].c_str());
Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__); Log::Info("[%s:%s]: (metric) labels passed interval [0, 1] check", GetName()[0].c_str(), __func__);
if (weights_ == nullptr) { if (weights_ == nullptr) {
sum_weights_ = static_cast<double>(num_data_); sum_weights_ = static_cast<double>(num_data_);
} else { } else {
float minw; float minw;
Common::obtain_min_max_sum(weights_, num_data_, &minw, nullptr, &sum_weights_); Common::ObtainMinMaxSum(weights_, num_data_, &minw, nullptr, &sum_weights_);
if (minw < 0.0f) { if (minw < 0.0f) {
Log::Fatal("[%s:%s]: (metric) at least one weight is negative", GetName()[0].c_str(), __func__); Log::Fatal("[%s:%s]: (metric) at least one weight is negative", GetName()[0].c_str(), __func__);
} }
......
...@@ -318,7 +318,7 @@ public: ...@@ -318,7 +318,7 @@ public:
// Safety check of labels // Safety check of labels
float miny; float miny;
double sumy; double sumy;
Common::obtain_min_max_sum(label_, num_data_, &miny, nullptr, &sumy); Common::ObtainMinMaxSum(label_, num_data_, &miny, nullptr, &sumy);
if (miny < 0.0f) { if (miny < 0.0f) {
Log::Fatal("[%s]: at least one target label is negative.", GetName()); Log::Fatal("[%s]: at least one target label is negative.", GetName());
} }
......
...@@ -52,13 +52,13 @@ public: ...@@ -52,13 +52,13 @@ public:
weights_ = metadata.weights(); weights_ = metadata.weights();
CHECK_NOTNULL(label_); CHECK_NOTNULL(label_);
Common::check_elements_interval_closed(label_, 0.0f, 1.0f, num_data_, GetName()); Common::CheckElementsIntervalClosed(label_, 0.0f, 1.0f, num_data_, GetName());
Log::Info("[%s:%s]: (objective) labels passed interval [0, 1] check", GetName(), __func__); Log::Info("[%s:%s]: (objective) labels passed interval [0, 1] check", GetName(), __func__);
if (weights_ != nullptr) { if (weights_ != nullptr) {
float minw; float minw;
double sumw; double sumw;
Common::obtain_min_max_sum(weights_, num_data_, &minw, nullptr, &sumw); Common::ObtainMinMaxSum(weights_, num_data_, &minw, nullptr, &sumw);
if (minw < 0.0f) { if (minw < 0.0f) {
Log::Fatal("[%s]: at least one weight is negative.", GetName()); Log::Fatal("[%s]: at least one weight is negative.", GetName());
} }
...@@ -158,12 +158,12 @@ public: ...@@ -158,12 +158,12 @@ public:
weights_ = metadata.weights(); weights_ = metadata.weights();
CHECK_NOTNULL(label_); CHECK_NOTNULL(label_);
Common::check_elements_interval_closed(label_, 0.0f, 1.0f, num_data_, GetName()); Common::CheckElementsIntervalClosed(label_, 0.0f, 1.0f, num_data_, GetName());
Log::Info("[%s:%s]: (objective) labels passed interval [0, 1] check", GetName(), __func__); Log::Info("[%s:%s]: (objective) labels passed interval [0, 1] check", GetName(), __func__);
if (weights_ != nullptr) { if (weights_ != nullptr) {
Common::obtain_min_max_sum(weights_, num_data_, &min_weight_, &max_weight_, nullptr); Common::ObtainMinMaxSum(weights_, num_data_, &min_weight_, &max_weight_, nullptr);
if (min_weight_ <= 0.0f) { if (min_weight_ <= 0.0f) {
Log::Fatal("[%s]: at least one weight is non-positive.", GetName()); Log::Fatal("[%s]: at least one weight is non-positive.", GetName());
} }
......
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