Fix excel constructor

This commit is contained in:
2024-02-29 13:20:37 +01:00
parent c69dc08134
commit b68d520726
8 changed files with 20 additions and 34 deletions

24
.vscode/launch.json vendored
View File

@@ -2,9 +2,9 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "sample",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "sample",
"program": "${workspaceFolder}/build_debug/sample/BayesNetSample", "program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
"args": [ "args": [
"-d", "-d",
@@ -14,14 +14,14 @@
"-s", "-s",
"271", "271",
"-p", "-p",
"/Users/rmontanana/Code/discretizbench/datasets/", "${workspaceFolder}/../discretizbench/datasets/",
], ],
//"cwd": "${workspaceFolder}/build/sample/", //"cwd": "${workspaceFolder}/build/sample/",
}, },
{ {
"name": "experimentPy",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "experimentPy",
"program": "${workspaceFolder}/build_debug/src/b_main", "program": "${workspaceFolder}/build_debug/src/b_main",
"args": [ "args": [
"-m", "-m",
@@ -36,9 +36,9 @@
"cwd": "${workspaceFolder}/../discretizbench", "cwd": "${workspaceFolder}/../discretizbench",
}, },
{ {
"name": "gridsearch",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "gridsearch",
"program": "${workspaceFolder}/build_debug/src/b_grid", "program": "${workspaceFolder}/build_debug/src/b_grid",
"args": [ "args": [
"-m", "-m",
@@ -52,9 +52,9 @@
"cwd": "${workspaceFolder}/../discretizbench", "cwd": "${workspaceFolder}/../discretizbench",
}, },
{ {
"name": "experimentBayes",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "experimentBayes",
"program": "${workspaceFolder}/build_debug/src/b_main", "program": "${workspaceFolder}/build_debug/src/b_main",
"args": [ "args": [
"-m", "-m",
@@ -69,23 +69,23 @@
"cwd": "/home/rmontanana/Code/discretizbench", "cwd": "/home/rmontanana/Code/discretizbench",
}, },
{ {
"name": "best",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "best",
"program": "${workspaceFolder}/build_debug/src/b_best", "program": "${workspaceFolder}/build_debug/src/b_best",
"args": [ "args": [
"-m", "-m",
"BoostAODE", "BoostAODE",
"-s", "-s",
"accuracy", "accuracy",
"--build", "--excel"
], ],
"cwd": "${workspaceFolder}/../discretizbench", "cwd": "${workspaceFolder}/../discretizbench",
}, },
{ {
"name": "manage",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "manage",
"program": "${workspaceFolder}/build_debug/src/b_manage", "program": "${workspaceFolder}/build_debug/src/b_manage",
"args": [ "args": [
"-n", "-n",
@@ -94,18 +94,20 @@
"cwd": "${workspaceFolder}/../discretizbench", "cwd": "${workspaceFolder}/../discretizbench",
}, },
{ {
"name": "list",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "list",
"program": "${workspaceFolder}/build_debug/src/b_list", "program": "${workspaceFolder}/build_debug/src/b_list",
"args": [], "args": [
"--excel"
],
//"cwd": "/Users/rmontanana/Code/discretizbench", //"cwd": "/Users/rmontanana/Code/discretizbench",
"cwd": "${workspaceFolder}/../discretizbench", "cwd": "${workspaceFolder}/../discretizbench",
}, },
{ {
"name": "test",
"type": "lldb", "type": "lldb",
"request": "launch", "request": "launch",
"name": "test",
"program": "${workspaceFolder}/build_debug/tests/unit_tests", "program": "${workspaceFolder}/build_debug/tests/unit_tests",
"args": [ "args": [
"-c=\"Metrics Test\"", "-c=\"Metrics Test\"",

View File

@@ -96,22 +96,6 @@ test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximu
done done
@echo ">>> Done"; @echo ">>> Done";
opt = ""
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...";
@$(MAKE) clean
@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 ;
@echo ">>> Done";
opt = ""
testb: ## Run Platform tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
@echo ">>> Running Platform tests...";
@$(MAKE) clean
@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 ;
@echo ">>> Done";
coverage: ## Run tests and generate coverage report (build/index.html) coverage: ## Run tests and generate coverage report (build/index.html)
@echo ">>> Building tests with coverage..." @echo ">>> Building tests with coverage..."
@$(MAKE) test @$(MAKE) test

View File

@@ -26,7 +26,7 @@ include_directories(
set(best_sources b_best.cc BestResults.cc Statistics.cc BestResultsExcel.cc) set(best_sources b_best.cc BestResults.cc Statistics.cc BestResultsExcel.cc)
list(TRANSFORM best_sources PREPEND best/) list(TRANSFORM best_sources PREPEND best/)
add_executable(b_best ${best_sources} main/Result.cc reports/ReportExcel.cc reports/ReportBase.cc reports/ExcelFile.cc common/Datasets.cc common/Dataset.cc) add_executable(b_best ${best_sources} main/Result.cc reports/ReportExcel.cc reports/ReportBase.cc reports/ExcelFile.cc common/Datasets.cc common/Dataset.cc)
target_link_libraries(b_best Boost::boost "${XLSXWRITER_LIB}" "${TORCH_LIBRARIES}" ArffFiles mdlp) target_link_libraries(b_best Boost::boost "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
# b_grid # b_grid
set(grid_sources b_grid.cc GridSearch.cc GridData.cc) set(grid_sources b_grid.cc GridSearch.cc GridData.cc)
@@ -38,13 +38,13 @@ target_link_libraries(b_grid PyClassifiers ${MPI_CXX_LIBRARIES} ArffFiles)
set(list_sources b_list.cc DatasetsExcel.cc) set(list_sources b_list.cc DatasetsExcel.cc)
list(TRANSFORM list_sources PREPEND list/) list(TRANSFORM list_sources PREPEND list/)
add_executable(b_list ${list_sources} common/Datasets.cc common/Dataset.cc reports/ReportExcel.cc reports/ExcelFile.cc reports/ReportBase.cc) add_executable(b_list ${list_sources} common/Datasets.cc common/Dataset.cc reports/ReportExcel.cc reports/ExcelFile.cc reports/ReportBase.cc)
target_link_libraries(b_list ArffFiles mdlp "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}") target_link_libraries(b_list "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
# b_main # b_main
set(main_sources b_main.cc Experiment.cc Models.cc HyperParameters.cc) set(main_sources b_main.cc Experiment.cc Models.cc HyperParameters.cc)
list(TRANSFORM main_sources PREPEND main/) list(TRANSFORM main_sources PREPEND main/)
add_executable(b_main ${main_sources} common/Datasets.cc common/Dataset.cc reports/ReportConsole.cc reports/ReportBase.cc main/Result.cc) add_executable(b_main ${main_sources} common/Datasets.cc common/Dataset.cc reports/ReportConsole.cc reports/ReportBase.cc main/Result.cc)
target_link_libraries(b_main PyClassifiers BayesNet ArffFiles mdlp "${TORCH_LIBRARIES}") target_link_libraries(b_main PyClassifiers BayesNet ArffFiles mdlp)
# b_manage # b_manage
set(manage_sources b_manage.cc ManageResults.cc CommandParser.cc Results.cc) set(manage_sources b_manage.cc ManageResults.cc CommandParser.cc Results.cc)

View File

@@ -37,6 +37,7 @@ namespace platform {
setProperties("Best Results"); setProperties("Best Results");
int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size(); int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size();
datasetNameSize = std::max(datasetNameSize, maxDatasetName); datasetNameSize = std::max(datasetNameSize, maxDatasetName);
createFormats();
} }
void BestResultsExcel::reportAll(const std::vector<std::string>& models, const json& table, const std::map<std::string, std::map<std::string, float>>& ranks, bool friedman, double significance) void BestResultsExcel::reportAll(const std::vector<std::string>& models, const json& table, const std::map<std::string, std::map<std::string, float>>& ranks, bool friedman, double significance)
{ {

View File

@@ -8,6 +8,7 @@ namespace platform {
{ {
file_name = "datasets.xlsx"; file_name = "datasets.xlsx";
workbook = workbook_new(getFileName().c_str()); workbook = workbook_new(getFileName().c_str());
createFormats();
setProperties("Datasets"); setProperties("Datasets");
} }
DatasetsExcel::~DatasetsExcel() DatasetsExcel::~DatasetsExcel()

View File

@@ -1,20 +1,18 @@
#include "ExcelFile.h" #include "ExcelFile.h"
#include "Paths.h"
namespace platform { namespace platform {
ExcelFile::ExcelFile() ExcelFile::ExcelFile()
{ {
setDefault(); setDefault();
createFormats();
} }
ExcelFile::ExcelFile(lxw_workbook* workbook) : workbook(workbook) ExcelFile::ExcelFile(lxw_workbook* workbook) : workbook(workbook)
{ {
setDefault(); setDefault();
createFormats();
} }
ExcelFile::ExcelFile(lxw_workbook* workbook, lxw_worksheet* worksheet) : workbook(workbook), worksheet(worksheet) ExcelFile::ExcelFile(lxw_workbook* workbook, lxw_worksheet* worksheet) : workbook(workbook), worksheet(worksheet)
{ {
setDefault(); setDefault();
createFormats();
} }
void ExcelFile::setDefault() void ExcelFile::setDefault()
{ {

View File

@@ -3,7 +3,6 @@
#include <locale> #include <locale>
#include <string> #include <string>
#include <map> #include <map>
#include "Paths.h"
#include "xlsxwriter.h" #include "xlsxwriter.h"
namespace platform { namespace platform {

View File

@@ -9,6 +9,7 @@ namespace platform {
ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook, lxw_worksheet* worksheet) : ReportBase(data_, compare), ExcelFile(workbook, worksheet) ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook, lxw_worksheet* worksheet) : ReportBase(data_, compare), ExcelFile(workbook, worksheet)
{ {
createFile(); createFile();
createFormats();
} }
void ReportExcel::formatColumns() void ReportExcel::formatColumns()