Skip to main content

Python bindings for Hera

Project description

Hera-TDA

Supported Python Versions PyPi License: BSD

Ubuntu Tests MacOS Tests

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 git@github.com: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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hera-tda-0.0.2.tar.gz (413.7 kB view hashes)

Uploaded Source

Built Distributions

hera_tda-0.0.2-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl (2.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.24+ x86-64

hera_tda-0.0.2-cp310-cp310-manylinux_2_24_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64

hera_tda-0.0.2-cp39-cp39-manylinux_2_24_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

hera_tda-0.0.2-cp38-cp38-manylinux_2_24_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

hera_tda-0.0.2-cp36-cp36m-manylinux_2_24_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.24+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page