API

The following classes and functions live in the dionysus module.

Filtration

class Simplex

an abstract simplex

__contains__(self: dionysus._dionysus.Simplex, v: int) → bool

test whether the simplex contains given vertex

__getitem__(self: dionysus._dionysus.Simplex, i: int) → int

access i-th vertex

__iter__(self: dionysus._dionysus.Simplex) → iterator

iterator over the vertices

__len__(self: dionysus._dionysus.Simplex) → int

simplex cardinality

boundary(self: object) → dionysus._dionysus.SimplexBoundaryIterator

returns iterator over the boundary of the simplex

data

access the data associated to the simplex

dimension(self: dionysus._dionysus.Simplex) → int

simplex dimension, one less than cardinality

join(self: dionysus._dionysus.Simplex, v: int) → dionysus._dionysus.Simplex

join a simplex and a vertex

class Filtration

store an ordered sequence of simplices, providing lookup

__contains__(self: dionysus._dionysus.Filtration, arg0: dionysus._dionysus.Simplex) → bool

test whether filtration contains the simplex

__getitem__(self: dionysus._dionysus.Filtration, arg0: int) → dionysus._dionysus.Simplex

access the simplex at the given index

__iter__(self: dionysus._dionysus.Filtration) → iterator

iterate over the simplices in sorted order

__len__(self: dionysus._dionysus.Filtration) → int

size of the filtration

add(self: dionysus._dionysus.Filtration, s: dionysus._dionysus.Simplex) → int

append simplex to the filtration, if not already in the filtration; either way return the index of the simplex

append(self: dionysus._dionysus.Filtration, s: dionysus._dionysus.Simplex) → None

append simplex to the filtration

index(self: dionysus._dionysus.Filtration, s: dionysus._dionysus.Simplex) → int

find the ordered index of a simplex in the filtration

sort(*args, **kwargs)

Overloaded function.

  1. sort(self: dionysus._dionysus.Filtration, reverse: bool=False) -> None

sort the filtration with respect to data, breaking ties using dimension, and then lexicographically

  1. sort(self: dionysus._dionysus.Filtration, cmp: Callable[[dionysus._dionysus.Simplex, dionysus._dionysus.Simplex], int], reverse: bool=False) -> None

sort the filtration with respect to the given functor

fill_rips(data: array, k: int, r: float) → dionysus._dionysus.Filtration

returns (sorted) filtration filled with the k-skeleton of the clique complex built on the points at distance at most r from each other

closure(simplices, k)

Compute the k-skeleton of the closure of the list of simplices.

fill_freudenthal(data: array, reverse: bool=False) → dionysus._dionysus.Filtration

returns (sorted) lower-star (or upper-star if reverse = True) filtration filled with the Freudenthal triangulation of the grid in the array data

Persistence

homology_persistence(*args, **kwargs)

Overloaded function.

  1. homology_persistence(filtration: dionysus._dionysus.Filtration, prime: int=2L, method: unicode=u’clearing’) -> dionysus::ReducedMatrix<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >

compute homology persistence of the filtration (pair simplices); method is one of clearing, row, column, or column_no_negative

  1. homology_persistence(filtration: dionysus._dionysus.Filtration, relative: dionysus._dionysus.Filtration, prime: int=2L, method: unicode=u’clearing’) -> dionysus::ReducedMatrix<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >

compute homology persistence of the filtration, relative to a subcomplex; method is one of clearing, row, column, or column_no_negative

cohomology_persistence(filtration: dionysus._dionysus.Filtration, prime: int=2L, keep_cocycles: bool=False) → dionysus::PairChainRecorder<dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> > >

compute cohomology persistence of the filtration

omnifield_homology_persistence(filtration: dionysus._dionysus.Filtration) → dionysus::OmniFieldPersistence<unsigned int, std::__1::less<unsigned int> >

compute homology persistence of the filtration (pair simplices) over all fields at once

zigzag_homology_persistence(filtration: dionysus._dionysus.Filtration, times: List[List[float]], prime: int=2L) → Tuple[dionysus::ZigzagPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >, List[dionysus::Diagram<float, unsigned int>]]

compute zigzag homology persistence of the filtration with respect to the given times

Parameters:
  • filtration – an instance of Filtration with the set of simplices used in the zigzag construction
  • times – a list of lists; the outer list runs parallel with the filtration; the inner list specifies for each simplex when it enters and leaves the zigzag (even entries, starting the indexing from 0, are interpreted as appearance times, odd entires as disappearance)
  • prime – prime modulo which to perform computation
Returns:

A pair. The first element is an instance of ZigzagPersistence, which offers access to the cycles alive at the end of the zigzag; the second is a list of persistence diagrams.

Diagrams

init_diagrams(*args, **kwargs)

Overloaded function.

  1. init_diagrams(m: dionysus::ReducedMatrix<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >, f: dionysus._dionysus.Filtration) -> List[dionysus::Diagram<float, unsigned int>]

initialize diagrams from reduced matrix and filtration

  1. init_diagrams(m: dionysus::PairChainRecorder<dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> > >, f: dionysus._dionysus.Filtration) -> List[dionysus::Diagram<float, unsigned int>]

initialize diagrams from cohomology persistence and filtration

  1. init_diagrams(ofp: dionysus::OmniFieldPersistence<unsigned int, std::__1::less<unsigned int> >, f: dionysus._dionysus.Filtration, p: int) -> List[dionysus::Diagram<float, unsigned int>]

initialize diagrams for a specific prime from omnifield persistence and filtration

class Diagram

persistence diagram

__iter__(self: dionysus._dionysus.Diagram) → iterator

iterate over the points of the diagram

__len__(self: dionysus._dionysus.Diagram) → int

size of the diagram

append(self: dionysus._dionysus.Diagram, p: dionysus::Diagram<float, unsigned int>::Point) → None

append point to the diagram

class DiagramPoint

persistence diagram point

birth

birth value

data

auxiliary data associated to the point (e.g., birth index)

death

death value

wasserstein_distance(dgm1: dionysus._dionysus.Diagram, dgm2: dionysus._dionysus.Diagram, q: int=2L, delta: float=0.01, internal_p: float=inf, initial_eps: float=0.0, eps_factor: float=0.0) → float

compute Wasserstein distance between two persistence diagrams

Matrices

class Chain

chain of indices (formal sum with coefficients in Zp)

__eq__(self: dionysus._dionysus.Chain, arg0: dionysus._dionysus.Chain) → bool

equality comparison

__getitem__(self: dionysus._dionysus.Chain, arg0: int) → dionysus::ChainEntry<dionysus::ZpField<long>, unsigned int>

access the entry at a given index

__iter__(self: dionysus._dionysus.Chain) → iterator

iterate over the entries of the chain

__len__(self: dionysus._dionysus.Chain) → int

size of the chain

__ne__(self: dionysus._dionysus.Chain, arg0: dionysus._dionysus.Chain) → bool

nonequal comparison

class ChainEntry

(coefficient, index) entry in a chain)

element

coefficient of the chain element

index

index of the chain element

class ReducedMatrix

matrix, where each column has a lowest non-zero entry in a unique row; supports iteration and indexing

__getitem__(self: dionysus._dionysus.ReducedMatrix, arg0: int) → std::__1::vector<dionysus::ChainEntry<dionysus::ZpField<long>, unsigned int>, std::__1::allocator<dionysus::ChainEntry<dionysus::ZpField<long>, unsigned int> > >

access the column at a given index

__iter__(self: dionysus._dionysus.ReducedMatrix) → iterator

iterate over the columns of the matrix

__len__(self: dionysus._dionysus.ReducedMatrix) → int

size of the matrix

pair(self: dionysus._dionysus.ReducedMatrix, arg0: int) → int

pair of the given index

unpaired

index representing lack of pair

class OmniFieldPersistence

compact composition of multiple reduced matrices

__len__(self: dionysus._dionysus.OmniFieldPersistence) → int

size of the persistence object

column(self: dionysus._dionysus.OmniFieldPersistence, arg0: int, arg1: int) → dionysus._dionysus.Chain

get the column over a specific prime

primes(self: dionysus._dionysus.OmniFieldPersistence) → List[int]

primes over which the matrix differs from the rest

special(self: dionysus._dionysus.OmniFieldPersistence, arg0: int, arg1: int) → bool

test whether the column has a special value over the given prime

class CoChain

chain of indices (formal sum with coefficients in Zp)

__eq__(self: dionysus._dionysus.CoChain, arg0: dionysus._dionysus.CoChain) → bool

equality comparison

__getitem__(self: dionysus._dionysus.CoChain, arg0: int) → dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >::Entry

access the entry at a given index

__iter__(self: dionysus._dionysus.CoChain) → iterator

iterate over the entries of the chain

__len__(self: dionysus._dionysus.CoChain) → int

size of the chain

__ne__(self: dionysus._dionysus.CoChain, arg0: dionysus._dionysus.CoChain) → bool

nonequal comparison

class CoChainEntry

(coefficient, index) entry in a chain)

element

coefficient of the chain element

index

index of the chain element

class CohomologyPersistenceColumnHead

Wrapper around columns in CohomologyPersistence.

cocycle

still alive cocycle

index

index when the column was added

class CohomologyPersistence

representation of pairs and alive cocycles

__iter__(self: dionysus._dionysus.CohomologyPersistence) → iterator

iterate over the column heads of the matrix

__len__(self: dionysus::PairRecorder<dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> > >) → int

size of the matrix

cocycle(self: dionysus._dionysus.CohomologyPersistence, arg0: int) → std::__1::vector<dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >::Entry, std::__1::allocator<dionysus::CohomologyPersistence<dionysus::ZpField<long>, unsigned int, std::__1::less<unsigned int> >::Entry> >

cocycle that died with the addition of the cell at the given index

pair(self: dionysus._dionysus.CohomologyPersistence, arg0: int) → int

pair of the given index

unpaired

index representing lack of pair

class ZigzagPersistence

representation of the current homology basis

__iter__(self: dionysus._dionysus.ZigzagPersistence) → iterator

iterator over the alive cycles

__len__(self: dionysus._dionysus.ZigzagPersistence) → int

number of alive cycles

class Zp

arithmetic mod p

Plotting

The following functions live in dionysus.plot module.

plot_diagram(dgm, show=False)

Plot the persistence diagram.

plot_bars(dgm, order='birth', show=False)

Plot the barcode.

plot_diagram_density(dgm, bins=200, lognorm=True, diagonal=True, show=False)

Plot the histogram of point density.