From 9e9511152a0495d123091d04af264e187fc6ab21 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Sat, 25 Apr 2020 11:02:14 +0200 Subject: Fix #259 --- src/python/gudhi/persistence_graphical_tools.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py index cc3db467..03fc9066 100644 --- a/src/python/gudhi/persistence_graphical_tools.py +++ b/src/python/gudhi/persistence_graphical_tools.py @@ -109,9 +109,6 @@ 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 @@ -126,6 +123,8 @@ def plot_persistence_barcode( print("file " + persistence_file + " not found.") return None + persistence = _array_handler(persistence) + if max_barcodes != 1000: print("Deprecated parameter. It has been replaced by max_intervals") max_intervals = max_barcodes @@ -255,8 +254,6 @@ 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): # Reset persistence @@ -271,6 +268,8 @@ def plot_persistence_diagram( print("file " + persistence_file + " not found.") return None + persistence = _array_handler(persistence) + if max_plots != 1000: print("Deprecated parameter. It has been replaced by max_intervals") max_intervals = max_plots @@ -425,8 +424,6 @@ 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: # All dimension case @@ -440,6 +437,7 @@ def plot_persistence_density( return None if len(persistence) > 0: + persistence = _array_handler(persistence) persistence_dim = np.array( [ (dim_interval[1][0], dim_interval[1][1]) -- cgit v1.2.3 From ae80ba10d9bf333a418b255e72c0be2a3c7e73ae Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Sun, 26 Apr 2020 09:16:31 +0200 Subject: Fix alpha complex user sphinx warnings as sphinx was confusing bullet lists and bold font syntax --- src/python/doc/alpha_complex_user.rst | 39 +++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index a3b35c10..60a2f94e 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -89,25 +89,28 @@ In order to build the alpha complex, first, a Simplex tree is built from the cel Filtration value computation algorithm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - **for** i : dimension :math:`\rightarrow` 0 **do** - **for all** :math:`\sigma` of dimension i - **if** filtration(:math:`\sigma`) is NaN **then** - filtration(:math:`\sigma`) = :math:`\alpha^2(\sigma)` - **end if** +.. code-block:: bash + + for i : dimension → 0 do + for all σ of dimension i + if filtration(σ) is NaN then + filtration(σ)=α2(σ) + end if + for all τ face of σ do // propagate alpha filtration value + if filtration(τ) is not NaN then + filtration(τ) = min( filtration(τ), filtration(σ) ) + else + if τ is not Gabriel for σ then + filtration(τ) = filtration(σ) + end if + end if + end for + end for + end for + + make_filtration_non_decreasing() + prune_above_filtration() - *//propagate alpha filtration value* - - **for all** :math:`\tau` face of :math:`\sigma` - **if** filtration(:math:`\tau`) is not NaN **then** - filtration(:math:`\tau`) = filtration(:math:`\sigma`) - **end if** - **end for** - **end for** - **end for** - - make_filtration_non_decreasing() - - prune_above_filtration() Dimension 2 ^^^^^^^^^^^ -- cgit v1.2.3 From f47b9607519b5c8c89bbe40341cf5bcc1382f5ef Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Sun, 26 Apr 2020 10:08:29 +0200 Subject: Fix barycenter sphinx warnings --- src/python/doc/alpha_complex_user.rst | 2 +- src/python/gudhi/wasserstein/barycenter.py | 53 +++++++++++++----------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index 60a2f94e..02d85389 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -94,7 +94,7 @@ Filtration value computation algorithm for i : dimension → 0 do for all σ of dimension i if filtration(σ) is NaN then - filtration(σ)=α2(σ) + filtration(σ)=α²(σ) end if for all τ face of σ do // propagate alpha filtration value if filtration(τ) is not NaN then diff --git a/src/python/gudhi/wasserstein/barycenter.py b/src/python/gudhi/wasserstein/barycenter.py index de7aea81..1cf8edb3 100644 --- a/src/python/gudhi/wasserstein/barycenter.py +++ b/src/python/gudhi/wasserstein/barycenter.py @@ -18,8 +18,7 @@ from gudhi.wasserstein import wasserstein_distance def _mean(x, m): ''' :param x: a list of 2D-points, off diagonal, x_0... x_{k-1} - :param m: total amount of points taken into account, - that is we have (m-k) copies of diagonal + :param m: total amount of points taken into account, that is we have (m-k) copies of diagonal :returns: the weighted mean of x with (m-k) copies of the diagonal ''' k = len(x) @@ -33,37 +32,31 @@ def _mean(x, m): def lagrangian_barycenter(pdiagset, init=None, verbose=False): ''' - :param pdiagset: a list of ``numpy.array`` of shape `(n x 2)` - (`n` can variate), encoding a set of - persistence diagrams with only finite coordinates. + :param pdiagset: a list of ``numpy.array`` of shape `(n x 2)` (`n` can variate), encoding a set of persistence + diagrams with only finite coordinates. :param init: The initial value for barycenter estimate. - If ``None``, init is made on a random diagram from the dataset. - Otherwise, it can be an ``int`` - (then initialization is made on ``pdiagset[init]``) - or a `(n x 2)` ``numpy.array`` enconding - a persistence diagram with `n` points. + If ``None``, init is made on a random diagram from the dataset. + Otherwise, it can be an ``int`` (then initialization is made on ``pdiagset[init]``) + or a `(n x 2)` ``numpy.array`` enconding a persistence diagram with `n` points. :type init: ``int``, or (n x 2) ``np.array`` - :param verbose: if ``True``, returns additional information about the - barycenter. + :param verbose: if ``True``, returns additional information about the barycenter. :type verbose: boolean - :returns: If not verbose (default), a ``numpy.array`` encoding - the barycenter estimate of pdiagset - (local minimum of the energy function). - If ``pdiagset`` is empty, returns ``None``. - If verbose, returns a couple ``(Y, log)`` - where ``Y`` is the barycenter estimate, - and ``log`` is a ``dict`` that contains additional informations: - - - `"groupings"`, a list of list of pairs ``(i,j)``. - Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates - that ``pdiagset[k][i]`` is matched to ``Y[j]`` - if ``i = -1`` or ``j = -1``, it means they - represent the diagonal. - - - `"energy"`, ``float`` representing the Frechet energy value obtained. - It is the mean of squared distances of observations to the output. - - - `"nb_iter"`, ``int`` number of iterations performed before convergence of the algorithm. + :returns: If not verbose (default), a ``numpy.array`` encoding the barycenter estimate of pdiagset + (local minimum of the energy function). + If ``pdiagset`` is empty, returns ``None``. + If verbose, returns a couple ``(Y, log)`` where ``Y`` is the barycenter estimate, + and ``log`` is a ``dict`` that contains additional informations: + + - `"groupings"`, a list of list of pairs ``(i,j)``. + + Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates that ``pdiagset[k][i]`` is matched to ``Y[j]`` + if ``i = -1`` or ``j = -1``, it means they represent the diagonal. + + - `"energy"`, ``float`` representing the Frechet energy value obtained. + + It is the mean of squared distances of observations to the output. + + - `"nb_iter"`, ``int`` number of iterations performed before convergence of the algorithm. ''' X = pdiagset # to shorten notations, not a copy m = len(X) # number of diagrams we are averaging -- cgit v1.2.3 From 88043e6b9da458eee7bdb0b9793f94a4e7d0aaa0 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Sun, 26 Apr 2020 10:24:30 +0200 Subject: vim code block has a better highlighting code --- src/python/doc/alpha_complex_user.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index 02d85389..ec218969 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -89,7 +89,7 @@ In order to build the alpha complex, first, a Simplex tree is built from the cel Filtration value computation algorithm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. code-block:: bash +.. code-block:: vim for i : dimension → 0 do for all σ of dimension i -- cgit v1.2.3 From 484732c8ad30721ba4fa596bcb8a3835ad3bc431 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 27 Apr 2020 07:06:16 +0200 Subject: lint pseudo code --- src/python/doc/alpha_complex_user.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index ec218969..de706de9 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -94,7 +94,7 @@ Filtration value computation algorithm for i : dimension → 0 do for all σ of dimension i if filtration(σ) is NaN then - filtration(σ)=α²(σ) + filtration(σ) = α²(σ) end if for all τ face of σ do // propagate alpha filtration value if filtration(τ) is not NaN then -- cgit v1.2.3 From 627772e4c5bc7038b0814182dbb918b08356c892 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Mon, 11 May 2020 08:42:40 +0200 Subject: Fixed by @tlacombe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Théo Lacombe --- src/python/gudhi/wasserstein/barycenter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/python/gudhi/wasserstein/barycenter.py b/src/python/gudhi/wasserstein/barycenter.py index 1cf8edb3..7eeeae7a 100644 --- a/src/python/gudhi/wasserstein/barycenter.py +++ b/src/python/gudhi/wasserstein/barycenter.py @@ -52,9 +52,7 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates that ``pdiagset[k][i]`` is matched to ``Y[j]`` if ``i = -1`` or ``j = -1``, it means they represent the diagonal. - - `"energy"`, ``float`` representing the Frechet energy value obtained. - - It is the mean of squared distances of observations to the output. + - `"energy"`, ``float`` representing the Frechet energy value obtained. It is the mean of squared distances of observations to the output. - `"nb_iter"`, ``int`` number of iterations performed before convergence of the algorithm. ''' @@ -149,4 +147,3 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): return Y, log else: return Y - -- cgit v1.2.3 From 779e4c4e8225e279ef8322988d4d06a6c2e06529 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Mon, 11 May 2020 08:43:06 +0200 Subject: Fixed by @tlacombe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Théo Lacombe --- src/python/gudhi/wasserstein/barycenter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/python/gudhi/wasserstein/barycenter.py b/src/python/gudhi/wasserstein/barycenter.py index 7eeeae7a..d67bcde7 100644 --- a/src/python/gudhi/wasserstein/barycenter.py +++ b/src/python/gudhi/wasserstein/barycenter.py @@ -47,10 +47,7 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False): If verbose, returns a couple ``(Y, log)`` where ``Y`` is the barycenter estimate, and ``log`` is a ``dict`` that contains additional informations: - - `"groupings"`, a list of list of pairs ``(i,j)``. - - Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates that ``pdiagset[k][i]`` is matched to ``Y[j]`` - if ``i = -1`` or ``j = -1``, it means they represent the diagonal. + - `"groupings"`, a list of list of pairs ``(i,j)``. Namely, ``G[k] = [...(i, j)...]``, where ``(i,j)`` indicates that `pdiagset[k][i]`` is matched to ``Y[j]`` if ``i = -1`` or ``j = -1``, it means they represent the diagonal. - `"energy"`, ``float`` representing the Frechet energy value obtained. It is the mean of squared distances of observations to the output. -- cgit v1.2.3