Commit 9653938a authored by Guolin Ke's avatar Guolin Ke
Browse files

some warning fixed

parent d6ef6cfa
...@@ -286,7 +286,7 @@ inline bool ConfigBase::GetBool( ...@@ -286,7 +286,7 @@ inline bool ConfigBase::GetBool(
const std::string& name, bool* out) { const std::string& name, bool* out) {
if (params.count(name) > 0) { if (params.count(name) > 0) {
std::string value = params.at(name); std::string value = params.at(name);
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
if (value == std::string("false") || value == std::string("-")) { if (value == std::string("false") || value == std::string("-")) {
*out = false; *out = false;
} else if (value == std::string("true") || value == std::string("+")) { } else if (value == std::string("true") || value == std::string("+")) {
......
...@@ -17,6 +17,12 @@ namespace LightGBM { ...@@ -17,6 +17,12 @@ namespace LightGBM {
namespace Common { namespace Common {
inline char tolower(char in) {
if (in <= 'Z' && in >= 'A')
return in - ('Z' - 'z');
return in;
}
inline static std::string& Trim(std::string& str) { inline static std::string& Trim(std::string& str) {
if (str.size() <= 0) { if (str.size() <= 0) {
return str; return str;
...@@ -173,7 +179,7 @@ inline static const char* Atof(const char* p, double* out) { ...@@ -173,7 +179,7 @@ inline static const char* Atof(const char* p, double* out) {
} }
if (cnt > 0) { if (cnt > 0) {
std::string tmp_str(p, cnt); std::string tmp_str(p, cnt);
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), ::tolower); std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), Common::tolower);
if (tmp_str == std::string("na") || tmp_str == std::string("nan")) { if (tmp_str == std::string("na") || tmp_str == std::string("nan")) {
*out = 0; *out = 0;
} else if (tmp_str == std::string("inf") || tmp_str == std::string("infinity")) { } else if (tmp_str == std::string("inf") || tmp_str == std::string("infinity")) {
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#include <cstdio> #include <cstdio>
#include <algorithm>
#include <functional> #include <functional>
#include <thread> #include <thread>
#include <memory> #include <memory>
#include <algorithm>
namespace LightGBM{ namespace LightGBM{
......
...@@ -66,7 +66,7 @@ void OverallConfig::Set(const std::unordered_map<std::string, std::string>& para ...@@ -66,7 +66,7 @@ void OverallConfig::Set(const std::unordered_map<std::string, std::string>& para
void OverallConfig::GetBoostingType(const std::unordered_map<std::string, std::string>& params) { void OverallConfig::GetBoostingType(const std::unordered_map<std::string, std::string>& params) {
std::string value; std::string value;
if (GetString(params, "boosting_type", &value)) { if (GetString(params, "boosting_type", &value)) {
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
if (value == std::string("gbdt") || value == std::string("gbrt")) { if (value == std::string("gbdt") || value == std::string("gbrt")) {
boosting_type = BoostingType::kGBDT; boosting_type = BoostingType::kGBDT;
} else if (value == std::string("dart")) { } else if (value == std::string("dart")) {
...@@ -80,7 +80,7 @@ void OverallConfig::GetBoostingType(const std::unordered_map<std::string, std::s ...@@ -80,7 +80,7 @@ void OverallConfig::GetBoostingType(const std::unordered_map<std::string, std::s
void OverallConfig::GetObjectiveType(const std::unordered_map<std::string, std::string>& params) { void OverallConfig::GetObjectiveType(const std::unordered_map<std::string, std::string>& params) {
std::string value; std::string value;
if (GetString(params, "objective", &value)) { if (GetString(params, "objective", &value)) {
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
objective_type = value; objective_type = value;
} }
} }
...@@ -91,13 +91,13 @@ void OverallConfig::GetMetricType(const std::unordered_map<std::string, std::str ...@@ -91,13 +91,13 @@ void OverallConfig::GetMetricType(const std::unordered_map<std::string, std::str
// clear old metrics // clear old metrics
metric_types.clear(); metric_types.clear();
// to lower // to lower
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
// split // split
std::vector<std::string> metrics = Common::Split(value.c_str(), ','); std::vector<std::string> metrics = Common::Split(value.c_str(), ',');
// remove dumplicate // remove dumplicate
std::unordered_map<std::string, int> metric_maps; std::unordered_map<std::string, int> metric_maps;
for (auto& metric : metrics) { for (auto& metric : metrics) {
std::transform(metric.begin(), metric.end(), metric.begin(), ::tolower); std::transform(metric.begin(), metric.end(), metric.begin(), Common::tolower);
if (metric_maps.count(metric) <= 0) { if (metric_maps.count(metric) <= 0) {
metric_maps[metric] = 1; metric_maps[metric] = 1;
} }
...@@ -114,7 +114,7 @@ void OverallConfig::GetMetricType(const std::unordered_map<std::string, std::str ...@@ -114,7 +114,7 @@ void OverallConfig::GetMetricType(const std::unordered_map<std::string, std::str
void OverallConfig::GetTaskType(const std::unordered_map<std::string, std::string>& params) { void OverallConfig::GetTaskType(const std::unordered_map<std::string, std::string>& params) {
std::string value; std::string value;
if (GetString(params, "task", &value)) { if (GetString(params, "task", &value)) {
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
if (value == std::string("train") || value == std::string("training")) { if (value == std::string("train") || value == std::string("training")) {
task_type = TaskType::kTrain; task_type = TaskType::kTrain;
} else if (value == std::string("predict") || value == std::string("prediction") } else if (value == std::string("predict") || value == std::string("prediction")
...@@ -308,7 +308,7 @@ void BoostingConfig::Set(const std::unordered_map<std::string, std::string>& par ...@@ -308,7 +308,7 @@ void BoostingConfig::Set(const std::unordered_map<std::string, std::string>& par
void BoostingConfig::GetTreeLearnerType(const std::unordered_map<std::string, std::string>& params) { void BoostingConfig::GetTreeLearnerType(const std::unordered_map<std::string, std::string>& params) {
std::string value; std::string value;
if (GetString(params, "tree_learner", &value)) { if (GetString(params, "tree_learner", &value)) {
std::transform(value.begin(), value.end(), value.begin(), ::tolower); std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
if (value == std::string("serial")) { if (value == std::string("serial")) {
tree_learner_type = TreeLearnerType::kSerialTreeLearner; tree_learner_type = TreeLearnerType::kSerialTreeLearner;
} else if (value == std::string("feature") || value == std::string("feature_parallel")) { } else if (value == std::string("feature") || value == std::string("feature_parallel")) {
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
data_size_t cur_pos = 0; data_size_t cur_pos = 0;
data_size_t i_delta = -1; data_size_t i_delta = -1;
while (bin_data_->NextNonzero(&i_delta, &cur_pos)) { while (bin_data_->NextNonzero(&i_delta, &cur_pos)) {
ordered_pair_.emplace_back(cur_pos, 0); ordered_pair_.emplace_back(cur_pos, static_cast<VAL_T>(0));
} }
ordered_pair_.shrink_to_fit(); ordered_pair_.shrink_to_fit();
} }
......
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