Python Bindings
The current bindings are exposed in the Python lophat package. For more information, please see the repository.
- lophat.compute_pairings(matrix, anti_transpose=True, options=None)
Decomposes the input matrix, using the lockfree algorithm.
- Parameters:
matrix (List[Tuple[int, List[int]]] | Iterator[Tuple[int, List[int]]]) – The boundary matrix, provided in sparse column format. Each column is a tuple of (dimension, boundary) where boundary is the list of non-zero indices.
anti_transpose (bool) – Whether to anti-transpose the matrix first; best left True with clearing on. Set to False if input matrix non-square.
options (LoPhatOptions) – Options to control the R=DV decomposition algorithm.
- Returns:
The persistence pairings read off from the R=DV decomposition.
- Return type:
- lophat.compute_pairings_with_reps(matrix, options=None)
Decomposes the input matrix, using the lockfree algorithm. Additionally returns representatives of the pairings found. Note that options will be overwritten to ensure that V is maintained in the decomposition.
- Parameters:
matrix (List[Tuple[int, List[int]]] | Iterator[Tuple[int, List[int]]]) – The boundary matrix, provided in sparse column format. Each column is a tuple of (dimension, boundary) where boundary is the list of non-zero indices.
options (LoPhatOptions) – Options to control the R=DV decomposition algorithm.
- Returns:
The persistence pairings read off from the R=DV decomposition.
- Return type:
- class lophat.LoPhatOptions(maintain_v=False, num_threads=0, column_height=None, max_chunk_len=1, clearing=True)
A class representing the persistence diagram computed by LoPHAT. Each column index in the input matrix appears exactly once, either in a pairing or as unpaired.
- Parameters:
maintain_v (bool) – Whether to maintain_v during decompositon, usually best left False.
num_threads (int) – Max number of threads to use. Set at 0 to use all threads.
column_height (int | None) – Optional hint to height of columns. If None, assumed that matrix is square.
min_chunk_len (int) – When splitting work, don’t reduce chunks to smaller than this size.
clearing (bool) – Whether to employ the clearing optimisation. Cannot use if input non-square.
- class lophat.PersistenceDiagram
A class representing the persistence diagram computed by LoPHAT. Each column index in the input matrix appears exactly once, either in a pairing or as unpaired.
- Parameters:
unpaired (Set[int]) – The set of input column indices that were not paired in the R=DV decomposition.
paired (Set[Tuple[int, int]]) – The set of (birth, death) pairs of column indices that were paired in the R=DV decomposition.
- class lophat.PersistenceDiagramWithReps
A class representing the persistence diagram computed by LoPHAT. Each column index in the input matrix appears exactly once, either in a pairing or as unpaired. For each (paired or unpaired) feature, a representative is stored in the same index in the corresponding list of representatives.
- Parameters:
unpaired (List[int]) – The list of input column indices that were not paired in the R=DV decomposition.
unpaired_reps (List[List[int]]) – A list of representatives for each of the unpaired features.
paired (List[Tuple[int, int]]) – The list of (birth, death) pairs of column indices that were paired in the R=DV decomposition.
paired_reps (List[List[int]]) – A list of representatives for each of the paired features.