The Diagram Class

class pdsketch.Diagram(points=(), mass: [] = None)

A class to store persistence diagrams. Main input is a set of points in the persistence plane with optional multiplicity. This implementation is a multiset.

Parameters
  • points (list) – The points in the the persistence diagram

  • mass (list) – The corresponding multiplicity of points

add(point, mass: int = 1)

Add a point to the diagram with multiplicity.

clear()

Remove all points from the diagram.

get_point_mass_lists()

Returns a tuple of lists. The first list contains all points in the diagram in PDPoint format. The second list contains all corresponding multiplicities.

Note: The diagonal is ignored.

load_from_file()

Loads a diagram from a text file. Format for ith line: b_i d_i; mass_i where (b_i, d_i) is the ith point in the diagram with multiplicity mass_i. The mass is optional.

points()

Return a list of points in the diagram.

remove(point: pdsketch.pdpoint.PDPoint)

Remove a point from the diagram.

save_to_file(filename: str = 'diagram.txt')

Save current diagram to a text file. Format for ith line: b_i d_i; mass_i where (b_i, d_i) is the ith point in the diagram with multiplicity mass_i.