Add Locale shared config to reports
This commit is contained in:
@@ -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);
|
||||
|
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 "ReportConsole.h"
|
||||
#include "BestScore.h"
|
||||
|
||||
#include "CLocale.h"
|
||||
|
||||
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)
|
||||
{
|
||||
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<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()
|
||||
{
|
||||
auto tmp = ConfigLocale();
|
||||
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
|
||||
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl;
|
||||
json lastResult;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -4,6 +4,8 @@
|
||||
#include "Symbols.h"
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <boost/math/distributions/normal.hpp>
|
||||
#include "CLocale.h"
|
||||
|
||||
|
||||
namespace platform {
|
||||
|
||||
@@ -12,6 +14,7 @@ namespace platform {
|
||||
{
|
||||
nModels = models.size();
|
||||
nDatasets = datasets.size();
|
||||
auto temp = ConfigLocale();
|
||||
};
|
||||
|
||||
void Statistics::fit()
|
||||
|
Reference in New Issue
Block a user