From c524232f734de875d69e2f190f01a6c976024368 Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Thu, 14 Jun 2018 20:39:01 +0200 Subject: GUDHI 2.2.0 as released by upstream in a tarball. --- cython/CMakeLists.txt | 41 ++----- cython/cython/alpha_complex.pyx | 4 +- cython/cython/bottleneck_distance.pyx | 4 +- cython/cython/cubical_complex.pyx | 29 ++--- cython/cython/euclidean_strong_witness_complex.pyx | 4 +- cython/cython/euclidean_witness_complex.pyx | 4 +- cython/cython/off_reader.pyx | 5 +- cython/cython/periodic_cubical_complex.pyx | 29 ++--- cython/cython/persistence_graphical_tools.py | 107 ++++++++++-------- cython/cython/reader_utils.pyx | 4 +- cython/cython/rips_complex.pyx | 39 +------ cython/cython/simplex_tree.pyx | 45 +++++++- cython/cython/strong_witness_complex.pyx | 4 +- cython/cython/subsampling.pyx | 4 +- cython/cython/tangential_complex.pyx | 19 ++-- cython/cython/witness_complex.pyx | 4 +- cython/doc/_templates/layout.html | 122 ++++++++++----------- cython/doc/alpha_complex_ref.rst | 4 + cython/doc/alpha_complex_sum.inc | 22 ++++ cython/doc/alpha_complex_sum.rst | 22 ---- cython/doc/alpha_complex_user.rst | 12 +- cython/doc/bottleneck_distance_sum.inc | 15 +++ cython/doc/bottleneck_distance_sum.rst | 15 --- cython/doc/bottleneck_distance_user.rst | 6 +- cython/doc/citation.rst | 4 + cython/doc/conf.py | 3 +- cython/doc/cubical_complex_ref.rst | 4 + cython/doc/cubical_complex_sum.inc | 15 +++ cython/doc/cubical_complex_sum.rst | 15 --- cython/doc/cubical_complex_user.rst | 7 +- .../doc/euclidean_strong_witness_complex_ref.rst | 4 + cython/doc/euclidean_witness_complex_ref.rst | 4 + cython/doc/examples.rst | 4 + cython/doc/fileformats.rst | 4 + cython/doc/index.rst | 18 +-- cython/doc/installation.rst | 15 ++- cython/doc/periodic_cubical_complex_ref.rst | 4 + cython/doc/persistence_graphical_tools_ref.rst | 5 +- cython/doc/persistence_graphical_tools_sum.inc | 12 ++ cython/doc/persistence_graphical_tools_sum.rst | 12 -- cython/doc/persistence_graphical_tools_user.rst | 71 +++++------- cython/doc/persistent_cohomology_sum.inc | 27 +++++ cython/doc/persistent_cohomology_sum.rst | 27 ----- cython/doc/persistent_cohomology_user.rst | 4 + cython/doc/pyplots/barcode_persistence.py | 7 -- cython/doc/pyplots/diagram_persistence.py | 8 -- cython/doc/pyplots/show_palette_values.py | 3 - cython/doc/reader_utils_ref.rst | 4 + cython/doc/rips_complex_ref.rst | 4 + cython/doc/rips_complex_sum.inc | 17 +++ cython/doc/rips_complex_sum.rst | 17 --- cython/doc/rips_complex_user.rst | 84 +++++++++++++- cython/doc/simplex_tree_ref.rst | 4 + cython/doc/simplex_tree_sum.inc | 14 +++ cython/doc/simplex_tree_sum.rst | 14 --- cython/doc/simplex_tree_user.rst | 6 +- cython/doc/strong_witness_complex_ref.rst | 4 + cython/doc/tangential_complex_ref.rst | 4 + cython/doc/tangential_complex_sum.inc | 15 +++ cython/doc/tangential_complex_sum.rst | 15 --- cython/doc/tangential_complex_user.rst | 13 ++- cython/doc/todos.rst | 4 + cython/doc/witness_complex_ref.rst | 4 + cython/doc/witness_complex_sum.inc | 19 ++++ cython/doc/witness_complex_sum.rst | 19 ---- cython/doc/witness_complex_user.rst | 6 +- ...ex_diagram_persistence_from_off_file_example.py | 8 +- .../example/alpha_complex_from_points_example.py | 4 +- .../alpha_rips_persistence_bottleneck_distance.py | 9 +- cython/example/bottleneck_basic_example.py | 6 +- ...ex_diagram_persistence_from_off_file_example.py | 8 +- ...ex_diagram_persistence_from_off_file_example.py | 8 +- cython/example/gudhi_graphical_tools_example.py | 11 +- ...arcode_persistence_from_perseus_file_example.py | 4 +- .../random_cubical_complex_persistence_example.py | 4 +- ...istence_from_correlation_matrix_file_example.py | 84 ++++++++++++++ ...ersistence_from_distance_matrix_file_example.py | 15 +-- ...ex_diagram_persistence_from_off_file_example.py | 11 +- cython/example/rips_complex_from_points_example.py | 4 +- cython/example/rips_persistence_diagram.py | 4 +- cython/example/simplex_tree_example.py | 4 +- ...complex_plain_homology_from_off_file_example.py | 13 ++- .../witness_complex_from_nearest_landmark_table.py | 4 +- cython/gudhi.pyx.in | 4 +- cython/include/Alpha_complex_interface.h | 2 +- cython/include/Bottleneck_distance_interface.h | 2 +- cython/include/Cubical_complex_interface.h | 2 +- .../Euclidean_strong_witness_complex_interface.h | 2 +- .../include/Euclidean_witness_complex_interface.h | 2 +- cython/include/Off_reader_interface.h | 2 +- cython/include/Persistent_cohomology_interface.h | 28 ++++- cython/include/Reader_utils_interface.h | 2 +- cython/include/Rips_complex_interface.h | 19 +--- cython/include/Simplex_tree_interface.h | 2 +- cython/include/Strong_witness_complex_interface.h | 2 +- cython/include/Subsampling_interface.h | 2 +- cython/include/Tangential_complex_interface.h | 15 +-- cython/include/Witness_complex_interface.h | 2 +- cython/setup.py.in | 9 +- cython/test/test_alpha_complex.py | 4 +- cython/test/test_bottleneck_distance.py | 4 +- cython/test/test_cubical_complex.py | 15 ++- cython/test/test_euclidean_witness_complex.py | 4 +- cython/test/test_reader_utils.py | 4 +- cython/test/test_rips_complex.py | 4 +- cython/test/test_simplex_tree.py | 48 +++++++- cython/test/test_subsampling.py | 4 +- cython/test/test_tangential_complex.py | 6 +- cython/test/test_witness_complex.py | 4 +- 109 files changed, 898 insertions(+), 605 deletions(-) create mode 100644 cython/doc/alpha_complex_sum.inc delete mode 100644 cython/doc/alpha_complex_sum.rst create mode 100644 cython/doc/bottleneck_distance_sum.inc delete mode 100644 cython/doc/bottleneck_distance_sum.rst create mode 100644 cython/doc/cubical_complex_sum.inc delete mode 100644 cython/doc/cubical_complex_sum.rst create mode 100644 cython/doc/persistence_graphical_tools_sum.inc delete mode 100644 cython/doc/persistence_graphical_tools_sum.rst create mode 100644 cython/doc/persistent_cohomology_sum.inc delete mode 100644 cython/doc/persistent_cohomology_sum.rst delete mode 100755 cython/doc/pyplots/barcode_persistence.py delete mode 100755 cython/doc/pyplots/diagram_persistence.py delete mode 100755 cython/doc/pyplots/show_palette_values.py create mode 100644 cython/doc/rips_complex_sum.inc delete mode 100644 cython/doc/rips_complex_sum.rst create mode 100644 cython/doc/simplex_tree_sum.inc delete mode 100644 cython/doc/simplex_tree_sum.rst create mode 100644 cython/doc/tangential_complex_sum.inc delete mode 100644 cython/doc/tangential_complex_sum.rst create mode 100644 cython/doc/witness_complex_sum.inc delete mode 100644 cython/doc/witness_complex_sum.rst create mode 100755 cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py (limited to 'cython') diff --git a/cython/CMakeLists.txt b/cython/CMakeLists.txt index afca9d60..17d440ee 100644 --- a/cython/CMakeLists.txt +++ b/cython/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8) project(Cython) function( add_gudhi_cython_lib THE_LIB ) @@ -32,35 +31,6 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") - # This is because of https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/tss.h - # CGAL is using boost thread if thread_local is not ready (requires XCode 8 for Mac). - # The test in https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/config.h - # #if __has_feature(cxx_thread_local) || \ - # ( (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L ) || \ - # ( _MSC_VER >= 1900 ) - # #define CGAL_CAN_USE_CXX11_THREAD_LOCAL - # #endif - set(CGAL_CAN_USE_CXX11_THREAD_LOCAL " - int main() { - #ifndef __has_feature - #define __has_feature(x) 0 // Compatibility with non-clang compilers. - #endif - #if __has_feature(cxx_thread_local) || \ - ( (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L ) || \ - ( _MSC_VER >= 1900 ) - bool has_feature_thread_local = true; - #else - // Explicit error of compilation for CMake test purpose - has_feature_thread_local is not defined - #endif - bool result = has_feature_thread_local; - } ") - check_cxx_source_compiles("${CGAL_CAN_USE_CXX11_THREAD_LOCAL}" CGAL_CAN_USE_CXX11_THREAD_LOCAL_RESULT) - - if (NOT CGAL_CAN_USE_CXX11_THREAD_LOCAL_RESULT) - add_gudhi_cython_lib(${Boost_THREAD_LIBRARY}) - set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") - endif() - # Gudhi and CGAL compilation option if(MSVC) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'/fp:strict', ") @@ -99,11 +69,16 @@ if(CYTHON_FOUND) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) if(CGAL_FOUND) + can_cgal_use_cxx11_thread_local() + if (NOT CGAL_CAN_USE_CXX11_THREAD_LOCAL_RESULT) + add_gudhi_cython_lib(${Boost_THREAD_LIBRARY}) + set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") + endif() # Add CGAL compilation args if(CGAL_HEADER_ONLY) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_HEADER_ONLY', ") else(CGAL_HEADER_ONLY) - add_gudhi_cython_lib(${CGAL_LIBRARIES}) + add_gudhi_cython_lib(${CGAL_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") # If CGAL is not header only, CGAL library may link with boost system, add_gudhi_cython_lib(${Boost_SYSTEM_LIBRARY}) @@ -135,7 +110,7 @@ if(CYTHON_FOUND) endforeach() set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/include', ") - if (TBB_FOUND) + if (TBB_FOUND AND WITH_GUDHI_USE_TBB) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DGUDHI_USE_TBB', ") add_gudhi_cython_lib(${TBB_RELEASE_LIBRARY}) add_gudhi_cython_lib(${TBB_MALLOC_RELEASE_LIBRARY}) @@ -181,7 +156,7 @@ if(CYTHON_FOUND) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) + --no-diagram -i 2 -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) add_gudhi_py_test(test_tangential_complex) diff --git a/cython/cython/alpha_complex.pyx b/cython/cython/alpha_complex.pyx index a0e8f9b7..4f772e31 100644 --- a/cython/cython/alpha_complex.pyx +++ b/cython/cython/alpha_complex.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": diff --git a/cython/cython/bottleneck_distance.pyx b/cython/cython/bottleneck_distance.pyx index 9fb377ff..76ef81f4 100644 --- a/cython/cython/bottleneck_distance.pyx +++ b/cython/cython/bottleneck_distance.pyx @@ -9,7 +9,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Bottleneck_distance_interface.h" namespace "Gudhi::persistence_diagram": diff --git a/cython/cython/cubical_complex.pyx b/cython/cython/cubical_complex.pyx index ffc85130..e94cd539 100644 --- a/cython/cython/cubical_complex.pyx +++ b/cython/cython/cubical_complex.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Cubical_complex_interface.h" namespace "Gudhi": @@ -104,22 +104,21 @@ cdef class CubicalComplex: return self.pcohptr != NULL def num_simplices(self): - """This function returns the number of simplices of the simplicial - complex. + """This function returns the number of all cubes in the complex. - :returns: int -- the simplicial complex number of simplices. + :returns: int -- the number of all cubes in the complex. """ return self.thisptr.num_simplices() def dimension(self): - """This function returns the dimension of the simplicial complex. + """This function returns the dimension of the complex. - :returns: int -- the simplicial complex dimension. + :returns: int -- the complex dimension. """ return self.thisptr.dimension() def persistence(self, homology_coeff_field=11, min_persistence=0): - """This function returns the persistence of the simplicial complex. + """This function returns the persistence of the complex. :param homology_coeff_field: The homology coefficient field. Must be a prime number @@ -130,7 +129,7 @@ cdef class CubicalComplex: Sets min_persistence to -1.0 to see all values. :type min_persistence: float. :returns: list of pairs(dimension, pair(birth, death)) -- the - persistence of the simplicial complex. + persistence of the complex. """ if self.pcohptr != NULL: del self.pcohptr @@ -142,12 +141,15 @@ cdef class CubicalComplex: return persistence_result def betti_numbers(self): - """This function returns the Betti numbers of the simplicial complex. + """This function returns the Betti numbers of the complex. :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). :note: betti_numbers function requires persistence function to be launched first. + + :note: betti_numbers function always returns [1, 0, 0, ...] as infinity + filtration cubes are not removed from the complex. """ cdef vector[int] bn_result if self.pcohptr != NULL: @@ -155,8 +157,7 @@ cdef class CubicalComplex: return bn_result def persistent_betti_numbers(self, from_value, to_value): - """This function returns the persistent Betti numbers of the - simplicial complex. + """This function returns the persistent Betti numbers of the complex. :param from_value: The persistence birth limit to be added in the numbers (persistent birth <= from_value). @@ -177,8 +178,8 @@ cdef class CubicalComplex: return pbn_result def persistence_intervals_in_dimension(self, dimension): - """This function returns the persistence intervals of the simplicial - complex in a specific dimension. + """This function returns the persistence intervals of the complex in a + specific dimension. :param dimension: The specific dimension. :type from_value: int. diff --git a/cython/cython/euclidean_strong_witness_complex.pyx b/cython/cython/euclidean_strong_witness_complex.pyx index c1523892..62b7cf71 100644 --- a/cython/cython/euclidean_strong_witness_complex.pyx +++ b/cython/cython/euclidean_strong_witness_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Euclidean_strong_witness_complex_interface.h" namespace "Gudhi": diff --git a/cython/cython/euclidean_witness_complex.pyx b/cython/cython/euclidean_witness_complex.pyx index 7c443b6b..c10ca73d 100644 --- a/cython/cython/euclidean_witness_complex.pyx +++ b/cython/cython/euclidean_witness_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Euclidean_witness_complex_interface.h" namespace "Gudhi": diff --git a/cython/cython/off_reader.pyx b/cython/cython/off_reader.pyx index b6e107ef..b939013f 100644 --- a/cython/cython/off_reader.pyx +++ b/cython/cython/off_reader.pyx @@ -9,7 +9,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Off_reader_interface.h" namespace "Gudhi": @@ -46,4 +46,5 @@ def read_off(off_file=''): return read_points_from_OFF_file(str.encode(off_file)) else: print("file " + off_file + " not found.") + return [] diff --git a/cython/cython/periodic_cubical_complex.pyx b/cython/cython/periodic_cubical_complex.pyx index 3025f125..e626950b 100644 --- a/cython/cython/periodic_cubical_complex.pyx +++ b/cython/cython/periodic_cubical_complex.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Cubical_complex_interface.h" namespace "Gudhi": @@ -106,22 +106,21 @@ cdef class PeriodicCubicalComplex: return self.pcohptr != NULL def num_simplices(self): - """This function returns the number of simplices of the simplicial - complex. + """This function returns the number of all cubes in the complex. - :returns: int -- the simplicial complex number of simplices. + :returns: int -- the number of all cubes in the complex. """ return self.thisptr.num_simplices() def dimension(self): - """This function returns the dimension of the simplicial complex. + """This function returns the dimension of the complex. - :returns: int -- the simplicial complex dimension. + :returns: int -- the complex dimension. """ return self.thisptr.dimension() def persistence(self, homology_coeff_field=11, min_persistence=0): - """This function returns the persistence of the simplicial complex. + """This function returns the persistence of the complex. :param homology_coeff_field: The homology coefficient field. Must be a prime number @@ -132,7 +131,7 @@ cdef class PeriodicCubicalComplex: Sets min_persistence to -1.0 to see all values. :type min_persistence: float. :returns: list of pairs(dimension, pair(birth, death)) -- the - persistence of the simplicial complex. + persistence of the complex. """ if self.pcohptr != NULL: del self.pcohptr @@ -144,12 +143,15 @@ cdef class PeriodicCubicalComplex: return persistence_result def betti_numbers(self): - """This function returns the Betti numbers of the simplicial complex. + """This function returns the Betti numbers of the complex. :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). :note: betti_numbers function requires persistence function to be launched first. + + :note: betti_numbers function always returns [1, 0, 0, ...] as infinity + filtration cubes are not removed from the complex. """ cdef vector[int] bn_result if self.pcohptr != NULL: @@ -157,8 +159,7 @@ cdef class PeriodicCubicalComplex: return bn_result def persistent_betti_numbers(self, from_value, to_value): - """This function returns the persistent Betti numbers of the - simplicial complex. + """This function returns the persistent Betti numbers of the complex. :param from_value: The persistence birth limit to be added in the numbers (persistent birth <= from_value). @@ -179,8 +180,8 @@ cdef class PeriodicCubicalComplex: return pbn_result def persistence_intervals_in_dimension(self, dimension): - """This function returns the persistence intervals of the simplicial - complex in a specific dimension. + """This function returns the persistence intervals of the complex in a + specific dimension. :param dimension: The specific dimension. :type from_value: int. diff --git a/cython/cython/persistence_graphical_tools.py b/cython/cython/persistence_graphical_tools.py index fb837e29..216ab8d6 100755 --- a/cython/cython/persistence_graphical_tools.py +++ b/cython/cython/persistence_graphical_tools.py @@ -1,4 +1,5 @@ import matplotlib.pyplot as plt +import matplotlib.patches as mpatches import numpy as np import os @@ -8,7 +9,7 @@ import os Author(s): Vincent Rouvreau, Bertrand Michel - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,16 +26,16 @@ import os """ __author__ = "Vincent Rouvreau, Bertrand Michel" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" -def __min_birth_max_death(persistence, band_boot=0.): +def __min_birth_max_death(persistence, band=0.): """This function returns (min_birth, max_death) from the persistence. :param persistence: The persistence to plot. :type persistence: list of tuples(dimension, tuple(birth, death)). - :param band_boot: bootstrap band - :type band_boot: float. + :param band: band + :type band: float. :returns: (float, float) -- (min_birth, max_death). """ # Look for minimum birth date and maximum death date for plot optimisation @@ -48,8 +49,8 @@ def __min_birth_max_death(persistence, band_boot=0.): max_death = float(interval[1][0]) if float(interval[1][0]) < min_birth: min_birth = float(interval[1][0]) - if band_boot > 0.: - max_death += band_boot + if band > 0.: + max_death += band return (min_birth, max_death) """ @@ -59,37 +60,27 @@ palette = ['#ff0000', '#00ff00', '#0000ff', '#00ffff', '#ff00ff', '#ffff00', '#000000', '#880000', '#008800', '#000088', '#888800', '#880088', '#008888'] -def show_palette_values(alpha=0.6): - """This function shows palette color values in function of the dimension. +def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, + max_barcodes=1000, inf_delta=0.1, legend=False): + """This function plots the persistence bar code from persistence values list + or from a :doc:`persistence file `. - :param alpha: alpha value in [0.0, 1.0] for horizontal bars (default is 0.6). - :type alpha: float. - :returns: plot the dimension palette values. - """ - colors = [] - for color in palette: - colors.append(color) - - y_pos = np.arange(len(palette)) - - plt.barh(y_pos, y_pos + 1, align='center', alpha=alpha, color=colors) - plt.ylabel('Dimension') - plt.title('Dimension palette values') - return plt - -def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, max_barcodes=0): - """This function plots the persistence bar code. - - :param persistence: The persistence to plot. + :param persistence: Persistence values list. :type persistence: list of tuples(dimension, tuple(birth, death)). - :param persistence_file: A persistence file style name (reset persistence if both are set). + :param persistence_file: A :doc:`persistence file ` style name + (reset persistence if both are set). :type persistence_file: string - :param alpha: alpha value in [0.0, 1.0] for horizontal bars (default is 0.6). + :param alpha: barcode transparency value (0.0 transparent through 1.0 opaque - default is 0.6). :type alpha: float. - :param max_barcodes: number of maximal barcodes to be displayed + :param max_barcodes: number of maximal barcodes to be displayed. + Set it to 0 to see all, Default value is 1000. (persistence will be sorted by life time if max_barcodes is set) :type max_barcodes: int. - :returns: plot -- An horizontal bar plot of persistence. + :param inf_delta: Infinity is placed at ((max_death - min_birth) x inf_delta). + A reasonable value is between 0.05 and 0.5 - default is 0.1. + :type inf_delta: float. + :returns: A matplotlib object containing horizontal bar plot of persistence + (launch `show()` method on it to display it). """ if persistence_file is not '': if os.path.isfile(persistence_file): @@ -107,9 +98,11 @@ def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, max # Sort by life time, then takes only the max_plots elements persistence = sorted(persistence, key=lambda life_time: life_time[1][1]-life_time[1][0], reverse=True)[:max_barcodes] + persistence = sorted(persistence, key=lambda birth: birth[1][0]) + (min_birth, max_death) = __min_birth_max_death(persistence) ind = 0 - delta = ((max_death - min_birth) / 10.0) + delta = ((max_death - min_birth) * inf_delta) # Replace infinity values with max_death + delta for bar code to be more # readable infinity = max_death + delta @@ -120,33 +113,49 @@ def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, max # Finite death case plt.barh(ind, (interval[1][1] - interval[1][0]), height=0.8, left = interval[1][0], alpha=alpha, - color = palette[interval[0]]) + color = palette[interval[0]], + linewidth=0) else: # Infinite death case for diagram to be nicer plt.barh(ind, (infinity - interval[1][0]), height=0.8, left = interval[1][0], alpha=alpha, - color = palette[interval[0]]) + color = palette[interval[0]], + linewidth=0) ind = ind + 1 + if legend: + dimensions = list(set(item[0] for item in persistence)) + plt.legend(handles=[mpatches.Patch(color=palette[dim], + label=str(dim)) for dim in dimensions], + loc='lower right') plt.title('Persistence barcode') # Ends plot on infinity value and starts a little bit before min_birth plt.axis([axis_start, infinity, 0, ind]) return plt -def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, band_boot=0., max_plots=0): - """This function plots the persistence diagram with an optional confidence band. +def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, + band=0., max_plots=1000, inf_delta=0.1, legend=False): + """This function plots the persistence diagram from persistence values list + or from a :doc:`persistence file `. - :param persistence: The persistence to plot. + :param persistence: Persistence values list. :type persistence: list of tuples(dimension, tuple(birth, death)). - :param persistence_file: A persistence file style name (reset persistence if both are set). + :param persistence_file: A :doc:`persistence file ` style name + (reset persistence if both are set). :type persistence_file: string - :param alpha: alpha value in [0.0, 1.0] for points and horizontal infinity line (default is 0.6). + :param alpha: plot transparency value (0.0 transparent through 1.0 opaque - default is 0.6). :type alpha: float. - :param band_boot: bootstrap band (not displayed if :math:`\leq` 0.) - :type band_boot: float. + :param band: band (not displayed if :math:`\leq` 0. - default is 0.) + :type band: float. :param max_plots: number of maximal plots to be displayed + Set it to 0 to see all, Default value is 1000. + (persistence will be sorted by life time if max_plots is set) :type max_plots: int. - :returns: plot -- A diagram plot of persistence. + :param inf_delta: Infinity is placed at ((max_death - min_birth) x inf_delta). + A reasonable value is between 0.05 and 0.5 - default is 0.1. + :type inf_delta: float. + :returns: A matplotlib object containing diagram plot of persistence + (launch `show()` method on it to display it). """ if persistence_file is not '': if os.path.isfile(persistence_file): @@ -164,9 +173,9 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, ban # Sort by life time, then takes only the max_plots elements persistence = sorted(persistence, key=lambda life_time: life_time[1][1]-life_time[1][0], reverse=True)[:max_plots] - (min_birth, max_death) = __min_birth_max_death(persistence, band_boot) + (min_birth, max_death) = __min_birth_max_death(persistence, band) ind = 0 - delta = ((max_death - min_birth) / 10.0) + delta = ((max_death - min_birth) * inf_delta) # Replace infinity values with max_death + delta for diagram to be more # readable infinity = max_death + delta @@ -179,8 +188,8 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, ban plt.plot(x, [infinity] * len(x), linewidth=1.0, color='k', alpha=alpha) plt.text(axis_start, infinity, r'$\infty$', color='k', alpha=alpha) # bootstrap band - if band_boot > 0.: - plt.fill_between(x, x, x+band_boot, alpha=alpha, facecolor='red') + if band > 0.: + plt.fill_between(x, x, x+band, alpha=alpha, facecolor='red') # Draw points in loop for interval in reversed(persistence): @@ -194,6 +203,10 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, ban color = palette[interval[0]]) ind = ind + 1 + if legend: + dimensions = list(set(item[0] for item in persistence)) + plt.legend(handles=[mpatches.Patch(color=palette[dim], label=str(dim)) for dim in dimensions]) + plt.title('Persistence diagram') plt.xlabel('Birth') plt.ylabel('Death') diff --git a/cython/cython/reader_utils.pyx b/cython/cython/reader_utils.pyx index 3a17c5a0..e4572db0 100644 --- a/cython/cython/reader_utils.pyx +++ b/cython/cython/reader_utils.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2017 INRIA + Copyright (C) 2017 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2017 INRIA" +__copyright__ = "Copyright (C) 2017 Inria" __license__ = "GPL v3" cdef extern from "Reader_utils_interface.h" namespace "Gudhi": diff --git a/cython/cython/rips_complex.pyx b/cython/cython/rips_complex.pyx index ad9b0a4d..59c16bff 100644 --- a/cython/cython/rips_complex.pyx +++ b/cython/cython/rips_complex.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,14 +28,12 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Rips_complex_interface.h" namespace "Gudhi": cdef cppclass Rips_complex_interface "Gudhi::rips_complex::Rips_complex_interface": Rips_complex_interface(vector[vector[double]] values, double threshold, bool euclidean) - # bool from_file is a workaround for cython to find the correct signature - Rips_complex_interface(string file_name, double threshold, bool euclidean, bool from_file) void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, int dim_max) # RipsComplex python interface @@ -49,7 +47,7 @@ cdef class RipsComplex: cdef Rips_complex_interface * thisptr # Fake constructor that does nothing but documenting the constructor - def __init__(self, points=None, off_file='', distance_matrix=None, csv_file='', max_edge_length=float('inf')): + def __init__(self, points=None, distance_matrix=None, max_edge_length=float('inf')): """RipsComplex constructor. :param max_edge_length: Rips value. @@ -60,41 +58,14 @@ cdef class RipsComplex: Or - :param off_file: An OFF file style name. - :type off_file: string - - Or - :param distance_matrix: A distance matrix (full square or lower triangular). :type points: list of list of double - - Or - - :param csv_file: A csv file style name containing a full square or a - lower triangular distance matrix. - :type csv_file: string """ # The real cython constructor - def __cinit__(self, points=None, off_file='', distance_matrix=None, csv_file='', max_edge_length=float('inf')): - if off_file is not '': - if os.path.isfile(off_file): - self.thisptr = new Rips_complex_interface(str.encode(off_file), - max_edge_length, - True, - True) - else: - print("file " + off_file + " not found.") - elif csv_file is not '': - if os.path.isfile(csv_file): - self.thisptr = new Rips_complex_interface(str.encode(csv_file), - max_edge_length, - False, - True) - else: - print("file " + csv_file + " not found.") - elif distance_matrix is not None: + def __cinit__(self, points=None, distance_matrix=None, max_edge_length=float('inf')): + if distance_matrix is not None: self.thisptr = new Rips_complex_interface(distance_matrix, max_edge_length, False) else: if points is None: diff --git a/cython/cython/simplex_tree.pyx b/cython/cython/simplex_tree.pyx index 0cb575d2..e302486b 100644 --- a/cython/cython/simplex_tree.pyx +++ b/cython/cython/simplex_tree.pyx @@ -10,7 +10,7 @@ from libcpp.string cimport string Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ from libcpp.string cimport string """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": @@ -55,6 +55,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": void expansion(int max_dim) void remove_maximal_simplex(vector[int] simplex) bool prune_above_filtration(double filtration) + bool make_filtration_non_decreasing() cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface>": @@ -64,6 +65,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": vector[int] persistent_betti_numbers(double from_value, double to_value) vector[pair[double,double]] intervals_in_dimension(int dimension) void write_output_diagram(string diagram_file_name) + vector[pair[vector[int], vector[int]]] persistence_pairs() # SimplexTree python interface cdef class SimplexTree: @@ -399,6 +401,26 @@ cdef class SimplexTree: """ self.thisptr.expansion(max_dim) + def make_filtration_non_decreasing(self): + """This function ensures that each simplex has a higher filtration + value than its faces by increasing the filtration values. + + :returns: The filtration modification information. + :rtype: bint + + + .. note:: + + Some simplex tree functions require the filtration to be valid. + make_filtration_non_decreasing function is not launching + :func:`initialize_filtration()` + but returns the filtration modification + information. If the complex has changed , please call + :func:`initialize_filtration()` + to recompute it. + """ + return self.thisptr.make_filtration_non_decreasing() + def persistence(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False): """This function returns the persistence of the simplicial complex. @@ -486,6 +508,25 @@ cdef class SimplexTree: " to be launched first.") return intervals_result + def persistence_pairs(self): + """This function returns the persistence pairs of the simplicial + complex. + + :returns: The persistence intervals. + :rtype: list of pair of list of int + + :note: intervals_in_dim function requires + :func:`persistence()` + function to be launched first. + """ + cdef vector[pair[vector[int],vector[int]]] persistence_pairs_result + if self.pcohptr != NULL: + persistence_pairs_result = self.pcohptr.persistence_pairs() + else: + print("persistence_pairs function requires persistence function" + " to be launched first.") + return persistence_pairs_result + def write_persistence_diagram(self, persistence_file=''): """This function writes the persistence intervals of the simplicial complex in a user given file name. diff --git a/cython/cython/strong_witness_complex.pyx b/cython/cython/strong_witness_complex.pyx index 770b46f5..74c5cb05 100644 --- a/cython/cython/strong_witness_complex.pyx +++ b/cython/cython/strong_witness_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Strong_witness_complex_interface.h" namespace "Gudhi": diff --git a/cython/cython/subsampling.pyx b/cython/cython/subsampling.pyx index 894a4fbe..ac09b7a3 100644 --- a/cython/cython/subsampling.pyx +++ b/cython/cython/subsampling.pyx @@ -10,7 +10,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Subsampling_interface.h" namespace "Gudhi::subsampling": diff --git a/cython/cython/tangential_complex.pyx b/cython/cython/tangential_complex.pyx index d55bb050..4bb07076 100644 --- a/cython/cython/tangential_complex.pyx +++ b/cython/cython/tangential_complex.pyx @@ -11,7 +11,7 @@ import os Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,14 +28,14 @@ import os """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Tangential_complex_interface.h" namespace "Gudhi": cdef cppclass Tangential_complex_interface "Gudhi::tangential_complex::Tangential_complex_interface": - Tangential_complex_interface(vector[vector[double]] points) + Tangential_complex_interface(int intrisic_dim, vector[vector[double]] points) # bool from_file is a workaround for cython to find the correct signature - Tangential_complex_interface(string off_file, bool from_file) + Tangential_complex_interface(int intrisic_dim, string off_file, bool from_file) vector[double] get_point(unsigned vertex) unsigned number_of_vertices() unsigned number_of_simplices() @@ -54,9 +54,12 @@ cdef class TangentialComplex: cdef Tangential_complex_interface * thisptr # Fake constructor that does nothing but documenting the constructor - def __init__(self, points=None, off_file=''): + def __init__(self, intrisic_dim, points=None, off_file=''): """TangentialComplex constructor. + :param intrisic_dim: Intrinsic dimension of the manifold. + :type intrisic_dim: integer + :param points: A list of points in d-Dimension. :type points: list of list of double @@ -67,17 +70,17 @@ cdef class TangentialComplex: """ # The real cython constructor - def __cinit__(self, points=None, off_file=''): + def __cinit__(self, intrisic_dim, points=None, off_file=''): if off_file is not '': if os.path.isfile(off_file): - self.thisptr = new Tangential_complex_interface(str.encode(off_file), True) + self.thisptr = new Tangential_complex_interface(intrisic_dim, str.encode(off_file), True) else: print("file " + off_file + " not found.") else: if points is None: # Empty tangential construction points=[] - self.thisptr = new Tangential_complex_interface(points) + self.thisptr = new Tangential_complex_interface(intrisic_dim, points) def __dealloc__(self): diff --git a/cython/cython/witness_complex.pyx b/cython/cython/witness_complex.pyx index 96d122bb..8591465a 100644 --- a/cython/cython/witness_complex.pyx +++ b/cython/cython/witness_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" cdef extern from "Witness_complex_interface.h" namespace "Gudhi": diff --git a/cython/doc/_templates/layout.html b/cython/doc/_templates/layout.html index 8e4eba40..1161ed8e 100644 --- a/cython/doc/_templates/layout.html +++ b/cython/doc/_templates/layout.html @@ -56,6 +56,12 @@

{%- endif %} {%- endblock %} +

GUDHI

+

File formats

+

GUDHI installation

+

Acknowledging the GUDHI library

+

Index

+

Examples

{%- if sidebars != None %} {#- new style sidebar: explicitly include/exclude templates #} {%- for sidebartemplate in sidebars %} @@ -64,13 +70,6 @@ {%- else %} {#- old style sidebars: using blocks -- should be deprecated #} {%- block sidebartoc %} -

GUDHI

-

File formats

-

GUDHI installation

-

Acknowledging the GUDHI library

-

Index

-

Examples

- {%- include "localtoc.html" %} {%- endblock %} {%- block sidebarrel %} @@ -166,60 +165,61 @@ diff --git a/cython/doc/alpha_complex_ref.rst b/cython/doc/alpha_complex_ref.rst index 6a122b09..7da79543 100644 --- a/cython/doc/alpha_complex_ref.rst +++ b/cython/doc/alpha_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ============================== Alpha complex reference manual ============================== diff --git a/cython/doc/alpha_complex_sum.inc b/cython/doc/alpha_complex_sum.inc new file mode 100644 index 00000000..1680a712 --- /dev/null +++ b/cython/doc/alpha_complex_sum.inc @@ -0,0 +1,22 @@ +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.7.0 Eigen3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | +| ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | +| :alt: Alpha complex representation | | +| :figclass: align-center | The filtration value of each simplex is computed as the square of the | +| | circumradius of the simplex if the circumsphere is empty (the simplex | +| Alpha complex representation | is then said to be Gabriel), and as the minimum of the filtration | +| | values of the codimension 1 cofaces that make it not Gabriel | +| | otherwise. All simplices that have a filtration value strictly | +| | greater than a given alpha squared value are not inserted into the | +| | complex. | +| | | +| | This package requires having CGAL version 4.7 or higher (4.8.1 is | +| | advised for better performance). | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/alpha_complex_sum.rst b/cython/doc/alpha_complex_sum.rst deleted file mode 100644 index 1680a712..00000000 --- a/cython/doc/alpha_complex_sum.rst +++ /dev/null @@ -1,22 +0,0 @@ -================================================================= =================================== =================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.7.0 Eigen3 -================================================================= =================================== =================================== - -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | -| ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | -| :alt: Alpha complex representation | | -| :figclass: align-center | The filtration value of each simplex is computed as the square of the | -| | circumradius of the simplex if the circumsphere is empty (the simplex | -| Alpha complex representation | is then said to be Gabriel), and as the minimum of the filtration | -| | values of the codimension 1 cofaces that make it not Gabriel | -| | otherwise. All simplices that have a filtration value strictly | -| | greater than a given alpha squared value are not inserted into the | -| | complex. | -| | | -| | This package requires having CGAL version 4.7 or higher (4.8.1 is | -| | advised for better performance). | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/alpha_complex_user.rst b/cython/doc/alpha_complex_user.rst index db7edd6f..d1e9c7cd 100644 --- a/cython/doc/alpha_complex_user.rst +++ b/cython/doc/alpha_complex_user.rst @@ -1,11 +1,15 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Alpha complex user manual ========================= Definition ---------- -.. include:: alpha_complex_sum.rst +.. include:: alpha_complex_sum.inc -Alpha_complex is constructing a :doc:`Simplex_tree ` using +Alpha_complex is constructing a :doc:`Simplex_tree ` using `Delaunay Triangulation `_ :cite:`cgal:hdj-t-15b` from `CGAL `_ (the Computational Geometry Algorithms Library :cite:`cgal:eb-15b`). @@ -99,9 +103,9 @@ Filtration value computation algorithm **end for** **end for** **end for** - + make_filtration_non_decreasing() - + prune_above_filtration() Dimension 2 diff --git a/cython/doc/bottleneck_distance_sum.inc b/cython/doc/bottleneck_distance_sum.inc new file mode 100644 index 00000000..030fad9e --- /dev/null +++ b/cython/doc/bottleneck_distance_sum.inc @@ -0,0 +1,15 @@ +================================================================= =================================== =================================== +:Author: François Godi :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 +================================================================= =================================== =================================== + ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | Bottleneck distance measures the similarity between two persistence | +| ../../doc/Bottleneck_distance/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | +| :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | +| | diagonal points) such that any couple of matched points are at | +| Bottleneck distance is the length of | distance at most b. | +| the longest edge | | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`bottleneck_distance_user` | | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/bottleneck_distance_sum.rst b/cython/doc/bottleneck_distance_sum.rst deleted file mode 100644 index 030fad9e..00000000 --- a/cython/doc/bottleneck_distance_sum.rst +++ /dev/null @@ -1,15 +0,0 @@ -================================================================= =================================== =================================== -:Author: François Godi :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.8.0 -================================================================= =================================== =================================== - -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | Bottleneck distance measures the similarity between two persistence | -| ../../doc/Bottleneck_distance/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | -| :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | -| | diagonal points) such that any couple of matched points are at | -| Bottleneck distance is the length of | distance at most b. | -| the longest edge | | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`bottleneck_distance_user` | | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/bottleneck_distance_user.rst b/cython/doc/bottleneck_distance_user.rst index 7692dce2..605db022 100644 --- a/cython/doc/bottleneck_distance_user.rst +++ b/cython/doc/bottleneck_distance_user.rst @@ -1,9 +1,13 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Bottleneck distance user manual =============================== Definition ---------- -.. include:: bottleneck_distance_sum.rst +.. include:: bottleneck_distance_sum.inc Function -------- diff --git a/cython/doc/citation.rst b/cython/doc/citation.rst index f4fdf83b..117eb9dd 100644 --- a/cython/doc/citation.rst +++ b/cython/doc/citation.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Acknowledging the GUDHI library ############################### diff --git a/cython/doc/conf.py b/cython/doc/conf.py index a13c9751..4a54d4fd 100755 --- a/cython/doc/conf.py +++ b/cython/doc/conf.py @@ -85,7 +85,7 @@ version = gudhi.__version__ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['_build', '*.inc'] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -125,6 +125,7 @@ html_theme_options = { "sidebarbgcolor": "#A1ADCD", "sidebartextcolor": "black", "sidebarlinkcolor": "#334D5C", + "body_max_width": "1200px", } # Add any paths that contain custom themes here, relative to this directory. diff --git a/cython/doc/cubical_complex_ref.rst b/cython/doc/cubical_complex_ref.rst index 84aa4223..1fe9d5fb 100644 --- a/cython/doc/cubical_complex_ref.rst +++ b/cython/doc/cubical_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Cubical complex reference manual ################################ diff --git a/cython/doc/cubical_complex_sum.inc b/cython/doc/cubical_complex_sum.inc new file mode 100644 index 00000000..280ad0e0 --- /dev/null +++ b/cython/doc/cubical_complex_sum.inc @@ -0,0 +1,15 @@ +================================================================= =================================== =================================== +:Author: Pawel Dlotko :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | The cubical complex is an example of a structured complex useful in | +| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | +| :alt: Cubical complex representation | analysis. | +| :figclass: align-center | | +| | | +| Cubical complex representation | | ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | +| | * :doc:`periodic_cubical_complex_ref` | ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/cubical_complex_sum.rst b/cython/doc/cubical_complex_sum.rst deleted file mode 100644 index 280ad0e0..00000000 --- a/cython/doc/cubical_complex_sum.rst +++ /dev/null @@ -1,15 +0,0 @@ -================================================================= =================================== =================================== -:Author: Pawel Dlotko :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== - -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | The cubical complex is an example of a structured complex useful in | -| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | -| :alt: Cubical complex representation | analysis. | -| :figclass: align-center | | -| | | -| Cubical complex representation | | -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/cubical_complex_user.rst b/cython/doc/cubical_complex_user.rst index 34598f02..320bd79b 100644 --- a/cython/doc/cubical_complex_user.rst +++ b/cython/doc/cubical_complex_user.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Cubical complex user manual =========================== Definition @@ -144,6 +148,7 @@ the program output is: .. testoutput:: Periodic cubical complex is of dimension 2 - 42 simplices. + Examples. --------- @@ -152,6 +157,6 @@ End user programs are available in cython/example/ folder. Bibliography ============ -.. bibliography:: ../../bibliography.bib +.. bibliography:: ../../biblio/bibliography.bib :filter: docnames :style: unsrt diff --git a/cython/doc/euclidean_strong_witness_complex_ref.rst b/cython/doc/euclidean_strong_witness_complex_ref.rst index bebf0f9a..1a602cd5 100644 --- a/cython/doc/euclidean_strong_witness_complex_ref.rst +++ b/cython/doc/euclidean_strong_witness_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ================================================= Euclidean strong witness complex reference manual ================================================= diff --git a/cython/doc/euclidean_witness_complex_ref.rst b/cython/doc/euclidean_witness_complex_ref.rst index 29b8806f..28daf965 100644 --- a/cython/doc/euclidean_witness_complex_ref.rst +++ b/cython/doc/euclidean_witness_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ========================================== Euclidean witness complex reference manual ========================================== diff --git a/cython/doc/examples.rst b/cython/doc/examples.rst index 1e596e18..d42f5a92 100644 --- a/cython/doc/examples.rst +++ b/cython/doc/examples.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Examples ######## diff --git a/cython/doc/fileformats.rst b/cython/doc/fileformats.rst index 4f0b6f6d..ff20f26e 100644 --- a/cython/doc/fileformats.rst +++ b/cython/doc/fileformats.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + File formats ############ diff --git a/cython/doc/index.rst b/cython/doc/index.rst index 3945d72a..4e444fb0 100644 --- a/cython/doc/index.rst +++ b/cython/doc/index.rst @@ -34,32 +34,32 @@ Data structures Alpha complex ============= -.. include:: alpha_complex_sum.rst +.. include:: alpha_complex_sum.inc Cubical complex =============== -.. include:: cubical_complex_sum.rst +.. include:: cubical_complex_sum.inc Rips complex ============ -.. include:: rips_complex_sum.rst +.. include:: rips_complex_sum.inc Simplex tree ============ -.. include:: simplex_tree_sum.rst +.. include:: simplex_tree_sum.inc Tangential complex ================== -.. include:: tangential_complex_sum.rst +.. include:: tangential_complex_sum.inc Witness complex =============== -.. include:: witness_complex_sum.rst +.. include:: witness_complex_sum.inc Toolbox @@ -68,17 +68,17 @@ Toolbox Bottleneck distance =================== -.. include:: bottleneck_distance_sum.rst +.. include:: bottleneck_distance_sum.inc Persistence cohomology ====================== -.. include:: persistent_cohomology_sum.rst +.. include:: persistent_cohomology_sum.inc Persistence graphical tools =========================== -.. include:: persistence_graphical_tools_sum.rst +.. include:: persistence_graphical_tools_sum.inc Bibliography ************ diff --git a/cython/doc/installation.rst b/cython/doc/installation.rst index c182f176..43ff85c5 100644 --- a/cython/doc/installation.rst +++ b/cython/doc/installation.rst @@ -1,12 +1,16 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Installation ############ Compiling ********* - -The library uses c++11 and requires `Boost `_ with -version 1.48.0 or more recent. It is a multi-platform library and compiles on -Linux, Mac OSX and Visual Studio 2015. +The library uses c++11 and requires `Boost `_ ≥ 1.48.0 +and `CMake `_ ≥ 3.1. +It is a multi-platform library and compiles on Linux, Mac OSX and Visual +Studio 2015. It also requires cmake to generate makefiles, and cython to compile the library. @@ -43,6 +47,9 @@ following command in a terminal: export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/cython' ctest -R py_test +If tests fail, please try to :code:`import gudhi` and check the errors. +The problem can come from a third-party library bad link or installation. + Documentation ============= diff --git a/cython/doc/periodic_cubical_complex_ref.rst b/cython/doc/periodic_cubical_complex_ref.rst index c6190a1b..4b831647 100644 --- a/cython/doc/periodic_cubical_complex_ref.rst +++ b/cython/doc/periodic_cubical_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Periodic cubical complex reference manual ######################################### diff --git a/cython/doc/persistence_graphical_tools_ref.rst b/cython/doc/persistence_graphical_tools_ref.rst index 27c2f68a..a2c6bcef 100644 --- a/cython/doc/persistence_graphical_tools_ref.rst +++ b/cython/doc/persistence_graphical_tools_ref.rst @@ -1,8 +1,11 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ============================================ Persistence graphical tools reference manual ============================================ .. autofunction:: gudhi.__min_birth_max_death -.. autofunction:: gudhi.show_palette_values .. autofunction:: gudhi.plot_persistence_barcode .. autofunction:: gudhi.plot_persistence_diagram diff --git a/cython/doc/persistence_graphical_tools_sum.inc b/cython/doc/persistence_graphical_tools_sum.inc new file mode 100644 index 00000000..d602daa7 --- /dev/null +++ b/cython/doc/persistence_graphical_tools_sum.inc @@ -0,0 +1,12 @@ +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: Matplotlib Numpy +================================================================= =================================== =================================== + ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | These graphical tools comes on top of persistence results and allows | +| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | +| | | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/cython/doc/persistence_graphical_tools_sum.rst b/cython/doc/persistence_graphical_tools_sum.rst deleted file mode 100644 index d602daa7..00000000 --- a/cython/doc/persistence_graphical_tools_sum.rst +++ /dev/null @@ -1,12 +0,0 @@ -================================================================= =================================== =================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: Matplotlib Numpy -================================================================= =================================== =================================== - -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| .. figure:: | These graphical tools comes on top of persistence results and allows | -| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | -| | | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/cython/doc/persistence_graphical_tools_user.rst b/cython/doc/persistence_graphical_tools_user.rst index 9033331f..292915eb 100644 --- a/cython/doc/persistence_graphical_tools_user.rst +++ b/cython/doc/persistence_graphical_tools_user.rst @@ -1,49 +1,26 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Persistence graphical tools user manual ======================================= Definition ---------- -.. include:: persistence_graphical_tools_sum.rst - - -Show palette values -------------------- - -This function is useful to show the color palette values of dimension: - +.. include:: persistence_graphical_tools_sum.inc -.. testcode:: - - import gudhi - plt = gudhi.show_palette_values(alpha=1.0) - plt.show() - -.. plot:: - - import gudhi - plt = gudhi.show_palette_values(alpha=1.0) - plt.show() Show persistence as a barcode ----------------------------- This function can display the persistence result as a barcode: -.. testcode:: - - import gudhi - - periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ - '/data/bitmap/3d_torus.txt') - diag = periodic_cc.persistence() - plt = gudhi.plot_persistence_barcode(diag) - plt.show() - .. plot:: + :include-source: import gudhi - periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ - '/data/bitmap/3d_torus.txt') + perseus_file = gudhi.__root_source_dir__ + '/data/bitmap/3d_torus.txt' + periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=perseus_file) diag = periodic_cc.persistence() print("diag = ", diag) plt = gudhi.plot_persistence_barcode(diag) @@ -54,24 +31,32 @@ Show persistence as a diagram This function can display the persistence result as a diagram: -.. testcode:: +.. plot:: + :include-source: import gudhi - - rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ - '/data/points/tore3D_1307.off', max_edge_length=0.2) - simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) - diag = simplex_tree.persistence() - plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) + + # rips_on_tore3D_1307.pers obtained from write_persistence_diagram method + persistence_file=gudhi.__root_source_dir__ + \ + '/data/persistence_diagram/rips_on_tore3D_1307.pers' + plt = gudhi.plot_persistence_diagram(persistence_file=persistence_file, + legend=True) plt.show() +If you want more information on a specific dimension, for instance: + .. plot:: + :include-source: import gudhi - rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ - '/data/points/tore3D_1307.off', max_edge_length=0.2) - simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) - diag = simplex_tree.persistence() - plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) + persistence_file=gudhi.__root_source_dir__ + \ + '/data/persistence_diagram/rips_on_tore3D_1307.pers' + diag = \ + gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file=\ + persistence_file) + dim = 1 + # Display all points with some transparency + plt = gudhi.plot_persistence_diagram([(dim,interval) for interval in diag[dim]], + max_plots=0, alpha=0.1) plt.show() diff --git a/cython/doc/persistent_cohomology_sum.inc b/cython/doc/persistent_cohomology_sum.inc new file mode 100644 index 00000000..a26df1dc --- /dev/null +++ b/cython/doc/persistent_cohomology_sum.inc @@ -0,0 +1,27 @@ +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | The theory of homology consists in attaching to a topological space | +| ../../doc/Persistent_cohomology/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | +| :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | +| | homology studies the evolution -- birth, life and death -- of these | +| Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | +| Torus | theory is essentially composed of three elements: topological spaces, | +| | their homology groups and an evolution scheme. | +| | | +| | Computation of persistent cohomology using the algorithm of | +| | :cite:`DBLP:journals/dcg/SilvaMV11` and | +| | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | +| | Annotation Matrix implementation of | +| | :cite:`DBLP:conf/esa/BoissonnatDM13`. | +| | | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | +| | feature for reference: | +| | | +| | * :doc:`simplex_tree_ref` | +| | * :doc:`cubical_complex_ref` | +| | * :doc:`periodic_cubical_complex_ref` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/cython/doc/persistent_cohomology_sum.rst b/cython/doc/persistent_cohomology_sum.rst deleted file mode 100644 index a26df1dc..00000000 --- a/cython/doc/persistent_cohomology_sum.rst +++ /dev/null @@ -1,27 +0,0 @@ -================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== - -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| .. figure:: | The theory of homology consists in attaching to a topological space | -| ../../doc/Persistent_cohomology/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | -| :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | -| | homology studies the evolution -- birth, life and death -- of these | -| Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | -| Torus | theory is essentially composed of three elements: topological spaces, | -| | their homology groups and an evolution scheme. | -| | | -| | Computation of persistent cohomology using the algorithm of | -| | :cite:`DBLP:journals/dcg/SilvaMV11` and | -| | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | -| | Annotation Matrix implementation of | -| | :cite:`DBLP:conf/esa/BoissonnatDM13`. | -| | | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | -| | feature for reference: | -| | | -| | * :doc:`simplex_tree_ref` | -| | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/cython/doc/persistent_cohomology_user.rst b/cython/doc/persistent_cohomology_user.rst index bf90c163..ce7fc685 100644 --- a/cython/doc/persistent_cohomology_user.rst +++ b/cython/doc/persistent_cohomology_user.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Persistent cohomology user manual ================================= Definition diff --git a/cython/doc/pyplots/barcode_persistence.py b/cython/doc/pyplots/barcode_persistence.py deleted file mode 100755 index de33d506..00000000 --- a/cython/doc/pyplots/barcode_persistence.py +++ /dev/null @@ -1,7 +0,0 @@ -import gudhi - -periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ - '/data/bitmap/3d_torus.txt') -diag = periodic_cc.persistence() -plt = gudhi.plot_persistence_barcode(diag) -plt.show() diff --git a/cython/doc/pyplots/diagram_persistence.py b/cython/doc/pyplots/diagram_persistence.py deleted file mode 100755 index c2fbf801..00000000 --- a/cython/doc/pyplots/diagram_persistence.py +++ /dev/null @@ -1,8 +0,0 @@ -import gudhi - -rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ - '/data/points/tore3D_1307.off', max_edge_length=0.2) -simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) -diag = simplex_tree.persistence() -plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) -plt.show() diff --git a/cython/doc/pyplots/show_palette_values.py b/cython/doc/pyplots/show_palette_values.py deleted file mode 100755 index fdf9645f..00000000 --- a/cython/doc/pyplots/show_palette_values.py +++ /dev/null @@ -1,3 +0,0 @@ -import gudhi -plt = gudhi.show_palette_values(alpha=1.0) -plt.show() diff --git a/cython/doc/reader_utils_ref.rst b/cython/doc/reader_utils_ref.rst index 9c1ea6fc..f3ecebad 100644 --- a/cython/doc/reader_utils_ref.rst +++ b/cython/doc/reader_utils_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ============================= Reader utils reference manual ============================= diff --git a/cython/doc/rips_complex_ref.rst b/cython/doc/rips_complex_ref.rst index b17dc4e0..22b5616c 100644 --- a/cython/doc/rips_complex_ref.rst +++ b/cython/doc/rips_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ============================= Rips complex reference manual ============================= diff --git a/cython/doc/rips_complex_sum.inc b/cython/doc/rips_complex_sum.inc new file mode 100644 index 00000000..5616bfa9 --- /dev/null +++ b/cython/doc/rips_complex_sum.inc @@ -0,0 +1,17 @@ +================================================================= =================================== =================================== +:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Rips complex is a simplicial complex constructed from a one skeleton | +| ../../doc/Rips_complex/rips_complex_representation.png | graph. | +| :figclass: align-center | | +| | The filtration value of each edge is computed from a user-given | +| Rips complex representation | distance function and is inserted until a user-given threshold | +| | value. | +| | | +| | This complex can be built from a point cloud and a distance function, | +| | or from a distance matrix. | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/rips_complex_sum.rst b/cython/doc/rips_complex_sum.rst deleted file mode 100644 index 5616bfa9..00000000 --- a/cython/doc/rips_complex_sum.rst +++ /dev/null @@ -1,17 +0,0 @@ -================================================================= =================================== =================================== -:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== - -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | Rips complex is a simplicial complex constructed from a one skeleton | -| ../../doc/Rips_complex/rips_complex_representation.png | graph. | -| :figclass: align-center | | -| | The filtration value of each edge is computed from a user-given | -| Rips complex representation | distance function and is inserted until a user-given threshold | -| | value. | -| | | -| | This complex can be built from a point cloud and a distance function, | -| | or from a distance matrix. | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/rips_complex_user.rst b/cython/doc/rips_complex_user.rst index 96ba9944..a8c06cf9 100644 --- a/cython/doc/rips_complex_user.rst +++ b/cython/doc/rips_complex_user.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Rips complex user manual ========================= Definition @@ -101,8 +105,8 @@ Finally, it is asked to display information about the Rips complex. .. testcode:: import gudhi - rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ - '/data/points/alphacomplexdoc.off', max_edge_length=12.0) + point_cloud = gudhi.read_off(off_file=gudhi.__root_source_dir__ + '/data/points/alphacomplexdoc.off') + rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=12.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ @@ -197,7 +201,7 @@ Example from csv file ^^^^^^^^^^^^^^^^^^^^^ This example builds the :doc:`Rips_complex ` from the given -points in an OFF file, and max_edge_length value. +distance matrix in a csv file, and max_edge_length value. Then it creates a :doc:`Simplex_tree ` with it. Finally, it is asked to display information about the Rips complex. @@ -206,8 +210,9 @@ Finally, it is asked to display information about the Rips complex. .. testcode:: import gudhi - rips_complex = gudhi.RipsComplex(csv_file=gudhi.__root_source_dir__ + \ - '/data/distance_matrix/full_square_distance_matrix.csv', max_edge_length=12.0) + distance_matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file=gudhi.__root_source_dir__ + \ + '/data/distance_matrix/full_square_distance_matrix.csv') + rips_complex = gudhi.RipsComplex(distance_matrix=distance_matrix, max_edge_length=12.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ @@ -240,3 +245,72 @@ the program output is: [0, 3] -> 9.43 [4, 6] -> 9.49 [3, 6] -> 11.00 + +Correlation matrix +------------------ + +Example from a correlation matrix +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Analogously to the case of distance matrix, Rips complexes can be also constructed based on correlation matrix. +Given a correlation matrix M, comportment-wise 1-M is a distance matrix. +This example builds the one skeleton graph from the given corelation matrix and threshold value. +Then it creates a :doc:`Simplex_tree ` with it. + +Finally, it is asked to display information about the simplicial complex. + +.. testcode:: + + import gudhi + import numpy as np + + # User defined correlation matrix is: + # |1 0.06 0.23 0.01 0.89| + # |0.06 1 0.74 0.01 0.61| + # |0.23 0.74 1 0.72 0.03| + # |0.01 0.01 0.72 1 0.7 | + # |0.89 0.61 0.03 0.7 1 | + correlation_matrix=np.array([[1., 0.06, 0.23, 0.01, 0.89], + [0.06, 1., 0.74, 0.01, 0.61], + [0.23, 0.74, 1., 0.72, 0.03], + [0.01, 0.01, 0.72, 1., 0.7], + [0.89, 0.61, 0.03, 0.7, 1.]], float) + + distance_matrix = np.ones((correlation_matrix.shape),float) - correlation_matrix + rips_complex = gudhi.RipsComplex(distance_matrix=distance_matrix, max_edge_length=1.0) + + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' + print(result_str) + fmt = '%s -> %.2f' + for filtered_value in simplex_tree.get_filtration(): + print(fmt % tuple(filtered_value)) + +When launching (Rips maximal distance between 2 points is 12.0, is expanded +until dimension 1 - one skeleton graph in other words), the output is: + +.. testoutput:: + + Rips complex is of dimension 1 - 15 simplices - 5 vertices. + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [0, 4] -> 0.11 + [1, 2] -> 0.26 + [2, 3] -> 0.28 + [3, 4] -> 0.30 + [1, 4] -> 0.39 + [0, 2] -> 0.77 + [0, 1] -> 0.94 + [2, 4] -> 0.97 + [0, 3] -> 0.99 + [1, 3] -> 0.99 + +.. note:: + As persistence diagrams points will be under the diagonal, + bottleneck distance and persistence graphical tool will not work properly, + this is a known issue. diff --git a/cython/doc/simplex_tree_ref.rst b/cython/doc/simplex_tree_ref.rst index 6d196843..9eb8c199 100644 --- a/cython/doc/simplex_tree_ref.rst +++ b/cython/doc/simplex_tree_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ============================= Simplex tree reference manual ============================= diff --git a/cython/doc/simplex_tree_sum.inc b/cython/doc/simplex_tree_sum.inc new file mode 100644 index 00000000..fb0e54c1 --- /dev/null +++ b/cython/doc/simplex_tree_sum.inc @@ -0,0 +1,14 @@ +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | The simplex tree is an efficient and flexible data structure for | +| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | +| :alt: Simplex tree representation | | +| :figclass: align-center | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica` | +| Simplex tree representation | | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/simplex_tree_sum.rst b/cython/doc/simplex_tree_sum.rst deleted file mode 100644 index fb0e54c1..00000000 --- a/cython/doc/simplex_tree_sum.rst +++ /dev/null @@ -1,14 +0,0 @@ -================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== - -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | The simplex tree is an efficient and flexible data structure for | -| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | -| :alt: Simplex tree representation | | -| :figclass: align-center | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica` | -| Simplex tree representation | | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/simplex_tree_user.rst b/cython/doc/simplex_tree_user.rst index 4b1dde19..aebeb29f 100644 --- a/cython/doc/simplex_tree_user.rst +++ b/cython/doc/simplex_tree_user.rst @@ -1,9 +1,13 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Simplex tree user manual ======================== Definition ---------- -.. include:: simplex_tree_sum.rst +.. include:: simplex_tree_sum.inc A simplicial complex :math:`\mathbf{K}` on a set of vertices :math:`V = \{1, \cdots ,|V|\}` is a collection of simplices :math:`\{\sigma\}`, :math:`\sigma \subseteq V` such that diff --git a/cython/doc/strong_witness_complex_ref.rst b/cython/doc/strong_witness_complex_ref.rst index 4ed4fe46..d624d711 100644 --- a/cython/doc/strong_witness_complex_ref.rst +++ b/cython/doc/strong_witness_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ======================================= Strong witness complex reference manual ======================================= diff --git a/cython/doc/tangential_complex_ref.rst b/cython/doc/tangential_complex_ref.rst index 35589475..cdfda082 100644 --- a/cython/doc/tangential_complex_ref.rst +++ b/cython/doc/tangential_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + =================================== Tangential complex reference manual =================================== diff --git a/cython/doc/tangential_complex_sum.inc b/cython/doc/tangential_complex_sum.inc new file mode 100644 index 00000000..72b4d7ba --- /dev/null +++ b/cython/doc/tangential_complex_sum.inc @@ -0,0 +1,15 @@ +================================================================= =================================== =================================== +:Author: Clément Jamin :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 Eigen3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | +| ../../doc/Tangential_complex/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | +| :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | +| | an unknown manifold. The running time depends only linearly on the | +| Tangential complex representation | extrinsic dimension :math:`d` and exponentially on the intrinsic | +| | dimension :math:`k`. | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/tangential_complex_sum.rst b/cython/doc/tangential_complex_sum.rst deleted file mode 100644 index 72b4d7ba..00000000 --- a/cython/doc/tangential_complex_sum.rst +++ /dev/null @@ -1,15 +0,0 @@ -================================================================= =================================== =================================== -:Author: Clément Jamin :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.8.0 Eigen3 -================================================================= =================================== =================================== - -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | -| ../../doc/Tangential_complex/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | -| :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | -| | an unknown manifold. The running time depends only linearly on the | -| Tangential complex representation | extrinsic dimension :math:`d` and exponentially on the intrinsic | -| | dimension :math:`k`. | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/cython/doc/tangential_complex_user.rst b/cython/doc/tangential_complex_user.rst index efa6d7ce..5ce69e86 100644 --- a/cython/doc/tangential_complex_user.rst +++ b/cython/doc/tangential_complex_user.rst @@ -1,6 +1,10 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Tangential complex user manual ============================== -.. include:: tangential_complex_sum.rst +.. include:: tangential_complex_sum.inc Definition ---------- @@ -122,8 +126,8 @@ This example builds the Tangential complex of point set read in an OFF file. .. testcode:: import gudhi - tc = gudhi.TangentialComplex(off_file=gudhi.__root_source_dir__ + \ - '/data/points/alphacomplexdoc.off') + tc = gudhi.TangentialComplex(intrisic_dim = 1, + off_file=gudhi.__root_source_dir__ + '/data/points/alphacomplexdoc.off') result_str = 'Tangential contains ' + repr(tc.num_simplices()) + \ ' simplices - ' + repr(tc.num_vertices()) + ' vertices.' print(result_str) @@ -169,7 +173,8 @@ simplices. .. testcode:: import gudhi - tc = gudhi.TangentialComplex(points=[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) + tc = gudhi.TangentialComplex(intrisic_dim = 1, + points=[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) result_str = 'Tangential contains ' + repr(tc.num_vertices()) + ' vertices.' print(result_str) diff --git a/cython/doc/todos.rst b/cython/doc/todos.rst index 78972a4c..ca274ced 100644 --- a/cython/doc/todos.rst +++ b/cython/doc/todos.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ========== To be done ========== diff --git a/cython/doc/witness_complex_ref.rst b/cython/doc/witness_complex_ref.rst index c78760cb..9987d3fd 100644 --- a/cython/doc/witness_complex_ref.rst +++ b/cython/doc/witness_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ================================ Witness complex reference manual ================================ diff --git a/cython/doc/witness_complex_sum.inc b/cython/doc/witness_complex_sum.inc new file mode 100644 index 00000000..a8a126a0 --- /dev/null +++ b/cython/doc/witness_complex_sum.inc @@ -0,0 +1,19 @@ +================================================================= =================================== =================================== +:Author: Siargey Kachanovich :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Euclidean version requires: CGAL :math:`\geq` 4.6.0 Eigen3 +================================================================= =================================== =================================== + ++-------------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | +| ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | +| :alt: Witness complex representation | | +| :figclass: align-center | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica`. | +| | | +| Witness complex representation | | ++-------------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | +| | * :doc:`strong_witness_complex_ref` | +| | * :doc:`euclidean_witness_complex_ref` | +| | * :doc:`euclidean_strong_witness_complex_ref` | ++-------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/witness_complex_sum.rst b/cython/doc/witness_complex_sum.rst deleted file mode 100644 index a8a126a0..00000000 --- a/cython/doc/witness_complex_sum.rst +++ /dev/null @@ -1,19 +0,0 @@ -================================================================= =================================== =================================== -:Author: Siargey Kachanovich :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Euclidean version requires: CGAL :math:`\geq` 4.6.0 Eigen3 -================================================================= =================================== =================================== - -+-------------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | -| ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | -| :alt: Witness complex representation | | -| :figclass: align-center | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica`. | -| | | -| Witness complex representation | | -+-------------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | -| | * :doc:`strong_witness_complex_ref` | -| | * :doc:`euclidean_witness_complex_ref` | -| | * :doc:`euclidean_strong_witness_complex_ref` | -+-------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/cython/doc/witness_complex_user.rst b/cython/doc/witness_complex_user.rst index 99be5185..40e94134 100644 --- a/cython/doc/witness_complex_user.rst +++ b/cython/doc/witness_complex_user.rst @@ -1,7 +1,11 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Witness complex user manual =========================== -.. include:: witness_complex_sum.rst +.. include:: witness_complex_sum.inc Definitions ----------- diff --git a/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py b/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py index b4487be4..4abe22d4 100755 --- a/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py +++ b/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='AlphaComplex creation from ' @@ -38,7 +38,7 @@ parser = argparse.ArgumentParser(description='AlphaComplex creation from ' 'points from the given OFF file.') parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, default=0.5) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -64,7 +64,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/cython/example/alpha_complex_from_points_example.py b/cython/example/alpha_complex_from_points_example.py index 7d6278ce..ad73c744 100755 --- a/cython/example/alpha_complex_from_points_example.py +++ b/cython/example/alpha_complex_from_points_example.py @@ -8,7 +8,7 @@ from gudhi import AlphaComplex, SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from gudhi import AlphaComplex, SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" print("#####################################################################") diff --git a/cython/example/alpha_rips_persistence_bottleneck_distance.py b/cython/example/alpha_rips_persistence_bottleneck_distance.py index ab5fc1e9..b51fa7a8 100755 --- a/cython/example/alpha_rips_persistence_bottleneck_distance.py +++ b/cython/example/alpha_rips_persistence_bottleneck_distance.py @@ -10,7 +10,7 @@ import math Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ import math """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='AlphaComplex and RipsComplex ' @@ -45,13 +45,14 @@ args = parser.parse_args() with open(args.file, 'r') as f: first_line = f.readline() if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + point_cloud = gudhi.read_off(off_file=args.file) print("#####################################################################") print("RipsComplex creation from points read in a OFF file") message = "RipsComplex with max_edge_length=" + repr(args.threshold) print(message) - rips_complex = gudhi.RipsComplex(off_file=args.file, + rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=args.threshold) rips_stree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) @@ -67,7 +68,7 @@ with open(args.file, 'r') as f: message = "AlphaComplex with max_edge_length=" + repr(args.threshold) print(message) - alpha_complex = gudhi.AlphaComplex(off_file=args.file) + alpha_complex = gudhi.AlphaComplex(points=point_cloud) alpha_stree = alpha_complex.create_simplex_tree(max_alpha_square=(args.threshold * args.threshold)) message = "Number of simplices=" + repr(alpha_stree.num_simplices()) diff --git a/cython/example/bottleneck_basic_example.py b/cython/example/bottleneck_basic_example.py index 31cecb29..287956e7 100755 --- a/cython/example/bottleneck_basic_example.py +++ b/cython/example/bottleneck_basic_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Francois Godi, Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,11 +25,9 @@ import gudhi """ __author__ = "Francois Godi, Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" -import gudhi - diag1 = [[2.7, 3.7],[9.6, 14.],[34.2, 34.974], [3.,float('Inf')]] diag2 = [[2.8, 4.45],[9.5, 14.1],[3.2,float('Inf')]] diff --git a/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py index e3f362dc..3b29781f 100755 --- a/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py +++ b/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='EuclideanStrongWitnessComplex creation from ' @@ -40,7 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, required=True) parser.add_argument("-n", "--number_of_landmarks", type=int, required=True) parser.add_argument("-d", "--limit_dimension", type=int, required=True) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -71,7 +71,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index c236d992..db34962d 100755 --- a/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py +++ b/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation from ' @@ -40,7 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, required=True) parser.add_argument("-n", "--number_of_landmarks", type=int, required=True) parser.add_argument("-d", "--limit_dimension", type=int, required=True) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -71,7 +71,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/cython/example/gudhi_graphical_tools_example.py b/cython/example/gudhi_graphical_tools_example.py index ed87806b..ac3d146c 100755 --- a/cython/example/gudhi_graphical_tools_example.py +++ b/cython/example/gudhi_graphical_tools_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,14 +25,9 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" -print("#####################################################################") -print("Show palette colors values for dimension") - -gudhi.show_palette_values() - print("#####################################################################") print("Show barcode persistence example") @@ -50,5 +45,5 @@ pplot.show() print("#####################################################################") print("Show diagram persistence example with a confidence band") -pplot = gudhi.plot_persistence_diagram(persistence, band_boot=0.2) +pplot = gudhi.plot_persistence_diagram(persistence, band=0.2) pplot.show() diff --git a/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py b/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py index 00334121..5f968bf1 100755 --- a/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py +++ b/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" def is_file_perseus(file): diff --git a/cython/example/random_cubical_complex_persistence_example.py b/cython/example/random_cubical_complex_persistence_example.py index c832d6bf..80ff2452 100755 --- a/cython/example/random_cubical_complex_persistence_example.py +++ b/cython/example/random_cubical_complex_persistence_example.py @@ -13,7 +13,7 @@ import operator Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ import operator """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='Random cubical complex.', diff --git a/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py b/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py new file mode 100755 index 00000000..0c9dfc43 --- /dev/null +++ b/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +import gudhi +import sys +import argparse + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2017 Inria + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2017 Inria" +__license__ = "GPL v3" + +parser = argparse.ArgumentParser(description='RipsComplex creation from ' + 'a correlation matrix read in a csv file.', + epilog='Example: ' + 'example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py ' + '-f ../data/correlation_matrix/lower_triangular_correlation_matrix.csv -e 12.0 -d 3' + '- Constructs a Rips complex with the ' + 'correlation matrix from the given csv file.') +parser.add_argument("-f", "--file", type=str, required=True) +parser.add_argument("-c", "--min_edge_correlation", type=float, default=0.5) +parser.add_argument("-d", "--max_dimension", type=int, default=1) +parser.add_argument("-b", "--band", type=float, default=0.) +parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') + +args = parser.parse_args() + +if not (-1. < args.min_edge_correlation < 1.): + print("Wrong value of the treshold corelation (should be between -1 and 1).") + sys.exit(1) + +print("#####################################################################") +print("Caution: as persistence diagrams points will be under the diagonal,") +print("bottleneck distance and persistence graphical tool will not work") +print("properly, this is a known issue.") + +print("#####################################################################") +print("RipsComplex creation from correlation matrix read in a csv file") + +message = "RipsComplex with min_edge_correlation=" + repr(args.min_edge_correlation) +print(message) + +correlation_matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file=args.file) +# Given a correlation matrix M, we compute component-wise M'[i,j] = 1-M[i,j] to get a distance matrix: +distance_matrix = [[1.-correlation_matrix[i][j] for j in range(len(correlation_matrix[i]))] for i in range(len(correlation_matrix))] + +rips_complex = gudhi.RipsComplex(distance_matrix=distance_matrix, + max_edge_length=1.-args.min_edge_correlation) +simplex_tree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) + +message = "Number of simplices=" + repr(simplex_tree.num_simplices()) +print(message) + +diag = simplex_tree.persistence() + +print("betti_numbers()=") +print(simplex_tree.betti_numbers()) + +# invert the persistence diagram +invert_diag = [(diag[pers][0],(1.-diag[pers][1][0], 1.-diag[pers][1][1])) for pers in range(len(diag))] + +if args.no_diagram == False: + pplot = gudhi.plot_persistence_diagram(invert_diag, band=args.band) + pplot.show() diff --git a/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py b/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py index 3baebd17..4d2ed577 100755 --- a/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py +++ b/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,20 +26,20 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='RipsComplex creation from ' - 'a distance matrix read in a OFF file.', + 'a distance matrix read in a csv file.', epilog='Example: ' 'example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py ' '-f ../data/distance_matrix/lower_triangular_distance_matrix.csv -e 12.0 -d 3' '- Constructs a Rips complex with the ' - 'points from the given OFF file.') + 'distance matrix from the given csv file.') parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-e", "--max_edge_length", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -50,7 +50,8 @@ print("RipsComplex creation from distance matrix read in a csv file") message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) -rips_complex = gudhi.RipsComplex(csv_file=args.file, max_edge_length=args.max_edge_length) +distance_matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file=args.file) +rips_complex = gudhi.RipsComplex(distance_matrix=distance_matrix, max_edge_length=args.max_edge_length) simplex_tree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) message = "Number of simplices=" + repr(simplex_tree.num_simplices()) @@ -62,5 +63,5 @@ print("betti_numbers()=") print(simplex_tree.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() diff --git a/cython/example/rips_complex_diagram_persistence_from_off_file_example.py b/cython/example/rips_complex_diagram_persistence_from_off_file_example.py index 5951eedf..d15d5eb0 100755 --- a/cython/example/rips_complex_diagram_persistence_from_off_file_example.py +++ b/cython/example/rips_complex_diagram_persistence_from_off_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='RipsComplex creation from ' @@ -39,7 +39,7 @@ parser = argparse.ArgumentParser(description='RipsComplex creation from ' parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-e", "--max_edge_length", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -53,7 +53,8 @@ with open(args.file, 'r') as f: message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) - rips_complex = gudhi.RipsComplex(off_file=args.file, max_edge_length=args.max_edge_length) + point_cloud = gudhi.read_off(off_file=args.file) + rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=args.max_edge_length) simplex_tree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) message = "Number of simplices=" + repr(simplex_tree.num_simplices()) @@ -65,7 +66,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/cython/example/rips_complex_from_points_example.py b/cython/example/rips_complex_from_points_example.py index 5d411b1a..ffa9d91f 100755 --- a/cython/example/rips_complex_from_points_example.py +++ b/cython/example/rips_complex_from_points_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" print("#####################################################################") diff --git a/cython/example/rips_persistence_diagram.py b/cython/example/rips_persistence_diagram.py index 9bfea41c..7a6a9f46 100755 --- a/cython/example/rips_persistence_diagram.py +++ b/cython/example/rips_persistence_diagram.py @@ -8,7 +8,7 @@ import gudhi Author(s): Marc Glisse - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Marc Glisse" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" print("#####################################################################") diff --git a/cython/example/simplex_tree_example.py b/cython/example/simplex_tree_example.py index 51a60e73..28679015 100755 --- a/cython/example/simplex_tree_example.py +++ b/cython/example/simplex_tree_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" print("#####################################################################") diff --git a/cython/example/tangential_complex_plain_homology_from_off_file_example.py b/cython/example/tangential_complex_plain_homology_from_off_file_example.py index 6145e7f2..0f8f5e80 100755 --- a/cython/example/tangential_complex_plain_homology_from_off_file_example.py +++ b/cython/example/tangential_complex_plain_homology_from_off_file_example.py @@ -9,7 +9,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,18 +26,19 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='TangentialComplex creation from ' 'points read in a OFF file.', epilog='Example: ' 'example/tangential_complex_plain_homology_from_off_file_example.py ' - '-f ../data/points/tore3D_300.off' + '-f ../data/points/tore3D_300.off -i 3' '- Constructs a tangential complex with the ' 'points from the given OFF file') parser.add_argument("-f", "--file", type=str, required=True) -parser.add_argument("-b", "--band_boot", type=float, default=0.) +parser.add_argument("-i", "--intrisic_dim", type=int, required=True) +parser.add_argument("-b", "--band", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -48,7 +49,7 @@ with open(args.file, 'r') as f: print("#####################################################################") print("TangentialComplex creation from points read in a OFF file") - tc = gudhi.TangentialComplex(off_file=args.file) + tc = gudhi.TangentialComplex(intrisic_dim = args.intrisic_dim, off_file=args.file) st = tc.create_simplex_tree() message = "Number of simplices=" + repr(st.num_simplices()) @@ -60,7 +61,7 @@ with open(args.file, 'r') as f: print(st.betti_numbers()) if args.no_diagram == False: - pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/cython/example/witness_complex_from_nearest_landmark_table.py b/cython/example/witness_complex_from_nearest_landmark_table.py index 92ed970b..e6b295ee 100755 --- a/cython/example/witness_complex_from_nearest_landmark_table.py +++ b/cython/example/witness_complex_from_nearest_landmark_table.py @@ -8,7 +8,7 @@ from gudhi import StrongWitnessComplex, SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from gudhi import StrongWitnessComplex, SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" print("#####################################################################") diff --git a/cython/gudhi.pyx.in b/cython/gudhi.pyx.in index a8dd9f80..b94f2251 100644 --- a/cython/gudhi.pyx.in +++ b/cython/gudhi.pyx.in @@ -4,7 +4,7 @@ Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" __version__ = "@GUDHI_VERSION@" # This variable is used by doctest to find files diff --git a/cython/include/Alpha_complex_interface.h b/cython/include/Alpha_complex_interface.h index d47db71f..8cf527fc 100644 --- a/cython/include/Alpha_complex_interface.h +++ b/cython/include/Alpha_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Bottleneck_distance_interface.h b/cython/include/Bottleneck_distance_interface.h index d5fbf6ea..5ad9d77d 100644 --- a/cython/include/Bottleneck_distance_interface.h +++ b/cython/include/Bottleneck_distance_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Cubical_complex_interface.h b/cython/include/Cubical_complex_interface.h index fad92c2c..85b717b3 100644 --- a/cython/include/Cubical_complex_interface.h +++ b/cython/include/Cubical_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Euclidean_strong_witness_complex_interface.h b/cython/include/Euclidean_strong_witness_complex_interface.h index b9dd8177..d86355d6 100644 --- a/cython/include/Euclidean_strong_witness_complex_interface.h +++ b/cython/include/Euclidean_strong_witness_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Euclidean_witness_complex_interface.h b/cython/include/Euclidean_witness_complex_interface.h index 2a09b3b5..dc303533 100644 --- a/cython/include/Euclidean_witness_complex_interface.h +++ b/cython/include/Euclidean_witness_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Off_reader_interface.h b/cython/include/Off_reader_interface.h index 0ca55500..f6b14f38 100644 --- a/cython/include/Off_reader_interface.h +++ b/cython/include/Off_reader_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Persistent_cohomology_interface.h b/cython/include/Persistent_cohomology_interface.h index 55028fd0..8cf71a4e 100644 --- a/cython/include/Persistent_cohomology_interface.h +++ b/cython/include/Persistent_cohomology_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,6 +85,32 @@ persistent_cohomology::Persistent_cohomology, std::vector>> persistence_pairs() { + auto pairs = persistent_cohomology::Persistent_cohomology::get_persistent_pairs(); + + std::vector, std::vector>> persistence_pairs; + persistence_pairs.reserve(pairs.size()); + for (auto pair : pairs) { + std::vector birth; + if (get<0>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<0>(pair))) { + birth.push_back(vertex); + } + } + + std::vector death; + if (get<1>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<1>(pair))) { + death.push_back(vertex); + } + } + + persistence_pairs.push_back(std::make_pair(birth, death)); + } + return persistence_pairs; + } + private: // A copy FilteredComplex* stptr_; diff --git a/cython/include/Reader_utils_interface.h b/cython/include/Reader_utils_interface.h index 8ec34f61..5f7527d9 100644 --- a/cython/include/Reader_utils_interface.h +++ b/cython/include/Reader_utils_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2017 INRIA + * Copyright (C) 2017 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Rips_complex_interface.h b/cython/include/Rips_complex_interface.h index 02985727..8b6c9c35 100644 --- a/cython/include/Rips_complex_interface.h +++ b/cython/include/Rips_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,9 +25,7 @@ #include #include -#include #include -#include #include "Simplex_tree_interface.h" @@ -56,21 +54,6 @@ class Rips_complex_interface { } } - Rips_complex_interface(const std::string& file_name, double threshold, bool euclidean, bool from_file = true) { - if (euclidean) { - // Rips construction where file_name is an OFF file - Gudhi::Points_off_reader off_reader(file_name); - rips_complex_ = new Rips_complex::Filtration_value>(off_reader.get_point_cloud(), - threshold, - Gudhi::Euclidean_distance()); - } else { - // Rips construction where values is a distance matrix - Distance_matrix distances = - Gudhi::read_lower_triangular_matrix_from_csv_file::Filtration_value>(file_name); - rips_complex_ = new Rips_complex::Filtration_value>(distances, threshold); - } - } - ~Rips_complex_interface() { delete rips_complex_; } diff --git a/cython/include/Simplex_tree_interface.h b/cython/include/Simplex_tree_interface.h index 54a4f824..3481eeff 100644 --- a/cython/include/Simplex_tree_interface.h +++ b/cython/include/Simplex_tree_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Strong_witness_complex_interface.h b/cython/include/Strong_witness_complex_interface.h index d05eaac5..3c72c916 100644 --- a/cython/include/Strong_witness_complex_interface.h +++ b/cython/include/Strong_witness_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Subsampling_interface.h b/cython/include/Subsampling_interface.h index b0f4a50a..f990da0c 100644 --- a/cython/include/Subsampling_interface.h +++ b/cython/include/Subsampling_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/include/Tangential_complex_interface.h b/cython/include/Tangential_complex_interface.h index 0c3a510e..71418886 100644 --- a/cython/include/Tangential_complex_interface.h +++ b/cython/include/Tangential_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,24 +45,19 @@ class Tangential_complex_interface { using TC = Tangential_complex; public: - Tangential_complex_interface(const std::vector>& points) { + Tangential_complex_interface(int intrisic_dim, const std::vector>& points) { Dynamic_kernel k; - unsigned intrisic_dim = 0; - if (points.size() > 0) - intrisic_dim = points[0].size() - 1; tangential_complex_ = new TC(points, intrisic_dim, k); tangential_complex_->compute_tangential_complex(); num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices(); } - Tangential_complex_interface(const std::string& off_file_name, bool from_file = true) { - Gudhi::Points_off_reader off_reader(off_file_name); + Tangential_complex_interface(int intrisic_dim, const std::string& off_file_name, bool from_file = true) { Dynamic_kernel k; - unsigned intrisic_dim = 0; + + Gudhi::Points_off_reader off_reader(off_file_name); std::vector points = off_reader.get_point_cloud(); - if (points.size() > 0) - intrisic_dim = points[0].size() - 1; tangential_complex_ = new TC(points, intrisic_dim, k); tangential_complex_->compute_tangential_complex(); diff --git a/cython/include/Witness_complex_interface.h b/cython/include/Witness_complex_interface.h index 6501cc35..01b372e7 100644 --- a/cython/include/Witness_complex_interface.h +++ b/cython/include/Witness_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/cython/setup.py.in b/cython/setup.py.in index c767e93d..ee381a1b 100644 --- a/cython/setup.py.in +++ b/cython/setup.py.in @@ -7,7 +7,7 @@ from Cython.Build import cythonize Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ from Cython.Build import cythonize """ __author__ = "GUDHI Editorial Board" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" gudhi = Extension( @@ -46,4 +46,9 @@ setup( version='@GUDHI_VERSION@', url='http://gudhi.gforge.inria.fr/', ext_modules = cythonize(gudhi), + install_requires = [ + "matplotlib", + "numpy", + "cython", + ], ) diff --git a/cython/test/test_alpha_complex.py b/cython/test/test_alpha_complex.py index 2c76d9d7..e97f2530 100755 --- a/cython/test/test_alpha_complex.py +++ b/cython/test/test_alpha_complex.py @@ -6,7 +6,7 @@ from gudhi import AlphaComplex, SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ from gudhi import AlphaComplex, SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_bottleneck_distance.py b/cython/test/test_bottleneck_distance.py index 3d982d34..4eb5848f 100755 --- a/cython/test/test_bottleneck_distance.py +++ b/cython/test/test_bottleneck_distance.py @@ -6,7 +6,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_cubical_complex.py b/cython/test/test_cubical_complex.py index 0e81554d..92e591e9 100755 --- a/cython/test/test_cubical_complex.py +++ b/cython/test/test_cubical_complex.py @@ -6,7 +6,7 @@ from gudhi import CubicalComplex Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ from gudhi import CubicalComplex """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" @@ -72,6 +72,17 @@ def test_dimension_simple_constructor(): assert cub.betti_numbers() == [1, 0, 0] assert cub.persistent_betti_numbers(0, 1000) == [0, 0, 0] +def test_user_case_simple_constructor(): + cub = CubicalComplex(dimensions=[3, 3], + top_dimensional_cells = [float('inf'), 0.,0.,0.,1.,0.,0.,0.,0.]) + assert cub.__is_defined() == True + assert cub.__is_persistence_defined() == False + assert cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float('inf')))] + assert cub.__is_persistence_defined() == True + other_cub = CubicalComplex(dimensions=[3, 3], + top_dimensional_cells = [1000., 0.,0.,0.,1.,0.,0.,0.,0.]) + assert other_cub.persistence() == [(1, (0.0, 1.0)), (0, (0.0, float('inf')))] + def test_dimension_file_constructor(): # Create test file test_file = open('CubicalOneSphere.txt', 'w') diff --git a/cython/test/test_euclidean_witness_complex.py b/cython/test/test_euclidean_witness_complex.py index 737f1ef4..2f77210a 100755 --- a/cython/test/test_euclidean_witness_complex.py +++ b/cython/test/test_euclidean_witness_complex.py @@ -6,7 +6,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_reader_utils.py b/cython/test/test_reader_utils.py index 25591fb3..b240c84f 100755 --- a/cython/test/test_reader_utils.py +++ b/cython/test/test_reader_utils.py @@ -6,7 +6,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2017 INRIA + Copyright (C) 2017 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2017 INRIA" +__copyright__ = "Copyright (C) 2017 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_rips_complex.py b/cython/test/test_rips_complex.py index c7d2ead4..c37b5400 100755 --- a/cython/test/test_rips_complex.py +++ b/cython/test/test_rips_complex.py @@ -7,7 +7,7 @@ from math import sqrt Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ from math import sqrt """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_simplex_tree.py b/cython/test/test_simplex_tree.py index 6dec5d94..cb701c9a 100755 --- a/cython/test/test_simplex_tree.py +++ b/cython/test/test_simplex_tree.py @@ -6,7 +6,7 @@ from gudhi import SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ from gudhi import SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" @@ -161,3 +161,47 @@ def test_automatic_dimension(): assert st.upper_bound_dimension() == 2 assert st.dimension() == 1 assert st.upper_bound_dimension() == 1 + +def test_make_filtration_non_decreasing(): + st = SimplexTree() + assert st.__is_defined() == True + assert st.__is_persistence_defined() == False + + # Inserted simplex: + # 1 + # o + # /X\ + # o---o---o---o + # 2 0 3\X/4 + # o + # 5 + assert st.insert([2, 1, 0], filtration=2.0) == True + assert st.insert([3, 0], filtration=2.0) == True + assert st.insert([3, 4, 5], filtration=2.0) == True + + assert st.make_filtration_non_decreasing() == False + + # Because of non decreasing property of simplex tree, { 0 } , { 1 } and + # { 0, 1 } are going to be set from value 2.0 to 1.0 + st.insert([0, 1, 6, 7], filtration=1.0); + + assert st.make_filtration_non_decreasing() == False + + # Modify specific values to test make_filtration_non_decreasing + st.assign_filtration([0,1,6,7], 0.8); + st.assign_filtration([0,1,6], 0.9); + st.assign_filtration([0,6], 0.6); + st.assign_filtration([3,4,5], 1.2); + st.assign_filtration([3,4], 1.1); + st.assign_filtration([4,5], 1.99); + + assert st.make_filtration_non_decreasing() == True + + assert st.filtration([0,1,6,7]) == 1. + assert st.filtration([0,1,6]) == 1. + assert st.filtration([0,1]) == 1. + assert st.filtration([0]) == 1. + assert st.filtration([1]) == 1. + assert st.filtration([3,4,5]) == 2. + assert st.filtration([3,4]) == 2. + assert st.filtration([4,5]) == 2. diff --git a/cython/test/test_subsampling.py b/cython/test/test_subsampling.py index 2caf4ddb..96906a6f 100755 --- a/cython/test/test_subsampling.py +++ b/cython/test/test_subsampling.py @@ -6,7 +6,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" diff --git a/cython/test/test_tangential_complex.py b/cython/test/test_tangential_complex.py index 8aa4023c..5385a0d3 100755 --- a/cython/test/test_tangential_complex.py +++ b/cython/test/test_tangential_complex.py @@ -6,7 +6,7 @@ from gudhi import TangentialComplex, SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,13 +23,13 @@ from gudhi import TangentialComplex, SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" def test_tangential(): point_list = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]] - tc = TangentialComplex(points=point_list) + tc = TangentialComplex(intrisic_dim = 1, points=point_list) assert tc.__is_defined() == True assert tc.num_vertices() == 4 diff --git a/cython/test/test_witness_complex.py b/cython/test/test_witness_complex.py index 7d1fb6be..bcbc521b 100755 --- a/cython/test/test_witness_complex.py +++ b/cython/test/test_witness_complex.py @@ -6,7 +6,7 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA + Copyright (C) 2016 Inria This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" +__copyright__ = "Copyright (C) 2016 Inria" __license__ = "GPL v3" -- cgit v1.2.3