diff options
author | Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> | 2019-07-01 17:32:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-01 17:32:10 +0200 |
commit | 00b9f30933134dbc8c5a90373308e4993a0e2871 (patch) | |
tree | 0da27b8d7cc6dd805201823bf15d685438153dad /src/cython | |
parent | e9e875a4ec84b7ca28b350f8cd0b9024246b00e2 (diff) | |
parent | 4d8dc4477942d196a304e71db4918ac71862e597 (diff) |
Merge pull request #76 from VincentRouvreau/gpl_to_mit
Gpl to mit
Diffstat (limited to 'src/cython')
79 files changed, 1561 insertions, 1809 deletions
diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index d4ace20e..509a122e 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -91,7 +91,7 @@ if(PYTHONINTERP_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ") endif (EIGEN3_FOUND) - if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_VERSION VERSION_LESS 4.11.0) set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}bottleneck_distance;") set(GUDHI_CYTHON_NERVE_GIC "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/nerve_gic.pyx'") @@ -100,7 +100,7 @@ if(PYTHONINTERP_FOUND) set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}bottleneck_distance;") set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}nerve_gic;") endif () - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}subsampling;") set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'") @@ -109,13 +109,13 @@ if(PYTHONINTERP_FOUND) set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}subsampling;") set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}tangential_complex;") endif () - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) set(GUDHI_CYTHON_ALPHA_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/alpha_complex.pyx'") set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}alpha_complex;") else() set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}alpha_complex;") endif () - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) set(GUDHI_CYTHON_EUCLIDEAN_WITNESS_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_witness_complex.pyx'\ninclude '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_strong_witness_complex.pyx'\n") set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}euclidean_witness_complex;") @@ -224,7 +224,7 @@ if(PYTHONINTERP_FOUND) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)") # Test examples - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Bottleneck and Alpha add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -259,8 +259,8 @@ if(PYTHONINTERP_FOUND) # Subsampling add_gudhi_py_test(test_subsampling) - endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) + if (NOT CGAL_VERSION VERSION_LESS 4.11.0) # Bottleneck add_test(NAME bottleneck_basic_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -299,9 +299,9 @@ if(PYTHONINTERP_FOUND) -f human.off -n 700 -v) add_gudhi_py_test(test_cover_complex) - endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) + endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Alpha add_test(NAME alpha_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -318,13 +318,13 @@ if(PYTHONINTERP_FOUND) add_gudhi_py_test(test_alpha_complex) - endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) - if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Euclidean witness add_gudhi_py_test(test_euclidean_witness_complex) - endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) # Cubical add_test(NAME periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test @@ -389,7 +389,7 @@ if(PYTHONINTERP_FOUND) if(MATPLOTLIB_FOUND) if(NUMPY_FOUND) if(SCIPY_FOUND) - if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) set (GUDHI_SPHINX_MESSAGE "Generating API documentation with Sphinx in ${CMAKE_CURRENT_BINARY_DIR}/sphinx/") # User warning - Sphinx is a static pages generator, and configured to work fine with user_version # Images and biblio warnings because not found on developper version @@ -411,10 +411,10 @@ if(PYTHONINTERP_FOUND) # Set missing or not modules set(GUDHI_MODULES ${GUDHI_MODULES} "python-documentation" CACHE INTERNAL "GUDHI_MODULES") - else(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - message("++ Python documentation module will not be compiled because it requires a CGAL with Eigen3 version greater or equal than 4.8.1") + else(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) + message("++ Python documentation module will not be compiled because it requires a Eigen3 and CGAL version >= 4.11.0") set(GUDHI_MISSING_MODULES ${GUDHI_MISSING_MODULES} "python-documentation" CACHE INTERNAL "GUDHI_MISSING_MODULES") - endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) else(SCIPY_FOUND) message("++ Python documentation module will not be compiled because scipy was not found") set(GUDHI_MISSING_MODULES ${GUDHI_MISSING_MODULES} "python-documentation" CACHE INTERNAL "GUDHI_MISSING_MODULES") diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/cython/alpha_complex.pyx index 4f772e31..249d51d0 100644 --- a/src/cython/cython/alpha_complex.pyx +++ b/src/cython/cython/alpha_complex.pyx @@ -5,26 +5,14 @@ from libcpp.string cimport string from libcpp cimport bool import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/bottleneck_distance.pyx b/src/cython/cython/bottleneck_distance.pyx index 76ef81f4..4b378cbc 100644 --- a/src/cython/cython/bottleneck_distance.pyx +++ b/src/cython/cython/bottleneck_distance.pyx @@ -3,26 +3,14 @@ from libcpp.vector cimport vector from libcpp.utility cimport pair import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/cubical_complex.pyx b/src/cython/cython/cubical_complex.pyx index 509af6ca..0dc133d1 100644 --- a/src/cython/cython/cubical_complex.pyx +++ b/src/cython/cython/cubical_complex.pyx @@ -7,31 +7,19 @@ import os from numpy import array as np_array -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Cubical_complex_interface.h" namespace "Gudhi": cdef cppclass Bitmap_cubical_complex_base_interface "Gudhi::Cubical_complex::Cubical_complex_interface<>": diff --git a/src/cython/cython/euclidean_strong_witness_complex.pyx b/src/cython/cython/euclidean_strong_witness_complex.pyx index 62b7cf71..26bd8375 100644 --- a/src/cython/cython/euclidean_strong_witness_complex.pyx +++ b/src/cython/cython/euclidean_strong_witness_complex.pyx @@ -2,26 +2,14 @@ from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/euclidean_witness_complex.pyx b/src/cython/cython/euclidean_witness_complex.pyx index c10ca73d..e687c6f3 100644 --- a/src/cython/cython/euclidean_witness_complex.pyx +++ b/src/cython/cython/euclidean_witness_complex.pyx @@ -2,26 +2,14 @@ from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/nerve_gic.pyx b/src/cython/cython/nerve_gic.pyx index 5f01b379..3c8f1200 100644 --- a/src/cython/cython/nerve_gic.pyx +++ b/src/cython/cython/nerve_gic.pyx @@ -5,26 +5,14 @@ from libcpp.string cimport string from libcpp cimport bool import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/off_reader.pyx b/src/cython/cython/off_reader.pyx index b939013f..9efd97ff 100644 --- a/src/cython/cython/off_reader.pyx +++ b/src/cython/cython/off_reader.pyx @@ -3,31 +3,19 @@ from libcpp.vector cimport vector from libcpp.string cimport string import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Off_reader_interface.h" namespace "Gudhi": vector[vector[double]] read_points_from_OFF_file(string off_file) diff --git a/src/cython/cython/periodic_cubical_complex.pyx b/src/cython/cython/periodic_cubical_complex.pyx index 3866f53b..724fadd4 100644 --- a/src/cython/cython/periodic_cubical_complex.pyx +++ b/src/cython/cython/periodic_cubical_complex.pyx @@ -7,31 +7,19 @@ import os from numpy import array as np_array -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2016 Inria - Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Cubical_complex_interface.h" namespace "Gudhi": cdef cppclass Periodic_cubical_complex_base_interface "Gudhi::Cubical_complex::Cubical_complex_interface<Gudhi::cubical_complex::Bitmap_cubical_complex_periodic_boundary_conditions_base<double>>": diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py index 7bb69840..34803222 100644 --- a/src/cython/cython/persistence_graphical_tools.py +++ b/src/cython/cython/persistence_graphical_tools.py @@ -2,33 +2,22 @@ from os import path from math import isfinite import numpy as np -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau, Bertrand Michel - Author(s): Vincent Rouvreau, Bertrand Michel + Copyright (C) 2016 Inria - Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau, Bertrand Michel" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -def __min_birth_max_death(persistence, band=0.): + +def __min_birth_max_death(persistence, band=0.0): """This function returns (min_birth, max_death) from the persistence. :param persistence: The persistence to plot. @@ -41,27 +30,47 @@ def __min_birth_max_death(persistence, band=0.): max_death = 0 min_birth = persistence[0][1][0] for interval in reversed(persistence): - if float(interval[1][1]) != float('inf'): + if float(interval[1][1]) != float("inf"): if float(interval[1][1]) > max_death: max_death = float(interval[1][1]) if float(interval[1][0]) > max_death: max_death = float(interval[1][0]) if float(interval[1][0]) < min_birth: min_birth = float(interval[1][0]) - if band > 0.: + if band > 0.0: max_death += band return (min_birth, max_death) + """ Only 13 colors for the palette """ -palette = ['#ff0000', '#00ff00', '#0000ff', '#00ffff', '#ff00ff', '#ffff00', - '#000000', '#880000', '#008800', '#000088', '#888800', '#880088', - '#008888'] - -def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, - max_intervals=1000, max_barcodes=1000, - inf_delta=0.1, legend=False): +palette = [ + "#ff0000", + "#00ff00", + "#0000ff", + "#00ffff", + "#ff00ff", + "#ffff00", + "#000000", + "#880000", + "#008800", + "#000088", + "#888800", + "#880088", + "#008888", +] + + +def plot_persistence_barcode( + persistence=[], + persistence_file="", + alpha=0.6, + max_intervals=1000, + 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 <fileformats>`. @@ -90,11 +99,13 @@ def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, import matplotlib.pyplot as plt import matplotlib.patches as mpatches - if persistence_file is not '': + if persistence_file is not "": if path.isfile(persistence_file): # Reset persistence persistence = [] - diag = read_persistence_intervals_grouped_by_dimension(persistence_file=persistence_file) + diag = read_persistence_intervals_grouped_by_dimension( + persistence_file=persistence_file + ) for key in diag.keys(): for persistence_interval in diag[key]: persistence.append((key, persistence_interval)) @@ -103,44 +114,62 @@ def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, return None if max_barcodes is not 1000: - print('Deprecated parameter. It has been replaced by max_intervals') + print("Deprecated parameter. It has been replaced by max_intervals") max_intervals = max_barcodes if max_intervals > 0 and max_intervals < len(persistence): # Sort by life time, then takes only the max_intervals elements - persistence = sorted(persistence, key=lambda life_time: life_time[1][1]-life_time[1][0], reverse=True)[:max_intervals] + persistence = sorted( + persistence, + key=lambda life_time: life_time[1][1] - life_time[1][0], + reverse=True, + )[:max_intervals] 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) * inf_delta) + 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 axis_start = min_birth - delta # Draw horizontal bars in loop for interval in reversed(persistence): - if float(interval[1][1]) != float('inf'): + if float(interval[1][1]) != float("inf"): # 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]], - linewidth=0) + plt.barh( + ind, + (interval[1][1] - interval[1][0]), + height=0.8, + left=interval[1][0], + alpha=alpha, + 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]], - linewidth=0) + plt.barh( + ind, + (infinity - interval[1][0]), + height=0.8, + left=interval[1][0], + alpha=alpha, + 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') + 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 @@ -148,8 +177,17 @@ def plot_persistence_barcode(persistence=[], persistence_file='', alpha=0.6, except ImportError: print("This function is not available, you may be missing matplotlib.") -def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, - band=0., max_intervals=1000, max_plots=1000, inf_delta=0.1, legend=False): + +def plot_persistence_diagram( + persistence=[], + persistence_file="", + alpha=0.6, + band=0.0, + max_intervals=1000, + 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 <fileformats>`. @@ -180,11 +218,13 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, import matplotlib.pyplot as plt import matplotlib.patches as mpatches - if persistence_file is not '': + if persistence_file is not "": if path.isfile(persistence_file): # Reset persistence persistence = [] - diag = read_persistence_intervals_grouped_by_dimension(persistence_file=persistence_file) + diag = read_persistence_intervals_grouped_by_dimension( + persistence_file=persistence_file + ) for key in diag.keys(): for persistence_interval in diag[key]: persistence.append((key, persistence_interval)) @@ -193,15 +233,19 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, return None if max_plots is not 1000: - print('Deprecated parameter. It has been replaced by max_intervals') + print("Deprecated parameter. It has been replaced by max_intervals") max_intervals = max_plots if max_intervals > 0 and max_intervals < len(persistence): # Sort by life time, then takes only the max_intervals elements - persistence = sorted(persistence, key=lambda life_time: life_time[1][1]-life_time[1][0], reverse=True)[:max_intervals] + persistence = sorted( + persistence, + key=lambda life_time: life_time[1][1] - life_time[1][0], + reverse=True, + )[:max_intervals] (min_birth, max_death) = __min_birth_max_death(persistence, band) - delta = ((max_death - min_birth) * inf_delta) + delta = (max_death - min_birth) * inf_delta # Replace infinity values with max_death + delta for diagram to be more # readable infinity = max_death + delta @@ -210,31 +254,41 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, # line display of equation : birth = death x = np.linspace(axis_start, infinity, 1000) # infinity line and text - plt.plot(x, x, color='k', linewidth=1.0) - plt.plot(x, [infinity] * len(x), linewidth=1.0, color='k', alpha=alpha) - plt.text(axis_start, infinity, r'$\infty$', color='k', alpha=alpha) + plt.plot(x, x, color="k", linewidth=1.0) + 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 > 0.: - plt.fill_between(x, x, x+band, alpha=alpha, facecolor='red') + if band > 0.0: + plt.fill_between(x, x, x + band, alpha=alpha, facecolor="red") # Draw points in loop for interval in reversed(persistence): - if float(interval[1][1]) != float('inf'): + if float(interval[1][1]) != float("inf"): # Finite death case - plt.scatter(interval[1][0], interval[1][1], alpha=alpha, - color = palette[interval[0]]) + plt.scatter( + interval[1][0], + interval[1][1], + alpha=alpha, + color=palette[interval[0]], + ) else: # Infinite death case for diagram to be nicer - plt.scatter(interval[1][0], infinity, alpha=alpha, - color = palette[interval[0]]) + plt.scatter( + interval[1][0], infinity, alpha=alpha, color=palette[interval[0]] + ) 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') + 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") # Ends plot on infinity value and starts a little bit before min_birth plt.axis([axis_start, infinity, axis_start, infinity + delta]) return plt @@ -242,10 +296,17 @@ def plot_persistence_diagram(persistence=[], persistence_file='', alpha=0.6, except ImportError: print("This function is not available, you may be missing matplotlib.") -def plot_persistence_density(persistence=[], persistence_file='', - nbins=300, bw_method=None, - max_intervals=1000, dimension=None, - cmap=None, legend=False): + +def plot_persistence_density( + persistence=[], + persistence_file="", + nbins=300, + bw_method=None, + max_intervals=1000, + dimension=None, + cmap=None, + legend=False, +): """This function plots the persistence density from persistence values list or from a :doc:`persistence file <fileformats>`. Be aware that this function does not distinguish the dimension, it is @@ -290,39 +351,53 @@ def plot_persistence_density(persistence=[], persistence_file='', import matplotlib.pyplot as plt from scipy.stats import kde - if persistence_file is not '': + if persistence_file is not "": if dimension is None: # All dimension case dimension = -1 if path.isfile(persistence_file): - persistence_dim = read_persistence_intervals_in_dimension(persistence_file=persistence_file, - only_this_dim=dimension) + persistence_dim = read_persistence_intervals_in_dimension( + persistence_file=persistence_file, only_this_dim=dimension + ) print(persistence_dim) else: print("file " + persistence_file + " not found.") return None if len(persistence) > 0: - persistence_dim = np.array([(dim_interval[1][0], dim_interval[1][1]) for dim_interval in persistence if (dim_interval[0] == dimension) or (dimension is None)]) - - persistence_dim = persistence_dim[np.isfinite(persistence_dim[:,1])] + persistence_dim = np.array( + [ + (dim_interval[1][0], dim_interval[1][1]) + for dim_interval in persistence + if (dim_interval[0] == dimension) or (dimension is None) + ] + ) + + persistence_dim = persistence_dim[np.isfinite(persistence_dim[:, 1])] if max_intervals > 0 and max_intervals < len(persistence_dim): # Sort by life time, then takes only the max_intervals elements - persistence_dim = np.array(sorted(persistence_dim, - key=lambda life_time: life_time[1]-life_time[0], - reverse=True)[:max_intervals]) + persistence_dim = np.array( + sorted( + persistence_dim, + key=lambda life_time: life_time[1] - life_time[0], + reverse=True, + )[:max_intervals] + ) # Set as numpy array birth and death (remove undefined values - inf and NaN) - birth = persistence_dim[:,0] - death = persistence_dim[:,1] + birth = persistence_dim[:, 0] + death = persistence_dim[:, 1] # line display of equation : birth = death x = np.linspace(death.min(), birth.max(), 1000) - plt.plot(x, x, color='k', linewidth=1.0) + plt.plot(x, x, color="k", linewidth=1.0) # Evaluate a gaussian kde on a regular grid of nbins x nbins over data extents - k = kde.gaussian_kde([birth,death], bw_method=bw_method) - xi, yi = np.mgrid[birth.min():birth.max():nbins*1j, death.min():death.max():nbins*1j] + k = kde.gaussian_kde([birth, death], bw_method=bw_method) + xi, yi = np.mgrid[ + birth.min() : birth.max() : nbins * 1j, + death.min() : death.max() : nbins * 1j, + ] zi = k(np.vstack([xi.flatten(), yi.flatten()])) # default cmap value cannot be done at argument definition level as matplotlib is not yet defined. @@ -334,10 +409,12 @@ def plot_persistence_density(persistence=[], persistence_file='', if legend: plt.colorbar() - plt.title('Persistence density') - plt.xlabel('Birth') - plt.ylabel('Death') + plt.title("Persistence density") + plt.xlabel("Birth") + plt.ylabel("Death") return plt except ImportError: - print("This function is not available, you may be missing matplotlib and/or scipy.") + print( + "This function is not available, you may be missing matplotlib and/or scipy." + ) diff --git a/src/cython/cython/reader_utils.pyx b/src/cython/cython/reader_utils.pyx index 6dde5286..147fae71 100644 --- a/src/cython/cython/reader_utils.pyx +++ b/src/cython/cython/reader_utils.pyx @@ -7,31 +7,19 @@ from libcpp.pair cimport pair from os import path from numpy import array as np_array -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2017 Inria - Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2017 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Reader_utils_interface.h" namespace "Gudhi": vector[vector[double]] read_matrix_from_csv_file(string off_file, char separator) diff --git a/src/cython/cython/rips_complex.pyx b/src/cython/cython/rips_complex.pyx index 7c83241c..b9a2331f 100644 --- a/src/cython/cython/rips_complex.pyx +++ b/src/cython/cython/rips_complex.pyx @@ -5,31 +5,19 @@ from libcpp.string cimport string from libcpp cimport bool import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Rips_complex_interface.h" namespace "Gudhi": cdef cppclass Rips_complex_interface "Gudhi::rips_complex::Rips_complex_interface": diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 43bc11c9..8e791c17 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -6,31 +6,19 @@ from libcpp.string cimport string from numpy import array as np_array -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2016 Inria - Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": cdef cppclass Simplex_tree_options_full_featured: diff --git a/src/cython/cython/strong_witness_complex.pyx b/src/cython/cython/strong_witness_complex.pyx index 4b7bff34..8c155815 100644 --- a/src/cython/cython/strong_witness_complex.pyx +++ b/src/cython/cython/strong_witness_complex.pyx @@ -2,31 +2,19 @@ from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Strong_witness_complex_interface.h" namespace "Gudhi": cdef cppclass Strong_witness_complex_interface "Gudhi::witness_complex::Strong_witness_complex_interface": diff --git a/src/cython/cython/subsampling.pyx b/src/cython/cython/subsampling.pyx index e9d61a37..1135c1fb 100644 --- a/src/cython/cython/subsampling.pyx +++ b/src/cython/cython/subsampling.pyx @@ -4,26 +4,14 @@ from libcpp.string cimport string from libcpp cimport bool import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx index 293ef8cb..00a84810 100644 --- a/src/cython/cython/tangential_complex.pyx +++ b/src/cython/cython/tangential_complex.pyx @@ -5,26 +5,14 @@ from libcpp.string cimport string from libcpp cimport bool import os -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" diff --git a/src/cython/cython/witness_complex.pyx b/src/cython/cython/witness_complex.pyx index b1cce83f..91046f57 100644 --- a/src/cython/cython/witness_complex.pyx +++ b/src/cython/cython/witness_complex.pyx @@ -2,31 +2,19 @@ from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" cdef extern from "Witness_complex_interface.h" namespace "Gudhi": cdef cppclass Witness_complex_interface "Gudhi::witness_complex::Witness_complex_interface": diff --git a/src/cython/doc/alpha_complex_sum.inc b/src/cython/doc/alpha_complex_sum.inc index 806988bb..9049e654 100644 --- a/src/cython/doc/alpha_complex_sum.inc +++ b/src/cython/doc/alpha_complex_sum.inc @@ -1,20 +1,20 @@ .. table:: :widths: 30 50 20 - +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------+ - | .. figure:: | Alpha complex is a simplicial complex constructed from the finite | :Author: Vincent Rouvreau | - | ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | | - | :alt: Alpha complex representation | | :Introduced in: GUDHI 2.0.0 | - | :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 | :Copyright: GPL v3 | - | | is then said to be Gabriel), and as the minimum of the filtration | | - | | values of the codimension 1 cofaces that make it not Gabriel | :Requires: Eigen3 and CGAL :math:`\geq` 4.7.0 | - | | 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` | - +----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------+ + | .. figure:: | Alpha complex is a simplicial complex constructed from the finite | :Author: Vincent Rouvreau | + | ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | | + | :alt: Alpha complex representation | | :Introduced in: GUDHI 2.0.0 | + | :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 | :Copyright: MIT (`GPL v3 </licensing/>`_) | + | | is then said to be Gabriel), and as the minimum of the filtration | | + | | values of the codimension 1 cofaces that make it not Gabriel | :Requires: `Eigen3 <installation.html#eigen3>`__ and `CGAL <installation.html#cgal>`__ :math:`\geq` 4.11.0 | + | | 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/src/cython/doc/bottleneck_distance_sum.inc b/src/cython/doc/bottleneck_distance_sum.inc index 6840e838..6eb0ac19 100644 --- a/src/cython/doc/bottleneck_distance_sum.inc +++ b/src/cython/doc/bottleneck_distance_sum.inc @@ -1,14 +1,14 @@ .. table:: :widths: 30 50 20 - +-----------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------+ - | .. figure:: | Bottleneck distance measures the similarity between two persistence | :Author: François Godi | - | ../../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 | :Introduced in: GUDHI 2.0.0 | - | | diagonal points) such that any couple of matched points are at | | - | Bottleneck distance is the length of | distance at most b, where the distance between points is the sup | :Copyright: GPL v3 | - | the longest edge | norm in :math:`\mathbb{R}^2`. | | - | | | :Requires: CGAL :math:`\geq` 4.8.0 | - +-----------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------+ - | * :doc:`bottleneck_distance_user` | | - +-----------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ + +-----------------------------------------------------------------+----------------------------------------------------------------------+------------------------------------------------------------------+ + | .. figure:: | Bottleneck distance measures the similarity between two persistence | :Author: François Godi | + | ../../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 | :Introduced in: GUDHI 2.0.0 | + | | diagonal points) such that any couple of matched points are at | | + | Bottleneck distance is the length of | distance at most b, where the distance between points is the sup | :Copyright: MIT (`GPL v3 </licensing/>`_) | + | the longest edge | norm in :math:`\mathbb{R}^2`. | | + | | | :Requires: `CGAL <installation.html#cgal>`__ :math:`\geq` 4.11.0 | + +-----------------------------------------------------------------+----------------------------------------------------------------------+------------------------------------------------------------------+ + | * :doc:`bottleneck_distance_user` | | + +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index ce08f679..e4c718c3 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -62,7 +62,7 @@ import gudhi # General information about the project. project = gudhi.__name__ -copyright = gudhi.__copyright__ + ' - ' + gudhi.__license__ +copyright = gudhi.__copyright__ + ' - MIT' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/src/cython/doc/cubical_complex_sum.inc b/src/cython/doc/cubical_complex_sum.inc index 6dcf8e48..f200e695 100644 --- a/src/cython/doc/cubical_complex_sum.inc +++ b/src/cython/doc/cubical_complex_sum.inc @@ -6,7 +6,7 @@ | ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | | | :alt: Cubical complex representation | analysis. | :Introduced in: GUDHI 2.0.0 | | :figclass: align-center | | | - | | | :Copyright: GPL v3 | + | | | :Copyright: MIT | | | | | +--------------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------+ | * :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index 855dea44..02b889d0 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -151,29 +151,18 @@ The :doc:`Alpha complex </alpha_complex_user>`, C++ library which provides easy access to efficient and reliable geometric algorithms. -Having CGAL, the Computational Geometry Algorithms Library, version 4.7.0 or -higher installed is recommended. The procedure to install this library +The procedure to install this library according to your operating system is detailed `here <http://doc.cgal.org/latest/Manual/installation.html>`_. -The following examples requires CGAL version ≥ 4.7.0: +The following examples requires CGAL version ≥ 4.11.0: .. only:: builder_html * :download:`alpha_complex_diagram_persistence_from_off_file_example.py <../example/alpha_complex_diagram_persistence_from_off_file_example.py>` * :download:`alpha_complex_from_points_example.py <../example/alpha_complex_from_points_example.py>` - -The following examples requires CGAL version ≥ 4.8.0: - -.. only:: builder_html - * :download:`bottleneck_basic_example.py <../example/bottleneck_basic_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` - -The following examples requires CGAL version ≥ 4.8.1: - -.. only:: builder_html - * :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>` * :download:`euclidean_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py>` diff --git a/src/cython/doc/nerve_gic_complex_sum.inc b/src/cython/doc/nerve_gic_complex_sum.inc index 0e606fe1..d633c4ff 100644 --- a/src/cython/doc/nerve_gic_complex_sum.inc +++ b/src/cython/doc/nerve_gic_complex_sum.inc @@ -1,16 +1,16 @@ .. table:: :widths: 30 50 20 - +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ - | .. figure:: | Nerves and Graph Induced Complexes are cover complexes, i.e. | :Author: Mathieu Carrière | - | ../../doc/Nerve_GIC/gicvisu.jpg | simplicial complexes that provably contain topological information | | - | :alt: Graph Induced Complex of a point cloud. | about the input data. They can be computed with a cover of the data, | :Introduced in: GUDHI 2.3.0 | - | :figclass: align-center | that comes i.e. from the preimage of a family of intervals covering | | - | | the image of a scalar-valued function defined on the data. | :Copyright: GPL v3 | - | | | | - | | | :Requires: CGAL :math:`\geq` 4.8.1 | - | | | | - | | | | - +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ - | * :doc:`nerve_gic_complex_user` | * :doc:`nerve_gic_complex_ref` | - +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------------------------------------+ + | .. figure:: | Nerves and Graph Induced Complexes are cover complexes, i.e. | :Author: Mathieu Carrière | + | ../../doc/Nerve_GIC/gicvisu.jpg | simplicial complexes that provably contain topological information | | + | :alt: Graph Induced Complex of a point cloud. | about the input data. They can be computed with a cover of the data, | :Introduced in: GUDHI 2.3.0 | + | :figclass: align-center | that comes i.e. from the preimage of a family of intervals covering | | + | | the image of a scalar-valued function defined on the data. | :Copyright: MIT (`GPL v3 </licensing/>`_) | + | | | | + | | | :Requires: `CGAL <installation.html#cgal>`__ :math:`\geq` 4.11.0 | + | | | | + | | | | + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------------------------------------+ + | * :doc:`nerve_gic_complex_user` | * :doc:`nerve_gic_complex_ref` | + +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/persistence_graphical_tools_sum.inc b/src/cython/doc/persistence_graphical_tools_sum.inc index b412de56..0cdf8072 100644 --- a/src/cython/doc/persistence_graphical_tools_sum.inc +++ b/src/cython/doc/persistence_graphical_tools_sum.inc @@ -6,7 +6,7 @@ | img/graphical_tools_representation.png | the user to build easily persistence barcode, diagram or density. | | | | | :Introduced in: GUDHI 2.0.0 | | | | | - | | | :Copyright: GPL v3 | + | | | :Copyright: MIT | | | | | | | | :Requires: matplotlib, numpy and scipy | +-----------------------------------------------------------------+-----------------------------------------------------------------------+-----------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_sum.inc b/src/cython/doc/persistent_cohomology_sum.inc index 20ca073c..4d7b077e 100644 --- a/src/cython/doc/persistent_cohomology_sum.inc +++ b/src/cython/doc/persistent_cohomology_sum.inc @@ -6,7 +6,7 @@ | ../../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 | :Introduced in: GUDHI 2.0.0 | | | 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 | :Copyright: GPL v3 | + | Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | :Copyright: MIT | | Torus | theory is essentially composed of three elements: topological spaces, | | | | their homology groups and an evolution scheme. | | | | | | diff --git a/src/cython/doc/rips_complex_sum.inc b/src/cython/doc/rips_complex_sum.inc index e8e505e2..857c6893 100644 --- a/src/cython/doc/rips_complex_sum.inc +++ b/src/cython/doc/rips_complex_sum.inc @@ -6,7 +6,7 @@ | ../../doc/Rips_complex/rips_complex_representation.png | graph. | | | :figclass: align-center | | :Introduced in: GUDHI 2.0.0 | | | The filtration value of each edge is computed from a user-given | | - | | distance function and is inserted until a user-given threshold | :Copyright: GPL v3 | + | | distance function and is inserted until a user-given threshold | :Copyright: MIT | | | value. | | | | | | | | This complex can be built from a point cloud and a distance function, | | diff --git a/src/cython/doc/simplex_tree_sum.inc b/src/cython/doc/simplex_tree_sum.inc index 086c69d5..5ba58d2b 100644 --- a/src/cython/doc/simplex_tree_sum.inc +++ b/src/cython/doc/simplex_tree_sum.inc @@ -6,7 +6,7 @@ | ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | | | :alt: Simplex tree representation | | :Introduced in: GUDHI 2.0.0 | | :figclass: align-center | The data structure is described in | | - | | :cite:`boissonnatmariasimplextreealgorithmica` | :Copyright: GPL v3 | + | | :cite:`boissonnatmariasimplextreealgorithmica` | :Copyright: MIT | | | | | +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------+ | * :doc:`simplex_tree_user` | * :doc:`simplex_tree_ref` | diff --git a/src/cython/doc/tangential_complex_sum.inc b/src/cython/doc/tangential_complex_sum.inc index 0f03ffb3..c8bc1177 100644 --- a/src/cython/doc/tangential_complex_sum.inc +++ b/src/cython/doc/tangential_complex_sum.inc @@ -1,14 +1,14 @@ .. table:: :widths: 30 50 20 - +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ - | .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | :Author: Clément Jamin | - | ../../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 | :Introduced in: GUDHI 2.0.0 | - | | an unknown manifold. The running time depends only linearly on the | | - | | extrinsic dimension :math:`d` and exponentially on the intrinsic | :Copyright: GPL v3 | - | | dimension :math:`k`. | | - | | | :Requires: CGAL :math:`\geq` 4.8.0 | - +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ - | * :doc:`tangential_complex_user` | * :doc:`tangential_complex_ref` | - +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------------------------------------+ + | .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | :Author: Clément Jamin | + | ../../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 | :Introduced in: GUDHI 2.0.0 | + | | an unknown manifold. The running time depends only linearly on the | | + | | extrinsic dimension :math:`d` and exponentially on the intrinsic | :Copyright: MIT (`GPL v3 </licensing/>`_) | + | | dimension :math:`k`. | | + | | | :Requires: `CGAL <installation.html#cgal>`__ :math:`\geq` 4.11.0 | + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------------------------------------+ + | * :doc:`tangential_complex_user` | * :doc:`tangential_complex_ref` | + +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/witness_complex_sum.inc b/src/cython/doc/witness_complex_sum.inc index 49577745..2be8b220 100644 --- a/src/cython/doc/witness_complex_sum.inc +++ b/src/cython/doc/witness_complex_sum.inc @@ -1,17 +1,18 @@ .. table:: :widths: 30 50 20 - +-------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------------------------------+ - | .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | :Author: Siargey Kachanovich | - | ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | | - | :alt: Witness complex representation | | :Introduced in: GUDHI 2.0.0 | - | :figclass: align-center | The data structure is described in | | - | | :cite:`boissonnatmariasimplextreealgorithmica`. | :Copyright: GPL v3 | - | | | | - | | | :Requires: Eigen3 and CGAL :math:`\geq` 4.6.0 for Euclidean versions only | - +-------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------------------------------+ - | * :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | - | | * :doc:`strong_witness_complex_ref` | - | | * :doc:`euclidean_witness_complex_ref` | - | | * :doc:`euclidean_strong_witness_complex_ref` | - +-------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+ + +-------------------------------------------------------------------+----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ + | .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | :Author: Siargey Kachanovich | + | ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | | + | :alt: Witness complex representation | | :Introduced in: GUDHI 2.0.0 | + | :figclass: align-center | The data structure is described in | | + | | :cite:`boissonnatmariasimplextreealgorithmica`. | :Copyright: MIT (`GPL v3 </licensing/>`_ for Euclidean versions only) | + | | | | + | | | :Requires: `Eigen3 <installation.html#eigen3>`__ and `CGAL <installation.html#cgal>`__ :math:`\geq` 4.11.0 for Euclidean versions only | + +-------------------------------------------------------------------+----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ + | * :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/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py index 4abe22d4..b8f283b3 100755 --- a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py @@ -3,66 +3,62 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='AlphaComplex creation from ' - 'points read in a OFF file.', - epilog='Example: ' - 'example/alpha_complex_diagram_persistence_from_off_file_example.py ' - '-f ../data/points/tore3D_300.off -a 0.6' - '- Constructs a alpha complex with the ' - 'points from the given OFF file.') +parser = argparse.ArgumentParser( + description="AlphaComplex creation from " "points read in a OFF file.", + epilog="Example: " + "example/alpha_complex_diagram_persistence_from_off_file_example.py " + "-f ../data/points/tore3D_300.off -a 0.6" + "- Constructs a alpha complex with the " + "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", type=float, default=0.) -parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + if (first_line == "OFF\n") or (first_line == "nOFF\n"): print("#####################################################################") print("AlphaComplex creation from points read in a OFF file") - + message = "AlphaComplex with max_edge_length=" + repr(args.max_alpha_square) print(message) - + alpha_complex = gudhi.AlphaComplex(off_file=args.file) - simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square) - + simplex_tree = alpha_complex.create_simplex_tree( + max_alpha_square=args.max_alpha_square + ) + message = "Number of simplices=" + repr(simplex_tree.num_simplices()) print(message) - + diag = simplex_tree.persistence() - + print("betti_numbers()=") print(simplex_tree.betti_numbers()) - + if args.no_diagram == False: pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() diff --git a/src/cython/example/alpha_complex_from_points_example.py b/src/cython/example/alpha_complex_from_points_example.py index ad73c744..a746998c 100755 --- a/src/cython/example/alpha_complex_from_points_example.py +++ b/src/cython/example/alpha_complex_from_points_example.py @@ -2,31 +2,19 @@ from gudhi import AlphaComplex, SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("AlphaComplex creation from points") diff --git a/src/cython/example/alpha_rips_persistence_bottleneck_distance.py b/src/cython/example/alpha_rips_persistence_bottleneck_distance.py index b51fa7a8..086307ee 100755 --- a/src/cython/example/alpha_rips_persistence_bottleneck_distance.py +++ b/src/cython/example/alpha_rips_persistence_bottleneck_distance.py @@ -4,47 +4,37 @@ import gudhi import argparse import math -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" - -parser = argparse.ArgumentParser(description='AlphaComplex and RipsComplex ' - 'persistence creation from points read in ' - 'a OFF file. Bottleneck distance computation' - ' on each dimension', - epilog='Example: ' - 'example/alpha_rips_persistence_bottleneck_distance.py ' - '-f ../data/points/tore3D_1307.off -t 0.15 -d 3') +__license__ = "MIT" + +parser = argparse.ArgumentParser( + description="AlphaComplex and RipsComplex " + "persistence creation from points read in " + "a OFF file. Bottleneck distance computation" + " on each dimension", + epilog="Example: " + "example/alpha_rips_persistence_bottleneck_distance.py " + "-f ../data/points/tore3D_1307.off -t 0.15 -d 3", +) parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-t", "--threshold", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + 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") @@ -52,8 +42,9 @@ with open(args.file, 'r') as f: message = "RipsComplex with max_edge_length=" + repr(args.threshold) print(message) - rips_complex = gudhi.RipsComplex(points=point_cloud, - max_edge_length=args.threshold) + rips_complex = gudhi.RipsComplex( + points=point_cloud, max_edge_length=args.threshold + ) rips_stree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) @@ -69,7 +60,9 @@ with open(args.file, 'r') as f: print(message) alpha_complex = gudhi.AlphaComplex(points=point_cloud) - alpha_stree = alpha_complex.create_simplex_tree(max_alpha_square=(args.threshold * args.threshold)) + alpha_stree = alpha_complex.create_simplex_tree( + max_alpha_square=(args.threshold * args.threshold) + ) message = "Number of simplices=" + repr(alpha_stree.num_simplices()) print(message) @@ -83,15 +76,26 @@ with open(args.file, 'r') as f: funcs = [math.sqrt, math.sqrt] alpha_intervals = [] for interval in alpha_stree.persistence_intervals_in_dimension(dim): - alpha_intervals.append(map(lambda func,value: func(value), funcs, interval)) + alpha_intervals.append( + map(lambda func, value: func(value), funcs, interval) + ) rips_intervals = rips_stree.persistence_intervals_in_dimension(dim) - bottleneck_distance = gudhi.bottleneck_distance(rips_intervals, alpha_intervals) - message = "In dimension " + repr(dim) + ", bottleneck distance = " + repr(bottleneck_distance) + bottleneck_distance = gudhi.bottleneck_distance( + rips_intervals, alpha_intervals + ) + message = ( + "In dimension " + + repr(dim) + + ", bottleneck distance = " + + repr(bottleneck_distance) + ) print(message) max_b_distance = max(bottleneck_distance, max_b_distance) - print("================================================================================") + print( + "================================================================================" + ) message = "Bottleneck distance is " + repr(max_b_distance) print(message) diff --git a/src/cython/example/bottleneck_basic_example.py b/src/cython/example/bottleneck_basic_example.py index 287956e7..392d2a6e 100755 --- a/src/cython/example/bottleneck_basic_example.py +++ b/src/cython/example/bottleneck_basic_example.py @@ -2,35 +2,23 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Francois Godi, Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -diag1 = [[2.7, 3.7],[9.6, 14.],[34.2, 34.974], [3.,float('Inf')]] +diag1 = [[2.7, 3.7], [9.6, 14.0], [34.2, 34.974], [3.0, float("Inf")]] -diag2 = [[2.8, 4.45],[9.5, 14.1],[3.2,float('Inf')]] +diag2 = [[2.8, 4.45], [9.5, 14.1], [3.2, float("Inf")]] message = "diag1=" + repr(diag1) print(message) @@ -38,9 +26,12 @@ print(message) message = "diag2=" + repr(diag2) print(message) -message = "Bottleneck distance approximation=" + repr(gudhi.bottleneck_distance(diag1, diag2, 0.1)) +message = "Bottleneck distance approximation=" + repr( + gudhi.bottleneck_distance(diag1, diag2, 0.1) +) print(message) -message = "Bottleneck distance exact value=" + repr(gudhi.bottleneck_distance(diag1, diag2)) +message = "Bottleneck distance exact value=" + repr( + gudhi.bottleneck_distance(diag1, diag2) +) print(message) - diff --git a/src/cython/example/coordinate_graph_induced_complex.py b/src/cython/example/coordinate_graph_induced_complex.py index 9e93109a..e32141b4 100755 --- a/src/cython/example/coordinate_graph_induced_complex.py +++ b/src/cython/example/coordinate_graph_induced_complex.py @@ -3,50 +3,45 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='Coordinate GIC ' - 'from points read in a OFF file.', - epilog='Example: ' - 'example/coordinate_graph_induced_complex.py ' - '-f ../data/points/KleinBottle5D.off -c 0 -v' - '- Constructs the coordinate GIC with the ' - 'points from the given OFF file.') +parser = argparse.ArgumentParser( + description="Coordinate GIC " "from points read in a OFF file.", + epilog="Example: " + "example/coordinate_graph_induced_complex.py " + "-f ../data/points/KleinBottle5D.off -c 0 -v" + "- Constructs the coordinate GIC with the " + "points from the given OFF file.", +) parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-c", "--coordinate", type=int, default=0) -parser.add_argument("-v", "--verbose", default=False, action='store_true' , help='Flag for program verbosity') +parser.add_argument( + "-v", + "--verbose", + default=False, + action="store_true", + help="Flag for program verbosity", +) args = parser.parse_args() nerve_complex = gudhi.CoverComplex() nerve_complex.set_verbose(args.verbose) -if (nerve_complex.read_point_cloud(args.file)): - nerve_complex.set_type('GIC') +if nerve_complex.read_point_cloud(args.file): + nerve_complex.set_type("GIC") nerve_complex.set_color_from_coordinate(args.coordinate) nerve_complex.set_function_from_coordinate(args.coordinate) nerve_complex.set_graph_from_automatic_rips() @@ -57,12 +52,17 @@ if (nerve_complex.read_point_cloud(args.file)): nerve_complex.plot_dot() simplex_tree = nerve_complex.create_simplex_tree() nerve_complex.compute_PD() - if (args.verbose): - print('Iterator on coordinate GIC simplices') - result_str = 'Coordinate GIC is of dimension ' + \ - repr(simplex_tree.dimension()) + ' - ' + \ - repr(simplex_tree.num_simplices()) + ' simplices - ' + \ - repr(simplex_tree.num_vertices()) + ' vertices.' + if args.verbose: + print("Iterator on coordinate GIC simplices") + result_str = ( + "Coordinate GIC is of dimension " + + repr(simplex_tree.dimension()) + + " - " + + repr(simplex_tree.num_simplices()) + + " simplices - " + + repr(simplex_tree.num_vertices()) + + " vertices." + ) print(result_str) for filtered_value in simplex_tree.get_filtration(): print(filtered_value[0]) diff --git a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py index 3b29781f..610ba44f 100755 --- a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py @@ -3,64 +3,68 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" - -parser = argparse.ArgumentParser(description='EuclideanStrongWitnessComplex creation from ' - 'points read in a OFF file.', - epilog='Example: ' - 'example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py ' - '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' - '- Constructs a strong witness complex with the ' - 'points from the given OFF file.') +__license__ = "MIT" + +parser = argparse.ArgumentParser( + description="EuclideanStrongWitnessComplex creation from " + "points read in a OFF file.", + epilog="Example: " + "example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py " + "-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2" + "- Constructs a strong witness complex with the " + "points from the given OFF file.", +) 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", type=float, default=0.) -parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + if (first_line == "OFF\n") or (first_line == "nOFF\n"): print("#####################################################################") print("EuclideanStrongWitnessComplex creation from points read in a OFF file") witnesses = gudhi.read_off(off_file=args.file) - landmarks = gudhi.pick_n_random_points(points=witnesses, nb_points=args.number_of_landmarks) - - message = "EuclideanStrongWitnessComplex with max_edge_length=" + repr(args.max_alpha_square) + \ - " - Number of landmarks=" + repr(args.number_of_landmarks) + landmarks = gudhi.pick_n_random_points( + points=witnesses, nb_points=args.number_of_landmarks + ) + + message = ( + "EuclideanStrongWitnessComplex with max_edge_length=" + + repr(args.max_alpha_square) + + " - Number of landmarks=" + + repr(args.number_of_landmarks) + ) print(message) - witness_complex = gudhi.EuclideanStrongWitnessComplex(witnesses=witnesses, landmarks=landmarks) - simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square, - limit_dimension=args.limit_dimension) + witness_complex = gudhi.EuclideanStrongWitnessComplex( + witnesses=witnesses, landmarks=landmarks + ) + simplex_tree = witness_complex.create_simplex_tree( + max_alpha_square=args.max_alpha_square, limit_dimension=args.limit_dimension + ) message = "Number of simplices=" + repr(simplex_tree.num_simplices()) print(message) diff --git a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index db34962d..7587b732 100755 --- a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py @@ -3,64 +3,67 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" - -parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation from ' - 'points read in a OFF file.', - epilog='Example: ' - 'example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py ' - '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' - '- Constructs a weak witness complex with the ' - 'points from the given OFF file.') +__license__ = "MIT" + +parser = argparse.ArgumentParser( + description="EuclideanWitnessComplex creation from " "points read in a OFF file.", + epilog="Example: " + "example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py " + "-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2" + "- Constructs a weak witness complex with the " + "points from the given OFF file.", +) 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", type=float, default=0.) -parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + if (first_line == "OFF\n") or (first_line == "nOFF\n"): print("#####################################################################") print("EuclideanWitnessComplex creation from points read in a OFF file") witnesses = gudhi.read_off(off_file=args.file) - landmarks = gudhi.pick_n_random_points(points=witnesses, nb_points=args.number_of_landmarks) - - message = "EuclideanWitnessComplex with max_edge_length=" + repr(args.max_alpha_square) + \ - " - Number of landmarks=" + repr(args.number_of_landmarks) + landmarks = gudhi.pick_n_random_points( + points=witnesses, nb_points=args.number_of_landmarks + ) + + message = ( + "EuclideanWitnessComplex with max_edge_length=" + + repr(args.max_alpha_square) + + " - Number of landmarks=" + + repr(args.number_of_landmarks) + ) print(message) - witness_complex = gudhi.EuclideanWitnessComplex(witnesses=witnesses, landmarks=landmarks) - simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square, - limit_dimension=args.limit_dimension) + witness_complex = gudhi.EuclideanWitnessComplex( + witnesses=witnesses, landmarks=landmarks + ) + simplex_tree = witness_complex.create_simplex_tree( + max_alpha_square=args.max_alpha_square, limit_dimension=args.limit_dimension + ) message = "Number of simplices=" + repr(simplex_tree.num_simplices()) print(message) diff --git a/src/cython/example/functional_graph_induced_complex.py b/src/cython/example/functional_graph_induced_complex.py index 6ad7c2ec..8b645040 100755 --- a/src/cython/example/functional_graph_induced_complex.py +++ b/src/cython/example/functional_graph_induced_complex.py @@ -3,51 +3,46 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='Functional GIC ' - 'from points read in a OFF file.', - epilog='Example: ' - 'example/functional_graph_induced_complex.py ' - '-o ../data/points/COIL_database/lucky_cat.off ' - '-f ../data/points/COIL_database/lucky_cat_PCA1' - '- Constructs the functional GIC with the ' - 'points from the given OFF and function files.') +parser = argparse.ArgumentParser( + description="Functional GIC " "from points read in a OFF file.", + epilog="Example: " + "example/functional_graph_induced_complex.py " + "-o ../data/points/COIL_database/lucky_cat.off " + "-f ../data/points/COIL_database/lucky_cat_PCA1" + "- Constructs the functional GIC with the " + "points from the given OFF and function files.", +) parser.add_argument("-o", "--off-file", type=str, required=True) parser.add_argument("-f", "--function-file", type=str, required=True) -parser.add_argument("-v", "--verbose", default=False, action='store_true' , help='Flag for program verbosity') +parser.add_argument( + "-v", + "--verbose", + default=False, + action="store_true", + help="Flag for program verbosity", +) args = parser.parse_args() nerve_complex = gudhi.CoverComplex() nerve_complex.set_verbose(args.verbose) -if (nerve_complex.read_point_cloud(args.off_file)): - nerve_complex.set_type('GIC') +if nerve_complex.read_point_cloud(args.off_file): + nerve_complex.set_type("GIC") nerve_complex.set_color_from_file(args.function_file) nerve_complex.set_function_from_file(args.function_file) nerve_complex.set_graph_from_automatic_rips() @@ -58,12 +53,17 @@ if (nerve_complex.read_point_cloud(args.off_file)): nerve_complex.plot_dot() simplex_tree = nerve_complex.create_simplex_tree() nerve_complex.compute_PD() - if (args.verbose): - print('Iterator on functional GIC simplices') - result_str = 'Functional GIC is of dimension ' + \ - repr(simplex_tree.dimension()) + ' - ' + \ - repr(simplex_tree.num_simplices()) + ' simplices - ' + \ - repr(simplex_tree.num_vertices()) + ' vertices.' + if args.verbose: + print("Iterator on functional GIC simplices") + result_str = ( + "Functional GIC is of dimension " + + repr(simplex_tree.dimension()) + + " - " + + repr(simplex_tree.num_simplices()) + + " simplices - " + + repr(simplex_tree.num_vertices()) + + " vertices." + ) print(result_str) for filtered_value in simplex_tree.get_filtration(): print(filtered_value[0]) diff --git a/src/cython/example/gudhi_graphical_tools_example.py b/src/cython/example/gudhi_graphical_tools_example.py index ac3d146c..3b0ca54d 100755 --- a/src/cython/example/gudhi_graphical_tools_example.py +++ b/src/cython/example/gudhi_graphical_tools_example.py @@ -2,38 +2,32 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("Show barcode persistence example") -persistence = [(2, (1.0, float('inf'))), (1, (1.4142135623730951, float('inf'))), - (1, (1.4142135623730951, float('inf'))), (0, (0.0, float('inf'))), - (0, (0.0, 1.0)), (0, (0.0, 1.0)), (0, (0.0, 1.0))] +persistence = [ + (2, (1.0, float("inf"))), + (1, (1.4142135623730951, float("inf"))), + (1, (1.4142135623730951, float("inf"))), + (0, (0.0, float("inf"))), + (0, (0.0, 1.0)), + (0, (0.0, 1.0)), + (0, (0.0, 1.0)), +] gudhi.plot_persistence_barcode(persistence) print("#####################################################################") diff --git a/src/cython/example/nerve_of_a_covering.py b/src/cython/example/nerve_of_a_covering.py index c5577cb1..3c8e0f90 100755 --- a/src/cython/example/nerve_of_a_covering.py +++ b/src/cython/example/nerve_of_a_covering.py @@ -3,52 +3,47 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='Nerve of a covering creation ' - 'from points read in a OFF file.', - epilog='Example: ' - 'example/nerve_of_a_covering.py ' - '-f ../data/points/human.off -c 2 -r 10 -g 0.3' - '- Constructs Nerve of a covering with the ' - 'points from the given OFF file.') +parser = argparse.ArgumentParser( + description="Nerve of a covering creation " "from points read in a OFF file.", + epilog="Example: " + "example/nerve_of_a_covering.py " + "-f ../data/points/human.off -c 2 -r 10 -g 0.3" + "- Constructs Nerve of a covering with the " + "points from the given OFF file.", +) parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-c", "--coordinate", type=int, default=0) parser.add_argument("-r", "--resolution", type=int, default=10) parser.add_argument("-g", "--gain", type=float, default=0.3) -parser.add_argument("-v", "--verbose", default=False, action='store_true' , help='Flag for program verbosity') +parser.add_argument( + "-v", + "--verbose", + default=False, + action="store_true", + help="Flag for program verbosity", +) args = parser.parse_args() nerve_complex = gudhi.CoverComplex() nerve_complex.set_verbose(args.verbose) -if (nerve_complex.read_point_cloud(args.file)): - nerve_complex.set_type('Nerve') +if nerve_complex.read_point_cloud(args.file): + nerve_complex.set_type("Nerve") nerve_complex.set_color_from_coordinate(args.coordinate) nerve_complex.set_function_from_coordinate(args.coordinate) nerve_complex.set_graph_from_OFF() @@ -59,12 +54,17 @@ if (nerve_complex.read_point_cloud(args.file)): nerve_complex.write_info() simplex_tree = nerve_complex.create_simplex_tree() nerve_complex.compute_PD() - if (args.verbose): - print('Iterator on graph induced complex simplices') - result_str = 'Nerve is of dimension ' + \ - repr(simplex_tree.dimension()) + ' - ' + \ - repr(simplex_tree.num_simplices()) + ' simplices - ' + \ - repr(simplex_tree.num_vertices()) + ' vertices.' + if args.verbose: + print("Iterator on graph induced complex simplices") + result_str = ( + "Nerve is of dimension " + + repr(simplex_tree.dimension()) + + " - " + + repr(simplex_tree.num_simplices()) + + " simplices - " + + repr(simplex_tree.num_vertices()) + + " vertices." + ) print(result_str) for filtered_value in simplex_tree.get_filtration(): print(filtered_value[0]) diff --git a/src/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py b/src/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py index 5f968bf1..9cb855cd 100755 --- a/src/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py +++ b/src/cython/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py @@ -3,34 +3,23 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" + def is_file_perseus(file): - num_lines = open(file).read().count('\n') + num_lines = open(file).read().count("\n") try: f = open(file) num_dim = int(f.readline()) @@ -48,14 +37,21 @@ def is_file_perseus(file): except ValueError: return False -parser = argparse.ArgumentParser(description='Periodic cubical complex from a ' - 'Perseus-style file name.', - epilog='Example: ' - './periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py' - ' -f ../data/bitmap/CubicalTwoSphere.txt') + +parser = argparse.ArgumentParser( + description="Periodic cubical complex from a " "Perseus-style file name.", + epilog="Example: " + "./periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" + " -f ../data/bitmap/CubicalTwoSphere.txt", +) parser.add_argument("-f", "--file", type=str, required=True) -parser.add_argument('--no-barcode', default=False, action='store_true' , help='Flag for not to display the barcodes') +parser.add_argument( + "--no-barcode", + default=False, + action="store_true", + help="Flag for not to display the barcodes", +) args = parser.parse_args() @@ -65,7 +61,9 @@ if is_file_perseus(args.file): periodic_cubical_complex = gudhi.PeriodicCubicalComplex(perseus_file=args.file) print("persistence(homology_coeff_field=3, min_persistence=0)=") - diag = periodic_cubical_complex.persistence(homology_coeff_field=3, min_persistence=0) + diag = periodic_cubical_complex.persistence( + homology_coeff_field=3, min_persistence=0 + ) print(diag) print("betti_numbers()=") diff --git a/src/cython/example/random_cubical_complex_persistence_example.py b/src/cython/example/random_cubical_complex_persistence_example.py index 80ff2452..da0eb177 100755 --- a/src/cython/example/random_cubical_complex_persistence_example.py +++ b/src/cython/example/random_cubical_complex_persistence_example.py @@ -7,49 +7,40 @@ import argparse import operator -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" - -parser = argparse.ArgumentParser(description='Random cubical complex.', - epilog='Example: ' - './random_cubical_complex_persistence_example.py' - ' 10 10 10 - Constructs a random cubical ' - 'complex in a dimension [10, 10, 10] (aka. ' - '1000 random top dimensional cells).') -parser.add_argument('dimension', type=int, nargs="*", - help='Cubical complex dimensions') +__license__ = "MIT" + +parser = argparse.ArgumentParser( + description="Random cubical complex.", + epilog="Example: " + "./random_cubical_complex_persistence_example.py" + " 10 10 10 - Constructs a random cubical " + "complex in a dimension [10, 10, 10] (aka. " + "1000 random top dimensional cells).", +) +parser.add_argument("dimension", type=int, nargs="*", help="Cubical complex dimensions") args = parser.parse_args() dimension_multiplication = reduce(operator.mul, args.dimension, 1) -if dimension_multiplication > 1: +if dimension_multiplication > 1: print("#####################################################################") print("CubicalComplex creation") - cubical_complex = gudhi.CubicalComplex(dimensions=args.dimension, - top_dimensional_cells = numpy.random.rand(dimension_multiplication)) + cubical_complex = gudhi.CubicalComplex( + dimensions=args.dimension, + top_dimensional_cells=numpy.random.rand(dimension_multiplication), + ) print("persistence(homology_coeff_field=2, min_persistence=0)=") print(cubical_complex.persistence(homology_coeff_field=2, min_persistence=0)) diff --git a/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py index 0c9dfc43..3571580b 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py @@ -4,48 +4,42 @@ 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __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.') +__license__ = "MIT" + +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') +parser.add_argument("-b", "--band", type=float, default=0.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.): +if not (-1.0 < args.min_edge_correlation < 1.0): print("Wrong value of the treshold corelation (should be between -1 and 1).") sys.exit(1) @@ -60,12 +54,18 @@ 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) +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) +distance_matrix = [ + [1.0 - 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.0 - 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()) @@ -77,7 +77,10 @@ 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))] +invert_diag = [ + (diag[pers][0], (1.0 - diag[pers][1][0], 1.0 - 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) diff --git a/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py index 4d2ed577..0b9a9ba9 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py @@ -3,44 +3,38 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" - -parser = argparse.ArgumentParser(description='RipsComplex creation from ' - '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 ' - 'distance matrix from the given csv file.') +__license__ = "MIT" + +parser = argparse.ArgumentParser( + description="RipsComplex creation from " "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 " + "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", type=float, default=0.) -parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() @@ -51,7 +45,9 @@ message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) 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) +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()) diff --git a/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py index d15d5eb0..2b335bba 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py @@ -3,68 +3,66 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='RipsComplex creation from ' - 'points read in a OFF file.', - epilog='Example: ' - 'example/rips_complex_diagram_persistence_from_off_file_example.py ' - '-f ../data/points/tore3D_300.off -a 0.6' - '- Constructs a Rips complex with the ' - 'points from the given OFF file.') +parser = argparse.ArgumentParser( + description="RipsComplex creation from " "points read in a OFF file.", + epilog="Example: " + "example/rips_complex_diagram_persistence_from_off_file_example.py " + "-f ../data/points/tore3D_300.off -a 0.6" + "- Constructs a Rips complex with the " + "points from the given OFF 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", type=float, default=0.) -parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + if (first_line == "OFF\n") or (first_line == "nOFF\n"): print("#####################################################################") print("RipsComplex creation from points read in a OFF file") - + message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) - + 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) - + 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()) print(message) - + diag = simplex_tree.persistence() - + print("betti_numbers()=") print(simplex_tree.betti_numbers()) - + if args.no_diagram == False: pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() diff --git a/src/cython/example/rips_complex_from_points_example.py b/src/cython/example/rips_complex_from_points_example.py index ffa9d91f..59d8a261 100755 --- a/src/cython/example/rips_complex_from_points_example.py +++ b/src/cython/example/rips_complex_from_points_example.py @@ -2,36 +2,23 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("RipsComplex creation from points") -rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], - max_edge_length=42) +rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], max_edge_length=42) simplex_tree = rips.create_simplex_tree(max_dimension=1) diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index 7a6a9f46..f5897d7b 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -2,36 +2,23 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Marc Glisse" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("RipsComplex creation from points") -rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], - max_edge_length=42) +rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], max_edge_length=42) simplex_tree = rips.create_simplex_tree(max_dimension=1) diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py index 28679015..30de00da 100755 --- a/src/cython/example/simplex_tree_example.py +++ b/src/cython/example/simplex_tree_example.py @@ -2,31 +2,19 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("SimplexTree creation from insertion") diff --git a/src/cython/example/sparse_rips_persistence_diagram.py b/src/cython/example/sparse_rips_persistence_diagram.py index d58c244c..671d5e34 100755 --- a/src/cython/example/sparse_rips_persistence_diagram.py +++ b/src/cython/example/sparse_rips_persistence_diagram.py @@ -2,36 +2,25 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Marc Glisse + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Marc Glisse" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("Sparse RipsComplex creation from points") -rips = gudhi.RipsComplex(points=[[0, 0], [0, 0.1], [1, 0], [0, 1], [1, 1]], - max_edge_length=42, sparse=.5) +rips = gudhi.RipsComplex( + points=[[0, 0], [0, 0.1], [1, 0], [0, 1], [1, 1]], max_edge_length=42, sparse=0.5 +) simplex_tree = rips.create_simplex_tree(max_dimension=2) diff --git a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py index 536517d1..456bc9eb 100755 --- a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py +++ b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py @@ -3,64 +3,58 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -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 -i 3' - '- Constructs a tangential complex with the ' - 'points from the given OFF file') +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 -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("-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') +parser.add_argument("-b", "--band", type=float, default=0.0) +parser.add_argument( + "--no-diagram", + default=False, + action="store_true", + help="Flag for not to display the diagrams", +) args = parser.parse_args() -with open(args.file, 'r') as f: +with open(args.file, "r") as f: first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + if (first_line == "OFF\n") or (first_line == "nOFF\n"): print("#####################################################################") print("TangentialComplex creation from points read in a OFF file") - - tc = gudhi.TangentialComplex(intrisic_dim = args.intrisic_dim, off_file=args.file) + + tc = gudhi.TangentialComplex(intrisic_dim=args.intrisic_dim, off_file=args.file) tc.compute_tangential_complex() st = tc.create_simplex_tree() - + message = "Number of simplices=" + repr(st.num_simplices()) print(message) - - diag = st.persistence(persistence_dim_max = True) - + + diag = st.persistence(persistence_dim_max=True) + print("betti_numbers()=") print(st.betti_numbers()) - + if args.no_diagram == False: pplot = gudhi.plot_persistence_diagram(diag, band=args.band) pplot.show() diff --git a/src/cython/example/voronoi_graph_induced_complex.py b/src/cython/example/voronoi_graph_induced_complex.py index 8266a0e4..38be6c92 100755 --- a/src/cython/example/voronoi_graph_induced_complex.py +++ b/src/cython/example/voronoi_graph_induced_complex.py @@ -3,50 +3,45 @@ import gudhi 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. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" -parser = argparse.ArgumentParser(description='Voronoi GIC ' - 'from points read in a OFF file.', - epilog='Example: ' - 'example/voronoi_graph_induced_complex.py ' - '-f ../data/points/human.off -n 700 -v' - '- Constructs the Voronoi GIC with the ' - 'points from the given OFF file.') +parser = argparse.ArgumentParser( + description="Voronoi GIC " "from points read in a OFF file.", + epilog="Example: " + "example/voronoi_graph_induced_complex.py " + "-f ../data/points/human.off -n 700 -v" + "- Constructs the Voronoi GIC with the " + "points from the given OFF file.", +) parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-n", "--subsample-nb-points", type=int, default=100) -parser.add_argument("-v", "--verbose", default=False, action='store_true' , help='Flag for program verbosity') +parser.add_argument( + "-v", + "--verbose", + default=False, + action="store_true", + help="Flag for program verbosity", +) args = parser.parse_args() nerve_complex = gudhi.CoverComplex() nerve_complex.set_verbose(args.verbose) -if (nerve_complex.read_point_cloud(args.file)): - nerve_complex.set_type('GIC') +if nerve_complex.read_point_cloud(args.file): + nerve_complex.set_type("GIC") nerve_complex.set_color_from_coordinate() nerve_complex.set_graph_from_OFF() nerve_complex.set_cover_from_Voronoi(args.subsample_nb_points) @@ -54,12 +49,17 @@ if (nerve_complex.read_point_cloud(args.file)): nerve_complex.plot_off() simplex_tree = nerve_complex.create_simplex_tree() nerve_complex.compute_PD() - if (args.verbose): - print('Iterator on graph induced complex simplices') - result_str = 'Graph induced complex is of dimension ' + \ - repr(simplex_tree.dimension()) + ' - ' + \ - repr(simplex_tree.num_simplices()) + ' simplices - ' + \ - repr(simplex_tree.num_vertices()) + ' vertices.' + if args.verbose: + print("Iterator on graph induced complex simplices") + result_str = ( + "Graph induced complex is of dimension " + + repr(simplex_tree.dimension()) + + " - " + + repr(simplex_tree.num_simplices()) + + " simplices - " + + repr(simplex_tree.num_vertices()) + + " vertices." + ) print(result_str) for filtered_value in simplex_tree.get_filtration(): print(filtered_value[0]) diff --git a/src/cython/example/witness_complex_from_nearest_landmark_table.py b/src/cython/example/witness_complex_from_nearest_landmark_table.py index 1b79d9b2..c04a82b2 100755 --- a/src/cython/example/witness_complex_from_nearest_landmark_table.py +++ b/src/cython/example/witness_complex_from_nearest_landmark_table.py @@ -2,39 +2,29 @@ from gudhi import StrongWitnessComplex, SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" print("#####################################################################") print("WitnessComplex creation from nearest landmark table") -nearest_landmark_table = [[[0, 0.0], [1, 0.1], [2, 0.2], [3, 0.3], [4, 0.4]], - [[1, 0.0], [2, 0.1], [3, 0.2], [4, 0.3], [0, 0.4]], - [[2, 0.0], [3, 0.1], [4, 0.2], [0, 0.3], [1, 0.4]], - [[3, 0.0], [4, 0.1], [0, 0.2], [1, 0.3], [2, 0.4]], - [[4, 0.0], [0, 0.1], [1, 0.2], [2, 0.3], [3, 0.4]]] +nearest_landmark_table = [ + [[0, 0.0], [1, 0.1], [2, 0.2], [3, 0.3], [4, 0.4]], + [[1, 0.0], [2, 0.1], [3, 0.2], [4, 0.3], [0, 0.4]], + [[2, 0.0], [3, 0.1], [4, 0.2], [0, 0.3], [1, 0.4]], + [[3, 0.0], [4, 0.1], [0, 0.2], [1, 0.3], [2, 0.4]], + [[4, 0.0], [0, 0.1], [1, 0.2], [2, 0.3], [3, 0.4]], +] witness_complex = StrongWitnessComplex(nearest_landmark_table=nearest_landmark_table) simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=0.41) diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 0d4b966b..1c380308 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -1,28 +1,16 @@ -"""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 +"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__copyright__ = "Copyright (C) 2016-2019 Inria" +__license__ = "https://gudhi.inria.fr/licensing/" __version__ = "@GUDHI_VERSION@" # This variable is used by doctest to find files __root_source_dir__ = "@CMAKE_SOURCE_DIR@" diff --git a/src/cython/include/Alpha_complex_interface.h b/src/cython/include/Alpha_complex_interface.h index faa059d1..1199b741 100644 --- a/src/cython/include/Alpha_complex_interface.h +++ b/src/cython/include/Alpha_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_ALPHA_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Bottleneck_distance_interface.h b/src/cython/include/Bottleneck_distance_interface.h index 5ad9d77d..22c9a97a 100644 --- a/src/cython/include/Bottleneck_distance_interface.h +++ b/src/cython/include/Bottleneck_distance_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_BOTTLENECK_DISTANCE_INTERFACE_H_ diff --git a/src/cython/include/Cubical_complex_interface.h b/src/cython/include/Cubical_complex_interface.h index 85b717b3..7d32914c 100644 --- a/src/cython/include/Cubical_complex_interface.h +++ b/src/cython/include/Cubical_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_CUBICAL_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Euclidean_strong_witness_complex_interface.h b/src/cython/include/Euclidean_strong_witness_complex_interface.h index d86355d6..90bd54ac 100644 --- a/src/cython/include/Euclidean_strong_witness_complex_interface.h +++ b/src/cython/include/Euclidean_strong_witness_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_EUCLIDEAN_STRONG_WITNESS_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Euclidean_witness_complex_interface.h b/src/cython/include/Euclidean_witness_complex_interface.h index dc303533..0c01a741 100644 --- a/src/cython/include/Euclidean_witness_complex_interface.h +++ b/src/cython/include/Euclidean_witness_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_EUCLIDEAN_WITNESS_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Nerve_gic_interface.h b/src/cython/include/Nerve_gic_interface.h index aa71e2a6..729b39fb 100644 --- a/src/cython/include/Nerve_gic_interface.h +++ b/src/cython/include/Nerve_gic_interface.h @@ -6,18 +6,8 @@ * * Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_NERVE_GIC_INTERFACE_H_ diff --git a/src/cython/include/Off_reader_interface.h b/src/cython/include/Off_reader_interface.h index f6b14f38..4b3643be 100644 --- a/src/cython/include/Off_reader_interface.h +++ b/src/cython/include/Off_reader_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_OFF_READER_INTERFACE_H_ diff --git a/src/cython/include/Persistent_cohomology_interface.h b/src/cython/include/Persistent_cohomology_interface.h index 8cf71a4e..64e2ddc8 100644 --- a/src/cython/include/Persistent_cohomology_interface.h +++ b/src/cython/include/Persistent_cohomology_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_PERSISTENT_COHOMOLOGY_INTERFACE_H_ diff --git a/src/cython/include/Reader_utils_interface.h b/src/cython/include/Reader_utils_interface.h index 5f7527d9..5bddf9ce 100644 --- a/src/cython/include/Reader_utils_interface.h +++ b/src/cython/include/Reader_utils_interface.h @@ -6,18 +6,8 @@ * * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_READER_UTILS_INTERFACE_H_ diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h index 40aff299..f818a2ed 100644 --- a/src/cython/include/Rips_complex_interface.h +++ b/src/cython/include/Rips_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_RIPS_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index ca98517d..c15a44a5 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_SIMPLEX_TREE_INTERFACE_H_ diff --git a/src/cython/include/Strong_witness_complex_interface.h b/src/cython/include/Strong_witness_complex_interface.h index 3c72c916..4c333da8 100644 --- a/src/cython/include/Strong_witness_complex_interface.h +++ b/src/cython/include/Strong_witness_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_STRONG_WITNESS_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Subsampling_interface.h b/src/cython/include/Subsampling_interface.h index f990da0c..bc390485 100644 --- a/src/cython/include/Subsampling_interface.h +++ b/src/cython/include/Subsampling_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_SUBSAMPLING_INTERFACE_H_ diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index c4ddbdbe..7c3f2789 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_TANGENTIAL_COMPLEX_INTERFACE_H_ diff --git a/src/cython/include/Witness_complex_interface.h b/src/cython/include/Witness_complex_interface.h index 01b372e7..609277d6 100644 --- a/src/cython/include/Witness_complex_interface.h +++ b/src/cython/include/Witness_complex_interface.h @@ -6,18 +6,8 @@ * * 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 - * 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 <http://www.gnu.org/licenses/>. + * Modification(s): + * - YYYY/MM Author: Description of the modification */ #ifndef INCLUDE_WITNESS_COMPLEX_INTERFACE_H_ diff --git a/src/cython/setup.py.in b/src/cython/setup.py.in index c66905ac..70c85852 100644 --- a/src/cython/setup.py.in +++ b/src/cython/setup.py.in @@ -2,26 +2,14 @@ from distutils.core import setup, Extension from Cython.Build import cythonize from numpy import get_include as numpy_get_include -"""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 +"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "GUDHI Editorial Board" diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py index e97f2530..24f8bf53 100755 --- a/src/cython/test/test_alpha_complex.py +++ b/src/cython/test/test_alpha_complex.py @@ -1,36 +1,25 @@ from gudhi import AlphaComplex, SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_alpha(): - alpha_complex = AlphaComplex(points=[[0,0]]) + alpha_complex = AlphaComplex(points=[[0, 0]]) assert alpha_complex.__is_defined() == True + def test_infinite_alpha(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] alpha_complex = AlphaComplex(points=point_list) @@ -41,18 +30,28 @@ def test_infinite_alpha(): assert simplex_tree.num_simplices() == 11 assert simplex_tree.num_vertices() == 4 - - assert simplex_tree.get_filtration() == \ - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), - ([0, 1], 0.25), ([0, 2], 0.25), ([1, 3], 0.25), - ([2, 3], 0.25), ([1, 2], 0.5), ([0, 1, 2], 0.5), - ([1, 2, 3], 0.5)] - assert simplex_tree.get_star([0]) == \ - [([0], 0.0), ([0, 1], 0.25), ([0, 1, 2], 0.5), - ([0, 2], 0.25)] - assert simplex_tree.get_cofaces([0], 1) == \ - [([0, 1], 0.25), ([0, 2], 0.25)] - + + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([3], 0.0), + ([0, 1], 0.25), + ([0, 2], 0.25), + ([1, 3], 0.25), + ([2, 3], 0.25), + ([1, 2], 0.5), + ([0, 1, 2], 0.5), + ([1, 2, 3], 0.5), + ] + assert simplex_tree.get_star([0]) == [ + ([0], 0.0), + ([0, 1], 0.25), + ([0, 1, 2], 0.5), + ([0, 2], 0.25), + ] + assert simplex_tree.get_cofaces([0], 1) == [([0, 1], 0.25), ([0, 2], 0.25)] + assert point_list[0] == alpha_complex.get_point(0) assert point_list[1] == alpha_complex.get_point(1) assert point_list[2] == alpha_complex.get_point(2) @@ -60,6 +59,7 @@ def test_infinite_alpha(): assert alpha_complex.get_point(4) == [] assert alpha_complex.get_point(125) == [] + def test_filtered_alpha(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] filtered_alpha = AlphaComplex(points=point_list) @@ -76,11 +76,15 @@ def test_filtered_alpha(): assert filtered_alpha.get_point(4) == [] assert filtered_alpha.get_point(125) == [] - assert simplex_tree.get_filtration() == \ - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), - ([0, 1], 0.25), ([0, 2], 0.25), ([1, 3], 0.25), - ([2, 3], 0.25)] - assert simplex_tree.get_star([0]) == \ - [([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)] - assert simplex_tree.get_cofaces([0], 1) == \ - [([0, 1], 0.25), ([0, 2], 0.25)] + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([3], 0.0), + ([0, 1], 0.25), + ([0, 2], 0.25), + ([1, 3], 0.25), + ([2, 3], 0.25), + ] + assert simplex_tree.get_star([0]) == [([0], 0.0), ([0, 1], 0.25), ([0, 2], 0.25)] + assert simplex_tree.get_cofaces([0], 1) == [([0, 1], 0.25), ([0, 2], 0.25)] diff --git a/src/cython/test/test_bottleneck_distance.py b/src/cython/test/test_bottleneck_distance.py index 4eb5848f..f5f019b9 100755 --- a/src/cython/test/test_bottleneck_distance.py +++ b/src/cython/test/test_bottleneck_distance.py @@ -1,35 +1,23 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_basic_bottleneck(): - 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')]] + diag1 = [[2.7, 3.7], [9.6, 14.0], [34.2, 34.974], [3.0, float("Inf")]] + diag2 = [[2.8, 4.45], [9.5, 14.1], [3.2, float("Inf")]] - assert(gudhi.bottleneck_distance(diag1, diag2, 0.1) == 0.8081763781405569) - assert(gudhi.bottleneck_distance(diag1, diag2) == 0.75) + assert gudhi.bottleneck_distance(diag1, diag2, 0.1) == 0.8081763781405569 + assert gudhi.bottleneck_distance(diag1, diag2) == 0.75 diff --git a/src/cython/test/test_cover_complex.py b/src/cython/test/test_cover_complex.py index 58935264..8cd12272 100755 --- a/src/cython/test/test_cover_complex.py +++ b/src/cython/test/test_cover_complex.py @@ -1,30 +1,18 @@ from gudhi import CoverComplex -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - Author(s): Vincent Rouvreau + Copyright (C) 2018 Inria - Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2018 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_constructor(): @@ -32,61 +20,66 @@ def test_empty_constructor(): cover = CoverComplex() assert cover.__is_defined() == True + def test_non_existing_file_read(): # Try to open a non existing file cover = CoverComplex() - assert (cover.read_point_cloud('pouetpouettralala.toubiloubabdou') == False) + assert cover.read_point_cloud("pouetpouettralala.toubiloubabdou") == False + def test_files_creation(): # Create test file - cloud_file = open('cloud', 'w') - cloud_file.write('nOFF\n3\n3 0 0\n0 0 0\n2 1 0\n4 0 0') + cloud_file = open("cloud", "w") + cloud_file.write("nOFF\n3\n3 0 0\n0 0 0\n2 1 0\n4 0 0") cloud_file.close() - cover_file = open('cover', 'w') - cover_file.write('1\n2\n3') + cover_file = open("cover", "w") + cover_file.write("1\n2\n3") cover_file.close() - graph_file = open('graph', 'w') - graph_file.write('0 1\n0 2\n1 2') + graph_file = open("graph", "w") + graph_file.write("0 1\n0 2\n1 2") graph_file.close() + def test_nerve(): nerve = CoverComplex() - nerve.set_type('Nerve') - assert (nerve.read_point_cloud('cloud') == True) + nerve.set_type("Nerve") + assert nerve.read_point_cloud("cloud") == True nerve.set_color_from_coordinate() - nerve.set_graph_from_file('graph') - nerve.set_cover_from_file('cover') + nerve.set_graph_from_file("graph") + nerve.set_cover_from_file("cover") nerve.find_simplices() stree = nerve.create_simplex_tree() - assert (stree.num_vertices() == 3) - assert ((stree.num_simplices() - stree.num_vertices()) == 0) - assert (stree.dimension() == 0) + assert stree.num_vertices() == 3 + assert (stree.num_simplices() - stree.num_vertices()) == 0 + assert stree.dimension() == 0 + def test_graph_induced_complex(): gic = CoverComplex() - gic.set_type('GIC') - assert (gic.read_point_cloud('cloud') == True) + gic.set_type("GIC") + assert gic.read_point_cloud("cloud") == True gic.set_color_from_coordinate() - gic.set_graph_from_file('graph') - gic.set_cover_from_file('cover') + gic.set_graph_from_file("graph") + gic.set_cover_from_file("cover") gic.find_simplices() stree = gic.create_simplex_tree() - assert (stree.num_vertices() == 3) - assert ((stree.num_simplices() - stree.num_vertices()) == 4) - assert (stree.dimension() == 2) + assert stree.num_vertices() == 3 + assert (stree.num_simplices() - stree.num_vertices()) == 4 + assert stree.dimension() == 2 + def test_voronoi_graph_induced_complex(): gic = CoverComplex() - gic.set_type('GIC') - assert (gic.read_point_cloud('cloud') == True) + gic.set_type("GIC") + assert gic.read_point_cloud("cloud") == True gic.set_color_from_coordinate() - gic.set_graph_from_file('graph') + gic.set_graph_from_file("graph") gic.set_cover_from_Voronoi(2) gic.find_simplices() stree = gic.create_simplex_tree() - assert (stree.num_vertices() == 2) - assert ((stree.num_simplices() - stree.num_vertices()) == 1) - assert (stree.dimension() == 1) + assert stree.num_vertices() == 2 + assert (stree.num_simplices() - stree.num_vertices()) == 1 + assert stree.dimension() == 1 diff --git a/src/cython/test/test_cubical_complex.py b/src/cython/test/test_cubical_complex.py index 92e591e9..68f54fbe 100755 --- a/src/cython/test/test_cubical_complex.py +++ b/src/cython/test/test_cubical_complex.py @@ -1,30 +1,18 @@ from gudhi import CubicalComplex -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_constructor(): @@ -33,65 +21,78 @@ def test_empty_constructor(): assert cub.__is_defined() == False assert cub.__is_persistence_defined() == False + def test_non_existing_perseus_file_constructor(): # Try to open a non existing file - cub = CubicalComplex(perseus_file='pouetpouettralala.toubiloubabdou') + cub = CubicalComplex(perseus_file="pouetpouettralala.toubiloubabdou") assert cub.__is_defined() == False assert cub.__is_persistence_defined() == False + def test_dimension_or_perseus_file_constructor(): # Create test file - test_file = open('CubicalOneSphere.txt', 'w') - test_file.write('2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n') + test_file = open("CubicalOneSphere.txt", "w") + test_file.write("2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n") test_file.close() # CubicalComplex can be constructed from dimensions and # top_dimensional_cells OR from a Perseus-style file name. - cub = CubicalComplex(dimensions=[3, 3], - top_dimensional_cells = [1,2,3,4,5,6,7,8,9], - perseus_file='CubicalOneSphere.txt') + cub = CubicalComplex( + dimensions=[3, 3], + top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9], + perseus_file="CubicalOneSphere.txt", + ) assert cub.__is_defined() == False assert cub.__is_persistence_defined() == False - cub = CubicalComplex(top_dimensional_cells = [1,2,3,4,5,6,7,8,9], - perseus_file='CubicalOneSphere.txt') + cub = CubicalComplex( + top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9], + perseus_file="CubicalOneSphere.txt", + ) assert cub.__is_defined() == False assert cub.__is_persistence_defined() == False - cub = CubicalComplex(dimensions=[3, 3], - perseus_file='CubicalOneSphere.txt') + cub = CubicalComplex(dimensions=[3, 3], perseus_file="CubicalOneSphere.txt") assert cub.__is_defined() == False assert cub.__is_persistence_defined() == False + def test_dimension_simple_constructor(): - cub = CubicalComplex(dimensions=[3, 3], - top_dimensional_cells = [1,2,3,4,5,6,7,8,9]) + cub = CubicalComplex( + dimensions=[3, 3], top_dimensional_cells=[1, 2, 3, 4, 5, 6, 7, 8, 9] + ) assert cub.__is_defined() == True assert cub.__is_persistence_defined() == False - assert cub.persistence() == [(0, (1.0, float('inf')))] + assert cub.persistence() == [(0, (1.0, float("inf")))] assert cub.__is_persistence_defined() == True 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.]) + cub = CubicalComplex( + dimensions=[3, 3], + top_dimensional_cells=[float("inf"), 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 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.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')))] + other_cub = CubicalComplex( + dimensions=[3, 3], + top_dimensional_cells=[1000.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 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') - test_file.write('2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n') + test_file = open("CubicalOneSphere.txt", "w") + test_file.write("2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n") test_file.close() - cub = CubicalComplex(perseus_file='CubicalOneSphere.txt') + cub = CubicalComplex(perseus_file="CubicalOneSphere.txt") assert cub.__is_defined() == True assert cub.__is_persistence_defined() == False - assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))] + assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float("inf")))] assert cub.__is_persistence_defined() == True assert cub.betti_numbers() == [1, 0, 0] assert cub.persistent_betti_numbers(0, 1000) == [1, 0, 0] diff --git a/src/cython/test/test_euclidean_witness_complex.py b/src/cython/test/test_euclidean_witness_complex.py index 2f77210a..f5eae5fa 100755 --- a/src/cython/test/test_euclidean_witness_complex.py +++ b/src/cython/test/test_euclidean_witness_complex.py @@ -1,61 +1,78 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_euclidean_witness_complex(): euclidean_witness = gudhi.EuclideanWitnessComplex() assert euclidean_witness.__is_defined() == False + def test_witness_complex(): - point_cloud = [[1.0, 1.0], [7.0, 0.0], [4.0, 6.0], [9.0, 6.0], - [0.0, 14.0], [2.0, 19.0], [9.0, 17.0]] + point_cloud = [ + [1.0, 1.0], + [7.0, 0.0], + [4.0, 6.0], + [9.0, 6.0], + [0.0, 14.0], + [2.0, 19.0], + [9.0, 17.0], + ] landmarks = [[1.0, 1.0], [7.0, 0.0], [4.0, 6.0]] - euclidean_witness_complex = gudhi.EuclideanWitnessComplex(landmarks=landmarks, witnesses = point_cloud) + euclidean_witness_complex = gudhi.EuclideanWitnessComplex( + landmarks=landmarks, witnesses=point_cloud + ) simplex_tree = euclidean_witness_complex.create_simplex_tree(max_alpha_square=4.1) assert landmarks[0] == euclidean_witness_complex.get_point(0) assert landmarks[1] == euclidean_witness_complex.get_point(1) assert landmarks[2] == euclidean_witness_complex.get_point(2) - assert simplex_tree.get_filtration() == [([0], 0.0), ([1], 0.0), - ([0, 1], 0.0), ([2], 0.0), ([0, 2], 0.0), ([1, 2], 0.0), - ([0, 1, 2], 0.0)] + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([0, 1], 0.0), + ([2], 0.0), + ([0, 2], 0.0), + ([1, 2], 0.0), + ([0, 1, 2], 0.0), + ] + def test_empty_euclidean_strong_witness_complex(): euclidean_strong_witness = gudhi.EuclideanStrongWitnessComplex() assert euclidean_strong_witness.__is_defined() == False + def test_strong_witness_complex(): - point_cloud = [[1.0, 1.0], [7.0, 0.0], [4.0, 6.0], [9.0, 6.0], - [0.0, 14.0], [2.0, 19.0], [9.0, 17.0]] + point_cloud = [ + [1.0, 1.0], + [7.0, 0.0], + [4.0, 6.0], + [9.0, 6.0], + [0.0, 14.0], + [2.0, 19.0], + [9.0, 17.0], + ] landmarks = [[1.0, 1.0], [7.0, 0.0], [4.0, 6.0]] - euclidean_strong_witness_complex = gudhi.EuclideanStrongWitnessComplex(landmarks=landmarks, witnesses = point_cloud) - simplex_tree = euclidean_strong_witness_complex.create_simplex_tree(max_alpha_square=14.9) + euclidean_strong_witness_complex = gudhi.EuclideanStrongWitnessComplex( + landmarks=landmarks, witnesses=point_cloud + ) + simplex_tree = euclidean_strong_witness_complex.create_simplex_tree( + max_alpha_square=14.9 + ) assert landmarks[0] == euclidean_strong_witness_complex.get_point(0) assert landmarks[1] == euclidean_strong_witness_complex.get_point(1) @@ -63,9 +80,16 @@ def test_strong_witness_complex(): assert simplex_tree.get_filtration() == [([0], 0.0), ([1], 0.0), ([2], 0.0)] - simplex_tree = euclidean_strong_witness_complex.create_simplex_tree(max_alpha_square=100.0) - - assert simplex_tree.get_filtration() == [([0], 0.0), ([1], 0.0), - ([2], 0.0), ([1, 2], 15.0), ([0, 2], 34.0), ([0, 1], 37.0), - ([0, 1, 2], 37.0)] - + simplex_tree = euclidean_strong_witness_complex.create_simplex_tree( + max_alpha_square=100.0 + ) + + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([1, 2], 15.0), + ([0, 2], 34.0), + ([0, 1], 37.0), + ([0, 1, 2], 37.0), + ] diff --git a/src/cython/test/test_reader_utils.py b/src/cython/test/test_reader_utils.py index 36e927b0..4c7b32c2 100755 --- a/src/cython/test/test_reader_utils.py +++ b/src/cython/test/test_reader_utils.py @@ -1,89 +1,126 @@ import gudhi import numpy as np -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2017 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_non_existing_csv_file(): # Try to open a non existing file - matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file='pouetpouettralala.toubiloubabdou') + matrix = gudhi.read_lower_triangular_matrix_from_csv_file( + csv_file="pouetpouettralala.toubiloubabdou" + ) assert matrix == [] + def test_full_square_distance_matrix_csv_file(): # Create test file - test_file = open('full_square_distance_matrix.csv', 'w') - test_file.write('0;1;2;3;\n1;0;4;5;\n2;4;0;6;\n3;5;6;0;') + test_file = open("full_square_distance_matrix.csv", "w") + test_file.write("0;1;2;3;\n1;0;4;5;\n2;4;0;6;\n3;5;6;0;") test_file.close() - matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file="full_square_distance_matrix.csv") + matrix = gudhi.read_lower_triangular_matrix_from_csv_file( + csv_file="full_square_distance_matrix.csv" + ) assert matrix == [[], [1.0], [2.0, 4.0], [3.0, 5.0, 6.0]] + def test_lower_triangular_distance_matrix_csv_file(): # Create test file - test_file = open('lower_triangular_distance_matrix.csv', 'w') - test_file.write('\n1,\n2,3,\n4,5,6,\n7,8,9,10,') + test_file = open("lower_triangular_distance_matrix.csv", "w") + test_file.write("\n1,\n2,3,\n4,5,6,\n7,8,9,10,") test_file.close() - matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file="lower_triangular_distance_matrix.csv", separator=",") + matrix = gudhi.read_lower_triangular_matrix_from_csv_file( + csv_file="lower_triangular_distance_matrix.csv", separator="," + ) assert matrix == [[], [1.0], [2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0, 10.0]] + def test_non_existing_persistence_file(): # Try to open a non existing file - persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='pouetpouettralala.toubiloubabdou') + persistence = gudhi.read_persistence_intervals_grouped_by_dimension( + persistence_file="pouetpouettralala.toubiloubabdou" + ) assert persistence == [] - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='pouetpouettralala.toubiloubabdou', only_this_dim=1) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="pouetpouettralala.toubiloubabdou", only_this_dim=1 + ) np.testing.assert_array_equal(persistence, []) + def test_read_persistence_intervals_without_dimension(): # Create test file - test_file = open('persistence_intervals_without_dimension.pers', 'w') - test_file.write('# Simple persistence diagram without dimension\n2.7 3.7\n9.6 14.\n34.2 34.974\n3. inf') + test_file = open("persistence_intervals_without_dimension.pers", "w") + test_file.write( + "# Simple persistence diagram without dimension\n2.7 3.7\n9.6 14.\n34.2 34.974\n3. inf" + ) test_file.close() - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers') - np.testing.assert_array_equal(persistence, [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))]) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=0) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_without_dimension.pers" + ) + np.testing.assert_array_equal( + persistence, [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float("Inf"))] + ) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_without_dimension.pers", only_this_dim=0 + ) np.testing.assert_array_equal(persistence, []) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=1) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_without_dimension.pers", only_this_dim=1 + ) np.testing.assert_array_equal(persistence, []) - persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_without_dimension.pers') - assert persistence == {-1: [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float('Inf'))]} + persistence = gudhi.read_persistence_intervals_grouped_by_dimension( + persistence_file="persistence_intervals_without_dimension.pers" + ) + assert persistence == { + -1: [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float("Inf"))] + } + def test_read_persistence_intervals_with_dimension(): # Create test file - test_file = open('persistence_intervals_with_dimension.pers', 'w') - test_file.write('# Simple persistence diagram with dimension\n0 2.7 3.7\n1 9.6 14.\n3 34.2 34.974\n1 3. inf') + test_file = open("persistence_intervals_with_dimension.pers", "w") + test_file.write( + "# Simple persistence diagram with dimension\n0 2.7 3.7\n1 9.6 14.\n3 34.2 34.974\n1 3. inf" + ) test_file.close() - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers') - np.testing.assert_array_equal(persistence, [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))]) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=0) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_with_dimension.pers" + ) + np.testing.assert_array_equal( + persistence, [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float("Inf"))] + ) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_with_dimension.pers", only_this_dim=0 + ) np.testing.assert_array_equal(persistence, [(2.7, 3.7)]) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=1) - np.testing.assert_array_equal(persistence, [(9.6, 14.), (3., float('Inf'))]) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=2) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_with_dimension.pers", only_this_dim=1 + ) + np.testing.assert_array_equal(persistence, [(9.6, 14.0), (3.0, float("Inf"))]) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_with_dimension.pers", only_this_dim=2 + ) np.testing.assert_array_equal(persistence, []) - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=3) + persistence = gudhi.read_persistence_intervals_in_dimension( + persistence_file="persistence_intervals_with_dimension.pers", only_this_dim=3 + ) np.testing.assert_array_equal(persistence, [(34.2, 34.974)]) - persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_with_dimension.pers') - assert persistence == {0: [(2.7, 3.7)], 1: [(9.6, 14.0), (3.0, float('Inf'))], 3: [(34.2, 34.974)]} + persistence = gudhi.read_persistence_intervals_grouped_by_dimension( + persistence_file="persistence_intervals_with_dimension.pers" + ) + assert persistence == { + 0: [(2.7, 3.7)], + 1: [(9.6, 14.0), (3.0, float("Inf"))], + 3: [(34.2, 34.974)], + } diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py index 05dfcaf7..d55ae22f 100755 --- a/src/cython/test/test_rips_complex.py +++ b/src/cython/test/test_rips_complex.py @@ -1,36 +1,25 @@ from gudhi import RipsComplex from math import sqrt -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_rips(): rips_complex = RipsComplex() + def test_rips_from_points(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] rips_complex = RipsComplex(points=point_list, max_edge_length=42) @@ -43,17 +32,30 @@ def test_rips_from_points(): assert simplex_tree.num_simplices() == 10 assert simplex_tree.num_vertices() == 4 - assert simplex_tree.get_filtration() == \ - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), - ([0, 1], 1.0), ([0, 2], 1.0), ([1, 3], 1.0), - ([2, 3], 1.0), ([1, 2], 1.4142135623730951), - ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_star([0]) == \ - [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_cofaces([0], 1) == \ - [([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)] + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([3], 0.0), + ([0, 1], 1.0), + ([0, 2], 1.0), + ([1, 3], 1.0), + ([2, 3], 1.0), + ([1, 2], 1.4142135623730951), + ([0, 3], 1.4142135623730951), + ] + assert simplex_tree.get_star([0]) == [ + ([0], 0.0), + ([0, 1], 1.0), + ([0, 2], 1.0), + ([0, 3], 1.4142135623730951), + ] + assert simplex_tree.get_cofaces([0], 1) == [ + ([0, 1], 1.0), + ([0, 2], 1.0), + ([0, 3], 1.4142135623730951), + ] + def test_filtered_rips_from_points(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] @@ -67,10 +69,10 @@ def test_filtered_rips_from_points(): assert simplex_tree.num_simplices() == 8 assert simplex_tree.num_vertices() == 4 + def test_sparse_filtered_rips_from_points(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] - filtered_rips = RipsComplex(points=point_list, max_edge_length=1.0, - sparse=.001) + filtered_rips = RipsComplex(points=point_list, max_edge_length=1.0, sparse=0.001) simplex_tree = filtered_rips.create_simplex_tree(max_dimension=1) @@ -80,13 +82,10 @@ def test_sparse_filtered_rips_from_points(): assert simplex_tree.num_simplices() == 8 assert simplex_tree.num_vertices() == 4 + def test_rips_from_distance_matrix(): - distance_matrix = [[0], - [1, 0], - [1, sqrt(2), 0], - [sqrt(2), 1, 1, 0]] - rips_complex = RipsComplex(distance_matrix=distance_matrix, - max_edge_length=42) + distance_matrix = [[0], [1, 0], [1, sqrt(2), 0], [sqrt(2), 1, 1, 0]] + rips_complex = RipsComplex(distance_matrix=distance_matrix, max_edge_length=42) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) @@ -96,25 +95,34 @@ def test_rips_from_distance_matrix(): assert simplex_tree.num_simplices() == 10 assert simplex_tree.num_vertices() == 4 - assert simplex_tree.get_filtration() == \ - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), - ([0, 1], 1.0), ([0, 2], 1.0), ([1, 3], 1.0), - ([2, 3], 1.0), ([1, 2], 1.4142135623730951), - ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_star([0]) == \ - [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)] - assert simplex_tree.get_cofaces([0], 1) == \ - [([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)] + assert simplex_tree.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([3], 0.0), + ([0, 1], 1.0), + ([0, 2], 1.0), + ([1, 3], 1.0), + ([2, 3], 1.0), + ([1, 2], 1.4142135623730951), + ([0, 3], 1.4142135623730951), + ] + assert simplex_tree.get_star([0]) == [ + ([0], 0.0), + ([0, 1], 1.0), + ([0, 2], 1.0), + ([0, 3], 1.4142135623730951), + ] + assert simplex_tree.get_cofaces([0], 1) == [ + ([0, 1], 1.0), + ([0, 2], 1.0), + ([0, 3], 1.4142135623730951), + ] + def test_filtered_rips_from_distance_matrix(): - distance_matrix = [[0], - [1, 0], - [1, sqrt(2), 0], - [sqrt(2), 1, 1, 0]] - filtered_rips = RipsComplex(distance_matrix=distance_matrix, - max_edge_length=1.0) + distance_matrix = [[0], [1, 0], [1, sqrt(2), 0], [sqrt(2), 1, 1, 0]] + filtered_rips = RipsComplex(distance_matrix=distance_matrix, max_edge_length=1.0) simplex_tree = filtered_rips.create_simplex_tree(max_dimension=1) diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index cb701c9a..8d8971c1 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -1,30 +1,18 @@ from gudhi import SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_insertion(): @@ -51,7 +39,7 @@ def test_insertion(): assert st.find([0]) == True assert st.find([1]) == True assert st.find([2]) == True - assert st.find([3]) == False + assert st.find([3]) == False assert st.find([0, 3]) == False assert st.find([1, 3]) == False assert st.find([2, 3]) == False @@ -67,21 +55,36 @@ def test_insertion(): assert st.filtration([1]) == 0.0 # skeleton test - assert st.get_skeleton(2) == \ - [([0, 1, 2], 4.0), ([0, 1], 0.0), ([0, 2], 4.0), - ([0], 0.0), ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] - assert st.get_skeleton(1) == \ - [([0, 1], 0.0), ([0, 2], 4.0), ([0], 0.0), - ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] - assert st.get_skeleton(0) == \ - [([0], 0.0), ([1], 0.0), ([2], 4.0)] + assert st.get_skeleton(2) == [ + ([0, 1, 2], 4.0), + ([0, 1], 0.0), + ([0, 2], 4.0), + ([0], 0.0), + ([1, 2], 4.0), + ([1], 0.0), + ([2], 4.0), + ] + assert st.get_skeleton(1) == [ + ([0, 1], 0.0), + ([0, 2], 4.0), + ([0], 0.0), + ([1, 2], 4.0), + ([1], 0.0), + ([2], 4.0), + ] + assert st.get_skeleton(0) == [([0], 0.0), ([1], 0.0), ([2], 4.0)] # remove_maximal_simplex test assert st.get_cofaces([0, 1, 2], 1) == [] st.remove_maximal_simplex([0, 1, 2]) - assert st.get_skeleton(2) == \ - [([0, 1], 0.0), ([0, 2], 4.0), ([0], 0.0), - ([1, 2], 4.0), ([1], 0.0), ([2], 4.0)] + assert st.get_skeleton(2) == [ + ([0, 1], 0.0), + ([0, 2], 4.0), + ([0], 0.0), + ([1, 2], 4.0), + ([1], 0.0), + ([2], 4.0), + ] assert st.find([0, 1, 2]) == False assert st.find([0, 1]) == True assert st.find([0, 2]) == True @@ -90,7 +93,10 @@ def test_insertion(): assert st.find([2]) == True st.initialize_filtration() - assert st.persistence(persistence_dim_max = True) == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] + assert st.persistence(persistence_dim_max=True) == [ + (1, (4.0, float("inf"))), + (0, (0.0, float("inf"))), + ] assert st.__is_persistence_defined() == True assert st.betti_numbers() == [1, 1] @@ -100,6 +106,7 @@ def test_insertion(): assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1] assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1] + def test_expansion(): st = SimplexTree() assert st.__is_defined() == True @@ -119,21 +126,56 @@ def test_expansion(): assert st.num_vertices() == 7 assert st.num_simplices() == 17 - assert st.get_filtration() == [([2], 0.1), ([3], 0.1), ([2, 3], 0.1), - ([0], 0.2), ([0, 2], 0.2), ([1], 0.3), ([0, 1], 0.3), ([1, 3], 0.4), - ([1, 2], 0.5), ([5], 0.6), ([6], 0.6), ([5, 6], 0.6), ([4], 0.7), - ([2, 4], 0.7), ([0, 3], 0.8), ([4, 6], 0.9), ([3, 6], 1.0)] + assert st.get_filtration() == [ + ([2], 0.1), + ([3], 0.1), + ([2, 3], 0.1), + ([0], 0.2), + ([0, 2], 0.2), + ([1], 0.3), + ([0, 1], 0.3), + ([1, 3], 0.4), + ([1, 2], 0.5), + ([5], 0.6), + ([6], 0.6), + ([5, 6], 0.6), + ([4], 0.7), + ([2, 4], 0.7), + ([0, 3], 0.8), + ([4, 6], 0.9), + ([3, 6], 1.0), + ] st.expansion(3) assert st.num_vertices() == 7 assert st.num_simplices() == 22 st.initialize_filtration() - assert st.get_filtration() == [([2], 0.1), ([3], 0.1), ([2, 3], 0.1), - ([0], 0.2), ([0, 2], 0.2), ([1], 0.3), ([0, 1], 0.3), ([1, 3], 0.4), - ([1, 2], 0.5), ([0, 1, 2], 0.5), ([1, 2, 3], 0.5), ([5], 0.6), ([6], 0.6), - ([5, 6], 0.6), ([4], 0.7), ([2, 4], 0.7), ([0, 3], 0.8), ([0, 1, 3], 0.8), - ([0, 2, 3], 0.8), ([0, 1, 2, 3], 0.8), ([4, 6], 0.9), ([3, 6], 1.0)] + assert st.get_filtration() == [ + ([2], 0.1), + ([3], 0.1), + ([2, 3], 0.1), + ([0], 0.2), + ([0, 2], 0.2), + ([1], 0.3), + ([0, 1], 0.3), + ([1, 3], 0.4), + ([1, 2], 0.5), + ([0, 1, 2], 0.5), + ([1, 2, 3], 0.5), + ([5], 0.6), + ([6], 0.6), + ([5, 6], 0.6), + ([4], 0.7), + ([2, 4], 0.7), + ([0, 3], 0.8), + ([0, 1, 3], 0.8), + ([0, 2, 3], 0.8), + ([0, 1, 2, 3], 0.8), + ([4, 6], 0.9), + ([3, 6], 1.0), + ] + def test_automatic_dimension(): st = SimplexTree() @@ -141,8 +183,8 @@ def test_automatic_dimension(): assert st.__is_persistence_defined() == False # insert test - assert st.insert([0,1,3], filtration=0.5) == True - assert st.insert([0,1,2], filtration=1.) == True + assert st.insert([0, 1, 3], filtration=0.5) == True + assert st.insert([0, 1, 2], filtration=1.0) == True assert st.num_vertices() == 4 assert st.num_simplices() == 11 @@ -162,6 +204,7 @@ def test_automatic_dimension(): assert st.dimension() == 1 assert st.upper_bound_dimension() == 1 + def test_make_filtration_non_decreasing(): st = SimplexTree() assert st.__is_defined() == True @@ -183,25 +226,25 @@ def test_make_filtration_non_decreasing(): # 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); + 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); + 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. + assert st.filtration([0, 1, 6, 7]) == 1.0 + assert st.filtration([0, 1, 6]) == 1.0 + assert st.filtration([0, 1]) == 1.0 + assert st.filtration([0]) == 1.0 + assert st.filtration([1]) == 1.0 + assert st.filtration([3, 4, 5]) == 2.0 + assert st.filtration([3, 4]) == 2.0 + assert st.filtration([4, 5]) == 2.0 diff --git a/src/cython/test/test_subsampling.py b/src/cython/test/test_subsampling.py index 96906a6f..c816e203 100755 --- a/src/cython/test/test_subsampling.py +++ b/src/cython/test/test_subsampling.py @@ -1,30 +1,18 @@ import gudhi -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_write_off_file_for_tests(): @@ -40,45 +28,72 @@ def test_write_off_file_for_tests(): file.write("9.0 17.0\n") file.close() + def test_simple_choose_n_farthest_points_with_a_starting_point(): - point_set = [[0,1], [0,0], [1,0], [1,1]] + point_set = [[0, 1], [0, 0], [1, 0], [1, 1]] i = 0 for point in point_set: # The iteration starts with the given starting point - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 1, starting_point = i) + sub_set = gudhi.choose_n_farthest_points( + points=point_set, nb_points=1, starting_point=i + ) assert sub_set[0] == point_set[i] i = i + 1 # The iteration finds then the farthest - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 1) + sub_set = gudhi.choose_n_farthest_points( + points=point_set, nb_points=2, starting_point=1 + ) assert sub_set[1] == point_set[3] - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 3) + sub_set = gudhi.choose_n_farthest_points( + points=point_set, nb_points=2, starting_point=3 + ) assert sub_set[1] == point_set[1] - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 0) + sub_set = gudhi.choose_n_farthest_points( + points=point_set, nb_points=2, starting_point=0 + ) assert sub_set[1] == point_set[2] - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = 2, starting_point = 2) + sub_set = gudhi.choose_n_farthest_points( + points=point_set, nb_points=2, starting_point=2 + ) assert sub_set[1] == point_set[0] # Test the limits - assert gudhi.choose_n_farthest_points(points = [], nb_points = 0, starting_point = 0) == [] - assert gudhi.choose_n_farthest_points(points = [], nb_points = 1, starting_point = 0) == [] - assert gudhi.choose_n_farthest_points(points = [], nb_points = 0, starting_point = 1) == [] - assert gudhi.choose_n_farthest_points(points = [], nb_points = 1, starting_point = 1) == [] + assert ( + gudhi.choose_n_farthest_points(points=[], nb_points=0, starting_point=0) == [] + ) + assert ( + gudhi.choose_n_farthest_points(points=[], nb_points=1, starting_point=0) == [] + ) + assert ( + gudhi.choose_n_farthest_points(points=[], nb_points=0, starting_point=1) == [] + ) + assert ( + gudhi.choose_n_farthest_points(points=[], nb_points=1, starting_point=1) == [] + ) # From off file test - for i in range (0, 7): - assert len(gudhi.choose_n_farthest_points(off_file = 'subsample.off', nb_points = i, starting_point = i)) == i + for i in range(0, 7): + assert ( + len( + gudhi.choose_n_farthest_points( + off_file="subsample.off", nb_points=i, starting_point=i + ) + ) + == i + ) + def test_simple_choose_n_farthest_points_randomed(): - point_set = [[0,1], [0,0], [1,0], [1,1]] + point_set = [[0, 1], [0, 0], [1, 0], [1, 1]] # Test the limits - assert gudhi.choose_n_farthest_points(points = [], nb_points = 0) == [] - assert gudhi.choose_n_farthest_points(points = [], nb_points = 1) == [] - assert gudhi.choose_n_farthest_points(points = point_set, nb_points = 0) == [] + assert gudhi.choose_n_farthest_points(points=[], nb_points=0) == [] + assert gudhi.choose_n_farthest_points(points=[], nb_points=1) == [] + assert gudhi.choose_n_farthest_points(points=point_set, nb_points=0) == [] # Go furter than point set on purpose - for iter in range(1,10): - sub_set = gudhi.choose_n_farthest_points(points = point_set, nb_points = iter) + for iter in range(1, 10): + sub_set = gudhi.choose_n_farthest_points(points=point_set, nb_points=iter) for sub in sub_set: found = False for point in point_set: @@ -88,19 +103,23 @@ def test_simple_choose_n_farthest_points_randomed(): assert found == True # From off file test - for i in range (0, 7): - assert len(gudhi.choose_n_farthest_points(off_file = 'subsample.off', nb_points = i)) == i + for i in range(0, 7): + assert ( + len(gudhi.choose_n_farthest_points(off_file="subsample.off", nb_points=i)) + == i + ) + def test_simple_pick_n_random_points(): - point_set = [[0,1], [0,0], [1,0], [1,1]] + point_set = [[0, 1], [0, 0], [1, 0], [1, 1]] # Test the limits - assert gudhi.pick_n_random_points(points = [], nb_points = 0) == [] - assert gudhi.pick_n_random_points(points = [], nb_points = 1) == [] - assert gudhi.pick_n_random_points(points = point_set, nb_points = 0) == [] + assert gudhi.pick_n_random_points(points=[], nb_points=0) == [] + assert gudhi.pick_n_random_points(points=[], nb_points=1) == [] + assert gudhi.pick_n_random_points(points=point_set, nb_points=0) == [] # Go furter than point set on purpose - for iter in range(1,10): - sub_set = gudhi.pick_n_random_points(points = point_set, nb_points = iter) + for iter in range(1, 10): + sub_set = gudhi.pick_n_random_points(points=point_set, nb_points=iter) print(5) for sub in sub_set: found = False @@ -111,23 +130,50 @@ def test_simple_pick_n_random_points(): assert found == True # From off file test - for i in range (0, 7): - assert len(gudhi.pick_n_random_points(off_file = 'subsample.off', nb_points = i)) == i + for i in range(0, 7): + assert ( + len(gudhi.pick_n_random_points(off_file="subsample.off", nb_points=i)) == i + ) + def test_simple_sparsify_points(): - point_set = [[0,1], [0,0], [1,0], [1,1]] + point_set = [[0, 1], [0, 0], [1, 0], [1, 1]] # Test the limits # assert gudhi.sparsify_point_set(points = [], min_squared_dist = 0.0) == [] # assert gudhi.sparsify_point_set(points = [], min_squared_dist = 10.0) == [] - assert gudhi.sparsify_point_set(points = point_set, min_squared_dist = 0.0) == point_set - assert gudhi.sparsify_point_set(points = point_set, min_squared_dist = 1.0) == point_set - assert gudhi.sparsify_point_set(points = point_set, min_squared_dist = 2.0) == [[0,1], [1,0]] - assert gudhi.sparsify_point_set(points = point_set, min_squared_dist = 2.01) == [[0,1]] - - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 0.0)) == 7 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 30.0)) == 5 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 40.0)) == 4 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 90.0)) == 3 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 100.0)) == 2 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 325.0)) == 2 - assert len(gudhi.sparsify_point_set(off_file = 'subsample.off', min_squared_dist = 325.01)) == 1 + assert gudhi.sparsify_point_set(points=point_set, min_squared_dist=0.0) == point_set + assert gudhi.sparsify_point_set(points=point_set, min_squared_dist=1.0) == point_set + assert gudhi.sparsify_point_set(points=point_set, min_squared_dist=2.0) == [ + [0, 1], + [1, 0], + ] + assert gudhi.sparsify_point_set(points=point_set, min_squared_dist=2.01) == [[0, 1]] + + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=0.0)) + == 7 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=30.0)) + == 5 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=40.0)) + == 4 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=90.0)) + == 3 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=100.0)) + == 2 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=325.0)) + == 2 + ) + assert ( + len(gudhi.sparsify_point_set(off_file="subsample.off", min_squared_dist=325.01)) + == 1 + ) diff --git a/src/cython/test/test_tangential_complex.py b/src/cython/test/test_tangential_complex.py index 5c62f278..0f828d8e 100755 --- a/src/cython/test/test_tangential_complex.py +++ b/src/cython/test/test_tangential_complex.py @@ -1,35 +1,23 @@ from gudhi import TangentialComplex, SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_tangential(): point_list = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]] - tc = TangentialComplex(intrisic_dim = 1, points=point_list) + tc = TangentialComplex(intrisic_dim=1, points=point_list) assert tc.__is_defined() == True assert tc.num_vertices() == 4 assert tc.num_simplices() == 0 @@ -48,11 +36,17 @@ def test_tangential(): assert st.num_simplices() == 6 assert st.num_vertices() == 4 - - assert st.get_filtration() == \ - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([0, 2], 0.0), ([3], 0.0), ([1, 3], 0.0)] + + assert st.get_filtration() == [ + ([0], 0.0), + ([1], 0.0), + ([2], 0.0), + ([0, 2], 0.0), + ([3], 0.0), + ([1, 3], 0.0), + ] assert st.get_cofaces([0], 1) == [([0, 2], 0.0)] - + assert point_list[0] == tc.get_point(0) assert point_list[1] == tc.get_point(1) assert point_list[2] == tc.get_point(2) diff --git a/src/cython/test/test_witness_complex.py b/src/cython/test/test_witness_complex.py index bcbc521b..36ced635 100755 --- a/src/cython/test/test_witness_complex.py +++ b/src/cython/test/test_witness_complex.py @@ -1,62 +1,62 @@ from gudhi import WitnessComplex, StrongWitnessComplex, SimplexTree -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau - 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 - 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 <http://www.gnu.org/licenses/>. + Modification(s): + - YYYY/MM Author: Description of the modification """ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 Inria" -__license__ = "GPL v3" +__license__ = "MIT" def test_empty_witness_complex(): witness = WitnessComplex() assert witness.__is_defined() == False + def test_witness_complex(): - nearest_landmark_table = [[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]], - [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], - [[2, 0], [3, 1], [4, 2], [0, 3], [1, 4]], - [[3, 0], [4, 1], [0, 2], [1, 3], [2, 4]], - [[4, 0], [0, 1], [1, 2], [2, 3], [3, 4]]] + nearest_landmark_table = [ + [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]], + [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], + [[2, 0], [3, 1], [4, 2], [0, 3], [1, 4]], + [[3, 0], [4, 1], [0, 2], [1, 3], [2, 4]], + [[4, 0], [0, 1], [1, 2], [2, 3], [3, 4]], + ] witness_complex = WitnessComplex(nearest_landmark_table=nearest_landmark_table) simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=4.1) assert simplex_tree.num_vertices() == 5 assert simplex_tree.num_simplices() == 31 - simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=4.1, limit_dimension=2) + simplex_tree = witness_complex.create_simplex_tree( + max_alpha_square=4.1, limit_dimension=2 + ) assert simplex_tree.num_vertices() == 5 assert simplex_tree.num_simplices() == 25 -def test_strong_witness_complex(): - nearest_landmark_table = [[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]], - [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], - [[2, 0], [3, 1], [4, 2], [0, 3], [1, 4]], - [[3, 0], [4, 1], [0, 2], [1, 3], [2, 4]], - [[4, 0], [0, 1], [1, 2], [2, 3], [3, 4]]] - strong_witness_complex = StrongWitnessComplex(nearest_landmark_table=nearest_landmark_table) +def test_strong_witness_complex(): + nearest_landmark_table = [ + [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]], + [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], + [[2, 0], [3, 1], [4, 2], [0, 3], [1, 4]], + [[3, 0], [4, 1], [0, 2], [1, 3], [2, 4]], + [[4, 0], [0, 1], [1, 2], [2, 3], [3, 4]], + ] + + strong_witness_complex = StrongWitnessComplex( + nearest_landmark_table=nearest_landmark_table + ) simplex_tree = strong_witness_complex.create_simplex_tree(max_alpha_square=4.1) assert simplex_tree.num_vertices() == 5 assert simplex_tree.num_simplices() == 31 - simplex_tree = strong_witness_complex.create_simplex_tree(max_alpha_square=4.1, limit_dimension=2) + simplex_tree = strong_witness_complex.create_simplex_tree( + max_alpha_square=4.1, limit_dimension=2 + ) assert simplex_tree.num_vertices() == 5 assert simplex_tree.num_simplices() == 25 |