Persistent Homology Algorithm Toolkit

Contents:

PHAT Python API reference

Bindings for the Persistent Homology Algorithm Toolbox

PHAT is a tool for algebraic topology. It can be used via phat.py to compute persistent (co)homology from boundary matrices, using various reduction algorithms and column data representations.

Here is a simple example of usage.

We will build an ordered boundary matrix of this simplicial complex consisting of a single triangle:

 3
 |\
 | \
 |  \
 |   \ 4
5|    \
 |     \
 |  6   \
 |       \
 |________\
 0    2    1

Now the code:

import phat

# define a boundary matrix with the chosen internal representation
boundary_matrix = phat.boundary_matrix(representation = phat.representations.vector_vector)

# set the respective columns -- (dimension, boundary) pairs
boundary_matrix.columns = [ (0, []),
                            (0, []),
                            (1, [0,1]),
                            (0, []),
                            (1, [1,3]),
                            (1, [0,3]),
                            (2, [2,4,5])]

# or equivalently,
# boundary_matrix = phat.boundary_matrix(representation = ...,
#                                        columns = ...)
# would combine the creation of the matrix and
# the assignment of the columns

# print some information of the boundary matrix:
print()
print("The boundary matrix has %d columns:" % len(boundary_matrix.columns))
for col in boundary_matrix.columns:
    s = "Column %d represents a cell of dimension %d." % (col.index, col.dimension)
    if (col.boundary):
        s = s + " Its boundary consists of the cells " + " ".join([str(c) for c in col.boundary])
    print(s)
print("Overall, the boundary matrix has %d entries." % len(boundary_matrix))

pairs = boundary_matrix.compute_persistence_pairs()

pairs.sort()

print()
print("There are %d persistence pairs: " % len(pairs))
for pair in pairs:
    print("Birth: %d, Death: %d" % pair)

Please see https://bitbucket.org/phat-code/phat/python for more information.

class phat.boundary_matrix(representation=<representations.bit_tree_pivot_column: 1>, source=None, columns=None)

Boundary matrices that store the shape information of a cell complex.

columns

A collection of column objects

compute_persistence_pairs(reduction=<reductions.twist_reduction: 1>)

Computes persistence pairs (birth, death) for the given boundary matrix.

compute_persistence_pairs_dualized(reduction=<reductions.twist_reduction: 1>)

Computes persistence pairs (birth, death) from the dualized form of the given boundary matrix.

convert(representation)

Copy this matrix to another with a different representation

dimensions

A collection of dimensions, equivalent to [c.dimension for c in self.columns]

load(file_name, mode='b')

Load this boundary matrix from a file

Parameters:
  • file_name (string) – The file name to load
  • mode (string, optional (defaults to 'b')) – The mode (‘b’ for binary, ‘t’ for text) to use for working with the file
Returns:

success

Return type:

bool

save(file_name, mode='b')

Save this boundary matrix to a file

Parameters:
  • file_name (string) – The file name to load
  • mode (string, optional (defaults to 'b')) – The mode (‘b’ for binary, ‘t’ for text) to use for working with the file
Returns:

success

Return type:

bool

class phat.representations

Available representations for internal storage of columns in a boundary_matrix

class phat.reductions

Available reduction algorithms

class _phat.persistence_pairs
append_pair(self : _phat.persistence_pairs, birth : int, death : int) → NoneType

Appends a single (birth, death) pair

clear(_phat.persistence_pairs) → NoneType

Empties the collection

load_ascii(_phat.persistence_pairs, str) → bool

Load the contents of a text file into this instance

load_binary(_phat.persistence_pairs, str) → bool

Load the contents of a binary file into this instance

save_ascii(_phat.persistence_pairs, str) → bool

Save this instance to a text file

save_binary(_phat.persistence_pairs, str) → bool

Save the contents of this instance to a binary file

set_pair(self : _phat.persistence_pairs, index : int, birth : int, death : int) → NoneType

Sets the (birth, death) pair at a given index

sort(_phat.persistence_pairs) → NoneType

Sort in place


Modules:

Indices and tables