From 8257a6ae39226113892f41a2c7b0c30f7bd845c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Wed, 20 Sep 2023 13:50:34 +0200 Subject: [PATCH] Add message of not exist Best Results --- src/Platform/ReportBase.cc | 7 +++++++ src/Platform/ReportBase.h | 4 +++- src/Platform/ReportConsole.cc | 3 +++ src/Platform/ReportExcel.cc | 3 +++ src/Platform/Results.cc | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Platform/ReportBase.cc b/src/Platform/ReportBase.cc index 6a5b885..702c3f0 100644 --- a/src/Platform/ReportBase.cc +++ b/src/Platform/ReportBase.cc @@ -94,6 +94,8 @@ namespace platform { ifstream resultData(Paths::results() + "/" + fileName); if (resultData.is_open()) { bestResults = json::parse(resultData); + } else { + existBestFile = false; } } try { @@ -101,7 +103,12 @@ namespace platform { } catch (exception) { value = 1.0; + } return value; } + bool ReportBase::getExistBestFile() + { + return existBestFile; + } } \ No newline at end of file diff --git a/src/Platform/ReportBase.h b/src/Platform/ReportBase.h index 7695102..c8400cf 100644 --- a/src/Platform/ReportBase.h +++ b/src/Platform/ReportBase.h @@ -28,6 +28,7 @@ namespace platform { json data; string fromVector(const string& key); string fVector(const string& title, const json& data, const int width, const int precision); + bool getExistBestFile(); virtual void header() = 0; virtual void body() = 0; virtual void showSummary() = 0; @@ -35,10 +36,11 @@ namespace platform { map summary; double margin; map meaning; + bool compare; private: double bestResult(const string& dataset, const string& model); - bool compare; json bestResults; + bool existBestFile = true; }; }; #endif \ No newline at end of file diff --git a/src/Platform/ReportConsole.cc b/src/Platform/ReportConsole.cc index 0de1c11..621f463 100644 --- a/src/Platform/ReportConsole.cc +++ b/src/Platform/ReportConsole.cc @@ -104,6 +104,9 @@ namespace platform { oss << score << " compared to " << BestResult::title() << " .: " << totalScore / BestResult::score(); cout << headerLine(oss.str()); } + if (!getExistBestFile() && compare) { + cout << headerLine("*** Best Results File not found. Couldn't compare any result!"); + } cout << string(MAXL, '*') << endl << Colors::RESET(); } } \ No newline at end of file diff --git a/src/Platform/ReportExcel.cc b/src/Platform/ReportExcel.cc index 41891e9..381a3d8 100644 --- a/src/Platform/ReportExcel.cc +++ b/src/Platform/ReportExcel.cc @@ -326,5 +326,8 @@ namespace platform { worksheet_merge_range(worksheet, row, 1, row, 5, (score + " compared to " + BestResult::title() + " .:").c_str(), efectiveStyle("text")); writeDouble(row, 6, totalScore / BestResult::score(), "result"); } + if (!getExistBestFile() && compare) { + worksheet_write_string(worksheet, row + 1, 0, "*** Best Results File not found. Couldn't compare any result!", styles["summaryStyle"]); + } } } \ No newline at end of file diff --git a/src/Platform/Results.cc b/src/Platform/Results.cc index 725952c..47f7725 100644 --- a/src/Platform/Results.cc +++ b/src/Platform/Results.cc @@ -300,7 +300,7 @@ namespace platform { if (openExcel) { workbook_close(workbook); } - cout << "Done!" << endl; + cout << Colors::RESET() << "Done!" << endl; } } \ No newline at end of file