From efae8ff48c6b6e4d29afea753b7a1ddee0925ad4 Mon Sep 17 00:00:00 2001 From: tlacombe Date: Tue, 3 Mar 2020 16:44:58 +0100 Subject: handle numpy array, should now adapt the doc --- src/python/gudhi/persistence_graphical_tools.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/python/gudhi/persistence_graphical_tools.py') diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py index 8ddfdba8..43776fc6 100644 --- a/src/python/gudhi/persistence_graphical_tools.py +++ b/src/python/gudhi/persistence_graphical_tools.py @@ -45,6 +45,13 @@ def __min_birth_max_death(persistence, band=0.0): return (min_birth, max_death) +def _array_handler(a): + if isinstance(a, np.ndarray): + return [[0, x] for x in a] + else: + return a + + def plot_persistence_barcode( persistence=[], persistence_file="", @@ -95,6 +102,9 @@ def plot_persistence_barcode( plt.rc('text', usetex=True) plt.rc('font', family='serif') + + persistence = _array_handler(persistence) + if persistence_file != "": if path.isfile(persistence_file): # Reset persistence @@ -237,6 +247,7 @@ def plot_persistence_diagram( plt.rc('text', usetex=True) plt.rc('font', family='serif') + persistence = _array_handler(persistence) if persistence_file != "": if path.isfile(persistence_file): @@ -399,6 +410,7 @@ def plot_persistence_density( plt.rc('text', usetex=True) plt.rc('font', family='serif') + persistence = _array_handler(persistence) if persistence_file != "": if dimension is None: -- cgit v1.2.3