Fix tests
This commit is contained in:
@@ -68,7 +68,7 @@ if (ENABLE_CLANG_TIDY)
|
|||||||
include(StaticAnalyzers) # clang-tidy
|
include(StaticAnalyzers) # clang-tidy
|
||||||
endif (ENABLE_CLANG_TIDY)
|
endif (ENABLE_CLANG_TIDY)
|
||||||
|
|
||||||
# External libraries - dependencies of BayesNet
|
# External libraries - dependencies of Platform
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
add_git_submodule("lib/PyClassifiers")
|
add_git_submodule("lib/PyClassifiers")
|
||||||
add_git_submodule("lib/argparse")
|
add_git_submodule("lib/argparse")
|
||||||
|
19
Makefile
19
Makefile
@@ -62,7 +62,7 @@ buildr: ## Build the release targets
|
|||||||
cmake --build $(f_release) -t $(app_targets) $(n_procs)
|
cmake --build $(f_release) -t $(app_targets) $(n_procs)
|
||||||
|
|
||||||
clean: ## Clean the tests info
|
clean: ## Clean the tests info
|
||||||
@echo ">>> Cleaning Debug BayesNet tests...";
|
@echo ">>> Cleaning Debug Platform tests...";
|
||||||
$(call ClearTests)
|
$(call ClearTests)
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
@@ -70,14 +70,14 @@ clang-uml: ## Create uml class and sequence diagrams
|
|||||||
clang-uml -p --add-compile-flag -I /usr/lib/gcc/x86_64-redhat-linux/8/include/
|
clang-uml -p --add-compile-flag -I /usr/lib/gcc/x86_64-redhat-linux/8/include/
|
||||||
|
|
||||||
debug: ## Build a debug version of the project
|
debug: ## Build a debug version of the project
|
||||||
@echo ">>> Building Debug BayesNet...";
|
@echo ">>> Building Debug Platform...";
|
||||||
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
||||||
@mkdir $(f_debug);
|
@mkdir $(f_debug);
|
||||||
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON
|
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
release: ## Build a Release version of the project
|
release: ## Build a Release version of the project
|
||||||
@echo ">>> Building Release BayesNet...";
|
@echo ">>> Building Release Platform...";
|
||||||
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
||||||
@mkdir $(f_release);
|
@mkdir $(f_release);
|
||||||
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
|
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
|
||||||
@@ -85,7 +85,7 @@ release: ## Build a Release version of the project
|
|||||||
|
|
||||||
opt = ""
|
opt = ""
|
||||||
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
||||||
@echo ">>> Running BayesNet & Platform tests...";
|
@echo ">>> Running Platform tests...";
|
||||||
@$(MAKE) clean
|
@$(MAKE) clean
|
||||||
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
|
@cmake --build $(f_debug) -t $(test_targets) $(n_procs)
|
||||||
@for t in $(test_targets); do \
|
@for t in $(test_targets); do \
|
||||||
@@ -105,19 +105,18 @@ testp: ## Run platform tests (opt="-s") to verbose output the tests, (opt="-c='S
|
|||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
opt = ""
|
opt = ""
|
||||||
testb: ## Run BayesNet tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
testb: ## Run Platform tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
||||||
@echo ">>> Running BayesNet tests...";
|
@echo ">>> Running Platform tests...";
|
||||||
@$(MAKE) clean
|
@$(MAKE) clean
|
||||||
@cmake --build $(f_debug) --target unit_tests_bayesnet $(n_procs)
|
@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 ;
|
@if [ -f $(f_debug)/tests/unit_tests_bayesnet ]; then cd $(f_debug)/tests ; ./unit_tests_bayesnet $(opt) ; fi ;
|
||||||
@echo ">>> Done";
|
@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
|
||||||
@cd $(f_debug) ; \
|
@gcovr $(f_debug)/tests
|
||||||
gcovr --config ../gcovr.cfg tests ;
|
@echo ">>> Done";
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
|
|
||||||
help: ## Show help message
|
help: ## Show help message
|
||||||
|
@@ -10,7 +10,7 @@ Platform to run Bayesian Networks and Machine Learning Classifiers experiments.
|
|||||||
|
|
||||||
## 0. Setup
|
## 0. Setup
|
||||||
|
|
||||||
Before compiling BayesNet.
|
Before compiling Platform.
|
||||||
|
|
||||||
### Miniconda
|
### Miniconda
|
||||||
|
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
if(ENABLE_TESTING)
|
if(ENABLE_TESTING)
|
||||||
set(TEST_PLATFORM "unit_tests_platform")
|
set(TEST_PLATFORM "unit_tests_platform")
|
||||||
include_directories(
|
include_directories(
|
||||||
${BayesNet_SOURCE_DIR}/src/BayesNet
|
${Platform_SOURCE_DIR}/src/Platform
|
||||||
${BayesNet_SOURCE_DIR}/src/Platform
|
${Platform_SOURCE_DIR}/lib/argparse/include
|
||||||
${BayesNet_SOURCE_DIR}/lib/Files
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/mdlp
|
||||||
${BayesNet_SOURCE_DIR}/lib/mdlp
|
${Platform_SOURCE_DIR}/lib/Files
|
||||||
${BayesNet_SOURCE_DIR}/lib/json/include
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
${BayesNet_SOURCE_DIR}/lib/argparse/include
|
|
||||||
)
|
)
|
||||||
set(TEST_SOURCES_PLATFORM TestUtils.cc)
|
set(TEST_SOURCES_PLATFORM TestUtils.cc)
|
||||||
add_executable(${TEST_PLATFORM} ${TEST_SOURCES_PLATFORM})
|
add_executable(${TEST_PLATFORM} ${TEST_SOURCES_PLATFORM})
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
#include "TestUtils.h"
|
#include "TestUtils.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
class Paths {
|
class Paths {
|
||||||
public:
|
public:
|
||||||
static std::string datasets()
|
static std::string datasets()
|
||||||
{
|
{
|
||||||
return "../../data/";
|
return { data_path.begin(), data_path.end() };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ std::vector<mdlp::labels_t> discretizeDataset(std::vector<mdlp::samples_t>& X, m
|
|||||||
return Xd;
|
return Xd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_exists(const std::std::string& name)
|
bool file_exists(const std::string& name)
|
||||||
{
|
{
|
||||||
if (FILE* file = fopen(name.c_str(), "r")) {
|
if (FILE* file = fopen(name.c_str(), "r")) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -44,7 +45,7 @@ bool file_exists(const std::std::string& name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<torch::Tensor, torch::Tensor, std::vector<std::string>, std::string, map<std::string, std::vector<int>>> loadDataset(const std::std::string& name, bool class_last, bool discretize_dataset)
|
tuple<torch::Tensor, torch::Tensor, std::vector<std::string>, std::string, map<std::string, std::vector<int>>> loadDataset(const std::string& name, bool class_last, bool discretize_dataset)
|
||||||
{
|
{
|
||||||
auto handler = ArffFiles();
|
auto handler = ArffFiles();
|
||||||
handler.load(Paths::datasets() + static_cast<std::string>(name) + ".arff", class_last);
|
handler.load(Paths::datasets() + static_cast<std::string>(name) + ".arff", class_last);
|
||||||
@@ -78,7 +79,7 @@ tuple<torch::Tensor, torch::Tensor, std::vector<std::string>, std::string, map<s
|
|||||||
return { Xd, torch::tensor(y, torch::kInt32), features, className, states };
|
return { Xd, torch::tensor(y, torch::kInt32), features, className, states };
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<std::vector<std::vector<int>>, std::vector<int>, std::vector<std::string>, std::string, map<std::string, std::vector<int>>> loadFile(const std::std::string& name)
|
tuple<std::vector<std::vector<int>>, std::vector<int>, std::vector<std::string>, std::string, map<std::string, std::vector<int>>> loadFile(const std::string& name)
|
||||||
{
|
{
|
||||||
auto handler = ArffFiles();
|
auto handler = ArffFiles();
|
||||||
handler.load(Paths::datasets() + static_cast<std::string>(name) + ".arff");
|
handler.load(Paths::datasets() + static_cast<std::string>(name) + ".arff");
|
||||||
|
@@ -4,11 +4,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <std::tuple>
|
#include <tuple>
|
||||||
#include "ArffFiles.h"
|
#include "ArffFiles.h"
|
||||||
#include "CPPFImdlp.h"
|
#include "CPPFImdlp.h"
|
||||||
|
|
||||||
bool file_exists(const std::std::string& name);
|
bool file_exists(const std::string& name);
|
||||||
std::pair<vector<mdlp::labels_t>, map<std::string, int>> discretize(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y, std::vector<string> features);
|
std::pair<vector<mdlp::labels_t>, map<std::string, int>> discretize(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y, std::vector<string> features);
|
||||||
std::vector<mdlp::labels_t> discretizeDataset(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y);
|
std::vector<mdlp::labels_t> discretizeDataset(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y);
|
||||||
std::tuple<vector<vector<int>>, std::vector<int>, std::vector<string>, std::string, map<std::string, std::vector<int>>> loadFile(const std::string& name);
|
std::tuple<vector<vector<int>>, std::vector<int>, std::vector<string>, std::string, map<std::string, std::vector<int>>> loadFile(const std::string& name);
|
||||||
|
Reference in New Issue
Block a user