From 7534cba7e6763f277d4f2540abc925e965810895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Fri, 8 Mar 2024 22:20:38 +0100 Subject: [PATCH] Refactor library structure --- .vscode/launch.json | 130 -------------------------------- CMakeLists.txt | 4 +- gcovr.cfg | 2 +- {src => pyclfs}/CMakeLists.txt | 2 +- {src => pyclfs}/ODTE.cc | 0 {src => pyclfs}/ODTE.h | 0 {src => pyclfs}/PyClassifier.cc | 0 {src => pyclfs}/PyClassifier.h | 8 +- {src => pyclfs}/PyHelper.hpp | 0 {src => pyclfs}/PyWrap.cc | 0 {src => pyclfs}/PyWrap.h | 2 +- {src => pyclfs}/RandomForest.cc | 0 {src => pyclfs}/RandomForest.h | 0 {src => pyclfs}/STree.cc | 0 {src => pyclfs}/STree.h | 0 {src => pyclfs}/SVC.cc | 0 {src => pyclfs}/SVC.h | 0 {src => pyclfs}/TypeId.h | 0 {src => pyclfs}/XGBoost.cc | 0 {src => pyclfs}/XGBoost.h | 0 tests/CMakeLists.txt | 6 +- tests/TestPythonClassifiers.cc | 18 ++--- tests/TestUtils.cc | 2 +- 23 files changed, 22 insertions(+), 152 deletions(-) delete mode 100644 .vscode/launch.json rename {src => pyclfs}/CMakeLists.txt (91%) rename {src => pyclfs}/ODTE.cc (100%) rename {src => pyclfs}/ODTE.h (100%) rename {src => pyclfs}/PyClassifier.cc (100%) rename {src => pyclfs}/PyClassifier.h (98%) rename {src => pyclfs}/PyHelper.hpp (100%) rename {src => pyclfs}/PyWrap.cc (100%) rename {src => pyclfs}/PyWrap.h (100%) rename {src => pyclfs}/RandomForest.cc (100%) rename {src => pyclfs}/RandomForest.h (100%) rename {src => pyclfs}/STree.cc (100%) rename {src => pyclfs}/STree.h (100%) rename {src => pyclfs}/SVC.cc (100%) rename {src => pyclfs}/SVC.h (100%) rename {src => pyclfs}/TypeId.h (100%) rename {src => pyclfs}/XGBoost.cc (100%) rename {src => pyclfs}/XGBoost.h (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 1e30c2d..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "sample", - "program": "${workspaceFolder}/build_debug/sample/BayesNetSample", - "args": [ - "-d", - "iris", - "-m", - "TANLd", - "-s", - "271", - "-p", - "/Users/rmontanana/Code/discretizbench/datasets/", - ], - //"cwd": "${workspaceFolder}/build/sample/", - }, - { - "type": "lldb", - "request": "launch", - "name": "experimentPy", - "program": "${workspaceFolder}/build_debug/src/Platform/b_main", - "args": [ - "-m", - "STree", - "--stratified", - "-d", - "iris", - //"--discretize" - // "--hyperparameters", - // "{\"repeatSparent\": true, \"maxModels\": 12}" - ], - "cwd": "${workspaceFolder}/../discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "gridsearch", - "program": "${workspaceFolder}/build_debug/src/Platform/b_grid", - "args": [ - "-m", - "KDB", - "--discretize", - "--continue", - "glass", - "--only", - "--compute" - ], - "cwd": "${workspaceFolder}/../discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "experimentBayes", - "program": "${workspaceFolder}/build_debug/src/Platform/b_main", - "args": [ - "-m", - "TAN", - "--stratified", - "--discretize", - "-d", - "iris", - "--hyperparameters", - "{\"repeatSparent\": true, \"maxModels\": 12}" - ], - "cwd": "/home/rmontanana/Code/discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "best", - "program": "${workspaceFolder}/build_debug/src/Platform/b_best", - "args": [ - "-m", - "BoostAODE", - "-s", - "accuracy", - "--build", - ], - "cwd": "${workspaceFolder}/../discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "manage", - "program": "${workspaceFolder}/build_debug/src/Platform/b_manage", - "args": [ - "-n", - "20" - ], - "cwd": "${workspaceFolder}/../discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "list", - "program": "${workspaceFolder}/build_debug/src/Platform/b_list", - "args": [], - //"cwd": "/Users/rmontanana/Code/discretizbench", - "cwd": "${workspaceFolder}/../discretizbench", - }, - { - "type": "lldb", - "request": "launch", - "name": "test", - "program": "${workspaceFolder}/build_debug/tests/unit_tests", - "args": [ - "-c=\"Metrics Test\"", - // "-s", - ], - "cwd": "${workspaceFolder}/build/tests", - }, - { - "name": "Build & debug active file", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build_debug/bayesnet", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "lldb", - "preLaunchTask": "CMake: build" - } - ] -} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c1c7d5..942002b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ find_library(BayesNet NAMES libBayesNet BayesNet) # Subdirectories # -------------- -add_subdirectory(src) +add_subdirectory(pyclfs) # Testing # ------- @@ -88,5 +88,5 @@ install(TARGETS PyClassifiers ARCHIVE DESTINATION lib LIBRARY DESTINATION lib CONFIGURATIONS Release) -install(DIRECTORY src/ DESTINATION include/pyclassifiers FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h" PATTERN "*.hpp") +install(DIRECTORY pyclfs/ DESTINATION include/pyclassifiers FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h" PATTERN "*.hpp") install(FILES /usr/local/include/bayesnet/config.h DESTINATION include/pyclassifiers CONFIGURATIONS Release) \ No newline at end of file diff --git a/gcovr.cfg b/gcovr.cfg index 89e0877..5af1915 100644 --- a/gcovr.cfg +++ b/gcovr.cfg @@ -1,4 +1,4 @@ -filter = src/ +filter = pyclfs/ exclude-directories = build_debug/lib/ print-summary = yes sort-percentage = yes diff --git a/src/CMakeLists.txt b/pyclfs/CMakeLists.txt similarity index 91% rename from src/CMakeLists.txt rename to pyclfs/CMakeLists.txt index ff9d751..1e329b9 100644 --- a/src/CMakeLists.txt +++ b/pyclfs/CMakeLists.txt @@ -2,7 +2,7 @@ include_directories( ${Python3_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS} ${PyClassifiers_SOURCE_DIR}/lib/json/include - /usr/local/include/bayesnet + /usr/local/include ) add_library(PyClassifiers ODTE.cc STree.cc SVC.cc RandomForest.cc XGBoost.cc PyClassifier.cc PyWrap.cc) target_link_libraries(PyClassifiers ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy) \ No newline at end of file diff --git a/src/ODTE.cc b/pyclfs/ODTE.cc similarity index 100% rename from src/ODTE.cc rename to pyclfs/ODTE.cc diff --git a/src/ODTE.h b/pyclfs/ODTE.h similarity index 100% rename from src/ODTE.h rename to pyclfs/ODTE.h diff --git a/src/PyClassifier.cc b/pyclfs/PyClassifier.cc similarity index 100% rename from src/PyClassifier.cc rename to pyclfs/PyClassifier.cc diff --git a/src/PyClassifier.h b/pyclfs/PyClassifier.h similarity index 98% rename from src/PyClassifier.h rename to pyclfs/PyClassifier.h index fc44bb4..e972686 100644 --- a/src/PyClassifier.h +++ b/pyclfs/PyClassifier.h @@ -1,15 +1,15 @@ #ifndef PYCLASSIFIER_H #define PYCLASSIFIER_H -#include "boost/python/detail/wrap_python.hpp" -#include -#include #include #include #include #include +#include "boost/python/detail/wrap_python.hpp" +#include #include +#include +#include "bayesnet/classifiers/Classifier.h" #include "PyWrap.h" -#include "classifiers/Classifier.h" #include "TypeId.h" namespace pywrap { diff --git a/src/PyHelper.hpp b/pyclfs/PyHelper.hpp similarity index 100% rename from src/PyHelper.hpp rename to pyclfs/PyHelper.hpp diff --git a/src/PyWrap.cc b/pyclfs/PyWrap.cc similarity index 100% rename from src/PyWrap.cc rename to pyclfs/PyWrap.cc diff --git a/src/PyWrap.h b/pyclfs/PyWrap.h similarity index 100% rename from src/PyWrap.h rename to pyclfs/PyWrap.h index d23b746..b953ff0 100644 --- a/src/PyWrap.h +++ b/pyclfs/PyWrap.h @@ -1,11 +1,11 @@ #ifndef PYWRAP_H #define PYWRAP_H -#include "boost/python/detail/wrap_python.hpp" #include #include #include #include #include +#include "boost/python/detail/wrap_python.hpp" #include "PyHelper.hpp" #include "TypeId.h" #pragma once diff --git a/src/RandomForest.cc b/pyclfs/RandomForest.cc similarity index 100% rename from src/RandomForest.cc rename to pyclfs/RandomForest.cc diff --git a/src/RandomForest.h b/pyclfs/RandomForest.h similarity index 100% rename from src/RandomForest.h rename to pyclfs/RandomForest.h diff --git a/src/STree.cc b/pyclfs/STree.cc similarity index 100% rename from src/STree.cc rename to pyclfs/STree.cc diff --git a/src/STree.h b/pyclfs/STree.h similarity index 100% rename from src/STree.h rename to pyclfs/STree.h diff --git a/src/SVC.cc b/pyclfs/SVC.cc similarity index 100% rename from src/SVC.cc rename to pyclfs/SVC.cc diff --git a/src/SVC.h b/pyclfs/SVC.h similarity index 100% rename from src/SVC.h rename to pyclfs/SVC.h diff --git a/src/TypeId.h b/pyclfs/TypeId.h similarity index 100% rename from src/TypeId.h rename to pyclfs/TypeId.h diff --git a/src/XGBoost.cc b/pyclfs/XGBoost.cc similarity index 100% rename from src/XGBoost.cc rename to pyclfs/XGBoost.cc diff --git a/src/XGBoost.h b/pyclfs/XGBoost.h similarity index 100% rename from src/XGBoost.h rename to pyclfs/XGBoost.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 047d879..d490b1c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,15 +1,15 @@ if(ENABLE_TESTING) set(TEST_PYCLASSIFIERS "unit_tests_pyclassifiers") include_directories( - ${PyClassifiers_SOURCE_DIR}/src/ + ${PyClassifiers_SOURCE_DIR} ${PyClassifiers_SOURCE_DIR}/lib/Files ${PyClassifiers_SOURCE_DIR}/lib/mdlp ${PyClassifiers_SOURCE_DIR}/lib/json/include ${Python3_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS} - /usr/local/include/bayesnet + /usr/local/include ) - file(GLOB_RECURSE PyClassifiers_SOURCES "${PyClassifiers_SOURCE_DIR}/src/*.cc") + file(GLOB_RECURSE PyClassifiers_SOURCES "${PyClassifiers_SOURCE_DIR}/pyclfs/*.cc") set(TEST_SOURCES_PYCLASSIFIERS TestPythonClassifiers.cc TestUtils.cc ${PyClassifiers_SOURCES}) add_executable(${TEST_PYCLASSIFIERS} ${TEST_SOURCES_PYCLASSIFIERS}) target_link_libraries(${TEST_PYCLASSIFIERS} PUBLIC "${TORCH_LIBRARIES}" ${Python3_LIBRARIES} ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy ArffFiles mdlp Catch2::Catch2WithMain) diff --git a/tests/TestPythonClassifiers.cc b/tests/TestPythonClassifiers.cc index efd08cf..e72c4b1 100644 --- a/tests/TestPythonClassifiers.cc +++ b/tests/TestPythonClassifiers.cc @@ -1,17 +1,17 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do -#include -#include -#include #include #include #include -#include "STree.h" -#include "SVC.h" -#include "RandomForest.h" -#include "XGBoost.h" -#include "ODTE.h" -#include "TestUtils.h" +#include +#include +#include #include +#include "pyclfs/STree.h" +#include "pyclfs/SVC.h" +#include "pyclfs/RandomForest.h" +#include "pyclfs/XGBoost.h" +#include "pyclfs/ODTE.h" +#include "TestUtils.h" const std::string ACTUAL_VERSION = "1.0.4"; diff --git a/tests/TestUtils.cc b/tests/TestUtils.cc index 5a0910e..64f5769 100644 --- a/tests/TestUtils.cc +++ b/tests/TestUtils.cc @@ -1,5 +1,5 @@ #include "TestUtils.h" -#include "config.h" +#include "bayesnet/config.h" class Paths { public: