From 17cf8da254d88fa42cbe9e7bb486147def47c26b Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 6 Dec 2019 15:27:15 +0100 Subject: Modify boost tests to be more verbose and errors in colour. I kept coverage tests (was only used by Jenkins) and they still can be activated through an option --- src/Alpha_complex/test/CMakeLists.txt | 22 +++++++-------- src/Bitmap_cubical_complex/test/CMakeLists.txt | 5 ++-- src/Bottleneck_distance/test/CMakeLists.txt | 5 ++-- src/Cech_complex/test/CMakeLists.txt | 5 ++-- src/Nerve_GIC/test/CMakeLists.txt | 5 ++-- .../test/CMakeLists.txt | 33 ++++++---------------- src/Persistent_cohomology/test/CMakeLists.txt | 13 ++++----- src/Rips_complex/test/CMakeLists.txt | 5 ++-- src/Simplex_tree/test/CMakeLists.txt | 18 ++++-------- src/Skeleton_blocker/test/CMakeLists.txt | 11 +++----- src/Spatial_searching/test/CMakeLists.txt | 9 ++---- src/Subsampling/test/CMakeLists.txt | 14 ++++----- src/Tangential_complex/test/CMakeLists.txt | 6 ++-- src/Toplex_map/test/CMakeLists.txt | 8 ++---- src/Witness_complex/test/CMakeLists.txt | 8 ++---- src/cmake/modules/GUDHI_boost_test.cmake | 26 +++++++++++++++++ src/cmake/modules/GUDHI_compilation_flags.cmake | 2 ++ src/cmake/modules/GUDHI_test_coverage.cmake | 26 ----------------- src/common/test/CMakeLists.txt | 13 +++------ 19 files changed, 95 insertions(+), 139 deletions(-) create mode 100644 src/cmake/modules/GUDHI_boost_test.cmake delete mode 100644 src/cmake/modules/GUDHI_test_coverage.cmake (limited to 'src') diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index ad5b6314..0476c6d4 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -1,27 +1,27 @@ project(Alpha_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Alpha_complex_test_unit Alpha_complex_unit_test.cpp ) - target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Alpha_complex_test_unit) + gudhi_add_boost_test(Alpha_complex_test_unit) add_executable ( Alpha_complex_3d_test_unit Alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Weighted_alpha_complex_3d_test_unit Weighted_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Weighted_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Weighted_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Periodic_alpha_complex_3d_test_unit Periodic_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) add_executable ( Weighted_periodic_alpha_complex_3d_test_unit Weighted_periodic_alpha_complex_3d_unit_test.cpp ) - target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_3d_test_unit ${TBB_LIBRARIES}) target_link_libraries(Weighted_alpha_complex_3d_test_unit ${TBB_LIBRARIES}) @@ -29,9 +29,9 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) target_link_libraries(Weighted_periodic_alpha_complex_3d_test_unit ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Weighted_alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Periodic_alpha_complex_3d_test_unit) - gudhi_add_coverage_test(Weighted_periodic_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Alpha_complex_3d_test_unit) + gudhi_add_boost_test(Weighted_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Periodic_alpha_complex_3d_test_unit) + gudhi_add_boost_test(Weighted_periodic_alpha_complex_3d_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Bitmap_cubical_complex/test/CMakeLists.txt b/src/Bitmap_cubical_complex/test/CMakeLists.txt index d2f002a6..eb7eb6b5 100644 --- a/src/Bitmap_cubical_complex/test/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/test/CMakeLists.txt @@ -1,14 +1,13 @@ project(Bitmap_cubical_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/sinusoid.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Bitmap_cubical_complex_test_unit Bitmap_test.cpp ) -target_link_libraries(Bitmap_cubical_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bitmap_cubical_complex_test_unit ${TBB_LIBRARIES}) endif() -gudhi_add_coverage_test(Bitmap_cubical_complex_test_unit) +gudhi_add_boost_test(Bitmap_cubical_complex_test_unit) diff --git a/src/Bottleneck_distance/test/CMakeLists.txt b/src/Bottleneck_distance/test/CMakeLists.txt index ec2d045f..3acd3d86 100644 --- a/src/Bottleneck_distance/test/CMakeLists.txt +++ b/src/Bottleneck_distance/test/CMakeLists.txt @@ -1,14 +1,13 @@ project(Bottleneck_distance_tests) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable ( Bottleneck_distance_test_unit bottleneck_unit_test.cpp ) - target_link_libraries(Bottleneck_distance_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bottleneck_distance_test_unit ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Bottleneck_distance_test_unit) + gudhi_add_boost_test(Bottleneck_distance_test_unit) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Cech_complex/test/CMakeLists.txt b/src/Cech_complex/test/CMakeLists.txt index 8db51173..db510af3 100644 --- a/src/Cech_complex/test/CMakeLists.txt +++ b/src/Cech_complex/test/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 2.6) project(Cech_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Cech_complex_test_unit test_cech_complex.cpp ) -target_link_libraries(Cech_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Cech_complex_test_unit ${TBB_LIBRARIES}) endif() @@ -12,4 +11,4 @@ endif() # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Cech_complex_test_unit) +gudhi_add_boost_test(Cech_complex_test_unit) diff --git a/src/Nerve_GIC/test/CMakeLists.txt b/src/Nerve_GIC/test/CMakeLists.txt index b89c18a2..567bf43f 100644 --- a/src/Nerve_GIC/test/CMakeLists.txt +++ b/src/Nerve_GIC/test/CMakeLists.txt @@ -1,16 +1,15 @@ project(Graph_induced_complex_tests) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable ( Nerve_GIC_test_unit test_GIC.cpp ) - target_link_libraries(Nerve_GIC_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Nerve_GIC_test_unit ${TBB_LIBRARIES}) endif() file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - gudhi_add_coverage_test(Nerve_GIC_test_unit) + gudhi_add_boost_test(Nerve_GIC_test_unit) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) diff --git a/src/Persistence_representations/test/CMakeLists.txt b/src/Persistence_representations/test/CMakeLists.txt index a95880c9..92d68a63 100644 --- a/src/Persistence_representations/test/CMakeLists.txt +++ b/src/Persistence_representations/test/CMakeLists.txt @@ -1,51 +1,36 @@ project(Persistence_representations_test) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # copy data directory for tests purpose. file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Persistence_intervals_test_unit persistence_intervals_test.cpp ) -target_link_libraries(Persistence_intervals_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_intervals_test_unit) +gudhi_add_boost_test(Persistence_intervals_test_unit) add_executable (Vector_representation_test_unit vector_representation_test.cpp ) -target_link_libraries(Vector_representation_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Vector_representation_test_unit) +gudhi_add_boost_test(Vector_representation_test_unit) add_executable (Persistence_lanscapes_test_unit persistence_lanscapes_test.cpp ) -target_link_libraries(Persistence_lanscapes_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_lanscapes_test_unit) +gudhi_add_boost_test(Persistence_lanscapes_test_unit) add_executable ( Persistence_lanscapes_on_grid_test_unit persistence_lanscapes_on_grid_test.cpp ) -target_link_libraries(Persistence_lanscapes_on_grid_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_lanscapes_on_grid_test_unit) +gudhi_add_boost_test(Persistence_lanscapes_on_grid_test_unit) add_executable (Persistence_heat_maps_test_unit persistence_heat_maps_test.cpp ) -target_link_libraries(Persistence_heat_maps_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Persistence_heat_maps_test_unit) +gudhi_add_boost_test(Persistence_heat_maps_test_unit) add_executable ( Read_persistence_from_file_test_unit read_persistence_from_file_test.cpp ) -target_link_libraries(Read_persistence_from_file_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(Read_persistence_from_file_test_unit) +gudhi_add_boost_test(Read_persistence_from_file_test_unit) add_executable ( kernels_unit kernels.cpp ) -target_link_libraries(kernels_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - -gudhi_add_coverage_test(kernels_unit) +gudhi_add_boost_test(kernels_unit) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_executable (Persistence_intervals_with_distances_test_unit persistence_intervals_with_distances_test.cpp ) - target_link_libraries(Persistence_intervals_with_distances_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistence_intervals_with_distances_test_unit ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Persistence_intervals_with_distances_test_unit) + gudhi_add_boost_test(Persistence_intervals_with_distances_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt index f8baf861..64669c4e 100644 --- a/src/Persistent_cohomology/test/CMakeLists.txt +++ b/src/Persistent_cohomology/test/CMakeLists.txt @@ -1,11 +1,9 @@ project(Persistent_cohomology_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Persistent_cohomology_test_unit persistent_cohomology_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Persistent_cohomology_test_betti_numbers betti_numbers_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_betti_numbers ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit ${TBB_LIBRARIES}) target_link_libraries(Persistent_cohomology_test_betti_numbers ${TBB_LIBRARIES}) @@ -16,13 +14,12 @@ file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) # Unitary tests -gudhi_add_coverage_test(Persistent_cohomology_test_unit) -gudhi_add_coverage_test(Persistent_cohomology_test_betti_numbers) +gudhi_add_boost_test(Persistent_cohomology_test_unit) +gudhi_add_boost_test(Persistent_cohomology_test_betti_numbers) if(GMPXX_FOUND AND GMP_FOUND) add_executable ( Persistent_cohomology_test_unit_multi_field persistent_cohomology_unit_test_multi_field.cpp ) - target_link_libraries(Persistent_cohomology_test_unit_multi_field - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_unit_multi_field ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit_multi_field ${TBB_LIBRARIES}) endif(TBB_FOUND) @@ -31,7 +28,7 @@ if(GMPXX_FOUND AND GMP_FOUND) file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) # Unitary tests - gudhi_add_coverage_test(Persistent_cohomology_test_unit_multi_field) + gudhi_add_boost_test(Persistent_cohomology_test_unit_multi_field) endif(GMPXX_FOUND AND GMP_FOUND) diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt index 745d953c..b359584e 100644 --- a/src/Rips_complex/test/CMakeLists.txt +++ b/src/Rips_complex/test/CMakeLists.txt @@ -1,9 +1,8 @@ project(Rips_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Rips_complex_test_unit test_rips_complex.cpp ) -target_link_libraries(Rips_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Rips_complex_test_unit ${TBB_LIBRARIES}) endif() @@ -12,4 +11,4 @@ endif() file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Rips_complex_test_unit) +gudhi_add_boost_test(Rips_complex_test_unit) diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 5bea3938..8b9163f5 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -1,38 +1,30 @@ project(Simplex_tree_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) # Do not forget to copy test files in current binary dir file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Simplex_tree_test_unit simplex_tree_unit_test.cpp ) -target_link_libraries(Simplex_tree_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_test_unit) +gudhi_add_boost_test(Simplex_tree_test_unit) add_executable ( Simplex_tree_remove_test_unit simplex_tree_remove_unit_test.cpp ) -target_link_libraries(Simplex_tree_remove_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_remove_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_remove_test_unit) +gudhi_add_boost_test(Simplex_tree_remove_test_unit) add_executable ( Simplex_tree_iostream_operator_test_unit simplex_tree_iostream_operator_unit_test.cpp ) -target_link_libraries(Simplex_tree_iostream_operator_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_iostream_operator_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_iostream_operator_test_unit) +gudhi_add_boost_test(Simplex_tree_iostream_operator_test_unit) add_executable ( Simplex_tree_ctor_and_move_test_unit simplex_tree_ctor_and_move_unit_test.cpp ) -target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${TBB_LIBRARIES}) endif() - -gudhi_add_coverage_test(Simplex_tree_ctor_and_move_test_unit) +gudhi_add_boost_test(Simplex_tree_ctor_and_move_test_unit) diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt index 19c65871..24b6c11e 100644 --- a/src/Skeleton_blocker/test/CMakeLists.txt +++ b/src/Skeleton_blocker/test/CMakeLists.txt @@ -1,17 +1,14 @@ project(Skeleton_blocker_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Skeleton_blocker_test_unit test_skeleton_blocker_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_geometric_complex test_skeleton_blocker_geometric_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_geometric_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_simplifiable test_skeleton_blocker_simplifiable.cpp ) -target_link_libraries(Skeleton_blocker_test_simplifiable ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "test2.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Skeleton_blocker_test_unit) -gudhi_add_coverage_test(Skeleton_blocker_test_geometric_complex) -gudhi_add_coverage_test(Skeleton_blocker_test_simplifiable) +gudhi_add_boost_test(Skeleton_blocker_test_unit) +gudhi_add_boost_test(Skeleton_blocker_test_geometric_complex) +gudhi_add_boost_test(Skeleton_blocker_test_simplifiable) diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt index 18f7c6b8..a6c23951 100644 --- a/src/Spatial_searching/test/CMakeLists.txt +++ b/src/Spatial_searching/test/CMakeLists.txt @@ -1,11 +1,8 @@ project(Spatial_searching_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) - + include(GUDHI_boost_test) add_executable( Spatial_searching_test_Kd_tree_search test_Kd_tree_search.cpp ) - target_link_libraries(Spatial_searching_test_Kd_tree_search - ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - - gudhi_add_coverage_test(Spatial_searching_test_Kd_tree_search) + target_link_libraries(Spatial_searching_test_Kd_tree_search ${CGAL_LIBRARY}) + gudhi_add_boost_test(Spatial_searching_test_Kd_tree_search) endif () diff --git a/src/Subsampling/test/CMakeLists.txt b/src/Subsampling/test/CMakeLists.txt index cf54788e..354021c1 100644 --- a/src/Subsampling/test/CMakeLists.txt +++ b/src/Subsampling/test/CMakeLists.txt @@ -1,18 +1,18 @@ project(Subsampling_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable( Subsampling_test_pick_n_random_points test_pick_n_random_points.cpp ) - target_link_libraries(Subsampling_test_pick_n_random_points ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_pick_n_random_points ${CGAL_LIBRARY}) add_executable( Subsampling_test_choose_n_farthest_points test_choose_n_farthest_points.cpp ) - target_link_libraries(Subsampling_test_choose_n_farthest_points ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_choose_n_farthest_points ${CGAL_LIBRARY}) add_executable(Subsampling_test_sparsify_point_set test_sparsify_point_set.cpp) - target_link_libraries(Subsampling_test_sparsify_point_set ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Subsampling_test_sparsify_point_set ${CGAL_LIBRARY}) - gudhi_add_coverage_test(Subsampling_test_pick_n_random_points) - gudhi_add_coverage_test(Subsampling_test_choose_n_farthest_points) - gudhi_add_coverage_test(Subsampling_test_sparsify_point_set) + gudhi_add_boost_test(Subsampling_test_pick_n_random_points) + gudhi_add_boost_test(Subsampling_test_choose_n_farthest_points) + gudhi_add_boost_test(Subsampling_test_sparsify_point_set) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index ae17a286..2207d67c 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -1,13 +1,13 @@ project(Tangential_complex_tests) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - include(GUDHI_test_coverage) + include(GUDHI_boost_test) add_executable( Tangential_complex_test_TC test_tangential_complex.cpp ) - target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES}) endif() - gudhi_add_coverage_test(Tangential_complex_test_TC) + gudhi_add_boost_test(Tangential_complex_test_TC) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/Toplex_map/test/CMakeLists.txt b/src/Toplex_map/test/CMakeLists.txt index 59517db5..2997584d 100644 --- a/src/Toplex_map/test/CMakeLists.txt +++ b/src/Toplex_map/test/CMakeLists.txt @@ -1,11 +1,9 @@ project(Toplex_map_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable( Toplex_map_unit_test toplex_map_unit_test.cpp ) -target_link_libraries(Toplex_map_unit_test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -gudhi_add_coverage_test(Toplex_map_unit_test) +gudhi_add_boost_test(Toplex_map_unit_test) add_executable( Lazy_toplex_map_unit_test lazy_toplex_map_unit_test.cpp ) -target_link_libraries(Lazy_toplex_map_unit_test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -gudhi_add_coverage_test(Lazy_toplex_map_unit_test) +gudhi_add_boost_test(Lazy_toplex_map_unit_test) diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 96188e46..690933aa 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -1,22 +1,20 @@ project(Witness_complex_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Witness_complex_test_simple_witness_complex test_simple_witness_complex.cpp ) -target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) -gudhi_add_coverage_test(Witness_complex_test_simple_witness_complex) +gudhi_add_boost_test(Witness_complex_test_simple_witness_complex) # CGAL and Eigen3 are required for Euclidean version of Witness if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_executable ( Witness_complex_test_euclidean_simple_witness_complex test_euclidean_simple_witness_complex.cpp ) - target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) - gudhi_add_coverage_test(Witness_complex_test_euclidean_simple_witness_complex) + gudhi_add_boost_test(Witness_complex_test_euclidean_simple_witness_complex) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) diff --git a/src/cmake/modules/GUDHI_boost_test.cmake b/src/cmake/modules/GUDHI_boost_test.cmake new file mode 100644 index 00000000..c3b29883 --- /dev/null +++ b/src/cmake/modules/GUDHI_boost_test.cmake @@ -0,0 +1,26 @@ +if (WITH_GUDHI_BOOST_TEST_COVERAGE) + # Make CTest output XML coverage report - WITH_GUDHI_BOOST_TEST_COVERAGE must be set - default is OFF + if (GCOVR_PATH) + # for gcovr to make coverage reports - Corbera Jenkins plugin + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + endif() + if (GPROF_PATH) + # for gprof to make coverage reports - Jenkins + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + endif() + set(GUDHI_UT_LOG_FORMAT "--log_format=XML") + set(GUDHI_UT_LOG_SINK "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml") + set(GUDHI_UT_LOG_LEVEL "--log_level=test_suite") + set(GUDHI_UT_REPORT_LEVEL "--report_level=no") +else (WITH_GUDHI_BOOST_TEST_COVERAGE) + # Make CTest more verbose and color output + set(GUDHI_UT_LOG_LEVEL "--color_output") + set(GUDHI_UT_REPORT_LEVEL "--report_level=detailed") +endif(WITH_GUDHI_BOOST_TEST_COVERAGE) + +function(gudhi_add_boost_test unitary_test) + target_link_libraries(${unitary_test} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + add_test(NAME ${unitary_test} COMMAND $ + ${GUDHI_UT_LOG_FORMAT} ${GUDHI_UT_LOG_SINK} + ${GUDHI_UT_LOG_LEVEL} ${GUDHI_UT_REPORT_LEVEL}) +endfunction() diff --git a/src/cmake/modules/GUDHI_compilation_flags.cmake b/src/cmake/modules/GUDHI_compilation_flags.cmake index 6cd2614d..34c2e065 100644 --- a/src/cmake/modules/GUDHI_compilation_flags.cmake +++ b/src/cmake/modules/GUDHI_compilation_flags.cmake @@ -73,3 +73,5 @@ if(CMAKE_BUILD_TYPE MATCHES Debug) else() message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") endif() + +option(WITH_GUDHI_BOOST_TEST_COVERAGE "Report xml coverage files on boost tests" OFF) diff --git a/src/cmake/modules/GUDHI_test_coverage.cmake b/src/cmake/modules/GUDHI_test_coverage.cmake deleted file mode 100644 index bea5b2d6..00000000 --- a/src/cmake/modules/GUDHI_test_coverage.cmake +++ /dev/null @@ -1,26 +0,0 @@ - -if (GCOVR_PATH) - # for gcovr to make coverage reports - Corbera Jenkins plugin - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") -endif() -if (GPROF_PATH) - # for gprof to make coverage reports - Jenkins - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") -endif() - -if (DEBUG_TRACES) - # Make CTest more verbose with DEBUG_TRACES - no XML output - set(GUDHI_UT_LOG_LEVEL "--log_level=all") - set(GUDHI_UT_REPORT_LEVEL "--report_level=detailed") -else() - set(GUDHI_UT_LOG_FORMAT "--log_format=XML") - set(GUDHI_UT_LOG_SINK "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml") - set(GUDHI_UT_LOG_LEVEL "--log_level=test_suite") - set(GUDHI_UT_REPORT_LEVEL "--report_level=no") -endif() - -function(gudhi_add_coverage_test unitary_test) - add_test(NAME ${unitary_test} COMMAND $ - ${GUDHI_UT_LOG_FORMAT} ${GUDHI_UT_LOG_SINK} - ${GUDHI_UT_LOG_LEVEL} ${GUDHI_UT_REPORT_LEVEL}) -endfunction() diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt index 0b49fa1e..34de7398 100644 --- a/src/common/test/CMakeLists.txt +++ b/src/common/test/CMakeLists.txt @@ -1,15 +1,10 @@ project(Common_tests) -include(GUDHI_test_coverage) +include(GUDHI_boost_test) add_executable ( Common_test_points_off_reader test_points_off_reader.cpp ) -target_link_libraries(Common_test_points_off_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - add_executable ( Common_test_distance_matrix_reader test_distance_matrix_reader.cpp ) -target_link_libraries(Common_test_distance_matrix_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - add_executable ( Common_test_persistence_intervals_reader test_persistence_intervals_reader.cpp ) -target_link_libraries(Common_test_persistence_intervals_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) @@ -19,6 +14,6 @@ file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_dimens file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_field.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_without_dimension.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Common_test_points_off_reader) -gudhi_add_coverage_test(Common_test_distance_matrix_reader) -gudhi_add_coverage_test(Common_test_persistence_intervals_reader) +gudhi_add_boost_test(Common_test_points_off_reader) +gudhi_add_boost_test(Common_test_distance_matrix_reader) +gudhi_add_boost_test(Common_test_persistence_intervals_reader) -- cgit v1.2.3 From ce58cc97866605fe64df479e96d455e90f56f8e2 Mon Sep 17 00:00:00 2001 From: MathieuCarriere Date: Sun, 8 Dec 2019 21:22:09 -0500 Subject: fixed useless coordinates in Landscape if min and max are computed from data --- src/python/doc/representations.rst | 25 ++++++++++++++++++++-- .../diagram_vectorizations_distances_kernels.py | 6 +++--- src/python/gudhi/representations/vector_methods.py | 12 ++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index b3131a25..b338f7f0 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -8,9 +8,9 @@ Representations manual .. include:: representations_sum.inc -This module, originally named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning tools, in particular scikit-learn. It provides tools, using the scikit-learn standard interface, to compute distances and kernels on diagrams, and to convert diagrams into vectors. +This module, originally available at https://github.com/MathieuCarriere/sklearn-tda and named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning, by providing implementations of most of the vector representations for persistence diagrams in the literature, in a scikit-learn format. More specifically, it provides tools, using the scikit-learn standard interface, to compute distances and kernels on persistence diagrams, and to convert these diagrams into vectors in Euclidean space. -A diagram is represented as a numpy array of shape (n,2), as can be obtained from :func:`~gudhi.SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. +A diagram is represented as a numpy array of shape (n,2), as can be obtained from `SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. A small example is provided @@ -46,3 +46,24 @@ Metrics :members: :special-members: :show-inheritance: + +Basic example +------------- + +This example computes the first two Landscapes associated to a persistence diagram with four points. The landscapes are evaluated on ten samples, leading to two vectors with ten coordinates each, that are eventually concatenated in order to produce a single vector representation. + +.. testcode:: + + import numpy as np + from gudhi.representations import Landscape + # A single diagram with 4 points + D = np.array([[0.,4.],[1.,2.],[3.,8.],[6.,8.]]) + diags = [D] + l=Landscape(num_landscapes=2,resolution=10).fit_transform(diags) + print(l) + +The output is: + +.. testoutput:: + + [[0. 1.25707872 2.51415744 1.88561808 0.7856742 2.04275292 3.29983165 2.51415744 1.25707872 0. 0. 0. 0.31426968 0. 0.62853936 0. 0. 0.31426968 1.25707872 0. ]] diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index 119072eb..f777984c 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:1000]) -plt.plot(L[0][1000:2000]) -plt.plot(L[0][2000:3000]) +plt.plot(L[0][:999]) +plt.plot(L[0][999:2*999]) +plt.plot(L[0][2*999:3*999]) plt.title("Landscape") plt.show() diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 61c4fb84..083551a4 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -104,10 +104,11 @@ class Landscape(BaseEstimator, TransformerMixin): X (list of n x 2 numpy arrays): input persistence diagrams. y (n x 1 array): persistence diagram labels (unused). """ + self.nan_in_range = np.isnan(np.array(self.sample_range)) if np.isnan(np.array(self.sample_range)).any(): pre = DiagramScaler(use=True, scalers=[([0], MinMaxScaler()), ([1], MinMaxScaler())]).fit(X,y) [mx,my],[Mx,My] = [pre.scalers[0][1].data_min_[0], pre.scalers[1][1].data_min_[0]], [pre.scalers[0][1].data_max_[0], pre.scalers[1][1].data_max_[0]] - self.sample_range = np.where(np.isnan(np.array(self.sample_range)), np.array([mx, My]), np.array(self.sample_range)) + self.sample_range = np.where(self.nan_in_range, np.array([mx, My]), np.array(self.sample_range)) return self def transform(self, X): @@ -121,7 +122,7 @@ class Landscape(BaseEstimator, TransformerMixin): numpy array with shape (number of diagrams) x (number of samples = **num_landscapes** x **resolution**): output persistence landscapes. """ num_diag, Xfit = len(X), [] - x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution) + x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution + self.nan_in_range.sum()) step_x = x_values[1] - x_values[0] for i in range(num_diag): @@ -157,7 +158,12 @@ class Landscape(BaseEstimator, TransformerMixin): for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] - Xfit.append(np.sqrt(2)*np.reshape(ls,[1,-1])) + if self.nan_in_range[0]: + ls = ls[:,1:] + if self.nan_in_range[1]: + ls = ls[:,:-1] + ls = np.sqrt(2)*np.reshape(ls,[1,-1]) + Xfit.append(ls) Xfit = np.concatenate(Xfit,0) -- cgit v1.2.3 From 5385b57782d63cf86048762e9a1c9b0c1070930c Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 10:29:02 +0100 Subject: Document 'ctest --output-on-failure' in installation tests section --- src/common/doc/installation.h | 5 ++++- src/python/doc/installation.rst | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index c320e7e0..c4ca10d1 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -32,7 +32,10 @@ make \endverbatim * * \subsection testsuites Test suites * To test your build, run the following command in a terminal: - * \verbatim make test \endverbatim + * \verbatim make test \endverbatim + * `make test` is using Ctest<\a> (CMake test driver + * program). If some of the tests are failing, plend send us the result of the following command: + * \verbatim ctest --output-on-failure \endverbatim * * \subsection documentationgeneration Documentation * To generate the documentation, Doxygen is required. diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 54504413..3553ae51 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -98,6 +98,18 @@ following command in a terminal: export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' make test +`make test` is using +`Ctest `_ (CMake test +driver program). If some of the tests are failing, plend send us the result of +the following command: + +.. code-block:: bash + + cd /path-to-gudhi/build/python + # For windows, you have to set PYTHONPATH environment variable + export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' + ctest --output-on-failure + Debugging issues ================ -- cgit v1.2.3 From 406d7349a4732a185374822bf465f914e95d07c9 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 11:11:00 +0100 Subject: Add some debug traces to find why sphinx fails --- .travis.yml | 3 ++- src/python/doc/python3-sphinx-build.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/.travis.yml b/.travis.yml index 51bc26c3..1c490b69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ matrix: - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='OFF' MAKE_TARGET='doxygen' CTEST_COMMAND='echo No tests for doxygen target' - env: # 5. Only Python, associated tests and sphinx documentation - - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='ON' MAKE_TARGET='all sphinx' CTEST_COMMAND='ctest --output-on-failure' + - CMAKE_EXAMPLE='OFF' CMAKE_TEST='OFF' CMAKE_UTILITIES='OFF' CMAKE_PYTHON='ON' MAKE_TARGET='all' CTEST_COMMAND='ctest --output-on-failure' cache: directories: @@ -56,6 +56,7 @@ install: - python3 -m pip install --upgrade pip setuptools wheel - python3 -m pip install --user pytest Cython sphinx sphinxcontrib-bibtex sphinx-paramlinks matplotlib numpy scipy scikit-learn - python3 -m pip install --user POT + - which python3 script: - rm -rf build diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 84d158cf..a8eede8a 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,6 +5,8 @@ Emulate sphinx-build for python3 """ from sys import exit, argv +print(sys.executable) +import sphinx from sphinx import main if __name__ == '__main__': -- cgit v1.2.3 From 3f99285cfbafd7c9fcabad6469bf16b3ba52396f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 13:31:18 +0100 Subject: need to import sys --- src/python/doc/python3-sphinx-build.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index a8eede8a..5dc26fd2 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,6 +5,7 @@ Emulate sphinx-build for python3 """ from sys import exit, argv +import sys print(sys.executable) import sphinx from sphinx import main -- cgit v1.2.3 From 83867c78935460f727831b54e390c5be30bb4eee Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 9 Dec 2019 13:59:07 +0100 Subject: need to import sys --- src/python/doc/python3-sphinx-build.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 5dc26fd2..3628e89e 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -4,9 +4,8 @@ Emulate sphinx-build for python3 """ -from sys import exit, argv -import sys -print(sys.executable) +from sys import exit, argv, executable +print(executable) import sphinx from sphinx import main -- cgit v1.2.3 From 4391bf38f14f483b9032e3eaf99f315f2f053026 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 00:04:02 +0100 Subject: Remove debug traces --- .travis.yml | 1 - src/python/doc/python3-sphinx-build.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/.travis.yml b/.travis.yml index b7cd854a..d6c82e70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,6 @@ install: - python3 -m pip install --upgrade pip setuptools wheel - python3 -m pip install --user pytest Cython sphinx sphinxcontrib-bibtex sphinx-paramlinks matplotlib numpy scipy scikit-learn - python3 -m pip install --user POT - - which python3 script: - rm -rf build diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index 3628e89e..d1f0f08e 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -4,8 +4,7 @@ Emulate sphinx-build for python3 """ -from sys import exit, argv, executable -print(executable) +from sys import exit, argv import sphinx from sphinx import main -- cgit v1.2.3 From 94118b7c5c723bf62dcdafd404d492e8d78d0019 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Tue, 10 Dec 2019 10:06:00 +0100 Subject: Remove useless import --- src/python/doc/python3-sphinx-build.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/python3-sphinx-build.py b/src/python/doc/python3-sphinx-build.py index d1f0f08e..84d158cf 100755 --- a/src/python/doc/python3-sphinx-build.py +++ b/src/python/doc/python3-sphinx-build.py @@ -5,7 +5,6 @@ Emulate sphinx-build for python3 """ from sys import exit, argv -import sphinx from sphinx import main if __name__ == '__main__': -- cgit v1.2.3 From 5ecc15ba30e7a20604d50c1fdec9e7da2de64898 Mon Sep 17 00:00:00 2001 From: mathieu Date: Tue, 10 Dec 2019 14:24:52 -0500 Subject: fixed doc and examples --- src/python/doc/representations.rst | 4 ++-- src/python/example/diagram_vectorizations_distances_kernels.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index b338f7f0..409e97da 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -10,7 +10,7 @@ Representations manual This module, originally available at https://github.com/MathieuCarriere/sklearn-tda and named sklearn_tda, aims at bridging the gap between persistence diagrams and machine learning, by providing implementations of most of the vector representations for persistence diagrams in the literature, in a scikit-learn format. More specifically, it provides tools, using the scikit-learn standard interface, to compute distances and kernels on persistence diagrams, and to convert these diagrams into vectors in Euclidean space. -A diagram is represented as a numpy array of shape (n,2), as can be obtained from `SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. +A diagram is represented as a numpy array of shape (n,2), as can be obtained from :func:`~gudhi.SimplexTree.persistence_intervals_in_dimension` for instance. Points at infinity are represented as a numpy array of shape (n,1), storing only the birth time. A small example is provided @@ -66,4 +66,4 @@ The output is: .. testoutput:: - [[0. 1.25707872 2.51415744 1.88561808 0.7856742 2.04275292 3.29983165 2.51415744 1.25707872 0. 0. 0. 0.31426968 0. 0.62853936 0. 0. 0.31426968 1.25707872 0. ]] + [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 2.95699199 3.08555686 0. 0.64282435 0. 0. 0.51425948 0. 0. 0. ]] diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index f777984c..0ea4ba79 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:999]) -plt.plot(L[0][999:2*999]) -plt.plot(L[0][2*999:3*999]) +plt.plot(L[0][:998]) +plt.plot(L[0][998:2*998]) +plt.plot(L[0][2*998:3*998]) plt.title("Landscape") plt.show() -- cgit v1.2.3 From 682f8c8cb18ba898a3d23a82fff454e862541aed Mon Sep 17 00:00:00 2001 From: Mathieu Carrière Date: Wed, 11 Dec 2019 13:48:26 -0500 Subject: Update src/python/doc/representations.rst Co-Authored-By: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> --- src/python/doc/representations.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index 409e97da..470b57bf 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -66,4 +66,6 @@ The output is: .. testoutput:: - [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 2.95699199 3.08555686 0. 0.64282435 0. 0. 0.51425948 0. 0. 0. ]] + [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 + 2.95699199 3.08555686 0. 0.64282435 0. 0. + 0.51425948 0. 0. 0. ]] -- cgit v1.2.3 From 363ae171ee7f45cf11d01653e4d4e9580117cfd0 Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 13:50:21 -0500 Subject: fixed landscape --- .../example/diagram_vectorizations_distances_kernels.py | 6 +++--- src/python/gudhi/representations/vector_methods.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/python/example/diagram_vectorizations_distances_kernels.py b/src/python/example/diagram_vectorizations_distances_kernels.py index 0ea4ba79..119072eb 100755 --- a/src/python/example/diagram_vectorizations_distances_kernels.py +++ b/src/python/example/diagram_vectorizations_distances_kernels.py @@ -26,9 +26,9 @@ plt.show() LS = Landscape(resolution=1000) L = LS.fit_transform(diags) -plt.plot(L[0][:998]) -plt.plot(L[0][998:2*998]) -plt.plot(L[0][2*998:3*998]) +plt.plot(L[0][:1000]) +plt.plot(L[0][1000:2000]) +plt.plot(L[0][2000:3000]) plt.title("Landscape") plt.show() diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 083551a4..cd532275 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -129,19 +129,19 @@ class Landscape(BaseEstimator, TransformerMixin): diagram, num_pts_in_diag = X[i], X[i].shape[0] - ls = np.zeros([self.num_landscapes, self.resolution]) + ls = np.zeros([self.num_landscapes, self.resolution + self.nan_in_range.sum()]) events = [] - for j in range(self.resolution): + for j in range(self.resolution + self.nan_in_range.sum()): events.append([]) for j in range(num_pts_in_diag): [px,py] = diagram[j,:2] - min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) - mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) - max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution) + min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - if min_idx < self.resolution and max_idx > 0: + if min_idx < self.resolution + self.nan_in_range.sum() and max_idx > 0: landscape_value = self.sample_range[0] + min_idx * step_x - px for k in range(min_idx, mid_idx): @@ -153,7 +153,7 @@ class Landscape(BaseEstimator, TransformerMixin): events[k].append(landscape_value) landscape_value -= step_x - for j in range(self.resolution): + for j in range(self.resolution + self.nan_in_range.sum()): events[j].sort(reverse=True) for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] -- cgit v1.2.3 From 9e75cc1832403f8ffec38fc3a4f6b1081fe4770e Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 13:57:15 -0500 Subject: update example --- src/python/doc/representations.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/doc/representations.rst b/src/python/doc/representations.rst index 470b57bf..11dcbcf9 100644 --- a/src/python/doc/representations.rst +++ b/src/python/doc/representations.rst @@ -67,5 +67,6 @@ The output is: .. testoutput:: [[1.02851895 2.05703791 2.57129739 1.54277843 0.89995409 1.92847304 - 2.95699199 3.08555686 0. 0.64282435 0. 0. - 0.51425948 0. 0. 0. ]] + 2.95699199 3.08555686 2.05703791 1.02851895 0. 0.64282435 + 0. 0. 0.51425948 0. 0. 0. + 0.77138922 1.02851895]] -- cgit v1.2.3 From 2886885ff4cf1f134863de0fa97b64f824d67622 Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 15:30:45 -0500 Subject: cleanup --- src/python/gudhi/representations/vector_methods.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index cd532275..9b280f68 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -95,6 +95,7 @@ class Landscape(BaseEstimator, TransformerMixin): sample_range ([double, double]): minimum and maximum of all piecewise-linear function domains, of the form [x_min, x_max] (default [numpy.nan, numpy.nan]). It is the interval on which samples will be drawn evenly. If one of the values is numpy.nan, it can be computed from the persistence diagrams with the fit() method. """ self.num_landscapes, self.resolution, self.sample_range = num_landscapes, resolution, sample_range + self.nan_in_range = np.isnan(np.array(self.sample_range)) def fit(self, X, y=None): """ @@ -104,8 +105,7 @@ class Landscape(BaseEstimator, TransformerMixin): X (list of n x 2 numpy arrays): input persistence diagrams. y (n x 1 array): persistence diagram labels (unused). """ - self.nan_in_range = np.isnan(np.array(self.sample_range)) - if np.isnan(np.array(self.sample_range)).any(): + if self.nan_in_range.any(): pre = DiagramScaler(use=True, scalers=[([0], MinMaxScaler()), ([1], MinMaxScaler())]).fit(X,y) [mx,my],[Mx,My] = [pre.scalers[0][1].data_min_[0], pre.scalers[1][1].data_min_[0]], [pre.scalers[0][1].data_max_[0], pre.scalers[1][1].data_max_[0]] self.sample_range = np.where(self.nan_in_range, np.array([mx, My]), np.array(self.sample_range)) -- cgit v1.2.3 From 7bd6907e577e22803fec179f652ecf0ec64dcb4a Mon Sep 17 00:00:00 2001 From: mathieu Date: Wed, 11 Dec 2019 15:38:00 -0500 Subject: cleanup for landscape resolution --- src/python/gudhi/representations/vector_methods.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 9b280f68..fe26dbe2 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -96,6 +96,7 @@ class Landscape(BaseEstimator, TransformerMixin): """ self.num_landscapes, self.resolution, self.sample_range = num_landscapes, resolution, sample_range self.nan_in_range = np.isnan(np.array(self.sample_range)) + self.new_resolution = self.resolution + self.nan_in_range.sum() def fit(self, X, y=None): """ @@ -122,26 +123,26 @@ class Landscape(BaseEstimator, TransformerMixin): numpy array with shape (number of diagrams) x (number of samples = **num_landscapes** x **resolution**): output persistence landscapes. """ num_diag, Xfit = len(X), [] - x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.resolution + self.nan_in_range.sum()) + x_values = np.linspace(self.sample_range[0], self.sample_range[1], self.new_resolution) step_x = x_values[1] - x_values[0] for i in range(num_diag): diagram, num_pts_in_diag = X[i], X[i].shape[0] - ls = np.zeros([self.num_landscapes, self.resolution + self.nan_in_range.sum()]) + ls = np.zeros([self.num_landscapes, self.new_resolution]) events = [] - for j in range(self.resolution + self.nan_in_range.sum()): + for j in range(self.new_resolution): events.append([]) for j in range(num_pts_in_diag): [px,py] = diagram[j,:2] - min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) - max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution + self.nan_in_range.sum()) + min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) + mid_idx = np.clip(np.ceil((0.5*(py+px) - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) + max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.new_resolution) - if min_idx < self.resolution + self.nan_in_range.sum() and max_idx > 0: + if min_idx < self.new_resolution and max_idx > 0: landscape_value = self.sample_range[0] + min_idx * step_x - px for k in range(min_idx, mid_idx): @@ -153,7 +154,7 @@ class Landscape(BaseEstimator, TransformerMixin): events[k].append(landscape_value) landscape_value -= step_x - for j in range(self.resolution + self.nan_in_range.sum()): + for j in range(self.new_resolution): events[j].sort(reverse=True) for k in range( min(self.num_landscapes, len(events[j])) ): ls[k,j] = events[j][k] -- cgit v1.2.3 From 7f426f5a85051676ffb6f8952689bd400ddcc10b Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Thu, 12 Dec 2019 09:40:35 +0100 Subject: Code review: Typo in src/common/doc/installation.h Co-Authored-By: Marc Glisse --- src/common/doc/installation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index c4ca10d1..d70a2efa 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -34,7 +34,7 @@ make \endverbatim * To test your build, run the following command in a terminal: * \verbatim make test \endverbatim * `make test` is using Ctest<\a> (CMake test driver - * program). If some of the tests are failing, plend send us the result of the following command: + * program). If some of the tests are failing, please send us the result of the following command: * \verbatim ctest --output-on-failure \endverbatim * * \subsection documentationgeneration Documentation -- cgit v1.2.3 From a1b6e5a034bc698b02d3c93e1707cab5622eaea6 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Thu, 12 Dec 2019 09:41:04 +0100 Subject: Code review: typo in src/python/doc/installation.rst Co-Authored-By: Marc Glisse --- src/python/doc/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 3553ae51..c3ddc017 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -100,7 +100,7 @@ following command in a terminal: `make test` is using `Ctest `_ (CMake test -driver program). If some of the tests are failing, plend send us the result of +driver program). If some of the tests are failing, please send us the result of the following command: .. code-block:: bash -- cgit v1.2.3 From 38f0ff98cf6da1e882b6b44fc3ed7b3d310fb91f Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 12 Dec 2019 10:00:10 +0100 Subject: Doc review: use ctest directly and provide options suggestions --- src/python/doc/installation.rst | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 3553ae51..50a697c7 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -83,32 +83,30 @@ Or install it definitely in your Python packages folder: .. code-block:: bash - python setup.py install --prefix /home/gudhi # Install in /home/gudhi directory + python setup.py install --prefix /home/gudhi # Install in /home/gudhi directory Test suites =========== -To test your build, `py.test `_ is optional. Run the -following command in a terminal: +To test your build, `py.test `_ is required. Run the +following `Ctest `_ +(CMake test driver program) command in a terminal: .. code-block:: bash cd /path-to-gudhi/build/python # For windows, you have to set PYTHONPATH environment variable export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' - make test + ctest -`make test` is using -`Ctest `_ (CMake test -driver program). If some of the tests are failing, plend send us the result of -the following command: +.. note:: + + One can use :code:`ctest` specific options in the python directory: .. code-block:: bash - cd /path-to-gudhi/build/python - # For windows, you have to set PYTHONPATH environment variable - export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' - ctest --output-on-failure + # Launch tests in parallel on 8 cores and set failing tests in verbose mode + ctest -j 8 --output-on-failure Debugging issues ================ -- cgit v1.2.3 From b884a620824a9d707cec82c9dddf7ab236263b95 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 12 Dec 2019 10:04:59 +0100 Subject: conflict resolution --- src/python/doc/installation.rst | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/python/doc/installation.rst b/src/python/doc/installation.rst index 14000ecf..50a697c7 100644 --- a/src/python/doc/installation.rst +++ b/src/python/doc/installation.rst @@ -99,16 +99,9 @@ following `Ctest `_ export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/python' ctest -<<<<<<< HEAD .. note:: One can use :code:`ctest` specific options in the python directory: -======= -`make test` is using -`Ctest `_ (CMake test -driver program). If some of the tests are failing, please send us the result of -the following command: ->>>>>>> a1b6e5a034bc698b02d3c93e1707cab5622eaea6 .. code-block:: bash -- cgit v1.2.3