author Dmitriy Morozov <>
Sat, 23 Nov 2019 21:29:50 -0800
changeset 294 5810d70ec967
parent 249 0c5c45ebbf97
permissions -rw-r--r--
Get rid of Boost.Signals dependency

:class:`PersistenceDiagram` class

.. class:: PersistenceDiagram

    .. method:: __init__( dimension )

        Initializes : an empty( no points ) :class:`PersistenceDiagram` object and sets
        the :attr:`~PersistenceDiagram.dimension` attribute( must be integer ) e.g.::

            dia = PersistenceDiagram( 1 )

    .. method:: __init__( dimension, point_seq )

        Initializes :class:`PersistenceDiagram` of specified dimension from the given sequence `seq` of tuples, e.g.::

            dia = PersistenceDiagram( 1, (1,2) )

        The tuples must have at least 2 elements ``(birth, death)``.
        If there is a third element, it is stored as extra data associated to
        a point.

    .. method:: append( p )

        Adds point `p` to the persistence diagram.

    .. attribute:: dimension

        Dimension of the persistence diagram. Must be an integer. Must be set at initialization.

    .. method:: __iter__( )

        Iterator over the points in the persistence diagram,

            for p in dia: print p

    .. method:: __len__( )

        :returns: The number of points in the diagram.

Utility functions for persistence diagrams

.. function:: init_diagrams(persistence, filtration[, eval = lambda s:[, data = lambda i: None]])

    Initializes a collection of :class:`PersistenceDiagram` instances from `persistence`
    and `filtration`. Optional `eval` can determine how to extract birth and
    death values from a simplex. For example, if `filtration` was filled using
    :func:`fill_alpha_complex()`, the :attr:`` contains a pair ``(value, critical)``.
    We can extract the ``value`` from the tuple::

        init_diagrams(persistence, filtration, lambda s:[0])

    Optional `data` argument can return arbitrary data to associate with each point,
    given an node of `persistence`.

.. function:: bottleneck_distance(dia1, dia2)

    Calculates the bottleneck distance between the two persistence diagrams.

.. function:: wasserstein_distance(dia1, dia2, p)

    Calculates the `p`-th Wasserstein distance between the two persistence diagrams.