Last updated:
0 purchases
heratda 0.0.2
Hera-TDA
Python bindings for Hera, a library for fast calculation of bottleneck distance and Wasserstein distance on persistence diagrams.
These bindings can be used with standard Python types (lists of lists). These bindings are also compatible with BATS.
Note that Hera is also used in Dionysus 2 for bottleneck distance computation.
Installation
You first need to install boost headers for Hera
dnf install boost-devel # fedora
pip install
pip install hera-tda
This will compile binaries.
Build from source
Then, do a recursive clone for submodules
git clone --recursive [email protected]:CompTop/pyhera.git
then you can install to your Python environment
python setup.py install
Basic Example
Bottleneck Distance
After installation, the package is available under the hera_tda namespace.
import hera_tda as hera
import hera_tda.bottleneck
pX = [[1.0, 2.0], [2.0,3.0]] # diagram 1
pY = [[1.1, 2.1], [2.1, 3.1]] # diagram 2
d, inds = hera.bottleneck.BottleneckDistance(pX, pY)
# d = 0.1
d is the computed bottleneck distance
inds is a tuple containing the indices of pX and pY that were the maximum-weight matching (-1 is used to indicate a diagonal point).
Wasserstein Distance
from hera_tda.wasserstein import WassersteinDistance
pX = [[1.0, 2.0], [2.0,3.0]]
pY = [[1.1, 2.1], [2.1, 3.1]]
p = 2.0 # wasserstein-p
d = WassersteinDistance(pX, pY, p)
# d = 0.1414...
WassersteinDistance just returns the distance. There is no matching.
Additional Examples
See demo.ipynb and wasserstein.ipynb
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.