Skip to main content

Python implementation persistent images representation of persistence diagrams.

Project description

PyPI version Build Status codecov License: MIT


Persim is a Python implementation of Persistence Images as first introduced in

It is designed to interface with Ripser, though any persistence diagram should work fine.


Currently, the only option is to install the library from source:

pip install persim


First, construct a diagram. In this example, we will use Ripser.

import numpy as np
from ripser import Rips
from sklearn import datasets

data = np.concatenate([150 * np.random.random((300,2)), 
                       10 + 10 * datasets.make_circles(n_samples=100)[0],
                       100 + 20 * datasets.make_circles(n_samples=100)[0]])

rips = Rips()
dgm = rips.fit_transform(data)
diagram = dgm[1] # Just diagram for H1

data and diagram

Then from this diagram, we construct the persistence image

from persim import PersImage

pim = PersImage()
img = pim.transform(diagram)

pers image of H1 diagram

Batch processing

If PersImage is given a list of diagrams, the dimensions will be the same for all resulting images. This is helpful if you want to process diagrams in batch and require them to be comparable.

diagrams = [rips.fit_transform(obs) for obs in observations]
imgs = pim.transform(diagrams)


Persistence Images were first introduced in Adams et al, 2017. Much of this work, an examples contained herein are inspired by the work of Obayashi and Hiraoka, 2017. Choices of weightings and general methods are often derived from Kusano, Fukumizu, and Yasuaki Hiraoka, 2016.

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
persim-0.0.6-py3-none-any.whl (4.6 kB) Copy SHA256 hash SHA256 Wheel py3 Jun 8, 2018
persim-0.0.6.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None Jun 8, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page