[mlpack-git] master: Print any output options at the end of the run. (52ffd75)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Jul 13 16:56:14 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/59bc0b32630a3ad786706993f4d5e8b087f1c702...0d9a0e263a32b99d8dcf5d2723b3b92c67e669fc
>---------------------------------------------------------------
commit 52ffd75b7f6b07b32693c7c7ea1956193b57bdff
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Jul 13 16:56:14 2016 -0400
Print any output options at the end of the run.
>---------------------------------------------------------------
52ffd75b7f6b07b32693c7c7ea1956193b57bdff
src/mlpack/core/util/cli.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++
src/mlpack/core/util/cli.hpp | 5 +++++
2 files changed, 55 insertions(+)
diff --git a/src/mlpack/core/util/cli.cpp b/src/mlpack/core/util/cli.cpp
index 468f9a4..d009466 100644
--- a/src/mlpack/core/util/cli.cpp
+++ b/src/mlpack/core/util/cli.cpp
@@ -50,6 +50,9 @@ CLI::CLI(const CLI& other) : desc(other.desc),
CLI::~CLI()
{
+ // We need to print any output options.
+ PrintOutput();
+
// Terminate the program timers.
std::map<std::string, std::chrono::microseconds>::iterator it;
for (it = timer.GetAllTimers().begin(); it != timer.GetAllTimers().end();
@@ -460,6 +463,53 @@ void CLI::RemoveDuplicateFlags(po::basic_parsed_options<char>& bpo)
}
}
+// Prints any output options.
+void CLI::PrintOutput()
+{
+ gmap_t& gmap = GetSingleton().globalValues;
+ gmap_t::iterator iter;
+
+ for (iter = gmap.begin(); iter != gmap.end(); ++iter)
+ {
+ std::string key = iter->first;
+ ParamData data = iter->second;
+
+ const std::list<std::string>& inputOptions = GetSingleton().inputOptions;
+ const bool input = (std::find(std::begin(inputOptions),
+ std::end(inputOptions), key) != std::end(inputOptions));
+
+ // Ignore input options.
+ if (input)
+ continue;
+
+ // Ignore string output options that end in _file.
+ if ((data.tname == TYPENAME(std::string)) &&
+ (data.name.substr(data.name.size() - 5, 5) == "_file"))
+ continue;
+
+ // Now, we must print it, so figure out what the type is.
+ if (data.tname == TYPENAME(std::string))
+ {
+ std::string value = GetParam<std::string>(key);
+ std::cout << key << ": " << value << std::endl;
+ }
+ else if (data.tname == TYPENAME(int))
+ {
+ int value = GetParam<int>(key);
+ std::cout << key << ": " << value << std::endl;
+ }
+ else if (data.tname == TYPENAME(double))
+ {
+ double value = GetParam<double>(key);
+ std::cout << key << ": " << value << std::endl;
+ }
+ else
+ {
+ std::cout << key << ": unknown data type" << std::endl;
+ }
+ }
+}
+
/* Prints out the current hierarchy. */
void CLI::Print()
{
diff --git a/src/mlpack/core/util/cli.hpp b/src/mlpack/core/util/cli.hpp
index dd98c0f..7eadf8a 100644
--- a/src/mlpack/core/util/cli.hpp
+++ b/src/mlpack/core/util/cli.hpp
@@ -311,6 +311,11 @@ class CLI
static void RemoveDuplicateFlags(po::basic_parsed_options<char>& bpo);
/**
+ * Print the value of any output options on stdout.
+ */
+ static void PrintOutput();
+
+ /**
* Print out the current hierarchy.
*/
static void Print();
More information about the mlpack-git
mailing list