summaryrefslogtreecommitdiff
path: root/src/python/gudhi
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/gudhi')
-rw-r--r--src/python/gudhi/persistence_graphical_tools.py30
-rw-r--r--src/python/gudhi/point_cloud/knn.py4
-rw-r--r--src/python/gudhi/point_cloud/timedelay.py5
-rw-r--r--src/python/gudhi/representations/metrics.py4
-rw-r--r--src/python/gudhi/wasserstein/barycenter.py49
5 files changed, 42 insertions, 50 deletions
diff --git a/src/python/gudhi/persistence_graphical_tools.py b/src/python/gudhi/persistence_graphical_tools.py
index cc3db467..6a74a6ca 100644
--- a/src/python/gudhi/persistence_graphical_tools.py
+++ b/src/python/gudhi/persistence_graphical_tools.py
@@ -72,11 +72,11 @@ def plot_persistence_barcode(
"""This function plots the persistence bar code from persistence values list
, a np.array of shape (N x 2) (representing a diagram
in a single homology dimension),
- or from a :doc:`persistence file <fileformats>`.
+ or from a `persistence diagram <fileformats.html#persistence-diagram>`_ file.
:param persistence: Persistence intervals values list. Can be grouped by dimension or not.
:type persistence: an array of (dimension, array of (birth, death)) or an array of (birth, death).
- :param persistence_file: A :doc:`persistence file <fileformats>` style name
+ :param persistence_file: A `persistence diagram <fileformats.html#persistence-diagram>`_ file style name
(reset persistence if both are set).
:type persistence_file: string
:param alpha: barcode transparency value (0.0 transparent through 1.0
@@ -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
@@ -214,11 +213,11 @@ def plot_persistence_diagram(
):
"""This function plots the persistence diagram from persistence values
list, a np.array of shape (N x 2) representing a diagram in a single
- homology dimension, or from a :doc:`persistence file <fileformats>`.
+ homology dimension, or from a `persistence diagram <fileformats.html#persistence-diagram>`_ file`.
:param persistence: Persistence intervals values list. Can be grouped by dimension or not.
:type persistence: an array of (dimension, array of (birth, death)) or an array of (birth, death).
- :param persistence_file: A :doc:`persistence file <fileformats>` style name
+ :param persistence_file: A `persistence diagram <fileformats.html#persistence-diagram>`_ file style name
(reset persistence if both are set).
:type persistence_file: string
:param alpha: plot transparency value (0.0 transparent through 1.0
@@ -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
@@ -369,17 +368,19 @@ def plot_persistence_density(
"""This function plots the persistence density from persistence
values list, np.array of shape (N x 2) representing a diagram
in a single homology dimension,
- or from a :doc:`persistence file <fileformats>`. Be
- aware that this function does not distinguish the dimension, it is
+ or from a `persistence diagram <fileformats.html#persistence-diagram>`_ file.
+ Be aware that this function does not distinguish the dimension, it is
up to you to select the required one. This function also does not handle
degenerate data set (scipy correlation matrix inversion can fail).
+ :Requires: `SciPy <installation.html#scipy>`_
+
:param persistence: Persistence intervals values list.
Can be grouped by dimension or not.
:type persistence: an array of (dimension, array of (birth, death))
or an array of (birth, death).
- :param persistence_file: A :doc:`persistence file <fileformats>`
- style name (reset persistence if both are set).
+ :param persistence_file: A `persistence diagram <fileformats.html#persistence-diagram>`_
+ file style name (reset persistence if both are set).
:type persistence_file: string
:param nbins: Evaluate a gaussian kde on a regular grid of nbins x
nbins over data extents (default is 300)
@@ -425,8 +426,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 +439,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])
diff --git a/src/python/gudhi/point_cloud/knn.py b/src/python/gudhi/point_cloud/knn.py
index 34e80b5d..86008bc3 100644
--- a/src/python/gudhi/point_cloud/knn.py
+++ b/src/python/gudhi/point_cloud/knn.py
@@ -19,6 +19,10 @@ __license__ = "MIT"
class KNearestNeighbors:
"""
Class wrapping several implementations for computing the k nearest neighbors in a point set.
+
+ :Requires: `PyKeOps <installation.html#pykeops>`_, `SciPy <installation.html#scipy>`_,
+ `Scikit-learn <installation.html#scikit-learn>`_, and/or `Hnswlib <installation.html#hnswlib>`_
+ in function of the selected `implementation`.
"""
def __init__(self, k, return_index=True, return_distance=False, metric="euclidean", **kwargs):
diff --git a/src/python/gudhi/point_cloud/timedelay.py b/src/python/gudhi/point_cloud/timedelay.py
index f01df442..5292e752 100644
--- a/src/python/gudhi/point_cloud/timedelay.py
+++ b/src/python/gudhi/point_cloud/timedelay.py
@@ -10,9 +10,8 @@ import numpy as np
class TimeDelayEmbedding:
- """Point cloud transformation class.
- Embeds time-series data in the R^d according to [Takens' Embedding Theorem]
- (https://en.wikipedia.org/wiki/Takens%27s_theorem) and obtains the
+ """Point cloud transformation class. Embeds time-series data in the R^d according to
+ `Takens' Embedding Theorem <https://en.wikipedia.org/wiki/Takens%27s_theorem>`_ and obtains the
coordinates of each point.
Parameters
diff --git a/src/python/gudhi/representations/metrics.py b/src/python/gudhi/representations/metrics.py
index ce416fb1..8a32f7e9 100644
--- a/src/python/gudhi/representations/metrics.py
+++ b/src/python/gudhi/representations/metrics.py
@@ -223,7 +223,9 @@ class SlicedWassersteinDistance(BaseEstimator, TransformerMixin):
class BottleneckDistance(BaseEstimator, TransformerMixin):
"""
- This is a class for computing the bottleneck distance matrix from a list of persistence diagrams.
+ This is a class for computing the bottleneck distance matrix from a list of persistence diagrams.
+
+ :Requires: `CGAL <installation.html#cgal>`_ :math:`\geq` 4.11.0
"""
def __init__(self, epsilon=None):
"""
diff --git a/src/python/gudhi/wasserstein/barycenter.py b/src/python/gudhi/wasserstein/barycenter.py
index de7aea81..d67bcde7 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,26 @@ 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
@@ -156,4 +144,3 @@ def lagrangian_barycenter(pdiagset, init=None, verbose=False):
return Y, log
else:
return Y
-