From cc918557ec40d88b20f76d4568bf75fbfc286d2a Mon Sep 17 00:00:00 2001 From: heisenbuug Date: Tue, 26 Oct 2021 12:58:47 +0530 Subject: [PATCH] More style changes --- src/mlpack/core/data/detect_file_type.cpp | 2 +- src/mlpack/core/data/load_arff_impl.hpp | 12 +++++------ src/mlpack/core/data/load_categorical_csv.hpp | 16 +++++++-------- src/mlpack/core/data/load_csv.hpp | 20 +++++++++---------- src/mlpack/core/data/load_impl.hpp | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/mlpack/core/data/detect_file_type.cpp b/src/mlpack/core/data/detect_file_type.cpp index 89c7068ad2..0219f95074 100644 --- a/src/mlpack/core/data/detect_file_type.cpp +++ b/src/mlpack/core/data/detect_file_type.cpp @@ -211,7 +211,7 @@ FileType AutoDetect(std::fstream& stream, const std::string& filename) const std::streampos pos = stream.tellg(); std::string line; std::getline(stream, line, '\n'); - trim(line); + Trim(line); // Reset stream position. stream.seekg(pos); diff --git a/src/mlpack/core/data/load_arff_impl.hpp b/src/mlpack/core/data/load_arff_impl.hpp index 280eb16cb1..33be092cfa 100644 --- a/src/mlpack/core/data/load_arff_impl.hpp +++ b/src/mlpack/core/data/load_arff_impl.hpp @@ -46,7 +46,7 @@ void LoadARFF(const std::string& filename, { // Read the next line, then strip whitespace from either side. std::getline(ifs, line, '\n'); - trim(line); + Trim(line); ++headerLines; // Is the first character a comment, or is the line empty? @@ -102,7 +102,7 @@ void LoadARFF(const std::string& filename, // `origDimType` string here instead (which has not had ::tolower used // on it). types.push_back(true); - trim_if(origDimType, + TrimIf(origDimType, [](char c) { return c == '{' || c == '}' || c == ' ' || c == '\t'; @@ -116,7 +116,7 @@ void LoadARFF(const std::string& filename, while (it != dimTok.end()) { std::string category = (*it); - trim(category); + Trim(category); categories.push_back(category); ++it; @@ -198,7 +198,7 @@ void LoadARFF(const std::string& filename, while (ifs.good()) { std::getline(ifs, line, '\n'); - trim(line); + Trim(line); // Each line of the @data section must be a CSV (except sparse data, which // we will handle later). So now we can tokenize the // CSV and parse it. The '?' representing a missing value is not allowed, @@ -232,7 +232,7 @@ void LoadARFF(const std::string& filename, { // Strip spaces before mapping. std::string token = *it; - trim(token); + Trim(token); const size_t currentNumMappings = info.NumMappings(col); const eT result = info.template MapString(token, col); @@ -272,7 +272,7 @@ void LoadARFF(const std::string& filename, // error, otherwise we issue a general error. std::stringstream error; std::string tokenStr = token.str(); - trim(tokenStr); + Trim(tokenStr); if (tokenStr == "?") error << "Missing values ('?') not supported, "; else diff --git a/src/mlpack/core/data/load_categorical_csv.hpp b/src/mlpack/core/data/load_categorical_csv.hpp index a9e5954dda..844611d1cf 100644 --- a/src/mlpack/core/data/load_categorical_csv.hpp +++ b/src/mlpack/core/data/load_categorical_csv.hpp @@ -88,7 +88,7 @@ void LoadCSV::InitializeTransposeMapper(size_t& rows, size_t& cols, std::getline(inFile, line); // Remove whitespaces from either side - trim(line); + Trim(line); // If it's an empty line decrease cols and break if (line.size() == 0) @@ -112,7 +112,7 @@ void LoadCSV::InitializeTransposeMapper(size_t& rows, size_t& cols, { std::getline(lineStream, token, delim); // Remove whitespace from either side - trim(token); + Trim(token); if (token[0] == '"' && token[token.size() - 1] != '"') { @@ -173,7 +173,7 @@ void LoadCSV::InitializeMapper(size_t& rows, size_t& cols, DatasetMapper& inout, DatasetMapper& inf while (std::getline(inFile, line)) { // Remove whitespaces from either side - trim(line); + Trim(line); // Reset the row we are looking at. (Remember this is transposed.) row = 0; std::stringstream lineStream; @@ -247,7 +247,7 @@ void LoadCSV::TransposeParse(arma::Mat& inout, DatasetMapper& inf { std::getline(lineStream, token, delim); // Remove whitespaces from either side - trim(token); + Trim(token); if (token[0] == '"' && token[token.size() - 1] != '"') { @@ -299,7 +299,7 @@ void LoadCSV::NonTransposeParse(arma::Mat& inout, while (std::getline(inFile, line)) { // Remove whitespaces from either side - trim(line); + Trim(line); std::stringstream lineStream; std::string token; @@ -314,7 +314,7 @@ void LoadCSV::NonTransposeParse(arma::Mat& inout, std::getline(lineStream, token, delim); // Remove whitespace from either side - trim(token); + Trim(token); if (token[0] == '"' && token[token.size() - 1] != '"') { diff --git a/src/mlpack/core/data/load_csv.hpp b/src/mlpack/core/data/load_csv.hpp index 734c27e426..e0eb527665 100644 --- a/src/mlpack/core/data/load_csv.hpp +++ b/src/mlpack/core/data/load_csv.hpp @@ -77,9 +77,9 @@ class LoadCSV * @param file path of the dataset. */ LoadCSV(const std::string& file) : - extension(Extension(file)), - filename(file), - inFile(file) + extension(Extension(file)), + filename(file), + inFile(file) { if (extension == "csv") { @@ -208,7 +208,7 @@ class LoadCSV inline std::pair GetMatrixSize(std::fstream& f, const char delim = ',') { - bool load_okay = f.good(); + bool loadOkay = f.good(); f.clear(); const std::fstream::pos_type pos1 = f.tellg(); @@ -219,7 +219,7 @@ class LoadCSV std::stringstream lineStream; std::string token; - while (f.good() && load_okay) + while (f.good() && loadOkay) { // Get a row of data. std::getline(f, lineString); @@ -228,20 +228,20 @@ class LoadCSV lineStream.clear(); lineStream.str(lineString); - size_t line_n_cols = 0; + size_t lineNCols = 0; // Get number of columns based on the type of data. if (isNumeric) - NumericMatSize(lineStream, line_n_cols, delim); + NumericMatSize(lineStream, lineNCols, delim); else - CategoricalMatSize(lineStream, line_n_cols, delim); + CategoricalMatSize(lineStream, lineNCols, delim); // If there are different number of columns in each // row, then the highest number of cols will be // considered as the size of the matrix. Missing // elements will be filled as 0. - if (fnCols < line_n_cols) - fnCols = line_n_cols; + if (fnCols < lineNCols) + fnCols = lineNCols; ++fnRows; } diff --git a/src/mlpack/core/data/load_impl.hpp b/src/mlpack/core/data/load_impl.hpp index 7b9f8eac90..226960a7e0 100644 --- a/src/mlpack/core/data/load_impl.hpp +++ b/src/mlpack/core/data/load_impl.hpp @@ -39,7 +39,7 @@ std::vector ToTokens(Tokenizer& lineTok) [&tokens](std::string const &str) { std::string trimmedToken(str); - trim(trimmedToken); + Trim(trimmedToken); return std::move(trimmedToken); });