From 1a534888d6f864124ab773a3f0194860c5c424ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sat, 19 Aug 2023 23:30:44 +0200 Subject: [PATCH] Fix report format --- src/Platform/Report.cc | 16 ++++++++-------- src/Platform/Report.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Platform/Report.cc b/src/Platform/Report.cc index b52a620..5690668 100644 --- a/src/Platform/Report.cc +++ b/src/Platform/Report.cc @@ -15,7 +15,7 @@ namespace platform { { stringstream oss; string sep = ""; - oss << "[" << fixed << setprecision(16); + oss << "["; for (auto& item : data[key]) { oss << sep << item.get(); sep = ", "; @@ -23,13 +23,13 @@ namespace platform { oss << "]"; return oss.str(); } - string fVector(const string& title, const json& data) + string fVector(const string& title, const json& data, const int width, const int precision) { stringstream oss; string sep = ""; - oss << title << "[" << fixed << setprecision(16); + oss << title << "["; for (const auto& item : data) { - oss << sep << item.get(); + oss << sep << fixed << setw(width) << setprecision(precision) << item.get(); sep = ", "; } oss << "]"; @@ -93,10 +93,10 @@ namespace platform { } if (data["results"].size() == 1) { cout << string(MAXL, '*') << endl; - cout << headerLine(fVector("Train scores: ", lastResult["scores_train"])); - cout << headerLine(fVector("Test scores: ", lastResult["scores_test"])); - cout << headerLine(fVector("Train times: ", lastResult["times_train"])); - cout << headerLine(fVector("Test times: ", lastResult["times_test"])); + cout << headerLine(fVector("Train scores: ", lastResult["scores_train"], 14, 12)); + cout << headerLine(fVector("Test scores: ", lastResult["scores_test"], 14, 12)); + cout << headerLine(fVector("Train times: ", lastResult["times_train"], 10, 3)); + cout << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3)); cout << string(MAXL, '*') << endl; } } diff --git a/src/Platform/Report.h b/src/Platform/Report.h index 2708d4e..105785f 100644 --- a/src/Platform/Report.h +++ b/src/Platform/Report.h @@ -6,7 +6,7 @@ #include "Colors.h" using json = nlohmann::json; -const int MAXL = 122; +const int MAXL = 128; namespace platform { using namespace std; class Report {