From 28b0a6bd117ce84f8e85b2d7278c52e8fbe02d22 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 30 Mar 2017 21:46:15 +0000 Subject: Move example tests in a new CMakeLists.txt git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2288 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8b2bce4c8be8a34b8fba9c664d2f0b3b60a50c20 --- src/CMakeLists.txt | 8 +-- src/cmake/modules/GUDHI_third_party_libraries.txt | 46 ++++++++++++ src/cython/CMakeLists.txt | 41 ----------- src/cython/example/CMakeLists.txt | 84 ++++++++++++++++++++++ ...ex_diagram_persistence_from_off_file_example.py | 2 +- ...ex_diagram_persistence_from_off_file_example.py | 2 +- 6 files changed, 136 insertions(+), 47 deletions(-) create mode 100644 src/cython/example/CMakeLists.txt (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4fa73662..48d433bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR}) include(${CMAKE_MODULE_PATH}/GUDHI_doxygen_target.txt) +# This variable is used by Cython CMakeLists.txt to know its path +set(GUDHI_CYTHON_PATH "cython") # For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH include("${CMAKE_MODULE_PATH}/GUDHI_third_party_libraries.txt") @@ -56,13 +58,11 @@ add_subdirectory(example/Bottleneck_distance) # data points generator add_subdirectory(data/points/generator) -# Please let GudhUI in last compilation position as QT is known to modify CMAKE_CXX_FLAGS -# GudhUI add_subdirectory(GudhUI) -# This variable is used by Cython CMakeLists.txt to know its path -set(GUDHI_CYTHON_PATH "cython") +# specific for cython module add_subdirectory(${GUDHI_CYTHON_PATH}) +add_subdirectory(${GUDHI_CYTHON_PATH}/example) #--------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------- diff --git a/src/cmake/modules/GUDHI_third_party_libraries.txt b/src/cmake/modules/GUDHI_third_party_libraries.txt index 1974f70f..2ddc9f1f 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.txt +++ b/src/cmake/modules/GUDHI_third_party_libraries.txt @@ -105,3 +105,49 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) message(STATUS "boost include dirs:" ${Boost_INCLUDE_DIRS}) message(STATUS "boost library dirs:" ${Boost_LIBRARY_DIRS}) + +macro( find_the_lib placeholder THE_LIBS ) + set (THE_LIB_WE_FOUND "NO") + foreach(THE_LIB ${THE_LIBS}) + if(EXISTS ${THE_LIB}) + get_filename_component(THE_LIB_WE ${THE_LIB} NAME_WE) + if (NOT THE_LIB_WE_FOUND) + set (THE_LIB_WE_FOUND "YES") + set(returnValue "${THE_LIB_WE}") + endif(NOT THE_LIB_WE_FOUND) + endif(EXISTS ${THE_LIB}) + endforeach(THE_LIB ${THE_LIBS}) +endmacro( find_the_lib ) + +# Find the correct Python interpreter. +# Can be set with -DPYTHON_EXECUTABLE=/usr/bin/python3 or -DPython_ADDITIONAL_VERSIONS=3 for instance. +if(PYTHON_EXECUTABLE) + if(NOT EXISTS "${PYTHON_EXECUTABLE}") + message(FATAL_ERROR "ERROR: ${PYTHON_EXECUTABLE} does not exist.") + endif(NOT EXISTS "${PYTHON_EXECUTABLE}") +endif(PYTHON_EXECUTABLE) +find_package(PythonInterp) + +if(NOT GUDHI_CYTHON_PATH) + message(FATAL_ERROR "ERROR: GUDHI_CYTHON_PATH is not valid.") +endif(NOT GUDHI_CYTHON_PATH) + +if(PYTHONINTERP_FOUND) + # Default found version 2 + if(PYTHON_VERSION_MAJOR EQUAL 2) + FIND_PROGRAM(CYTHON_PATH cython) + # Unitary tests are available through py.test + find_program( PYTEST_PATH py.test ) + # Documentation generation is available through sphinx + find_program( SPHINX_PATH sphinx-build ) + elseif(PYTHON_VERSION_MAJOR EQUAL 3) + FIND_PROGRAM(CYTHON_PATH cython3) + # Unitary tests are available through py.test + find_program( PYTEST_PATH py.test ) + # Documentation generation is available through sphinx + set(SPHINX_PATH "${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") + else() + message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") + endif(PYTHON_VERSION_MAJOR EQUAL 2) +endif(PYTHONINTERP_FOUND) + diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 233a557e..da55fb9b 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -1,47 +1,6 @@ cmake_minimum_required(VERSION 2.8) project(Cython) -macro( find_the_lib placeholder THE_LIBS ) - set (THE_LIB_WE_FOUND "NO") - foreach(THE_LIB ${THE_LIBS}) - if(EXISTS ${THE_LIB}) - get_filename_component(THE_LIB_WE ${THE_LIB} NAME_WE) - if (NOT THE_LIB_WE_FOUND) - set (THE_LIB_WE_FOUND "YES") - set(returnValue "${THE_LIB_WE}") - endif(NOT THE_LIB_WE_FOUND) - endif(EXISTS ${THE_LIB}) - endforeach(THE_LIB ${THE_LIBS}) -endmacro( find_the_lib ) - -# Find the correct Python interpreter. -# Can be set with -DPYTHON_EXECUTABLE=/usr/bin/python3 or -DPython_ADDITIONAL_VERSIONS=3 for instance. -if(PYTHON_EXECUTABLE) - if(NOT EXISTS "${PYTHON_EXECUTABLE}") - message(FATAL_ERROR "ERROR: ${PYTHON_EXECUTABLE} does not exist.") - endif(NOT EXISTS "${PYTHON_EXECUTABLE}") -endif(PYTHON_EXECUTABLE) -find_package(PythonInterp) - -if(PYTHONINTERP_FOUND) - # Default found version 2 - if(PYTHON_VERSION_MAJOR EQUAL 2) - FIND_PROGRAM(CYTHON_PATH cython) - # Unitary tests are available through py.test - find_program( PYTEST_PATH py.test ) - # Documentation generation is available through sphinx - find_program( SPHINX_PATH sphinx-build ) - elseif(PYTHON_VERSION_MAJOR EQUAL 3) - FIND_PROGRAM(CYTHON_PATH cython3) - # Unitary tests are available through py.test - find_program( PYTEST_PATH py.test ) - # Documentation generation is available through sphinx - set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build") - else() - message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") - endif(PYTHON_VERSION_MAJOR EQUAL 2) -endif(PYTHONINTERP_FOUND) - if(CYTHON_PATH) message("${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_PATH} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") diff --git a/src/cython/example/CMakeLists.txt b/src/cython/example/CMakeLists.txt new file mode 100644 index 00000000..d55b39aa --- /dev/null +++ b/src/cython/example/CMakeLists.txt @@ -0,0 +1,84 @@ +cmake_minimum_required(VERSION 2.8) +project(Cython_examples) + +if(CYTHON_PATH) + # Test examples + add_test(NAME alpha_complex_from_points_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_complex_from_points_example.py") + set_tests_properties(alpha_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) + set_tests_properties(alpha_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" + -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) + set_tests_properties(alpha_rips_persistence_bottleneck_distance_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME bottleneck_basic_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/bottleneck_basic_example.py") + set_tests_properties(bottleneck_basic_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + set_tests_properties(euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + set_tests_properties(euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" + --no-barcode -f ${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt) + set_tests_properties(periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME random_cubical_complex_persistence_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/random_cubical_complex_persistence_example.py" + 10 10 10) + set_tests_properties(random_cubical_complex_persistence_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/distance_matrix/lower_triangular_distance_matrix.csv -e 12.0 -d 3) + set_tests_properties(rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME rips_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_diagram_persistence_from_off_file_example.py + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -e 0.25 -d 3) + set_tests_properties(rips_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME rips_complex_from_points_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_from_points_example.py) + set_tests_properties(rips_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME simplex_tree_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/simplex_tree_example.py) + set_tests_properties(simplex_tree_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) + set_tests_properties(tangential_complex_plain_homology_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test(NAME witness_complex_from_nearest_landmark_table_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/witness_complex_from_nearest_landmark_table.py) + set_tests_properties(witness_complex_from_nearest_landmark_table_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") +endif(CYTHON_PATH) diff --git a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py index 2474fc87..2371c36c 100755 --- a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py @@ -32,7 +32,7 @@ __license__ = "GPL v3" parser = argparse.ArgumentParser(description='EuclideanStrongWitnessComplex creation from ' 'points read in a OFF file.', epilog='Example: ' - 'example/witness_complex_diagram_persistence_from_off_file_example.py ' + 'example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py ' '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' '- Constructs a strong witness complex with the ' 'points from the given OFF file.') diff --git a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index 5a75417b..5748aa8a 100755 --- a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py @@ -32,7 +32,7 @@ __license__ = "GPL v3" parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation from ' 'points read in a OFF file.', epilog='Example: ' - 'example/witness_complex_diagram_persistence_from_off_file_example.py ' + 'example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py ' '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' '- Constructs a weak witness complex with the ' 'points from the given OFF file.') -- cgit v1.2.3