From 47f150ba81e353cd1d4128fa63a0d74952b0eae5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 1 Jun 2016 11:00:44 +0000 Subject: Add interfaces with pandas, numpy and matplotlib new examples : rips_persistence_diagram.py, random_cubical_complex_example & alpha_complex_from_file_example new data files for alpha_complex_from_file_example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1235 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 901cc5eb791633f7bfcd86c0b7b8733cb6eb054c --- src/cython/example/rips_persistence_diagram.py | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 src/cython/example/rips_persistence_diagram.py (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py new file mode 100755 index 00000000..3e95f2cc --- /dev/null +++ b/src/cython/example/rips_persistence_diagram.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import gudhi +import matplotlib.pyplot as plt + +"""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): Marc Glisse + + Copyright (C) 2016 INRIA Saclay (France) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +__author__ = "Marc Glisse" +__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__license__ = "GPL v3" + +print("#####################################################################") +print("RipsComplex creation from points") +rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], + max_dimension=1, max_edge_length=42) + +diag = rips.persistence(homology_coeff_field=2, min_persistence=0) +print("diag=", diag) + +diag0=[i[1] for i in diag if i[0]==0] +diag1=[i[1] for i in diag if i[0]==1] + +plt.plot([i[0] for i in diag0],[min(i[1],1.5) for i in diag0],'ro', + [i[0] for i in diag1],[i[1] for i in diag1],'bs',[-.2,1.5],[-.2,1.5], + '-') +plt.axis([-.2,1.5,-.2,1.5]) +plt.show() -- cgit v1.2.3 From 4a089fe4840f09b4aabafa06ad53200baa6d6547 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 6 Jun 2016 14:54:17 +0000 Subject: bar code persistence tool Copyright modification git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1251 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ff7a8baeffbcafe6d074786b6a7956d815edd21b --- src/cython/Makefile | 1 - src/cython/example/alpha_complex_example.py | 4 +- .../example/alpha_complex_from_file_example.py | 4 +- .../example/gudhi_graphical_tools_example.py | 42 +++++++++++ src/cython/example/mini_simplex_tree_example.py | 4 +- .../example/random_cubical_complex_example.py | 4 +- src/cython/example/rips_complex_example.py | 4 +- src/cython/example/rips_persistence_diagram.py | 14 +--- src/cython/example/simplex_tree_example.py | 4 +- src/cython/gudhi.pyx | 1 + src/cython/src/cpp/Alpha_complex_interface.h | 2 +- src/cython/src/cpp/Cubical_complex_interface.h | 2 +- .../src/cpp/Persistent_cohomology_interface.h | 2 +- src/cython/src/cpp/Simplex_tree_interface.h | 2 +- src/cython/src/cython/alpha_complex.pyx | 4 +- src/cython/src/cython/cubical_complex.pyx | 4 +- src/cython/src/cython/mini_simplex_tree.pyx | 4 +- .../src/cython/persistence_graphical_tools.py | 82 ++++++++++++++++++++++ src/cython/src/cython/rips_complex.pyx | 4 +- src/cython/src/cython/simplex_tree.pyx | 4 +- src/cython/test/test_alpha_complex.py | 4 +- src/cython/test/test_mini_simplex_tree.py | 4 +- src/cython/test/test_rips_complex.py | 4 +- src/cython/test/test_simplex_tree.py | 4 +- 24 files changed, 162 insertions(+), 46 deletions(-) create mode 100755 src/cython/example/gudhi_graphical_tools_example.py create mode 100755 src/cython/src/cython/persistence_graphical_tools.py (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/Makefile b/src/cython/Makefile index 05b831f6..e6054122 100644 --- a/src/cython/Makefile +++ b/src/cython/Makefile @@ -13,7 +13,6 @@ example: python example/rips_complex_example.py python example/alpha_complex_example.py python example/random_cubical_complex_example.py 10 10 - python example/rips_persistence_diagram.py python example/alpha_complex_from_file_example.py data/500_random_points_on_3D_Torus.csv clean: diff --git a/src/cython/example/alpha_complex_example.py b/src/cython/example/alpha_complex_example.py index 37c04f23..cfeff5d8 100755 --- a/src/cython/example/alpha_complex_example.py +++ b/src/cython/example/alpha_complex_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") diff --git a/src/cython/example/alpha_complex_from_file_example.py b/src/cython/example/alpha_complex_from_file_example.py index 9ceb82b1..04b4b279 100755 --- a/src/cython/example/alpha_complex_from_file_example.py +++ b/src/cython/example/alpha_complex_from_file_example.py @@ -10,7 +10,7 @@ import argparse Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ import argparse """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") diff --git a/src/cython/example/gudhi_graphical_tools_example.py b/src/cython/example/gudhi_graphical_tools_example.py new file mode 100755 index 00000000..c43b2338 --- /dev/null +++ b/src/cython/example/gudhi_graphical_tools_example.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +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. + + 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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +print("#####################################################################") +print("Show palette colors values for dimension") + +gudhi.show_palette_values() + +print("#####################################################################") +print("Show bar code 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))] +gudhi.bar_code_persistence(persistence) diff --git a/src/cython/example/mini_simplex_tree_example.py b/src/cython/example/mini_simplex_tree_example.py index d7189ddf..7b65a9d6 100755 --- a/src/cython/example/mini_simplex_tree_example.py +++ b/src/cython/example/mini_simplex_tree_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") diff --git a/src/cython/example/random_cubical_complex_example.py b/src/cython/example/random_cubical_complex_example.py index b479e2e6..147eaa49 100755 --- a/src/cython/example/random_cubical_complex_example.py +++ b/src/cython/example/random_cubical_complex_example.py @@ -12,7 +12,7 @@ import operator Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + 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 @@ -29,7 +29,7 @@ import operator """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" parser = argparse.ArgumentParser(description='Random cubical complex.', diff --git a/src/cython/example/rips_complex_example.py b/src/cython/example/rips_complex_example.py index 449ea2b3..65246c9c 100755 --- a/src/cython/example/rips_complex_example.py +++ b/src/cython/example/rips_complex_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index 3e95f2cc..57f25b22 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import gudhi -import matplotlib.pyplot as plt """This file is part of the Gudhi Library. The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ @@ -9,7 +8,7 @@ import matplotlib.pyplot as plt Author(s): Marc Glisse - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +25,7 @@ import matplotlib.pyplot as plt """ __author__ = "Marc Glisse" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") @@ -37,11 +36,4 @@ rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], diag = rips.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) -diag0=[i[1] for i in diag if i[0]==0] -diag1=[i[1] for i in diag if i[0]==1] - -plt.plot([i[0] for i in diag0],[min(i[1],1.5) for i in diag0],'ro', - [i[0] for i in diag1],[i[1] for i in diag1],'bs',[-.2,1.5],[-.2,1.5], - '-') -plt.axis([-.2,1.5,-.2,1.5]) -plt.show() +gudhi.bar_code_persistence(diag) diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py index 45d57c53..cc33ed6e 100755 --- a/src/cython/example/simplex_tree_example.py +++ b/src/cython/example/simplex_tree_example.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" print("#####################################################################") diff --git a/src/cython/gudhi.pyx b/src/cython/gudhi.pyx index d0e2df99..b8cb032e 100644 --- a/src/cython/gudhi.pyx +++ b/src/cython/gudhi.pyx @@ -29,3 +29,4 @@ include "src/cython/mini_simplex_tree.pyx" include "src/cython/rips_complex.pyx" include "src/cython/alpha_complex.pyx" include "src/cython/cubical_complex.pyx" +include "src/cython/persistence_graphical_tools.py" diff --git a/src/cython/src/cpp/Alpha_complex_interface.h b/src/cython/src/cpp/Alpha_complex_interface.h index 3378ee6e..c745543a 100644 --- a/src/cython/src/cpp/Alpha_complex_interface.h +++ b/src/cython/src/cpp/Alpha_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA Saclay (France) + * Copyright (C) 2016 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cython/src/cpp/Cubical_complex_interface.h b/src/cython/src/cpp/Cubical_complex_interface.h index b817198d..1bed6fd1 100644 --- a/src/cython/src/cpp/Cubical_complex_interface.h +++ b/src/cython/src/cpp/Cubical_complex_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA Saclay (France) + * Copyright (C) 2016 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cython/src/cpp/Persistent_cohomology_interface.h b/src/cython/src/cpp/Persistent_cohomology_interface.h index 53aea58e..58421799 100644 --- a/src/cython/src/cpp/Persistent_cohomology_interface.h +++ b/src/cython/src/cpp/Persistent_cohomology_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA Saclay (France) + * Copyright (C) 2016 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cython/src/cpp/Simplex_tree_interface.h b/src/cython/src/cpp/Simplex_tree_interface.h index 223590aa..9aee630b 100644 --- a/src/cython/src/cpp/Simplex_tree_interface.h +++ b/src/cython/src/cpp/Simplex_tree_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA Saclay (France) + * Copyright (C) 2016 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cython/src/cython/alpha_complex.pyx b/src/cython/src/cython/alpha_complex.pyx index 5df7a659..0d44cbce 100644 --- a/src/cython/src/cython/alpha_complex.pyx +++ b/src/cython/src/cython/alpha_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": diff --git a/src/cython/src/cython/cubical_complex.pyx b/src/cython/src/cython/cubical_complex.pyx index d513191c..002e99c9 100644 --- a/src/cython/src/cython/cubical_complex.pyx +++ b/src/cython/src/cython/cubical_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Cubical_complex_interface.h" namespace "Gudhi": diff --git a/src/cython/src/cython/mini_simplex_tree.pyx b/src/cython/src/cython/mini_simplex_tree.pyx index a5077820..3d216fe2 100644 --- a/src/cython/src/cython/mini_simplex_tree.pyx +++ b/src/cython/src/cython/mini_simplex_tree.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": diff --git a/src/cython/src/cython/persistence_graphical_tools.py b/src/cython/src/cython/persistence_graphical_tools.py new file mode 100755 index 00000000..b845e405 --- /dev/null +++ b/src/cython/src/cython/persistence_graphical_tools.py @@ -0,0 +1,82 @@ +import matplotlib.pyplot as plt +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. + + 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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +""" +Only 13 colors for the palette +""" +palette = ['#ff0000', '#00ff00', '#0000ff', '#00ffff', '#ff00ff', '#ffff00', + '#000000', '#880000', '#008800', '#000088', '#888800', '#880088', + '#008888'] + +def show_palette_values(): + colors = [] + for color in palette: + colors.append(color) + + y_pos = np.arange(len(palette)) + + plt.barh(y_pos, y_pos + 1, align='center', alpha=0.4, color=colors) + plt.ylabel('Dimension') + plt.title('Dimension palette values') + + plt.show() + +def bar_code_persistence(persistence): + # Look for minimum birth date and maximum death date for plot optimisation + 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]) > 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]) + + ind = 0 + delta = ((max_death - min_birth) / 10.0) + 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'): + # Finite death case + plt.barh(ind, (interval[1][1] - interval[1][0]), height=0.8, + left = interval[1][0], alpha=0.4, + color = palette[interval[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=0.4, + color = palette[interval[0]]) + ind = ind + 1 + # Ends plot on infinity value and starts a little bit before min_birth + plt.axis([axis_start, infinity, 0, ind]) + plt.show() diff --git a/src/cython/src/cython/rips_complex.pyx b/src/cython/src/cython/rips_complex.pyx index d01f79cb..52a3cfd8 100644 --- a/src/cython/src/cython/rips_complex.pyx +++ b/src/cython/src/cython/rips_complex.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": diff --git a/src/cython/src/cython/simplex_tree.pyx b/src/cython/src/cython/simplex_tree.pyx index 071b19e3..b84b7758 100644 --- a/src/cython/src/cython/simplex_tree.pyx +++ b/src/cython/src/cython/simplex_tree.pyx @@ -8,7 +8,7 @@ from libcpp.utility cimport pair Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from libcpp.utility cimport pair """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py index 8a346bb9..a1e57294 100755 --- a/src/cython/test/test_alpha_complex.py +++ b/src/cython/test/test_alpha_complex.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" diff --git a/src/cython/test/test_mini_simplex_tree.py b/src/cython/test/test_mini_simplex_tree.py index 6622fa57..ec1f5044 100755 --- a/src/cython/test/test_mini_simplex_tree.py +++ b/src/cython/test/test_mini_simplex_tree.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py index 3ad26b53..ecc676c7 100755 --- a/src/cython/test/test_rips_complex.py +++ b/src/cython/test/test_rips_complex.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 3451ca4b..7663ed70 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -8,7 +8,7 @@ import gudhi Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ import gudhi """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -- cgit v1.2.3 From 24cf70e130a5e999cb16de3fcecd7c53d98c381b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 8 Jun 2016 06:21:53 +0000 Subject: Add example rips_complex_from_file_example.py to compare with alpha complex. Modify existing examples. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1260 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: df5ac5ac6ad0427d9f943a632b36802581043760 --- src/cython/Makefile | 4 +- .../example/alpha_complex_from_file_example.py | 2 + .../example/rips_complex_from_file_example.py | 62 ++++++++++++++++++++++ src/cython/example/rips_persistence_diagram.py | 2 +- 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100755 src/cython/example/rips_complex_from_file_example.py (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/Makefile b/src/cython/Makefile index e3952f12..ada1d15b 100644 --- a/src/cython/Makefile +++ b/src/cython/Makefile @@ -13,8 +13,10 @@ example: python example/rips_complex_example.py python example/alpha_complex_example.py python example/random_cubical_complex_example.py 10 10 - # python example/alpha_complex_from_file_example.py data/500_random_points_on_3D_Torus.csv # python example/gudhi_graphical_tools_example.py + # python example/rips_persistence_diagram.py + # python example/alpha_complex_from_file_example.py data/500_random_points_on_3D_Torus.csv + # python example/rips_complex_from_file_example.py data/500_random_points_on_3D_Torus.csv clean: rm -rf build/ *.o *.so *.cpp diff --git a/src/cython/example/alpha_complex_from_file_example.py b/src/cython/example/alpha_complex_from_file_example.py index da7ae857..d1040e83 100755 --- a/src/cython/example/alpha_complex_from_file_example.py +++ b/src/cython/example/alpha_complex_from_file_example.py @@ -46,6 +46,8 @@ args = parser.parse_args() points = pandas.read_csv(args.file, header=None) +print("AlphaComplex with max_alpha_square=0.5") + alpha_complex = gudhi.AlphaComplex(points=points.values, max_alpha_square=0.5) diff --git a/src/cython/example/rips_complex_from_file_example.py b/src/cython/example/rips_complex_from_file_example.py new file mode 100755 index 00000000..1831a5e9 --- /dev/null +++ b/src/cython/example/rips_complex_from_file_example.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +import gudhi +import pandas +import argparse + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +print("#####################################################################") +print("RipsComplex creation from points read in a file") + +parser = argparse.ArgumentParser(description='RipsComplex creation from ' + 'points read in a file.', + epilog='Example: ' + 'example/rips_complex_from_file_example.py ' + 'data/500_random_points_on_3D_Torus.csv ' + '- Constructs a rips complex with the ' + 'points from the given file. File format ' + 'is X1, X2, ..., Xn') +parser.add_argument('file', type=argparse.FileType('r')) +args = parser.parse_args() + +points = pandas.read_csv(args.file, header=None) + +print("RipsComplex with max_edge_length=1.9") + +rips_complex = gudhi.RipsComplex(points=points.values, + max_dimension=len(points.values[0]), max_edge_length=1.9) + +rips_complex.initialize_filtration() +diag = rips_complex.persistence(homology_coeff_field=2, min_persistence=0.1) + +print("betti_numbers()=") +print(rips_complex.betti_numbers()) + +gudhi.diagram_persistence(diag) + +gudhi.bar_code_persistence(diag) diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index 57f25b22..fddea298 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -36,4 +36,4 @@ rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], diag = rips.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) -gudhi.bar_code_persistence(diag) +gudhi.diagram_persistence(diag) -- cgit v1.2.3 From ad9c182c0ffa8b517cd20d174de823db05250514 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Jan 2017 08:59:20 +0000 Subject: Fix rips complex with the new interface Remove mini simplex tree Fix persistent cohomology doc - only simplex tree used Remove useless type definition in Cython C++ interfaces git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2003 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fff43192b00df1c70d59109a6c14932013992ff1 --- src/cython/cython/mini_simplex_tree.pyx | 352 -------------------- src/cython/cython/rips_complex.pyx | 354 +++------------------ src/cython/doc/persistent_cohomology_sum.rst | 3 - src/cython/doc/persistent_cohomology_user.rst | 3 - src/cython/example/mini_simplex_tree_example.py | 73 ----- ...am_persistence_with_pandas_interface_example.py | 11 +- .../example/rips_complex_from_points_example.py | 10 +- src/cython/example/rips_persistence_diagram.py | 7 +- src/cython/gudhi.pyx.in | 1 - src/cython/include/Alpha_complex_interface.h | 9 +- src/cython/include/Cubical_complex_interface.h | 4 +- src/cython/include/Rips_complex_interface.h | 70 ++++ src/cython/include/Simplex_tree_interface.h | 34 +- src/cython/include/Subsampling_interface.h | 3 +- src/cython/include/Tangential_complex_interface.h | 5 - src/cython/include/Witness_complex_interface.h | 4 +- src/cython/test/test_mini_simplex_tree.py | 50 --- src/cython/test/test_rips_complex.py | 35 +- 18 files changed, 158 insertions(+), 870 deletions(-) delete mode 100644 src/cython/cython/mini_simplex_tree.pyx delete mode 100755 src/cython/example/mini_simplex_tree_example.py create mode 100644 src/cython/include/Rips_complex_interface.h delete mode 100755 src/cython/test/test_mini_simplex_tree.py (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/cython/mini_simplex_tree.pyx b/src/cython/cython/mini_simplex_tree.pyx deleted file mode 100644 index 3ba7e853..00000000 --- a/src/cython/cython/mini_simplex_tree.pyx +++ /dev/null @@ -1,352 +0,0 @@ -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. - - 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 . -""" - -__author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" -__license__ = "GPL v3" - -cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": - cdef cppclass Simplex_tree_options_mini: - pass - - cdef cppclass Simplex_tree_interface_mini "Gudhi::Simplex_tree_interface": - Simplex_tree() - double filtration() - double simplex_filtration(vector[int] simplex) - void set_filtration(double filtration) - void initialize_filtration() - int num_vertices() - int num_simplices() - void set_dimension(int dimension) - int dimension() - bint find_simplex(vector[int] simplex) - bint insert_simplex_and_subfaces(vector[int] simplex, - double filtration) - vector[pair[vector[int], double]] get_filtered_tree() - vector[pair[vector[int], double]] get_skeleton_tree(int dimension) - vector[pair[vector[int], double]] get_star_tree(vector[int] simplex) - vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, - int dimension) - void remove_maximal_simplex(vector[int] simplex) - -cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": - cdef cppclass Mini_simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface>": - Mini_simplex_tree_persistence_interface(Simplex_tree_interface_mini * st) - vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence) - vector[int] betti_numbers() - vector[int] persistent_betti_numbers(double from_value, double to_value) - -# MiniSimplexTree python interface -cdef class MiniSimplexTree: - """The simplex tree is an efficient and flexible data structure for - representing general (filtered) simplicial complexes. The data structure - is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex - Tree: An Efficient Data Structure for General Simplicial Complexes. - Algorithmica, pages 1–22, 2014. - - This class is a non-filtered, with keys, and non contiguous vertices - version of the simplex tree. - """ - cdef Simplex_tree_interface_mini * thisptr - - cdef Mini_simplex_tree_persistence_interface * pcohptr - - # Fake constructor that does nothing but documenting the constructor - def __init__(self, points=[], max_alpha_square=float('inf')): - """MiniSimplexTree constructor. - """ - - # The real cython constructor - def __cinit__(self): - self.thisptr = new Simplex_tree_interface_mini() - - def __dealloc__(self): - if self.thisptr != NULL: - del self.thisptr - if self.pcohptr != NULL: - del self.pcohptr - - def __is_defined(self): - """Returns true if MiniSimplexTree pointer is not NULL. - """ - return self.thisptr != NULL - - def __is_persistence_defined(self): - """Returns true if Persistence pointer is not NULL. - """ - return self.pcohptr != NULL - - def get_filtration(self): - """This function returns the main simplicial complex filtration value. - - :returns: float -- the simplicial complex filtration value. - """ - return self.thisptr.filtration() - - def filtration(self, simplex): - """This function returns the simplicial complex filtration value for a - given N-simplex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :returns: float -- the simplicial complex filtration value. - """ - return self.thisptr.simplex_filtration(simplex) - - def set_filtration(self, filtration): - """This function sets the main simplicial complex filtration value. - - :param filtration: The filtration value. - :type filtration: float. - """ - self.thisptr.set_filtration( filtration) - - def initialize_filtration(self): - """This function initializes and sorts the simplicial complex - filtration vector. - - .. note:: - - This function must be launched before persistence, betti_numbers, - persistent_betti_numbers or get_filtered_tree after inserting or - removing simplices. - """ - self.thisptr.initialize_filtration() - - def num_vertices(self): - """This function returns the number of vertices of the simplicial - complex. - - :returns: int -- the simplicial complex number of vertices. - """ - return self.thisptr.num_vertices() - - def num_simplices(self): - """This function returns the number of simplices of the simplicial - complex. - - :returns: int -- the simplicial complex number of simplices. - """ - return self.thisptr.num_simplices() - - def dimension(self): - """This function returns the dimension of the simplicial complex. - - :returns: int -- the simplicial complex dimension. - """ - return self.thisptr.dimension() - - def set_dimension(self, dimension): - """This function sets the dimension of the simplicial complex. - - :param dimension: The new dimension value. - :type dimension: int. - """ - self.thisptr.set_dimension(dimension) - - def find(self, simplex): - """This function returns if the N-simplex was found in the simplicial - complex or not. - - :param simplex: The N-simplex to find, represented by a list of vertex. - :type simplex: list of int. - :returns: bool -- true if the simplex was found, false otherwise. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - return self.thisptr.find_simplex(complex) - - def insert(self, simplex, filtration=0.0): - """This function inserts the given N-simplex with the given filtration - value (default value is '0.0'). - - :param simplex: The N-simplex to insert, represented by a list of - vertex. - :type simplex: list of int. - :param filtration: The filtration value of the simplex. - :type filtration: float. - :returns: bool -- true if the simplex was found, false otherwise. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - return self.thisptr.insert_simplex_and_subfaces(complex, - filtration) - - def get_filtered_tree(self): - """This function returns the tree sorted by increasing filtration - values. - - :returns: list of tuples(simplex, filtration) -- the tree sorted by - increasing filtration values. - """ - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_filtered_tree() - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_skeleton_tree(self, dimension): - """This function returns the tree skeleton of a maximum given - dimension. - - :param dimension: The skeleton dimension value. - :type dimension: int. - :returns: list of tuples(simplex, filtration) -- the skeleton tree - of a maximum dimension. - """ - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_skeleton_tree(dimension) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_star_tree(self, simplex): - """This function returns the star tree of a given N-simplex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :returns: list of tuples(simplex, filtration) -- the star tree of a - simplex. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_star_tree(complex) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_coface_tree(self, simplex, codimension): - """This function returns the coface tree of a given N-simplex with a - given codimension. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :param codimension: The codimension. If codimension = 0, all cofaces - are returned (equivalent of get_star_tree function) - :type codimension: int. - :returns: list of tuples(simplex, filtration) -- the coface tree of a - simplex. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_coface_tree(complex, codimension) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def remove_maximal_simplex(self, simplex): - """This function removes a given maximal N-simplex from the simplicial - complex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - """ - self.thisptr.remove_maximal_simplex(simplex) - - def persistence(self, homology_coeff_field=11): - """This function returns the persistence of the simplicial complex. - - :param homology_coeff_field: The homology coefficient field. Must be a - prime number - :type homology_coeff_field: int. - :param min_persistence: The minimum persistence value to take into - account (strictly greater than min_persistence). Default value is - 0.0. - Sets min_persistence to -1.0 to see all values. - :type min_persistence: float. - :returns: list of pairs(dimension, pair(birth, death)) -- the - persistence of the simplicial complex. - """ - if self.pcohptr != NULL: - del self.pcohptr - self.pcohptr = new Mini_simplex_tree_persistence_interface(self.thisptr) - cdef vector[pair[int, pair[double, double]]] persistence_result - if self.pcohptr != NULL: - persistence_result = self.pcohptr.get_persistence(homology_coeff_field, 0) - return persistence_result - - def betti_numbers(self): - """This function returns the Betti numbers of the simplicial complex. - - :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). - - :note: betti_numbers function requires persistence function to be - launched first. - """ - cdef vector[int] bn_result - if self.pcohptr != NULL: - bn_result = self.pcohptr.betti_numbers() - else: - print("betti_numbers function requires persistence function" - " to be launched first.") - return bn_result - - def persistent_betti_numbers(self, from_value, to_value): - """This function returns the persistent Betti numbers of the - simplicial complex. - - :param from_value: The persistence birth limit to be added in the - numbers (persistent birth <= from_value). - :type from_value: float. - :param to_value: The persistence death limit to be added in the - numbers (persistent death > to_value). - :type to_value: float. - - :returns: list of int -- The persistent Betti numbers ([B0, B1, ..., - Bn]). - - :note: persistent_betti_numbers function requires persistence - function to be launched first. - """ - cdef vector[int] pbn_result - if self.pcohptr != NULL: - pbn_result = self.pcohptr.persistent_betti_numbers(from_value, to_value) - else: - print("persistent_betti_numbers function requires persistence function" - " to be launched first.") - return pbn_result diff --git a/src/cython/cython/rips_complex.pyx b/src/cython/cython/rips_complex.pyx index 08bd2388..2e739ac3 100644 --- a/src/cython/cython/rips_complex.pyx +++ b/src/cython/cython/rips_complex.pyx @@ -3,6 +3,7 @@ from libcpp.vector cimport vector from libcpp.utility cimport pair 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++ @@ -30,61 +31,37 @@ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": - cdef cppclass Simplex_tree_options_full_featured: - pass - - cdef cppclass Rips_complex_interface "Gudhi::Simplex_tree_interface": - Simplex_tree() - double filtration() - double simplex_filtration(vector[int] simplex) - void set_filtration(double filtration) - void initialize_filtration() - int num_vertices() - int num_simplices() - void set_dimension(int dimension) - int dimension() - bint find_simplex(vector[int] simplex) - bint insert_simplex_and_subfaces(vector[int] simplex, - double filtration) - vector[pair[vector[int], double]] get_filtered_tree() - vector[pair[vector[int], double]] get_skeleton_tree(int dimension) - vector[pair[vector[int], double]] get_star_tree(vector[int] simplex) - vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, - int dimension) - void remove_maximal_simplex(vector[int] simplex) - void graph_expansion(vector[vector[double]] points, int max_dimension, - double max_edge_length) - void graph_expansion(string off_file, int max_dimension, - double max_edge_length, bool from_file) - -cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": - cdef cppclass Rips_complex_persistence_interface "Gudhi::Persistent_cohomology_interface>": - Rips_complex_persistence_interface(Rips_complex_interface * st) - vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence) - vector[int] betti_numbers() - vector[int] persistent_betti_numbers(double from_value, double to_value) +cdef extern from "Rips_complex_interface.h" namespace "Gudhi": + cdef cppclass Rips_complex_interface "Gudhi::rips_complex::Rips_complex_interface": + Rips_complex_interface(vector[vector[double]] points, double threshold) + # bool from_file is a workaround for cython to find the correct signature + Rips_complex_interface(string off_file, double threshold, bool from_file) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, int dim_max) # RipsComplex python interface cdef class RipsComplex: - """RipsComplex is a simplicial complex constructed from a list of points. + """RipsComplex is a simplicial complex constructed from the finite cells + of a Delaunay Triangulation. + + The filtration value of each simplex is computed as the square of the + circumradius of the simplex if the circumsphere is empty (the simplex is + then said to be Gabriel), and as the minimum of the filtration values of + the codimension 1 cofaces that make it not Gabriel otherwise. + + All simplices that have a filtration value strictly greater than a given + alpha squared value are not inserted into the complex. + + .. note:: - Each point Pn is inserted as a vertex in the simplicial complex with a - null filtration value. + When Rips_complex is constructed with an infinite value of alpha, the + complex is a Delaunay complex. - A N-simplex represented by the list of vertices Vi, ..., Vj is inserted in - the simplicial complex if all the points Pi, ..., Pj corresponding to the - vertices are within a distance less or equal to a given maximum edge length - value, and if N (dimension of the N-simplex) is less or equal to a given - maximum dimension. """ - cdef Rips_complex_interface * thisptr - cdef Rips_complex_persistence_interface * pcohptr + cdef Rips_complex_interface * thisptr # Fake constructor that does nothing but documenting the constructor - def __init__(self, points=[], off_file='', max_dimension=3, - max_edge_length=float('inf')): + def __init__(self, points=[], off_file='', max_edge_length=float('inf')): """RipsComplex constructor. :param points: A list of points in d-Dimension. @@ -95,291 +72,40 @@ cdef class RipsComplex: :param off_file: An OFF file style name. :type off_file: string - :param max_dimension: Maximum dimension of the complex to be expanded. - :type max_dimension: int - :param max_edge_length: Maximum edge length value (rips radius). - :type max_edge_length: double + :param max_edge_length: Rips value. + :type max_edge_length: int """ # The real cython constructor - def __cinit__(self, points=[], off_file='', max_dimension=3, - max_edge_length=float('inf')): - self.thisptr = new Rips_complex_interface() - # Constructor from graph expansion + def __cinit__(self, points=[], off_file='', max_edge_length=float('inf')): if off_file is not '': if os.path.isfile(off_file): - self.thisptr.graph_expansion(off_file, max_dimension, - max_edge_length, True) + self.thisptr = new Rips_complex_interface(off_file, + max_edge_length, + True) else: print("file " + off_file + " not found.") else: - self.thisptr.graph_expansion(points, max_dimension, - max_edge_length) + self.thisptr = new Rips_complex_interface(points, max_edge_length) + def __dealloc__(self): if self.thisptr != NULL: del self.thisptr - if self.pcohptr != NULL: - del self.pcohptr def __is_defined(self): """Returns true if RipsComplex pointer is not NULL. """ return self.thisptr != NULL - def __is_persistence_defined(self): - """Returns true if Persistence pointer is not NULL. - """ - return self.pcohptr != NULL - - def get_filtration(self): - """This function returns the main simplicial complex filtration value. - - :returns: float -- the simplicial complex filtration value. - """ - return self.thisptr.filtration() - - def filtration(self, simplex): - """This function returns the simplicial complex filtration value for a - given N-simplex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :returns: float -- the simplicial complex filtration value. - """ - return self.thisptr.simplex_filtration(simplex) - - def set_filtration(self, filtration): - """This function sets the main simplicial complex filtration value. - - :param filtration: The filtration value. - :type filtration: float. + def create_simplex_tree(self, max_dimension=1): """ - self.thisptr.set_filtration( filtration) - - def initialize_filtration(self): - """This function initializes and sorts the simplicial complex - filtration vector. - - .. note:: - - This function must be launched before persistence, betti_numbers, - persistent_betti_numbers or get_filtered_tree after inserting or - removing simplices. - """ - self.thisptr.initialize_filtration() - - def num_vertices(self): - """This function returns the number of vertices of the simplicial - complex. - - :returns: int -- the simplicial complex number of vertices. - """ - return self.thisptr.num_vertices() - - def num_simplices(self): - """This function returns the number of simplices of the simplicial - complex. - - :returns: int -- the simplicial complex number of simplices. - """ - return self.thisptr.num_simplices() - - def dimension(self): - """This function returns the dimension of the simplicial complex. - - :returns: int -- the simplicial complex dimension. - """ - return self.thisptr.dimension() - - def set_dimension(self, dimension): - """This function sets the dimension of the simplicial complex. - - :param dimension: The new dimension value. - :type dimension: int. - """ - self.thisptr.set_dimension(dimension) - - def find(self, simplex): - """This function returns if the N-simplex was found in the simplicial - complex or not. - - :param simplex: The N-simplex to find, represented by a list of vertex. - :type simplex: list of int. - :returns: bool -- true if the simplex was found, false otherwise. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - return self.thisptr.find_simplex(complex) - - def insert(self, simplex, filtration=0.0): - """This function inserts the given N-simplex with the given filtration - value (default value is '0.0'). - - :param simplex: The N-simplex to insert, represented by a list of - vertex. - :type simplex: list of int. - :param filtration: The filtration value of the simplex. - :type filtration: float. - :returns: bool -- true if the simplex was found, false otherwise. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - return self.thisptr.insert_simplex_and_subfaces(complex, - filtration) - - def get_filtered_tree(self): - """This function returns the tree sorted by increasing filtration - values. - - :returns: list of tuples(simplex, filtration) -- the tree sorted by - increasing filtration values. - """ - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_filtered_tree() - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_skeleton_tree(self, dimension): - """This function returns the tree skeleton of a maximum given - dimension. - - :param dimension: The skeleton dimension value. - :type dimension: int. - :returns: list of tuples(simplex, filtration) -- the skeleton tree - of a maximum dimension. - """ - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_skeleton_tree(dimension) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_star_tree(self, simplex): - """This function returns the star tree of a given N-simplex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :returns: list of tuples(simplex, filtration) -- the star tree of a - simplex. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_star_tree(complex) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def get_coface_tree(self, simplex, codimension): - """This function returns the coface tree of a given N-simplex with a - given codimension. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - :param codimension: The codimension. If codimension = 0, all cofaces - are returned (equivalent of get_star_tree function) - :type codimension: int. - :returns: list of tuples(simplex, filtration) -- the coface tree of a - simplex. - """ - cdef vector[int] complex - for i in simplex: - complex.push_back(i) - cdef vector[pair[vector[int], double]] coface_tree \ - = self.thisptr.get_coface_tree(complex, codimension) - ct = [] - for filtered_complex in coface_tree: - v = [] - for vertex in filtered_complex.first: - v.append(vertex) - ct.append((v, filtered_complex.second)) - return ct - - def remove_maximal_simplex(self, simplex): - """This function removes a given maximal N-simplex from the simplicial - complex. - - :param simplex: The N-simplex, represented by a list of vertex. - :type simplex: list of int. - """ - self.thisptr.remove_maximal_simplex(simplex) - - def persistence(self, homology_coeff_field=11, min_persistence=0): - """This function returns the persistence of the simplicial complex. - - :param homology_coeff_field: The homology coefficient field. Must be a - prime number - :type homology_coeff_field: int. - :param min_persistence: The minimum persistence value to take into - account (strictly greater than min_persistence). Default value is - 0.0. - Sets min_persistence to -1.0 to see all values. - :type min_persistence: float. - :note: list of pairs(dimension, pair(birth, death)) -- the - persistence of the simplicial complex. - """ - if self.pcohptr != NULL: - del self.pcohptr - self.pcohptr = new Rips_complex_persistence_interface(self.thisptr) - cdef vector[pair[int, pair[double, double]]] persistence_result - if self.pcohptr != NULL: - persistence_result = self.pcohptr.get_persistence(homology_coeff_field, min_persistence) - return persistence_result - - def betti_numbers(self): - """This function returns the Betti numbers of the simplicial complex. - - :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). - - :note: betti_numbers function requires persistence function to be - launched first. - """ - cdef vector[int] bn_result - if self.pcohptr != NULL: - bn_result = self.pcohptr.betti_numbers() - else: - print("betti_numbers function requires persistence function" - " to be launched first.") - return bn_result - - def persistent_betti_numbers(self, from_value, to_value): - """This function returns the persistent Betti numbers of the - simplicial complex. - - :param from_value: The persistence birth limit to be added in the - numbers (persistent birth <= from_value). - :type from_value: float. - :param to_value: The persistence death limit to be added in the - numbers (persistent death > to_value). - :type to_value: float. - - :returns: list of int -- The persistent Betti numbers ([B0, B1, ..., - Bn]). - - :note: persistent_betti_numbers function requires persistence - function to be launched first. + :param max_dimension: graph expansion for rips until this given maximal + dimension. + :type max_dimension: int + :returns: A simplex tree created from the Delaunay Triangulation. + :rtype: SimplexTree """ - cdef vector[int] pbn_result - if self.pcohptr != NULL: - pbn_result = self.pcohptr.persistent_betti_numbers(from_value, to_value) - else: - print("persistent_betti_numbers function requires persistence function" - " to be launched first.") - return pbn_result + simplex_tree = SimplexTree() + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_dimension) + return simplex_tree diff --git a/src/cython/doc/persistent_cohomology_sum.rst b/src/cython/doc/persistent_cohomology_sum.rst index b306b3d4..cf3029fc 100644 --- a/src/cython/doc/persistent_cohomology_sum.rst +++ b/src/cython/doc/persistent_cohomology_sum.rst @@ -21,8 +21,5 @@ | :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | | | feature for reference: | | | | -| | * :doc:`alpha_complex_ref` | -| | * :doc:`cubical_complex_ref` | | | * :doc:`simplex_tree_ref` | -| | * :doc:`witness_complex_ref` | +---------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index 33b19ce2..ca936754 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -11,10 +11,7 @@ Definition | :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | | | feature for reference: | | | | -| | * :doc:`alpha_complex_ref` | -| | * :doc:`cubical_complex_ref` | | | * :doc:`simplex_tree_ref` | -| | * :doc:`witness_complex_ref` | +---------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/example/mini_simplex_tree_example.py b/src/cython/example/mini_simplex_tree_example.py deleted file mode 100755 index 7b65a9d6..00000000 --- a/src/cython/example/mini_simplex_tree_example.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python - -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. - - 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 . -""" - -__author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" -__license__ = "GPL v3" - -print("#####################################################################") -print("MiniSimplexTree creation from insertion") - -""" Complex to build. - 1 3 - o---o - /X\ / - o---o o - 2 0 4 -""" - -triangle012 = [0, 1, 2] -edge03 = [0, 3] -edge13 = [1, 3] -vertex4 = [4] -mini_st = gudhi.MiniSimplexTree() -mini_st.insert(triangle012) -mini_st.insert(edge03) -mini_st.insert(edge13) -mini_st.insert(vertex4) - -# FIXME: Remove this line -mini_st.set_dimension(2) - -# initialize_filtration required before plain_homology -mini_st.initialize_filtration() - -print("persistence(homology_coeff_field=2)=") -print(mini_st.persistence(homology_coeff_field=2)) - -edge02 = [0, 2] -if mini_st.find(edge02): - # Only coface is 012 - print("coface(edge02,1)=", mini_st.get_coface_tree(edge02, 1)) - -if mini_st.get_coface_tree(triangle012, 1) == []: - # Precondition: Check the simplex has no coface before removing it. - mini_st.remove_maximal_simplex(triangle012) - -# initialize_filtration required after removing -mini_st.initialize_filtration() - -print("filtered_tree after triangle012 removal =", mini_st.get_filtered_tree()) diff --git a/src/cython/example/rips_complex_diagram_persistence_with_pandas_interface_example.py b/src/cython/example/rips_complex_diagram_persistence_with_pandas_interface_example.py index bcf2fbcb..8af1b767 100755 --- a/src/cython/example/rips_complex_diagram_persistence_with_pandas_interface_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_with_pandas_interface_example.py @@ -53,16 +53,17 @@ message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) print(message) rips_complex = gudhi.RipsComplex(points=points.values, - max_dimension=len(points.values[0]), max_edge_length=args.max_edge_length) + max_edge_length=args.max_edge_length) -message = "Number of simplices=" + repr(rips_complex.num_simplices()) +simplex_tree = rips_complex.create_simplex_tree(max_dimension=len(points.values[0])) + +message = "Number of simplices=" + repr(simplex_tree.num_simplices()) print(message) -rips_complex.initialize_filtration() -diag = rips_complex.persistence() +diag = simplex_tree.persistence() print("betti_numbers()=") -print(rips_complex.betti_numbers()) +print(simplex_tree.betti_numbers()) if args.no_diagram == False: gudhi.diagram_persistence(diag) diff --git a/src/cython/example/rips_complex_from_points_example.py b/src/cython/example/rips_complex_from_points_example.py index 1a22d8e3..df6252cd 100755 --- a/src/cython/example/rips_complex_from_points_example.py +++ b/src/cython/example/rips_complex_from_points_example.py @@ -31,8 +31,10 @@ __license__ = "GPL v3" print("#####################################################################") print("RipsComplex creation from points") rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], - max_dimension=1, max_edge_length=42) + max_edge_length=42) -print("filtered_tree=", rips.get_filtered_tree()) -print("star([0])=", rips.get_star_tree([0])) -print("coface([0], 1)=", rips.get_coface_tree([0], 1)) +simplex_tree = rips.create_simplex_tree(max_dimension=1) + +print("filtered_tree=", simplex_tree.get_filtered_tree()) +print("star([0])=", simplex_tree.get_star_tree([0])) +print("coface([0], 1)=", simplex_tree.get_coface_tree([0], 1)) diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index fddea298..e485b2f5 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -31,9 +31,12 @@ __license__ = "GPL v3" print("#####################################################################") print("RipsComplex creation from points") rips = gudhi.RipsComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]], - max_dimension=1, max_edge_length=42) + max_edge_length=42) -diag = rips.persistence(homology_coeff_field=2, min_persistence=0) +simplex_tree = rips.create_simplex_tree(max_dimension=1) + + +diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) gudhi.diagram_persistence(diag) diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 60f4c30b..5dcb9d48 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -25,7 +25,6 @@ __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" include "cython/simplex_tree.pyx" -include "cython/mini_simplex_tree.pyx" include "cython/rips_complex.pyx" include "cython/cubical_complex.pyx" include "cython/periodic_cubical_complex.pyx" diff --git a/src/cython/include/Alpha_complex_interface.h b/src/cython/include/Alpha_complex_interface.h index 81761c77..9f308ae9 100644 --- a/src/cython/include/Alpha_complex_interface.h +++ b/src/cython/include/Alpha_complex_interface.h @@ -29,9 +29,9 @@ #include "Simplex_tree_interface.h" -#include -#include // std::pair #include +#include +#include namespace Gudhi { @@ -40,11 +40,6 @@ namespace alpha_complex { class Alpha_complex_interface { using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; using Point_d = Dynamic_kernel::Point_d; - typedef typename Simplex_tree<>::Simplex_handle Simplex_handle; - typedef typename std::pair Insertion_result; - using Simplex = std::vector; - using Filtered_complex = std::pair; - using Complex_tree = std::vector; typedef typename Simplex_tree<>::Simplex_key Simplex_key; diff --git a/src/cython/include/Cubical_complex_interface.h b/src/cython/include/Cubical_complex_interface.h index 5d17ff6b..4c53523b 100644 --- a/src/cython/include/Cubical_complex_interface.h +++ b/src/cython/include/Cubical_complex_interface.h @@ -27,9 +27,9 @@ #include #include -#include -#include // std::pair #include +#include +#include namespace Gudhi { diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h new file mode 100644 index 00000000..7e897b1d --- /dev/null +++ b/src/cython/include/Rips_complex_interface.h @@ -0,0 +1,70 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 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 . + */ + +#ifndef RIPS_COMPLEX_INTERFACE_H +#define RIPS_COMPLEX_INTERFACE_H + +#include +#include +#include +#include + +#include "Simplex_tree_interface.h" + +#include +#include +#include // std::pair +#include + +namespace Gudhi { + +namespace rips_complex { + +class Rips_complex_interface { + using Point_d = std::vector; + + public: + Rips_complex_interface(std::vector>&points, double threshold) { + rips_complex_ = new Rips_complex::Filtration_value>(points, threshold, + Euclidean_distance()); + } + + Rips_complex_interface(std::string off_file_name, double threshold, bool from_file = true) { + Gudhi::Points_off_reader off_reader(off_file_name); + rips_complex_ = new Rips_complex::Filtration_value>(off_reader.get_point_cloud(), + threshold, Euclidean_distance()); + } + + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, int dim_max) { + rips_complex_->create_complex(*simplex_tree, dim_max); + simplex_tree->initialize_filtration(); + } + + private: + Rips_complex::Filtration_value>* rips_complex_; +}; + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // RIPS_COMPLEX_INTERFACE_H diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 8e9dd966..19e02ca4 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -30,15 +30,17 @@ #include "Persistent_cohomology_interface.h" +#include #include #include // std::pair -#include namespace Gudhi { template class Simplex_tree_interface : public Simplex_tree { public: + typedef typename Simplex_tree::Filtration_value Filtration_value; + typedef typename Simplex_tree::Vertex_handle Vertex_handle; typedef typename Simplex_tree::Simplex_handle Simplex_handle; typedef typename std::pair Insertion_result; using Simplex = std::vector; @@ -115,42 +117,12 @@ class Simplex_tree_interface : public Simplex_tree { return coface_tree; } - void graph_expansion(std::vector>&points, int max_dimension, double max_edge_length) { - Graph_t prox_graph = compute_proximity_graph(points, max_edge_length, euclidean_distance>); - Simplex_tree::insert_graph(prox_graph); - Simplex_tree::expansion(max_dimension); - Simplex_tree::initialize_filtration(); - } - - void graph_expansion(std::string& off_file_name, int max_dimension, double max_edge_length, bool from_file=true) { - Gudhi::Points_off_reader> off_reader(off_file_name); - // Check the read operation was correct - if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << off_file_name << std::endl; - } else { - std::vector> points = off_reader.get_point_cloud(); - Graph_t prox_graph = compute_proximity_graph(points, max_edge_length, - euclidean_distance>); - Simplex_tree::insert_graph(prox_graph); - Simplex_tree::expansion(max_dimension); - Simplex_tree::initialize_filtration(); - } - } - void create_persistence(Gudhi::Persistent_cohomology_interface>* pcoh) { pcoh = new Gudhi::Persistent_cohomology_interface>(*this); } }; -struct Simplex_tree_options_mini : Simplex_tree_options_full_featured { - // Not doing persistence, so we don't need those - static const bool store_key = true; - static const bool store_filtration = false; - // I have few vertices - typedef short Vertex_handle; -}; - } // namespace Gudhi #endif // SIMPLEX_TREE_INTERFACE_H diff --git a/src/cython/include/Subsampling_interface.h b/src/cython/include/Subsampling_interface.h index 9340cd86..fb047441 100644 --- a/src/cython/include/Subsampling_interface.h +++ b/src/cython/include/Subsampling_interface.h @@ -29,8 +29,9 @@ #include #include -#include #include +#include +#include namespace Gudhi { diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index 9da32757..7c774c73 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -41,11 +41,6 @@ namespace tangential_complex { class Tangential_complex_interface { using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; using Point_d = Dynamic_kernel::Point_d; - typedef typename Simplex_tree<>::Simplex_handle Simplex_handle; - typedef typename std::pair Insertion_result; - using Simplex = std::vector; - using Filtered_complex = std::pair; - using Complex_tree = std::vector; using TC = Tangential_complex; public: diff --git a/src/cython/include/Witness_complex_interface.h b/src/cython/include/Witness_complex_interface.h index ab99adf5..a753bc1d 100644 --- a/src/cython/include/Witness_complex_interface.h +++ b/src/cython/include/Witness_complex_interface.h @@ -40,6 +40,8 @@ namespace witness_complex { class Witness_complex_interface { typedef typename Simplex_tree<>::Simplex_handle Simplex_handle; + typedef typename Simplex_tree<>::Filtration_value Filtration_value; + typedef typename Simplex_tree<>::Vertex_handle Vertex_handle; typedef typename std::pair Insertion_result; using Simplex = std::vector; using Filtered_complex = std::pair; @@ -51,7 +53,7 @@ class Witness_complex_interface { std::vector > knn; std::vector> landmarks; Gudhi::subsampling::pick_n_random_points(points, number_of_landmarks, std::back_inserter(landmarks)); - Gudhi::witness_complex::construct_closest_landmark_table(points, landmarks, knn); + Gudhi::witness_complex::construct_closest_landmark_table(points, landmarks, knn); Gudhi::witness_complex::witness_complex(knn, number_of_landmarks, points[0].size(), simplex_tree_); } diff --git a/src/cython/test/test_mini_simplex_tree.py b/src/cython/test/test_mini_simplex_tree.py deleted file mode 100755 index e44bfdbc..00000000 --- a/src/cython/test/test_mini_simplex_tree.py +++ /dev/null @@ -1,50 +0,0 @@ -from gudhi import MiniSimplexTree - -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. - - Author(s): Vincent Rouvreau - - Copyright (C) 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 . -""" - -__author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" -__license__ = "GPL v3" - - -def test_mini(): - triangle012 = [0, 1, 2] - edge03 = [0, 3] - mini_st = MiniSimplexTree() - assert mini_st.__is_defined() == True - assert mini_st.__is_persistence_defined() == False - assert mini_st.insert(triangle012) == True - assert mini_st.insert(edge03) == True - # FIXME: Remove this line - mini_st.set_dimension(2) - - edge02 = [0, 2] - assert mini_st.find(edge02) == True - assert mini_st.get_coface_tree(edge02, 1) == \ - [([0, 1, 2], 0.0)] - - # remove_maximal_simplex test - assert mini_st.get_coface_tree(triangle012, 1) == [] - mini_st.remove_maximal_simplex(triangle012) - assert mini_st.find(edge02) == True - assert mini_st.find(triangle012) == False diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py index 877289cf..687e8529 100755 --- a/src/cython/test/test_rips_complex.py +++ b/src/cython/test/test_rips_complex.py @@ -30,36 +30,39 @@ __license__ = "GPL v3" def test_empty_rips(): rips_complex = RipsComplex() assert rips_complex.__is_defined() == True - assert rips_complex.__is_persistence_defined() == False def test_rips(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] - rips_complex = RipsComplex(points=point_list, max_dimension=1, - max_edge_length=42) - assert rips_complex.__is_defined() == True - assert rips_complex.__is_persistence_defined() == False + rips_complex = RipsComplex(points=point_list, max_edge_length=42) + + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + + assert simplex_tree.__is_defined() == True + assert simplex_tree.__is_persistence_defined() == False - assert rips_complex.num_simplices() == 10 - assert rips_complex.num_vertices() == 4 + assert simplex_tree.num_simplices() == 10 + assert simplex_tree.num_vertices() == 4 - assert rips_complex.get_filtered_tree() == \ + assert simplex_tree.get_filtered_tree() == \ [([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 rips_complex.get_star_tree([0]) == \ + assert simplex_tree.get_star_tree([0]) == \ [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] - assert rips_complex.get_coface_tree([0], 1) == \ + assert simplex_tree.get_coface_tree([0], 1) == \ [([0, 1], 1.0), ([0, 2], 1.0), ([0, 3], 1.4142135623730951)] def test_filtered_rips(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] - filtered_rips = RipsComplex(points=point_list, max_dimension=1, - max_edge_length=1.0) - assert filtered_rips.__is_defined() == True - assert filtered_rips.__is_persistence_defined() == False + filtered_rips = RipsComplex(points=point_list, max_edge_length=1.0) + + simplex_tree = filtered_rips.create_simplex_tree(max_dimension=1) + + assert simplex_tree.__is_defined() == True + assert simplex_tree.__is_persistence_defined() == False - assert filtered_rips.num_simplices() == 8 - assert filtered_rips.num_vertices() == 4 + assert simplex_tree.num_simplices() == 8 + assert simplex_tree.num_vertices() == 4 -- cgit v1.2.3 From 30374ed5154610dc63198742220153aa9387139c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 20 Mar 2017 15:48:04 +0000 Subject: Rename barcode_persistence and diagram_persistence functions git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2204 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f91e283fa6b6b02198ae28a44f41bd761c1c1f48 --- src/cython/cython/persistence_graphical_tools.py | 4 ++-- src/cython/doc/persistence_graphical_tools_ref.rst | 4 ++-- src/cython/doc/persistence_graphical_tools_user.rst | 8 ++++---- src/cython/doc/pyplots/barcode_persistence.py | 2 +- src/cython/doc/pyplots/diagram_persistence.py | 2 +- .../alpha_complex_diagram_persistence_from_off_file_example.py | 2 +- src/cython/example/alpha_rips_persistence_bottleneck_distance.py | 2 -- ...g_witness_complex_diagram_persistence_from_off_file_example.py | 4 ++-- ...n_witness_complex_diagram_persistence_from_off_file_example.py | 4 ++-- src/cython/example/gudhi_graphical_tools_example.py | 4 ++-- ...bical_complex_barcode_persistence_from_perseus_file_example.py | 2 +- ...mplex_diagram_persistence_from_distance_matrix_file_example.py | 2 +- .../rips_complex_diagram_persistence_from_off_file_example.py | 2 +- src/cython/example/rips_persistence_diagram.py | 2 +- .../tangential_complex_plain_homology_from_off_file_example.py | 2 +- 15 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py index 2a3d9f63..d7287a66 100755 --- a/src/cython/cython/persistence_graphical_tools.py +++ b/src/cython/cython/persistence_graphical_tools.py @@ -73,7 +73,7 @@ def show_palette_values(alpha=0.6): plt.show() -def barcode_persistence(persistence, alpha=0.6): +def plot_barcode_persistence(persistence, alpha=0.6): """This function plots the persistence bar code. :param persistence: The persistence to plot. @@ -108,7 +108,7 @@ def barcode_persistence(persistence, alpha=0.6): plt.axis([axis_start, infinity, 0, ind]) plt.show() -def diagram_persistence(persistence, alpha=0.6): +def plot_diagram_persistence(persistence, alpha=0.6): """This function plots the persistence diagram. :param persistence: The persistence to plot. diff --git a/src/cython/doc/persistence_graphical_tools_ref.rst b/src/cython/doc/persistence_graphical_tools_ref.rst index a12021c4..3d7e4fc7 100644 --- a/src/cython/doc/persistence_graphical_tools_ref.rst +++ b/src/cython/doc/persistence_graphical_tools_ref.rst @@ -4,5 +4,5 @@ Persistence graphical tools reference manual .. autofunction:: gudhi.__min_birth_max_death .. autofunction:: gudhi.show_palette_values -.. autofunction:: gudhi.barcode_persistence -.. autofunction:: gudhi.diagram_persistence +.. autofunction:: gudhi.plot_barcode_persistence +.. autofunction:: gudhi.plot_diagram_persistence diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index 1a5195c5..2644aa11 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -33,7 +33,7 @@ This function can display the persistence result as a barcode: periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') diag = periodic_cc.persistence() - gudhi.barcode_persistence(diag) + gudhi.plot_barcode_persistence(diag) .. plot:: @@ -41,7 +41,7 @@ This function can display the persistence result as a barcode: periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') diag = periodic_cc.persistence() - gudhi.barcode_persistence(diag) + gudhi.plot_barcode_persistence(diag) Show persistence as a diagram ----------------------------- @@ -55,7 +55,7 @@ This function can display the persistence result as a diagram: rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) .. plot:: @@ -64,4 +64,4 @@ This function can display the persistence result as a diagram: rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) diff --git a/src/cython/doc/pyplots/barcode_persistence.py b/src/cython/doc/pyplots/barcode_persistence.py index 95bbd343..9fcb33d0 100755 --- a/src/cython/doc/pyplots/barcode_persistence.py +++ b/src/cython/doc/pyplots/barcode_persistence.py @@ -2,4 +2,4 @@ import gudhi periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='../3d_torus.txt') diag = periodic_cc.persistence() -gudhi.barcode_persistence(diag) +gudhi.plot_barcode_persistence(diag) diff --git a/src/cython/doc/pyplots/diagram_persistence.py b/src/cython/doc/pyplots/diagram_persistence.py index b006b0bf..fbb6e60b 100755 --- a/src/cython/doc/pyplots/diagram_persistence.py +++ b/src/cython/doc/pyplots/diagram_persistence.py @@ -2,4 +2,4 @@ import gudhi alpha_complex = gudhi.AlphaComplex(off_file='../tore3D_300.off') diag = alpha_complex.persistence() -gudhi.diagram_persistence(diag) +gudhi.plot_diagram_persistence(diag) 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 ae03aa67..9714b382 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 @@ -63,7 +63,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/alpha_rips_persistence_bottleneck_distance.py b/src/cython/example/alpha_rips_persistence_bottleneck_distance.py index 04a59b44..cd64704b 100755 --- a/src/cython/example/alpha_rips_persistence_bottleneck_distance.py +++ b/src/cython/example/alpha_rips_persistence_bottleneck_distance.py @@ -42,8 +42,6 @@ parser.add_argument("-t", "--threshold", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) args = parser.parse_args() -print(repr(float('inf'))) -print(repr(math.sqrt(float('inf')))) with open(args.file, 'r') as f: first_line = f.readline() if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): 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 6c3e3a8a..3addf708 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 @@ -34,7 +34,7 @@ parser = argparse.ArgumentParser(description='EuclideanStrongWitnessComplex crea epilog='Example: ' 'example/witness_complex_diagram_persistence_from_off_file_example.py ' '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' - '- Constructs a alpha complex with the ' + '- 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) @@ -70,7 +70,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index 7f04a98e..1e7d788a 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 @@ -34,7 +34,7 @@ parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation f epilog='Example: ' 'example/witness_complex_diagram_persistence_from_off_file_example.py ' '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2' - '- Constructs a alpha complex with the ' + '- 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) @@ -70,7 +70,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/gudhi_graphical_tools_example.py b/src/cython/example/gudhi_graphical_tools_example.py index 40558bee..f1aa5d73 100755 --- a/src/cython/example/gudhi_graphical_tools_example.py +++ b/src/cython/example/gudhi_graphical_tools_example.py @@ -39,9 +39,9 @@ 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))] -gudhi.barcode_persistence(persistence) +gudhi.plot_barcode_persistence(persistence) print("#####################################################################") print("Show diagram persistence example") -gudhi.diagram_persistence(persistence) +gudhi.plot_diagram_persistence(persistence) 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 a9545ee9..128706b2 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 @@ -71,6 +71,6 @@ if is_file_perseus(args.file): print("betti_numbers()=") print(periodic_cubical_complex.betti_numbers()) if args.no_barcode == False: - gudhi.barcode_persistence(diag) + gudhi.plot_barcode_persistence(diag) else: print(args.file, "is not a valid perseus style file") 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 2b726f90..5f1416be 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 @@ -64,7 +64,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") 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 eb1c4ed5..4f888e77 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 @@ -64,7 +64,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index e485b2f5..3d51f379 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -39,4 +39,4 @@ simplex_tree = rips.create_simplex_tree(max_dimension=1) diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) -gudhi.diagram_persistence(diag) +gudhi.plot_diagram_persistence(diag) 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 be4c40be..a3fc9911 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 @@ -59,7 +59,7 @@ with open(args.file, 'r') as f: print(st.betti_numbers()) if args.no_diagram == False: - gudhi.diagram_persistence(diag) + gudhi.plot_diagram_persistence(diag) else: print(args.file, "is not a valid OFF file") -- cgit v1.2.3 From 0724c2bcab0fa444ecf8178c27f59ca788a0aa03 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 22 Mar 2017 21:19:15 +0000 Subject: Rename plot_persistence_diagram and barcode git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2220 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 66a06ffdc62d5284119df80c3f104a48568cd241 --- src/cython/cython/persistence_graphical_tools.py | 4 ++-- src/cython/doc/persistence_graphical_tools_ref.rst | 4 ++-- src/cython/doc/persistence_graphical_tools_user.rst | 8 ++++---- src/cython/doc/pyplots/barcode_persistence.py | 2 +- src/cython/doc/pyplots/diagram_persistence.py | 2 +- .../alpha_complex_diagram_persistence_from_off_file_example.py | 2 +- ...g_witness_complex_diagram_persistence_from_off_file_example.py | 2 +- ...n_witness_complex_diagram_persistence_from_off_file_example.py | 2 +- src/cython/example/gudhi_graphical_tools_example.py | 4 ++-- ...bical_complex_barcode_persistence_from_perseus_file_example.py | 2 +- ...mplex_diagram_persistence_from_distance_matrix_file_example.py | 2 +- .../rips_complex_diagram_persistence_from_off_file_example.py | 2 +- src/cython/example/rips_persistence_diagram.py | 2 +- .../tangential_complex_plain_homology_from_off_file_example.py | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/cython/example/rips_persistence_diagram.py') diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py index d7287a66..a984633e 100755 --- a/src/cython/cython/persistence_graphical_tools.py +++ b/src/cython/cython/persistence_graphical_tools.py @@ -73,7 +73,7 @@ def show_palette_values(alpha=0.6): plt.show() -def plot_barcode_persistence(persistence, alpha=0.6): +def plot_persistence_barcode(persistence, alpha=0.6): """This function plots the persistence bar code. :param persistence: The persistence to plot. @@ -108,7 +108,7 @@ def plot_barcode_persistence(persistence, alpha=0.6): plt.axis([axis_start, infinity, 0, ind]) plt.show() -def plot_diagram_persistence(persistence, alpha=0.6): +def plot_persistence_diagram(persistence, alpha=0.6): """This function plots the persistence diagram. :param persistence: The persistence to plot. diff --git a/src/cython/doc/persistence_graphical_tools_ref.rst b/src/cython/doc/persistence_graphical_tools_ref.rst index 3d7e4fc7..27c2f68a 100644 --- a/src/cython/doc/persistence_graphical_tools_ref.rst +++ b/src/cython/doc/persistence_graphical_tools_ref.rst @@ -4,5 +4,5 @@ Persistence graphical tools reference manual .. autofunction:: gudhi.__min_birth_max_death .. autofunction:: gudhi.show_palette_values -.. autofunction:: gudhi.plot_barcode_persistence -.. autofunction:: gudhi.plot_diagram_persistence +.. autofunction:: gudhi.plot_persistence_barcode +.. autofunction:: gudhi.plot_persistence_diagram diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index 2644aa11..f713e971 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -33,7 +33,7 @@ This function can display the persistence result as a barcode: periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') diag = periodic_cc.persistence() - gudhi.plot_barcode_persistence(diag) + gudhi.plot_persistence_barcode(diag) .. plot:: @@ -41,7 +41,7 @@ This function can display the persistence result as a barcode: periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') diag = periodic_cc.persistence() - gudhi.plot_barcode_persistence(diag) + gudhi.plot_persistence_barcode(diag) Show persistence as a diagram ----------------------------- @@ -55,7 +55,7 @@ This function can display the persistence result as a diagram: rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) .. plot:: @@ -64,4 +64,4 @@ This function can display the persistence result as a diagram: rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) diff --git a/src/cython/doc/pyplots/barcode_persistence.py b/src/cython/doc/pyplots/barcode_persistence.py index 9fcb33d0..c06ac5a7 100755 --- a/src/cython/doc/pyplots/barcode_persistence.py +++ b/src/cython/doc/pyplots/barcode_persistence.py @@ -2,4 +2,4 @@ import gudhi periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='../3d_torus.txt') diag = periodic_cc.persistence() -gudhi.plot_barcode_persistence(diag) +gudhi.plot_persistence_barcode(diag) diff --git a/src/cython/doc/pyplots/diagram_persistence.py b/src/cython/doc/pyplots/diagram_persistence.py index fbb6e60b..b4714fe3 100755 --- a/src/cython/doc/pyplots/diagram_persistence.py +++ b/src/cython/doc/pyplots/diagram_persistence.py @@ -2,4 +2,4 @@ import gudhi alpha_complex = gudhi.AlphaComplex(off_file='../tore3D_300.off') diag = alpha_complex.persistence() -gudhi.plot_diagram_persistence(diag) +gudhi.plot_persistence_diagram(diag) 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 9714b382..adedc7d2 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 @@ -63,7 +63,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") 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 3addf708..2474fc87 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 @@ -70,7 +70,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index 1e7d788a..5a75417b 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 @@ -70,7 +70,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/gudhi_graphical_tools_example.py b/src/cython/example/gudhi_graphical_tools_example.py index f1aa5d73..bc3b16ec 100755 --- a/src/cython/example/gudhi_graphical_tools_example.py +++ b/src/cython/example/gudhi_graphical_tools_example.py @@ -39,9 +39,9 @@ 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))] -gudhi.plot_barcode_persistence(persistence) +gudhi.plot_persistence_barcode(persistence) print("#####################################################################") print("Show diagram persistence example") -gudhi.plot_diagram_persistence(persistence) +gudhi.plot_persistence_diagram(persistence) 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 128706b2..db530161 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 @@ -71,6 +71,6 @@ if is_file_perseus(args.file): print("betti_numbers()=") print(periodic_cubical_complex.betti_numbers()) if args.no_barcode == False: - gudhi.plot_barcode_persistence(diag) + gudhi.plot_persistence_barcode(diag) else: print(args.file, "is not a valid perseus style file") 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 5f1416be..664eb5c4 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 @@ -64,7 +64,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") 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 4f888e77..4c21b98e 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 @@ -64,7 +64,7 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index 3d51f379..4e5cd2c8 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -39,4 +39,4 @@ simplex_tree = rips.create_simplex_tree(max_dimension=1) diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) -gudhi.plot_diagram_persistence(diag) +gudhi.plot_persistence_diagram(diag) 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 a3fc9911..4845eb47 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 @@ -59,7 +59,7 @@ with open(args.file, 'r') as f: print(st.betti_numbers()) if args.no_diagram == False: - gudhi.plot_diagram_persistence(diag) + gudhi.plot_persistence_diagram(diag) else: print(args.file, "is not a valid OFF file") -- cgit v1.2.3