From f48864a415172951bec21c907fee32f28cb125f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Wed, 19 Feb 2025 13:32:07 +0100 Subject: [PATCH] Fix back button in manage Fix sort datasets in b_main when --datasets is used --- src/main/ArgumentsExperiment.cpp | 5 +++++ src/main/Experiment.cpp | 2 -- src/manage/ManageScreen.cpp | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/ArgumentsExperiment.cpp b/src/main/ArgumentsExperiment.cpp index d66a5d0..aa8199e 100644 --- a/src/main/ArgumentsExperiment.cpp +++ b/src/main/ArgumentsExperiment.cpp @@ -178,6 +178,11 @@ namespace platform { } } filesToTest = file_names; + sort(filesToTest.begin(), filesToTest.end(), [](const auto& lhs, const auto& rhs) { + const auto result = mismatch(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), [](const auto& lhs, const auto& rhs) {return tolower(lhs) == tolower(rhs);}); + + return result.second != rhs.cend() && (result.first == lhs.cend() || tolower(*result.first) < tolower(*result.second)); + }); saveResults = true; if (title == "") { title = "Test " + to_string(file_names.size()) + " datasets " + model_name + " " + to_string(n_folds) + " folds"; diff --git a/src/main/Experiment.cpp b/src/main/Experiment.cpp index 0f54baf..06cbc41 100644 --- a/src/main/Experiment.cpp +++ b/src/main/Experiment.cpp @@ -82,8 +82,6 @@ namespace platform { std::cout << Colors::RESET() << std::endl; } int num = 0; - // Sort files to test to have a consistent order even if --datasets is used - std::stable_sort(filesToTest.begin(), filesToTest.end()); for (auto fileName : filesToTest) { if (!quiet) std::cout << " " << setw(3) << right << num++ << " " << setw(max_name) << left << fileName << right << flush; diff --git a/src/manage/ManageScreen.cpp b/src/manage/ManageScreen.cpp index 5e30c15..30c2b65 100644 --- a/src/manage/ManageScreen.cpp +++ b/src/manage/ManageScreen.cpp @@ -487,20 +487,19 @@ namespace platform { index_A = index; list("A set to " + std::to_string(index), Colors::GREEN()); break; - case 'B': // set_b or back to list - if (output_type == OutputType::EXPERIMENTS) { - if (index == index_A) { - list("A and B cannot be the same!", Colors::RED()); - break; - } - index_B = index; - list("B set to " + std::to_string(index), Colors::GREEN()); - } else { - // back to show the report - output_type = OutputType::RESULT; - paginator[static_cast(OutputType::DETAIL)].setPage(1); - list(STATUS_OK, STATUS_COLOR); + case 'B': // set_b + if (index == index_A) { + list("A and B cannot be the same!", Colors::RED()); + break; } + index_B = index; + list("B set to " + std::to_string(index), Colors::GREEN()); + break; + case 'b': // back to list + // back to show the report + output_type = OutputType::RESULT; + paginator[static_cast(OutputType::DETAIL)].setPage(1); + list(STATUS_OK, STATUS_COLOR); break; case 'c': if (index_A == -1 || index_B == -1) {