[mlpack-git] master: Fix minor style issues. (c6477da)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Jun 15 09:12:34 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/97402b9098d9d72889aa795923cf8fd67a4d87bf...c6477da79947c2e916a6953ed7e080e7148a78db
>---------------------------------------------------------------
commit c6477da79947c2e916a6953ed7e080e7148a78db
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Jun 15 06:12:34 2016 -0700
Fix minor style issues.
>---------------------------------------------------------------
c6477da79947c2e916a6953ed7e080e7148a78db
src/mlpack/core/util/cli.cpp | 2 +-
src/mlpack/core/util/cli_impl.hpp | 27 ++++++++++++----------
src/mlpack/methods/emst/emst_main.cpp | 2 +-
src/mlpack/methods/gmm/gmm_generate_main.cpp | 4 ++--
src/mlpack/methods/gmm/gmm_probability_main.cpp | 5 ++--
src/mlpack/methods/perceptron/perceptron_main.cpp | 1 -
.../methods/preprocess/preprocess_split_main.cpp | 8 ++++---
7 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/mlpack/core/util/cli.cpp b/src/mlpack/core/util/cli.cpp
index a9a353a..21b41fe 100644
--- a/src/mlpack/core/util/cli.cpp
+++ b/src/mlpack/core/util/cli.cpp
@@ -105,7 +105,7 @@ void CLI::Add(const std::string& identifier,
// Must make use of boost option name syntax.
std::string progOptId =
- alias.length() ? identifier + "," + alias : identifier;
+ alias.length() ? identifier + "," + alias : identifier;
// Deal with a required alias.
AddAlias(alias, identifier);
diff --git a/src/mlpack/core/util/cli_impl.hpp b/src/mlpack/core/util/cli_impl.hpp
index 607bfb2..cc7c896 100644
--- a/src/mlpack/core/util/cli_impl.hpp
+++ b/src/mlpack/core/util/cli_impl.hpp
@@ -14,15 +14,6 @@
// Include option.hpp here because it requires CLI but is also templated.
#include "option.hpp"
-// Color code escape sequences.
-#ifndef _WIN32
- #define BASH_RED "\033[0;31m"
- #define BASH_CLEAR "\033[0m"
-#else
- #define BASH_RED ""
- #define BASH_CLEAR ""
-#endif
-
namespace mlpack {
/**
@@ -43,15 +34,27 @@ void CLI::Add(const std::string& identifier,
const std::string& alias,
bool required)
{
- // Temporary outstream object for detecting duplicate identifiers
+ // Temporarily define color code escape sequences.
+ #ifndef _WIN32
+ #define BASH_RED "\033[0;31m"
+ #define BASH_CLEAR "\033[0m"
+ #else
+ #define BASH_RED ""
+ #define BASH_CLEAR ""
+ #endif
+
+ // Temporary outstream object for detecting duplicate identifiers.
util::PrefixedOutStream outstr(std::cerr,
BASH_RED "[FATAL] " BASH_CLEAR, false, true /* fatal */);
- // identifier and alias maps
+ #undef BASH_RED
+ #undef BASH_CLEAR
+
+ // Define identifier and alias maps.
gmap_t& gmap = GetSingleton().globalValues;
amap_t& amap = GetSingleton().aliasValues;
- // if found in current map, print fatal error and terminate the program.
+ // If found in current map, print fatal error and terminate the program.
if (gmap.count(identifier))
outstr << "Parameter --" << identifier << "(-" << alias << ") "
<< "is defined multiple times with same identifiers." << std::endl;
diff --git a/src/mlpack/methods/emst/emst_main.cpp b/src/mlpack/methods/emst/emst_main.cpp
index ddd3e03..f6d18be 100644
--- a/src/mlpack/methods/emst/emst_main.cpp
+++ b/src/mlpack/methods/emst/emst_main.cpp
@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
if (CLI::HasParam("output_file"))
Log::Warn << "--output_file (-o) is not specified; no results will be "
- << "saved!" << endl;
+ << "saved!" << endl;
arma::mat dataPoints;
data::Load(inputFile, dataPoints, true);
diff --git a/src/mlpack/methods/gmm/gmm_generate_main.cpp b/src/mlpack/methods/gmm/gmm_generate_main.cpp
index 38508f7..32f3567 100644
--- a/src/mlpack/methods/gmm/gmm_generate_main.cpp
+++ b/src/mlpack/methods/gmm/gmm_generate_main.cpp
@@ -31,7 +31,7 @@ int main(int argc, char** argv)
if (CLI::HasParam("output_file"))
Log::Warn << "--output_file (-o) is not specified;"
- << "no results will be saved!" << endl;
+ << "no results will be saved!" << endl;
if (CLI::GetParam<int>("seed") == 0)
mlpack::math::RandomSeed(time(NULL));
@@ -50,6 +50,6 @@ int main(int argc, char** argv)
for (size_t i = 0; i < length; ++i)
samples.col(i) = gmm.Random();
- if(CLI::HasParam("output_file"))
+ if (CLI::HasParam("output_file"))
data::Save(CLI::GetParam<string>("output_file"), samples);
}
diff --git a/src/mlpack/methods/gmm/gmm_probability_main.cpp b/src/mlpack/methods/gmm/gmm_probability_main.cpp
index 5a740cd..15006dd 100644
--- a/src/mlpack/methods/gmm/gmm_probability_main.cpp
+++ b/src/mlpack/methods/gmm/gmm_probability_main.cpp
@@ -21,7 +21,8 @@ PROGRAM_INFO("GMM Probability Calculator",
PARAM_STRING_REQ("input_model_file", "File containing input GMM.", "m");
PARAM_STRING_REQ("input_file", "File containing points.", "i");
-PARAM_STRING("output_file", "File to save calculated probabilities to.", "o", "");
+PARAM_STRING("output_file", "File to save calculated probabilities to.", "o",
+ "");
int main(int argc, char** argv)
{
@@ -33,7 +34,7 @@ int main(int argc, char** argv)
if (CLI::HasParam("output_file"))
Log::Warn << "--output_file (-o) is not specified;"
- << "no results will be saved!" << endl;
+ << "no results will be saved!" << endl;
// Get the GMM and the points.
GMM gmm;
diff --git a/src/mlpack/methods/perceptron/perceptron_main.cpp b/src/mlpack/methods/perceptron/perceptron_main.cpp
index 23e6609..3c99fc6 100644
--- a/src/mlpack/methods/perceptron/perceptron_main.cpp
+++ b/src/mlpack/methods/perceptron/perceptron_main.cpp
@@ -126,7 +126,6 @@ int main(int argc, char** argv)
if (CLI::HasParam("test_file") && !CLI::HasParam("output_file"))
Log::Fatal << "--output_file must be specified with --test_file" << endl;
-
// Now, load our model, if there is one.
Perceptron<>* p = NULL;
Col<size_t> mappings;
diff --git a/src/mlpack/methods/preprocess/preprocess_split_main.cpp b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
index fc73ae6..a615f37 100644
--- a/src/mlpack/methods/preprocess/preprocess_split_main.cpp
+++ b/src/mlpack/methods/preprocess/preprocess_split_main.cpp
@@ -72,11 +72,13 @@ int main(int argc, char** argv)
{
if (!CLI::HasParam("training_labels_file"))
{
- Log::Fatal << "You did not specify --training_labels_file" << endl;
+ Log::Fatal << "--training_labels_file (-l) must be specified if "
+ << "--input_labels (-l) is specified!" << endl;
}
if (!CLI::HasParam("test_labels_file"))
{
- Log::Fatal << "You did not specify --test_labels_fil" << endl;
+ Log::Fatal << "--test_labels_file (-L) must be specified if "
+ << "--input_labels (-I) is specified!" << endl;
}
}
else
@@ -85,7 +87,7 @@ int main(int argc, char** argv)
CLI::HasParam("test_labels_file"))
{
Log::Fatal << "When specifying --training_labels_file or "
- << "--test_labels_file, you must also specify --input_labels. "
+ << "--test_labels_file, you must also specify --input_labels."
<< endl;
}
}
More information about the mlpack-git
mailing list