diff --git a/Makefile b/Makefile index c289e16..f6650a2 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ define ClearTests rm -f $(f_debug)/tests/$$t ; \ fi ; \ done - $(eval nfiles=$(find . -name "*.gcda" -print)) - @if test "${nfiles}" != "" ; then \ + @nfiles="$(find . -name "*.gcda" -print0)" ; \ + if test "${nfiles}" != "" ; then \ find . -name "*.gcda" -print0 | xargs -0 rm 2>/dev/null ;\ fi ; endef @@ -47,10 +47,10 @@ dependency: ## Create a dependency graph diagram of the project (build/dependenc cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png buildd: ## Build the debug targets - cmake --build $(f_debug) -t $(app_targets) -j $(n_procs) + cmake --build $(f_debug) -t $(app_targets) $(n_procs) buildr: ## Build the release targets - cmake --build $(f_release) -t $(app_targets) -j $(n_procs) + cmake --build $(f_release) -t $(app_targets) $(n_procs) clean: ## Clean the tests info @echo ">>> Cleaning Debug BayesNet tests..."; @@ -78,7 +78,7 @@ opt = "" test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section @echo ">>> Running BayesNet & Platform tests..."; @$(MAKE) clean - @cmake --build $(f_debug) -t $(test_targets) -j $(n_procs) + @cmake --build $(f_debug) -t $(test_targets) $(n_procs) @for t in $(test_targets); do \ if [ -f $(f_debug)/tests/$$t ]; then \ cd $(f_debug)/tests ; \ @@ -91,7 +91,7 @@ opt = "" testp: ## Run platform tests (opt="-s") to verbose output the tests, (opt="-c='Stratified Fold Test'") to run only that section @echo ">>> Running Platform tests..."; @$(MAKE) clean - @cmake --build $(f_debug) --target unit_tests_platform -j $(n_procs) + @cmake --build $(f_debug) --target unit_tests_platform $(n_procs) @if [ -f $(f_debug)/tests/unit_tests_platform ]; then cd $(f_debug)/tests ; ./unit_tests_platform $(opt) ; fi ; @echo ">>> Done"; @@ -99,7 +99,7 @@ opt = "" testb: ## Run BayesNet tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section @echo ">>> Running BayesNet tests..."; @$(MAKE) clean - @cmake --build $(f_debug) --target unit_tests_bayesnet -j $(n_procs) + @cmake --build $(f_debug) --target unit_tests_bayesnet $(n_procs) @if [ -f $(f_debug)/tests/unit_tests_bayesnet ]; then cd $(f_debug)/tests ; ./unit_tests_bayesnet $(opt) ; fi ; @echo ">>> Done"; diff --git a/src/Platform/BestResults.cc b/src/Platform/BestResults.cc index 2a94182..94c08a3 100644 --- a/src/Platform/BestResults.cc +++ b/src/Platform/BestResults.cc @@ -8,6 +8,7 @@ #include "Colors.h" #include "Statistics.h" #include "BestResultsExcel.h" +#include "CLocale.h" namespace fs = std::filesystem; @@ -156,6 +157,7 @@ namespace platform { cerr << Colors::MAGENTA() << "File " << bestFileName << " doesn't exist." << Colors::RESET() << endl; exit(1); } + auto temp = ConfigLocale(); auto date = ftime_to_string(filesystem::last_write_time(bestFileName)); auto data = loadFile(bestFileName); auto datasets = getDatasets(data); diff --git a/src/Platform/CLocale.h b/src/Platform/CLocale.h new file mode 100644 index 0000000..f88b05b --- /dev/null +++ b/src/Platform/CLocale.h @@ -0,0 +1,24 @@ +#ifndef LOCALE_H +#define LOCALE_H +#include +#include +#include +#include +using namespace std; +namespace platform { + struct separation : numpunct { + char do_decimal_point() const { return ','; } + char do_thousands_sep() const { return '.'; } + string do_grouping() const { return "\03"; } + }; + class ConfigLocale { + public: + explicit ConfigLocale() + { + locale mylocale(cout.getloc(), new separation); + locale::global(mylocale); + cout.imbue(mylocale); + } + }; +} +#endif \ No newline at end of file diff --git a/src/Platform/ReportConsole.cc b/src/Platform/ReportConsole.cc index daf6242..bb08ef3 100644 --- a/src/Platform/ReportConsole.cc +++ b/src/Platform/ReportConsole.cc @@ -2,15 +2,9 @@ #include #include "ReportConsole.h" #include "BestScore.h" - +#include "CLocale.h" namespace platform { - struct separated : numpunct { - char do_decimal_point() const { return ','; } - char do_thousands_sep() const { return '.'; } - string do_grouping() const { return "\03"; } - }; - string ReportConsole::headerLine(const string& text, int utf = 0) { int n = MAXL - text.length() - 3; @@ -20,9 +14,6 @@ namespace platform { void ReportConsole::header() { - locale mylocale(cout.getloc(), new separated); - locale::global(mylocale); - cout.imbue(mylocale); stringstream oss; cout << Colors::MAGENTA() << string(MAXL, '*') << endl; cout << headerLine("Report " + data["model"].get() + " ver. " + data["version"].get() + " with " + to_string(data["folds"].get()) + " Folds cross validation and " + to_string(data["seeds"].size()) + " random seeds. " + data["date"].get() + " " + data["time"].get()); @@ -36,6 +27,7 @@ namespace platform { } void ReportConsole::body() { + auto tmp = ConfigLocale(); cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl; cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl; json lastResult; diff --git a/src/Platform/Result.cc b/src/Platform/Result.cc index 156ffa7..436d5de 100644 --- a/src/Platform/Result.cc +++ b/src/Platform/Result.cc @@ -4,6 +4,8 @@ #include "Result.h" #include "Colors.h" #include "BestScore.h" +#include "CLocale.h" + namespace platform { Result::Result(const string& path, const string& filename) : path(path) @@ -37,14 +39,17 @@ namespace platform { string Result::to_string() const { + auto tmp = ConfigLocale(); stringstream oss; + double durationShow = duration > 3600 ? duration / 3600 : duration > 60 ? duration / 60 : duration; + string durationUnit = duration > 3600 ? "h" : duration > 60 ? "m" : "s"; oss << date << " "; oss << setw(12) << left << model << " "; oss << setw(11) << left << scoreName << " "; oss << right << setw(11) << setprecision(7) << fixed << score << " "; auto completeString = isComplete() ? "C" : "P"; oss << setw(1) << " " << completeString << " "; - oss << setw(9) << setprecision(3) << fixed << duration << " "; + oss << setw(7) << setprecision(2) << fixed << durationShow << " " << durationUnit << " "; oss << setw(50) << left << title << " "; return oss.str(); } diff --git a/src/Platform/Results.cc b/src/Platform/Results.cc index f313d91..1f0cd66 100644 --- a/src/Platform/Results.cc +++ b/src/Platform/Results.cc @@ -4,6 +4,7 @@ #include "ReportExcel.h" #include "BestScore.h" #include "Colors.h" +#include "CLocale.h" namespace platform { void Results::load() { @@ -25,6 +26,7 @@ namespace platform { } void Results::show() const { + auto temp = ConfigLocale(); cout << Colors::GREEN() << "Results found: " << files.size() << endl; cout << "-------------------" << endl; if (complete) { diff --git a/src/Platform/Statistics.cc b/src/Platform/Statistics.cc index bf5451c..c64b9b0 100644 --- a/src/Platform/Statistics.cc +++ b/src/Platform/Statistics.cc @@ -4,6 +4,8 @@ #include "Symbols.h" #include #include +#include "CLocale.h" + namespace platform { @@ -12,6 +14,7 @@ namespace platform { { nModels = models.size(); nDatasets = datasets.size(); + auto temp = ConfigLocale(); }; void Statistics::fit() diff --git a/tests/TestBayesNetwork.cc b/tests/TestBayesNetwork.cc index d680e50..db290b5 100644 --- a/tests/TestBayesNetwork.cc +++ b/tests/TestBayesNetwork.cc @@ -159,7 +159,6 @@ TEST_CASE("Test Bayesian Network", "[BayesNet]") net.addEdge("A", "C"); auto str = net.graph("Test Graph"); REQUIRE(str.size() == 7); - cout << str << endl; REQUIRE(str[0] == "digraph BayesNet {\nlabel=\nfontsize=30\nfontcolor=blue\nlabelloc=t\nlayout=circo\n"); REQUIRE(str[1] == "A [shape=circle] \n"); REQUIRE(str[2] == "A -> B");