summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistent_cohomology/test')
-rw-r--r--src/Persistent_cohomology/test/CMakeLists.txt44
-rw-r--r--src/Persistent_cohomology/test/README6
-rw-r--r--src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp5
-rw-r--r--src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp89
-rw-r--r--src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt58
-rw-r--r--src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt.REMOVED.git-id1
6 files changed, 128 insertions, 75 deletions
diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt
index 9dc19251..ed63a6ac 100644
--- a/src/Persistent_cohomology/test/CMakeLists.txt
+++ b/src/Persistent_cohomology/test/CMakeLists.txt
@@ -1,29 +1,39 @@
cmake_minimum_required(VERSION 2.6)
-project(GUDHITestSimplexTree)
+project(GUDHIPersistentCohomologyUT)
-if(NOT MSVC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --coverage")
+if (GCOVR_PATH)
+ # for gcovr to make coverage reports - Corbera Jenkins plugin
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
+endif()
+if (GPROF_PATH)
+ # for gprof to make coverage reports - Jenkins
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
endif()
-add_executable ( persistent_cohomology_unit_test persistent_cohomology_unit_test.cpp )
-target_link_libraries(persistent_cohomology_unit_test ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+add_executable ( PersistentCohomologyUT persistent_cohomology_unit_test.cpp )
+target_link_libraries(PersistentCohomologyUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
# Unitary tests
-add_test(persistent_cohomology_unit_test ${CMAKE_CURRENT_BINARY_DIR}/persistent_cohomology_unit_test ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_unit_test.txt)
+add_test(NAME PersistentCohomologyUT
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/PersistentCohomologyUT
+ ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_unit_test.txt
+ # XML format for Jenkins xUnit plugin
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/PersistentCohomologyUT.xml --log_level=test_suite --report_level=no)
if(GMPXX_FOUND AND GMP_FOUND)
- add_executable ( persistent_cohomology_unit_test_multi_field persistent_cohomology_unit_test_multi_field.cpp )
- target_link_libraries(persistent_cohomology_unit_test_multi_field ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
+ add_executable ( PersistentCohomologyMultiFieldUT persistent_cohomology_unit_test_multi_field.cpp )
+ target_link_libraries(PersistentCohomologyMultiFieldUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
- # Unitary tests
- add_test(persistent_cohomology_unit_test_multi_field ${CMAKE_CURRENT_BINARY_DIR}/persistent_cohomology_unit_test_multi_field ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt)
-endif()
+ # Unitary tests
+ add_test(NAME PersistentCohomologyMultiFieldUT
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/PersistentCohomologyMultiFieldUT
+ ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt
+ # XML format for Jenkins xUnit plugin
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/PersistentCohomologyMultiFieldUT.xml --log_level=test_suite --report_level=no)
-if (LCOV_PATH)
- # Lcov code coverage of unitary test
- add_test(src/Persistent_cohomology/lcov/coverage.log ${CMAKE_SOURCE_DIR}/scripts/check_code_coverage.sh ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology)
endif()
-cpplint_add_tests("${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/include/gudhi")
diff --git a/src/Persistent_cohomology/test/README b/src/Persistent_cohomology/test/README
index ddceac63..6c64b5fe 100644
--- a/src/Persistent_cohomology/test/README
+++ b/src/Persistent_cohomology/test/README
@@ -1,7 +1,9 @@
To compile:
***********
+cd /path-to-gudhi/
cmake .
+cd /path-to-test/
make
To launch with details:
@@ -9,13 +11,13 @@ To launch with details:
SINGLE FIELD
------------
-./persistent_cohomology_unit_test simplex_tree_file_for_unit_test.txt --report_level=detailed --log_level=all
+./PersistentCohomologyUT simplex_tree_file_for_unit_test.txt --report_level=detailed --log_level=all
==> echo $? returns 0 in case of success (non-zero otherwise)
MULTI FIELD
-----------
-./persistent_cohomology_unit_test_multi_field simplex_tree_file_for_multi_field_unit_test.txt --report_level=detailed --log_level=all
+./PersistentCohomologyMultiFieldUT simplex_tree_file_for_multi_field_unit_test.txt --report_level=detailed --log_level=all
==> echo $? returns 0 in case of success (non-zero otherwise)
diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
index 1e7a74a7..55bc7066 100644
--- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
+++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
@@ -1,4 +1,4 @@
-#define BOOST_TEST_MODULE const_string test
+#define BOOST_TEST_MODULE persistent_cohomology test
#include <boost/test/included/unit_test.hpp>
#include <boost/system/error_code.hpp>
#include <boost/chrono/thread_clock.hpp>
@@ -22,8 +22,7 @@ using namespace boost::unit_test;
typedef Simplex_tree<> typeST;
std::string test_rips_persistence(int coefficient, int min_persistence) {
- // Check file name is given as parameter from CMakeLists.txt
- BOOST_CHECK(framework::master_test_suite().argc >= 2);
+ // file name is given as parameter from CMakeLists.txt
const std::string inputFile(framework::master_test_suite().argv[1]);
std::ifstream simplex_tree_stream;
diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp
index e88add3a..18a4725e 100644
--- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp
+++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp
@@ -1,4 +1,4 @@
-#define BOOST_TEST_MODULE const_string test
+#define BOOST_TEST_MODULE persistent_cohomology_multi_field test
#include <boost/test/included/unit_test.hpp>
#include <boost/system/error_code.hpp>
#include <boost/chrono/thread_clock.hpp>
@@ -23,8 +23,7 @@ using namespace boost::unit_test;
typedef Simplex_tree<> typeST;
std::string test_rips_persistence(int min_coefficient, int max_coefficient, int min_persistence) {
- // Check file name is given as parameter from CMakeLists.txt
- BOOST_CHECK(framework::master_test_suite().argc >= 2);
+ // file name is given as parameter from CMakeLists.txt
const std::string inputFile(framework::master_test_suite().argv[1]);
std::ifstream simplex_tree_stream;
@@ -38,9 +37,9 @@ std::string test_rips_persistence(int min_coefficient, int max_coefficient, int
<< " - filtration= " << st.filtration() << std::endl;
// Check
- BOOST_CHECK(st.num_simplices() == 6142604);
+ BOOST_CHECK(st.num_simplices() == 58);
BOOST_CHECK(st.dimension() == 3);
- BOOST_CHECK(st.filtration() == 0.249999);
+ BOOST_CHECK(st.filtration() == 0.4);
// Sort the simplices in the order of the filtration
st.initialize_filtration();
@@ -48,9 +47,9 @@ std::string test_rips_persistence(int min_coefficient, int max_coefficient, int
// Compute the persistence diagram of the complex
Persistent_cohomology<Simplex_tree<>, Multi_field> pcoh(st);
- pcoh.init_coefficients(min_coefficient, max_coefficient); // initializes the coefficient field for homology
+ pcoh.init_coefficients(min_coefficient, max_coefficient); // initializes the coefficient field for homology
// Check infinite rips
- pcoh.compute_persistent_cohomology(min_persistence); // Minimal lifetime of homology feature to be recorded.
+ pcoh.compute_persistent_cohomology(min_persistence); // Minimal lifetime of homology feature to be recorded.
std::ostringstream ossRips;
pcoh.output_diagram(ossRips);
@@ -60,68 +59,54 @@ std::string test_rips_persistence(int min_coefficient, int max_coefficient, int
}
void test_rips_persistence_in_dimension(int min_dimension, int max_dimension) {
- std::string value0(" 0 0 inf");
- std::string value1(" 1 0.0702103 inf");
- std::string value2("2 1 0.0702103 inf");
- std::string value3("2 2 0.159992 inf");
+ // there are 2 discontinued ensembles
+ std::string value0(" 0 0.25 inf");
+ std::string value1(" 1 0.4 inf");
+ // And a big hole - cut in 2 pieces after 0.3
+ std::string value2(" 0 0.2 0.3");
+
+ // For dim <= 1 =>
+ std::string value3(" 1 0.25 inf");
+ std::string value4(" 2 0.25 inf");
+ std::string value5(" 1 0.3 inf");
+ std::string value6(" 2 0.3 inf");
+ std::string value7(" 2 0.4 inf");
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF RIPS_PERSISTENT_COHOMOLOGY_MULTI_FIELD MIN_DIM=" << min_dimension << " MAX_DIM=" << max_dimension << " MIN_PERS=0" << std::endl;
- std::string str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, 1);
-
- BOOST_CHECK(str_rips_persistence.find(value0) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value1) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value2) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value3) != std::string::npos); // Check found
- std::cout << "str_rips_persistence=" << str_rips_persistence << std::endl;
-
- std::cout << "********************************************************************" << std::endl;
- std::cout << "TEST OF RIPS_PERSISTENT_COHOMOLOGY_MULTI_FIELD DIM=" << min_dimension << " MAX_DIM=" << max_dimension << " MIN_PERS=2" << std::endl;
-
- str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, 2);
-
- BOOST_CHECK(str_rips_persistence.find(value0) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value1) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value2) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value3) != std::string::npos); // Check found
+ std::string str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, static_cast<Filtration_value> (0.0));
std::cout << "str_rips_persistence=" << str_rips_persistence << std::endl;
- std::cout << "********************************************************************" << std::endl;
- std::cout << "TEST OF RIPS_PERSISTENT_COHOMOLOGY_MULTI_FIELD DIM=" << min_dimension << " MAX_DIM=" << max_dimension << " MIN_PERS=3" << std::endl;
-
- str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, 3);
-
BOOST_CHECK(str_rips_persistence.find(value0) != std::string::npos); // Check found
BOOST_CHECK(str_rips_persistence.find(value1) != std::string::npos); // Check found
BOOST_CHECK(str_rips_persistence.find(value2) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value3) != std::string::npos); // Check found
- std::cout << "str_rips_persistence=" << str_rips_persistence << std::endl;
- std::cout << "********************************************************************" << std::endl;
- std::cout << "TEST OF RIPS_PERSISTENT_COHOMOLOGY_MULTI_FIELD DIM=" << min_dimension << " MAX_DIM=" << max_dimension << " MIN_PERS=Inf" << std::endl;
+ if ((min_dimension < 2) && (max_dimension < 2)) {
+ BOOST_CHECK(str_rips_persistence.find(value3) != std::string::npos); // Check found
+ BOOST_CHECK(str_rips_persistence.find(value4) != std::string::npos); // Check found
+ BOOST_CHECK(str_rips_persistence.find(value5) != std::string::npos); // Check found
+ BOOST_CHECK(str_rips_persistence.find(value6) != std::string::npos); // Check found
+ BOOST_CHECK(str_rips_persistence.find(value7) != std::string::npos); // Check found
+ } else {
+ BOOST_CHECK(str_rips_persistence.find(value3) == std::string::npos); // Check not found
+ BOOST_CHECK(str_rips_persistence.find(value4) == std::string::npos); // Check not found
+ BOOST_CHECK(str_rips_persistence.find(value5) == std::string::npos); // Check not found
+ BOOST_CHECK(str_rips_persistence.find(value6) == std::string::npos); // Check not found
+ BOOST_CHECK(str_rips_persistence.find(value7) == std::string::npos); // Check not found
+ }
- str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, std::numeric_limits<int>::max());
-
- BOOST_CHECK(str_rips_persistence.find(value0) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value1) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value2) != std::string::npos); // Check found
- BOOST_CHECK(str_rips_persistence.find(value3) != std::string::npos); // Check found
- std::cout << "str_rips_persistence=" << str_rips_persistence << std::endl;
}
-BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_multi_field_dim_1_2 )
-{
- test_rips_persistence_in_dimension(1, 2);
+BOOST_AUTO_TEST_CASE(rips_persistent_cohomology_multi_field_dim_1_2) {
+ test_rips_persistence_in_dimension(0, 1);
}
-BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_multi_field_dim_2_3 )
-{
- test_rips_persistence_in_dimension(2, 3);
+BOOST_AUTO_TEST_CASE(rips_persistent_cohomology_multi_field_dim_2_3) {
+ test_rips_persistence_in_dimension(1, 3);
}
-BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_multi_field_dim_1_5 )
-{
+BOOST_AUTO_TEST_CASE(rips_persistent_cohomology_multi_field_dim_1_5) {
test_rips_persistence_in_dimension(1, 5);
}
diff --git a/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt b/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt
new file mode 100644
index 00000000..ed2c0c3d
--- /dev/null
+++ b/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt
@@ -0,0 +1,58 @@
+0 0 0.2
+0 3 0.2
+1 3 0 0.2
+0 6 0.2
+0 11 0.2
+1 11 6 0.2
+0 13 0.25
+0 14 0.25
+1 14 13 0.25
+0 15 0.25
+1 15 13 0.25
+1 15 14 0.25
+2 15 14 13 0.25
+0 1 0.3
+1 1 0 0.3
+0 2 0.3
+1 2 0 0.3
+1 2 1 0.3
+2 2 1 0 0.3
+0 4 0.3
+1 4 3 0.3
+0 5 0.3
+1 5 3 0.3
+1 5 4 0.3
+2 5 4 3 0.3
+0 9 0.3
+0 10 0.3
+1 10 2 0.3
+1 10 9 0.3
+1 11 9 0.3
+1 11 10 0.3
+2 11 10 9 0.3
+0 12 0.3
+1 12 2 0.3
+1 12 10 0.3
+2 12 10 2 0.3
+1 6 0 0.4
+1 6 1 0.4
+2 6 1 0 0.4
+0 7 0.4
+1 7 0 0.4
+1 7 1 0.4
+2 7 1 0 0.4
+1 7 6 0.4
+2 7 6 0 0.4
+2 7 6 1 0.4
+3 7 6 1 0 0.4
+0 8 0.4
+1 8 4 0.4
+1 8 5 0.4
+2 8 5 4 0.4
+1 9 4 0.4
+1 9 5 0.4
+2 9 5 4 0.4
+1 9 8 0.4
+2 9 8 4 0.4
+2 9 8 5 0.4
+3 9 8 5 4 0.4
diff --git a/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt.REMOVED.git-id b/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt.REMOVED.git-id
deleted file mode 100644
index 2dd38515..00000000
--- a/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-ce87199d425b05f51c74cbf635870bfa5abbc7a1 \ No newline at end of file