Add Locale shared config to reports
This commit is contained in:
parent
8fdad78a8c
commit
7d8aca4f59
14
Makefile
14
Makefile
@ -15,8 +15,8 @@ define ClearTests
|
|||||||
rm -f $(f_debug)/tests/$$t ; \
|
rm -f $(f_debug)/tests/$$t ; \
|
||||||
fi ; \
|
fi ; \
|
||||||
done
|
done
|
||||||
$(eval nfiles=$(find . -name "*.gcda" -print))
|
@nfiles="$(find . -name "*.gcda" -print0)" ; \
|
||||||
@if test "${nfiles}" != "" ; then \
|
if test "${nfiles}" != "" ; then \
|
||||||
find . -name "*.gcda" -print0 | xargs -0 rm 2>/dev/null ;\
|
find . -name "*.gcda" -print0 | xargs -0 rm 2>/dev/null ;\
|
||||||
fi ;
|
fi ;
|
||||||
endef
|
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
|
cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png
|
||||||
|
|
||||||
buildd: ## Build the debug targets
|
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
|
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
|
clean: ## Clean the tests info
|
||||||
@echo ">>> Cleaning Debug BayesNet tests...";
|
@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
|
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...";
|
@echo ">>> Running BayesNet & Platform tests...";
|
||||||
@$(MAKE) clean
|
@$(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 \
|
@for t in $(test_targets); do \
|
||||||
if [ -f $(f_debug)/tests/$$t ]; then \
|
if [ -f $(f_debug)/tests/$$t ]; then \
|
||||||
cd $(f_debug)/tests ; \
|
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
|
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...";
|
@echo ">>> Running Platform tests...";
|
||||||
@$(MAKE) clean
|
@$(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 ;
|
@if [ -f $(f_debug)/tests/unit_tests_platform ]; then cd $(f_debug)/tests ; ./unit_tests_platform $(opt) ; fi ;
|
||||||
@echo ">>> Done";
|
@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
|
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...";
|
@echo ">>> Running BayesNet tests...";
|
||||||
@$(MAKE) clean
|
@$(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 ;
|
@if [ -f $(f_debug)/tests/unit_tests_bayesnet ]; then cd $(f_debug)/tests ; ./unit_tests_bayesnet $(opt) ; fi ;
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
#include "Statistics.h"
|
#include "Statistics.h"
|
||||||
#include "BestResultsExcel.h"
|
#include "BestResultsExcel.h"
|
||||||
|
#include "CLocale.h"
|
||||||
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@ -156,6 +157,7 @@ namespace platform {
|
|||||||
cerr << Colors::MAGENTA() << "File " << bestFileName << " doesn't exist." << Colors::RESET() << endl;
|
cerr << Colors::MAGENTA() << "File " << bestFileName << " doesn't exist." << Colors::RESET() << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
auto temp = ConfigLocale();
|
||||||
auto date = ftime_to_string(filesystem::last_write_time(bestFileName));
|
auto date = ftime_to_string(filesystem::last_write_time(bestFileName));
|
||||||
auto data = loadFile(bestFileName);
|
auto data = loadFile(bestFileName);
|
||||||
auto datasets = getDatasets(data);
|
auto datasets = getDatasets(data);
|
||||||
|
24
src/Platform/CLocale.h
Normal file
24
src/Platform/CLocale.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef LOCALE_H
|
||||||
|
#define LOCALE_H
|
||||||
|
#include <locale>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
namespace platform {
|
||||||
|
struct separation : numpunct<char> {
|
||||||
|
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
|
@ -2,15 +2,9 @@
|
|||||||
#include <locale>
|
#include <locale>
|
||||||
#include "ReportConsole.h"
|
#include "ReportConsole.h"
|
||||||
#include "BestScore.h"
|
#include "BestScore.h"
|
||||||
|
#include "CLocale.h"
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
struct separated : numpunct<char> {
|
|
||||||
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)
|
string ReportConsole::headerLine(const string& text, int utf = 0)
|
||||||
{
|
{
|
||||||
int n = MAXL - text.length() - 3;
|
int n = MAXL - text.length() - 3;
|
||||||
@ -20,9 +14,6 @@ namespace platform {
|
|||||||
|
|
||||||
void ReportConsole::header()
|
void ReportConsole::header()
|
||||||
{
|
{
|
||||||
locale mylocale(cout.getloc(), new separated);
|
|
||||||
locale::global(mylocale);
|
|
||||||
cout.imbue(mylocale);
|
|
||||||
stringstream oss;
|
stringstream oss;
|
||||||
cout << Colors::MAGENTA() << string(MAXL, '*') << endl;
|
cout << Colors::MAGENTA() << string(MAXL, '*') << endl;
|
||||||
cout << headerLine("Report " + data["model"].get<string>() + " ver. " + data["version"].get<string>() + " with " + to_string(data["folds"].get<int>()) + " Folds cross validation and " + to_string(data["seeds"].size()) + " random seeds. " + data["date"].get<string>() + " " + data["time"].get<string>());
|
cout << headerLine("Report " + data["model"].get<string>() + " ver. " + data["version"].get<string>() + " with " + to_string(data["folds"].get<int>()) + " Folds cross validation and " + to_string(data["seeds"].size()) + " random seeds. " + data["date"].get<string>() + " " + data["time"].get<string>());
|
||||||
@ -36,6 +27,7 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
void ReportConsole::body()
|
void ReportConsole::body()
|
||||||
{
|
{
|
||||||
|
auto tmp = ConfigLocale();
|
||||||
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
|
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
|
||||||
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl;
|
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl;
|
||||||
json lastResult;
|
json lastResult;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "Result.h"
|
#include "Result.h"
|
||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
#include "BestScore.h"
|
#include "BestScore.h"
|
||||||
|
#include "CLocale.h"
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
Result::Result(const string& path, const string& filename)
|
Result::Result(const string& path, const string& filename)
|
||||||
: path(path)
|
: path(path)
|
||||||
@ -37,14 +39,17 @@ namespace platform {
|
|||||||
|
|
||||||
string Result::to_string() const
|
string Result::to_string() const
|
||||||
{
|
{
|
||||||
|
auto tmp = ConfigLocale();
|
||||||
stringstream oss;
|
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 << date << " ";
|
||||||
oss << setw(12) << left << model << " ";
|
oss << setw(12) << left << model << " ";
|
||||||
oss << setw(11) << left << scoreName << " ";
|
oss << setw(11) << left << scoreName << " ";
|
||||||
oss << right << setw(11) << setprecision(7) << fixed << score << " ";
|
oss << right << setw(11) << setprecision(7) << fixed << score << " ";
|
||||||
auto completeString = isComplete() ? "C" : "P";
|
auto completeString = isComplete() ? "C" : "P";
|
||||||
oss << setw(1) << " " << completeString << " ";
|
oss << setw(1) << " " << completeString << " ";
|
||||||
oss << setw(9) << setprecision(3) << fixed << duration << " ";
|
oss << setw(7) << setprecision(2) << fixed << durationShow << " " << durationUnit << " ";
|
||||||
oss << setw(50) << left << title << " ";
|
oss << setw(50) << left << title << " ";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "ReportExcel.h"
|
#include "ReportExcel.h"
|
||||||
#include "BestScore.h"
|
#include "BestScore.h"
|
||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
|
#include "CLocale.h"
|
||||||
namespace platform {
|
namespace platform {
|
||||||
void Results::load()
|
void Results::load()
|
||||||
{
|
{
|
||||||
@ -25,6 +26,7 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
void Results::show() const
|
void Results::show() const
|
||||||
{
|
{
|
||||||
|
auto temp = ConfigLocale();
|
||||||
cout << Colors::GREEN() << "Results found: " << files.size() << endl;
|
cout << Colors::GREEN() << "Results found: " << files.size() << endl;
|
||||||
cout << "-------------------" << endl;
|
cout << "-------------------" << endl;
|
||||||
if (complete) {
|
if (complete) {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "Symbols.h"
|
#include "Symbols.h"
|
||||||
#include <boost/math/distributions/chi_squared.hpp>
|
#include <boost/math/distributions/chi_squared.hpp>
|
||||||
#include <boost/math/distributions/normal.hpp>
|
#include <boost/math/distributions/normal.hpp>
|
||||||
|
#include "CLocale.h"
|
||||||
|
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
|
|
||||||
@ -12,6 +14,7 @@ namespace platform {
|
|||||||
{
|
{
|
||||||
nModels = models.size();
|
nModels = models.size();
|
||||||
nDatasets = datasets.size();
|
nDatasets = datasets.size();
|
||||||
|
auto temp = ConfigLocale();
|
||||||
};
|
};
|
||||||
|
|
||||||
void Statistics::fit()
|
void Statistics::fit()
|
||||||
|
@ -159,7 +159,6 @@ TEST_CASE("Test Bayesian Network", "[BayesNet]")
|
|||||||
net.addEdge("A", "C");
|
net.addEdge("A", "C");
|
||||||
auto str = net.graph("Test Graph");
|
auto str = net.graph("Test Graph");
|
||||||
REQUIRE(str.size() == 7);
|
REQUIRE(str.size() == 7);
|
||||||
cout << str << endl;
|
|
||||||
REQUIRE(str[0] == "digraph BayesNet {\nlabel=<BayesNet Test Graph>\nfontsize=30\nfontcolor=blue\nlabelloc=t\nlayout=circo\n");
|
REQUIRE(str[0] == "digraph BayesNet {\nlabel=<BayesNet Test Graph>\nfontsize=30\nfontcolor=blue\nlabelloc=t\nlayout=circo\n");
|
||||||
REQUIRE(str[1] == "A [shape=circle] \n");
|
REQUIRE(str[1] == "A [shape=circle] \n");
|
||||||
REQUIRE(str[2] == "A -> B");
|
REQUIRE(str[2] == "A -> B");
|
||||||
|
Loading…
Reference in New Issue
Block a user