mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-15 07:25:56 +00:00
Compiling right
This commit is contained in:
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -104,6 +104,10 @@
|
||||
"stop_token": "cpp",
|
||||
"text_encoding": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"valarray": "cpp"
|
||||
"valarray": "cpp",
|
||||
"csignal": "cpp",
|
||||
"regex": "cpp",
|
||||
"future": "cpp",
|
||||
"shared_mutex": "cpp"
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ endif()
|
||||
|
||||
if (ENABLE_TESTING)
|
||||
message("Debug mode")
|
||||
|
||||
enable_testing()
|
||||
set(CODE_COVERAGE ON)
|
||||
set(GCC_COVERAGE_LINK_FLAGS "${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||
@@ -47,7 +48,7 @@ include_directories(
|
||||
)
|
||||
|
||||
add_library(fimdlp src/CPPFImdlp.cpp src/Metrics.cpp src/BinDisc.cpp src/Discretizer.cpp)
|
||||
target_link_libraries(fimdlp torch::torch)
|
||||
target_link_libraries(fimdlp PRIVATE torch::torch)
|
||||
|
||||
# Installation
|
||||
# ------------
|
||||
|
@@ -54,11 +54,9 @@ class FimdlpConan(ConanFile):
|
||||
self.requires("libtorch/2.7.0")
|
||||
|
||||
def build_requirements(self):
|
||||
# Test dependencies - only when testing is enabled
|
||||
self.requires("arff-files/1.2.0") # for tests and sample
|
||||
if self.options.enable_testing:
|
||||
self.requires("catch2/3.8.1")
|
||||
self.requires("arff/1.2.0")
|
||||
self.requires("gtest/1.16.0")
|
||||
self.test_requires("gtest/1.16.0")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
@@ -2,14 +2,15 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
find_package(Torch REQUIRED)
|
||||
find_package(arff-files REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${fimdlp_SOURCE_DIR}/src
|
||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||
${CMAKE_BINARY_DIR}/configured_files/include
|
||||
${libtorch_INCLUDE_DIRS_RELEASE}
|
||||
${arff-files_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
add_executable(sample sample.cpp )
|
||||
target_link_libraries(sample PRIVATE fimdlp torch::torch)
|
||||
add_executable(sample sample.cpp)
|
||||
target_link_libraries(sample PRIVATE fimdlp torch::torch arff-files::arff-files)
|
||||
|
@@ -16,13 +16,13 @@ namespace mdlp {
|
||||
const float margin = 1e-4;
|
||||
static std::string set_data_path()
|
||||
{
|
||||
std::string path = "../datasets/";
|
||||
std::string path = "datasets/";
|
||||
std::ifstream file(path + "iris.arff");
|
||||
if (file.is_open()) {
|
||||
file.close();
|
||||
return path;
|
||||
}
|
||||
return "../../tests/datasets/";
|
||||
return "tests/datasets/";
|
||||
}
|
||||
const std::string data_path = set_data_path();
|
||||
class TestBinDisc3U : public BinDisc, public testing::Test {
|
||||
|
@@ -1,27 +1,11 @@
|
||||
# Check if we should use Catch2 from Conan or GoogleTest via FetchContent
|
||||
find_package(Catch2 3 QUIET)
|
||||
|
||||
if(Catch2_FOUND)
|
||||
message(STATUS "Using Catch2 from Conan")
|
||||
set(TEST_FRAMEWORK "Catch2")
|
||||
else()
|
||||
message(STATUS "Using GoogleTest via FetchContent")
|
||||
set(TEST_FRAMEWORK "GoogleTest")
|
||||
include(FetchContent)
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
endif()
|
||||
find_package(arff-files REQUIRED)
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${libtorch_INCLUDE_DIRS_DEBUG}
|
||||
${fimdlp_SOURCE_DIR}/src
|
||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||
${arff-files_INCLUDE_DIRS}
|
||||
${CMAKE_BINARY_DIR}/configured_files/include
|
||||
)
|
||||
|
||||
@@ -32,18 +16,18 @@ target_link_options(Metrics_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(FImdlp_unittest FImdlp_unittest.cpp
|
||||
${fimdlp_SOURCE_DIR}/src/CPPFImdlp.cpp ${fimdlp_SOURCE_DIR}/src/Metrics.cpp ${fimdlp_SOURCE_DIR}/src/Discretizer.cpp)
|
||||
target_link_libraries(FImdlp_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_link_libraries(FImdlp_unittest GTest::gtest_main torch::torch)
|
||||
target_compile_options(FImdlp_unittest PRIVATE --coverage)
|
||||
target_link_options(FImdlp_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(BinDisc_unittest BinDisc_unittest.cpp ${fimdlp_SOURCE_DIR}/src/BinDisc.cpp ${fimdlp_SOURCE_DIR}/src/Discretizer.cpp)
|
||||
target_link_libraries(BinDisc_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_link_libraries(BinDisc_unittest GTest::gtest_main torch::torch)
|
||||
target_compile_options(BinDisc_unittest PRIVATE --coverage)
|
||||
target_link_options(BinDisc_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(Discretizer_unittest Discretizer_unittest.cpp
|
||||
${fimdlp_SOURCE_DIR}/src/BinDisc.cpp ${fimdlp_SOURCE_DIR}/src/CPPFImdlp.cpp ${fimdlp_SOURCE_DIR}/src/Metrics.cpp ${fimdlp_SOURCE_DIR}/src/Discretizer.cpp )
|
||||
target_link_libraries(Discretizer_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_link_libraries(Discretizer_unittest GTest::gtest_main torch::torch)
|
||||
target_compile_options(Discretizer_unittest PRIVATE --coverage)
|
||||
target_link_options(Discretizer_unittest PRIVATE --coverage)
|
||||
|
||||
|
@@ -17,13 +17,13 @@ namespace mdlp {
|
||||
const float margin = 1e-4;
|
||||
static std::string set_data_path()
|
||||
{
|
||||
std::string path = "../datasets/";
|
||||
std::string path = "datasets/";
|
||||
std::ifstream file(path + "iris.arff");
|
||||
if (file.is_open()) {
|
||||
file.close();
|
||||
return path;
|
||||
}
|
||||
return "../../tests/datasets/";
|
||||
return "tests/datasets/";
|
||||
}
|
||||
const std::string data_path = set_data_path();
|
||||
const labels_t iris_quantile = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 3, 3, 3, 1, 3, 1, 2, 0, 3, 1, 0, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 1, 2, 3, 2, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 1, 1, 2, 2, 3, 2, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 3, 2, 3, 1, 3, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 2, 2 };
|
||||
@@ -33,7 +33,7 @@ namespace mdlp {
|
||||
auto version = disc->version();
|
||||
delete disc;
|
||||
std::cout << "Version computed: " << version;
|
||||
EXPECT_EQ("2.0.1", version);
|
||||
EXPECT_EQ("2.1.0", version);
|
||||
}
|
||||
TEST(Discretizer, BinIrisUniform)
|
||||
{
|
||||
|
@@ -40,13 +40,13 @@ namespace mdlp {
|
||||
|
||||
static string set_data_path()
|
||||
{
|
||||
string path = "../datasets/";
|
||||
string path = "datasets/";
|
||||
ifstream file(path + "iris.arff");
|
||||
if (file.is_open()) {
|
||||
file.close();
|
||||
return path;
|
||||
}
|
||||
return "../../tests/datasets/";
|
||||
return "tests/datasets/";
|
||||
}
|
||||
|
||||
void checkSortedVector()
|
||||
|
Reference in New Issue
Block a user