summaryrefslogtreecommitdiff
path: root/src/cython/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/cython/example')
-rwxr-xr-xsrc/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py4
-rwxr-xr-xsrc/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py5
-rwxr-xr-xsrc/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py5
-rwxr-xr-xsrc/cython/example/gudhi_graphical_tools_example.py9
-rwxr-xr-xsrc/cython/example/persistence_representations_diagrams_example.py70
-rwxr-xr-xsrc/cython/example/persistence_representations_landscapes_example.py63
-rwxr-xr-xsrc/cython/example/persistence_representations_landscapes_on_grid_example.py110
-rwxr-xr-xsrc/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py4
-rwxr-xr-xsrc/cython/example/rips_complex_diagram_persistence_from_off_file_example.py4
-rwxr-xr-xsrc/cython/example/rips_persistence_diagram.py3
-rwxr-xr-xsrc/cython/example/simplex_tree_example.py3
-rwxr-xr-xsrc/cython/example/tangential_complex_plain_homology_from_off_file_example.py4
12 files changed, 28 insertions, 256 deletions
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 adedc7d2..b4487be4 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
@@ -38,6 +38,7 @@ parser = argparse.ArgumentParser(description='AlphaComplex creation from '
'points from the given OFF file.')
parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-a", "--max_alpha_square", type=float, default=0.5)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -63,7 +64,8 @@ with open(args.file, 'r') as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
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 2371c36c..e3f362dc 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
@@ -40,6 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-a", "--max_alpha_square", type=float, required=True)
parser.add_argument("-n", "--number_of_landmarks", type=int, required=True)
parser.add_argument("-d", "--limit_dimension", type=int, required=True)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -70,8 +71,8 @@ with open(args.file, 'r') as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
-
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
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 5748aa8a..c236d992 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
@@ -40,6 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-a", "--max_alpha_square", type=float, required=True)
parser.add_argument("-n", "--number_of_landmarks", type=int, required=True)
parser.add_argument("-d", "--limit_dimension", type=int, required=True)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -70,8 +71,8 @@ with open(args.file, 'r') as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
-
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
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 bc3b16ec..ed87806b 100755
--- a/src/cython/example/gudhi_graphical_tools_example.py
+++ b/src/cython/example/gudhi_graphical_tools_example.py
@@ -44,4 +44,11 @@ gudhi.plot_persistence_barcode(persistence)
print("#####################################################################")
print("Show diagram persistence example")
-gudhi.plot_persistence_diagram(persistence)
+pplot = gudhi.plot_persistence_diagram(persistence)
+pplot.show()
+
+print("#####################################################################")
+print("Show diagram persistence example with a confidence band")
+
+pplot = gudhi.plot_persistence_diagram(persistence, band_boot=0.2)
+pplot.show()
diff --git a/src/cython/example/persistence_representations_diagrams_example.py b/src/cython/example/persistence_representations_diagrams_example.py
deleted file mode 100755
index bd7452a0..00000000
--- a/src/cython/example/persistence_representations_diagrams_example.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-
-import gudhi
-import argparse
-
-"""This file is part of the Gudhi Library. The Gudhi library
- (Geometric Understanding in Higher Dimensions) is a generic C++
- library for computational topology.
-
- Author(s): Pawel Dlotko
-
- Copyright (C) 2017 Swansea University
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-__author__ = "Pawel Dlotko"
-__copyright__ = "Copyright (C) 2017 Swansea University"
-__license__ = "GPL v3"
-
-print("#####################################################################")
-print("Persistence representations diagrams example")
-
-
-parser = argparse.ArgumentParser(description='Statistics of persistence diagrams from file ',
- epilog='Example: '
- 'example/persistence_representations_diagrams_example.py '
- '-f file_with_diagram -d 1')
-parser.add_argument("-f", "--file", type=str, required=True)
-parser.add_argument("-d", "--dimension", type=int, default=0)
-
-args = parser.parse_args()
-
-print "Here are the parameters of the program: ",args.file," , " ,args.dimension
-
-p = gudhi.PersistenceIntervals(None,args.dimension,args.file);
-min_max_ = p.get_x_range();
-print "Birth-death range : ", min_max_
-
-dominant_ten_intervals_length = p.length_of_dominant_intervals(10)
-print "Length of ten dominant intervals : ", dominant_ten_intervals_length
-
-ten_dominant_intervals = p.dominant_intervals(10);
-print "Here are the dominant intervals : " , ten_dominant_intervals
-
-histogram = p.histogram_of_lengths(10);
-print "Here is the histogram of barcode's length : ", histogram
-
-cumulative_histogram = p.cumulative_histogram_of_lengths(10)
-print "Cumulative histogram : " ,cumulative_histogram
-
-char_funct_diag = p.characteristic_function_of_diagram(min_max_[0], min_max_[1],None)
-print "Characteristic function of diagram : ",char_funct_diag
-
-cumul_char_funct_diag = p.cumulative_characteristic_function_of_diagram(min_max_[0], min_max_[1],None)
-print "Cumulative characteristic function of diagram : ",cumul_char_funct_diag
-
-pbns = p.compute_persistent_betti_numbers()
-print "Persistence Betti numbers ", pbns
diff --git a/src/cython/example/persistence_representations_landscapes_example.py b/src/cython/example/persistence_representations_landscapes_example.py
deleted file mode 100755
index 94b68225..00000000
--- a/src/cython/example/persistence_representations_landscapes_example.py
+++ /dev/null
@@ -1,63 +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): Pawel Dlotko
-
- Copyright (C) 2017 Swansea University
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-__author__ = "Pawel Dlotko"
-__copyright__ = "Copyright (C) 2017 Swansea University"
-__license__ = "GPL v3"
-
-print("#####################################################################")
-print("Persistence representations landscapes example")
-
-persistence1 = [(1,2),(6,8),(0,4),(3,8)]
-persistence2 = [(2,9),(1,6),(3,5),(6,10)]
-
-
-#create two persistence landscapes based on persistence1 and persistence2:
-l1 = gudhi.PersistenceLandscapes(vector_of_intervals=persistence1, dimension=3)
-l2 = gudhi.PersistenceLandscapes(vector_of_intervals=persistence2)
-
-#This is how to compute integral of landscapes:
-print "Integral of the first landscape : ", l1.compute_integral_of_landscape()
-print "Integral of the second landscape : ", l2.compute_integral_of_landscape()
-
-#here are the maxima of the functions:
-print "Maximum of l1 : ", l1.compute_maximum()
-print "Maximum of l2 : ", l2.compute_maximum()
-
-#here are the norms of landscapes:
-print "L^1 Norm of l1 : ", l1.compute_norm_of_landscape(1.)
-print "L^1 Norm of l2 : ", l2.compute_norm_of_landscape(1.)
-
-#here is the average of landscapes:
-average = gudhi.PersistenceLandscapes()
-average.compute_average(to_average=[l1, l2])
-
-#here is the distance of landscapes:
-print "Distance : ", l1.distance(average,1)
-
-#here is the scalar product of landscapes:
-print "Scalar product : ", l1.compute_scalar_product(l2)
diff --git a/src/cython/example/persistence_representations_landscapes_on_grid_example.py b/src/cython/example/persistence_representations_landscapes_on_grid_example.py
deleted file mode 100755
index 60b0e873..00000000
--- a/src/cython/example/persistence_representations_landscapes_on_grid_example.py
+++ /dev/null
@@ -1,110 +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): Pawel Dlotko
-
- Copyright (C) 2017 Swansea University
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-__author__ = "Pawel Dlotko"
-__copyright__ = "Copyright (C) 2017 Swansea University"
-__license__ = "GPL v3"
-
-print("#####################################################################")
-print("Persistence representations landscapes on a grid example")
-
-persistence1 = [(1, 2),(6, 8),(0, 4),(3, 8)]
-persistence2 = [(2, 9),(1, 6),(3, 5),(6, 10)]
-
-#create two persistence landscapes based on persistence1 and persistence2:
-l1 = PersistenceLandscapeOnGrid(persistence1, 0, 11, 20)
-l2 = PersistenceLandscapeOnGrid(persistence2, 0, 11, 20)
-
-#This is how to compute integral of landscapes:
-print "Integral of the first landscape : " , l1.compute_integral_of_landscape()
-print "Integral of the second landscape : " , l2.compute_integral_of_landscape()
-
-#here are the maxima of the functions:
-print "Maximum of l1 : " , l1.compute_maximum()
-print "Maximum of l2 : " , l2.compute_maximum()
-
-#here are the norms of landscapes:
-print "L^1 Norm of l1 : " , l1.compute_norm_of_landscape(1.)
-print "L^1 Norm of l2 : " , l2.compute_norm_of_landscape(1.)
-
-#here is the average of landscapes:
-average = PersistenceLandscapeOnGrid();
-average.compute_average(to_average=[l1, l2]);
-
-
-#here is the distance of landscapes:
-print "Distance : " , l1.distance(l2)
-
-#here is the scalar product of landscapes:
-print "Scalar product : " , l1.compute_scalar_product(l2)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-persistence1 = [(1,2),(6,8),(0,4),(3,8)]
-persistence2 = [(2,9),(1,6),(3,5),(6,10)]
-
-
-#create two persistence landscapes based on persistence1 and persistence2:
-l1 = gudhi.PersistenceLandscapes(vector_of_intervals=persistence1, dimension=3)
-l2 = gudhi.PersistenceLandscapes(vector_of_intervals=persistence2)
-
-#This is how to compute integral of landscapes:
-print "Integral of the first landscape : ", l1.compute_integral_of_landscape()
-print "Integral of the second landscape : ", l2.compute_integral_of_landscape()
-
-#here are the maxima of the functions:
-print "Maximum of l1 : ", l1.compute_maximum()
-print "Maximum of l2 : ", l2.compute_maximum()
-
-#here are the norms of landscapes:
-print "L^1 Norm of l1 : ", l1.compute_norm_of_landscape(1.)
-print "L^1 Norm of l2 : ", l2.compute_norm_of_landscape(1.)
-
-#here is the average of landscapes:
-average = gudhi.PersistenceLandscapes()
-average.compute_average(to_average=[l1, l2])
-
-#here is the distance of landscapes:
-print "Distance : ", l1.distance(average,1)
-
-#here is the scalar product of landscapes:
-print "Scalar product : ", l1.compute_scalar_product(l2)
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 984dbf1b..3baebd17 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
@@ -39,6 +39,7 @@ parser = argparse.ArgumentParser(description='RipsComplex creation from '
parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-e", "--max_edge_length", type=float, default=0.5)
parser.add_argument("-d", "--max_dimension", type=int, default=1)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -61,4 +62,5 @@ print("betti_numbers()=")
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
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 4c21b98e..5951eedf 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
@@ -39,6 +39,7 @@ parser = argparse.ArgumentParser(description='RipsComplex creation from '
parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-e", "--max_edge_length", type=float, default=0.5)
parser.add_argument("-d", "--max_dimension", type=int, default=1)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -64,7 +65,8 @@ with open(args.file, 'r') as f:
print(simplex_tree.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
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 4e5cd2c8..9bfea41c 100755
--- a/src/cython/example/rips_persistence_diagram.py
+++ b/src/cython/example/rips_persistence_diagram.py
@@ -39,4 +39,5 @@ 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_persistence_diagram(diag)
+pplot = gudhi.plot_persistence_diagram(diag)
+pplot.show()
diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py
index 3af20fcf..51a60e73 100755
--- a/src/cython/example/simplex_tree_example.py
+++ b/src/cython/example/simplex_tree_example.py
@@ -48,11 +48,8 @@ if st.insert([0, 1, 2], filtration=4.0):
else:
print("Not inserted...")
-# FIXME: Remove this line
-st.set_dimension(3)
print("dimension=", st.dimension())
-st.set_filtration(4.0)
st.initialize_filtration()
print("filtration=", st.get_filtration())
print("filtration[1, 2]=", st.filtration([1, 2]))
diff --git a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py
index 4845eb47..6145e7f2 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
@@ -37,6 +37,7 @@ parser = argparse.ArgumentParser(description='TangentialComplex creation from '
'- Constructs a tangential complex with the '
'points from the given OFF file')
parser.add_argument("-f", "--file", type=str, required=True)
+parser.add_argument("-b", "--band_boot", type=float, default=0.)
parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams')
args = parser.parse_args()
@@ -59,7 +60,8 @@ with open(args.file, 'r') as f:
print(st.betti_numbers())
if args.no_diagram == False:
- gudhi.plot_persistence_diagram(diag)
+ pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot)
+ pplot.show()
else:
print(args.file, "is not a valid OFF file")