commutazzio.compute package

Submodules

commutazzio.compute.commutative_grid_quiver module

This module defines classes and functions for creating commutative grid quivers, converting coordinate numbering systems, and performing topological computations such as longest matching and multiplicity of zigzag filtrations.

Dependencies:
  • networkx: For creating and manipulating graph structures.

  • numpy: For numerical operations.

  • itertools.product: For generating Cartesian products.

  • ZigzagFiltration: Custom class from the ‘filtration’ module for handling zigzag filtrations.

class commutazzio.compute.commutative_grid_quiver.CommutativeGrid2DQuiver(m: int, n: int, orientation: str = 'equi', one_based=True, verbose=False)

Bases: CommutativeGridQuiver

A subclass of CommutativeGridQuiver for generating and manipulating 2-dimensional grid quivers.

Attributes:

orientation (str): A string representing the orientation of arrows between nodes in the grid.

plot()

Plots the 2D grid quiver using matplotlib, with nodes positioned according to their grid coordinates.

This overridden method ensures that the grid is visualized in a manner consistent with its 2D structure, with node positions reflecting their actual locations within the grid layout.

class commutazzio.compute.commutative_grid_quiver.CommutativeGridQuiver(dim_vector, one_based=True, verbose=False)

Bases: object

A class to represent a directed graph (quiver) constructed from a grid, supporting commutative diagrams.

Attributes:

G (networkx.DiGraph): The directed graph representing the quiver. shape (list of int): The dimensions of the grid. one_based (bool): Flag to use 1-based indexing for grid coordinates.

Methods:

plot(): Plots the quiver using networkx drawing facilities. attribute_sequence(nodes, attribute): Generates a list of attributes for given nodes.

attribute_sequence(nodes, attribute='simplicial_complex')

Generates a sequence of attributes for a given list of nodes in the quiver.

Parameters:

nodes (list): A list of node identifiers within the quiver. attribute (str, optional): The attribute to extract for each node. Defaults to “simplicial_complex”.

Returns:

list: A list containing the specified attributes of the given nodes.

static computePD(i)

Static method (placeholder) for computing persistence diagrams, intended for compatibility testing.

Parameters:

i (int): An arbitrary input parameter for testing purposes.

Returns:

int: A random integer, simulating a computation result.

static multiplicity_zigzag(sc_zigzag_list, dim=1, prime=2)

Computes the multiplicity of the longest interval in a given zigzag filtration of simplicial complexes.

Parameters:

sc_zigzag_list (list): A list of simplicial complexes in the zigzag filtration. dim (int, optional): The dimension in which to compute the multiplicity. Defaults to 1. prime (int, optional): The prime base for field coefficients in homology computations. Defaults to 2.

Returns:

int: The multiplicity of the longest interval in the specified dimension.

plot()

Plots the quiver using matplotlib, with nodes labeled according to their grid coordinates.

commutazzio.compute.commutative_grid_quiver.longest_matching(diagram_point)

Determine if a given diagram point is of the form (0, infinity), indicating an infinite persistence interval.

Parameters:

diagram_point: A point in the persistence diagram, typically a tuple (birth, death).

Returns:

bool: True if the point represents an infinite interval, False otherwise.

commutazzio.compute.commutative_grid_quiver.one_based_numbering(dim_vector)

Generate a mapping from 0-based to 1-based indexing for coordinates within given dimensions.

Parameters:

dim_vector (list of int): Dimension sizes for each axis of the grid.

Returns:

dict: A dictionary mapping 0-based indices to 1-based indices.

Example:

If dim_vector = [2, 2], the function returns {(0, 0): (1, 1), (0, 1): (1, 2), (1, 0): (2, 1), (1, 1): (2, 2)}.

commutazzio.compute.commutative_ladder_quiver module

Created on Sun Oct 31 19:20:11 2021

@author: kasumi

class commutazzio.compute.commutative_ladder_quiver.CommutativeLadderQuiver(m: int, orientation: str = 'equi', one_based=True, verbose=False)

Bases: CommutativeGrid2DQuiver

Equi-oriented by default

filtration_input(upper_row, lower_row)
info(index=0)
multiplicity_computation(dim=1, prime=2, recalculate=False, output_message=True, enable_multi_processing=False, num_cores=1)

Return the vector of multiplicities

plot()

Plots the 2D grid quiver using matplotlib, with nodes positioned according to their grid coordinates.

This overridden method ensures that the grid is visualized in a manner consistent with its 2D structure, with node positions reflecting their actual locations within the grid layout.

tours_vector(dim, prime, enable_multi_processing, num_cores: int)

Returns the vector of all the tours over the simplicial complex. mp_method: multiprocessing method, 0 for none, 1 for pool num_cores: int

commutazzio.compute.compute_engine module

class commutazzio.compute.compute_engine.CLInvariants(clf: CLFiltration, enable_multi_processing: bool = False, num_cores: int = -1, algorithm_phat: str = 'chunk_reduction', verbose: bool = False)

Bases: object

cPD_computation(homology_dim=1)

Compute the connected persistence diagram of the filtration at dimension dim. The coefficient field is GF(2). (using FZZ) (Can choose other finite field if we use dionysus2)

property cPDs
property decompositions_all

Return a list of all decompositions computed.

delete_filtration_file()
lower_sc_array()
repr_generation()
total_decomposition_computation(dim=1, prime=2, recalculate=False, output_message=True)
upper_sc_array()

commutazzio.compute.connected_persistence_diagram module

Created on Sun Jan 2 17:29:27 2022

@author: kasumi

class commutazzio.compute.connected_persistence_diagram.ConnectedPersistenceDiagram(filtration_filepath, ladder_length, homology_dim, filtration_values, enable_multi_processing: bool = False, num_cores: int = -1, verbose: bool = False, clean_up: bool = True, algorithm_phat: str = 'chunk_reduction', **kwargs)

Bases: object

NodeToStr
PathToStr
clean_up
complexes
complexes_generator(**kw)
compute_connecting_lines()
compute_dec_obj()
compute_dotdec()

Generate decomposition for dots

compute_plot_dots()
d_ss
dec
deco(**kw)
delt_ss
dim
dotdec
dots
fzz_barcode_compute_lower()
fzz_barcode_compute_upper(**kw)
static fzz_compute_inside_loop_local_mp(args)
indexAligner
intv
join_intv(X, Y)

helper function to join two intervals works for 2D commutative grid

ladder_length
lines
logging_memory_usage_of_attributes()

Print the memory usage of each attribute of an object

m
n
node2str_generator(**kw)
path2str_generator(**kw)
property plot_data
plot_dots
preprocess_filtration_values(filtration_values)

Preprocess the filtration values

times
txf
txf_basename_wo_ext
txf_dir
variables
wake(I)
static write_list_of_lists_of_sets_to_file(file_path, list_of_lists_of_sets)
static write_node_to_str(NodeToStr, file_path)

commutazzio.compute.courses module

Created on Fri Oct 29 16:15:49 2021

@author: kasumi

commutazzio.compute.courses.courses_cl3(one_based=True)
commutazzio.compute.courses.courses_cl4(one_based=True)
commutazzio.compute.courses.read_numpy_array(filename)
commutazzio.compute.courses.read_numpy_array_from_txt(filename)

commutazzio.compute.decomposition_container module

class commutazzio.compute.decomposition_container.Decomposition(mult, dim, prime)

Bases: object

A namedtuple-like class to store information of multiplicity values.

property dim
property m
property mult
property nonzero_components

Return the nonzero components of the multiplicity vector

property nonzero_nonintervals

Return non-trivial non-intervals

pretty_print()

Print out the multiplicity values line by line

property prime
statistics()

Print out the statistics of the multiplicity values

to_dict(skip_zero: bool = True, verbose=True)

Return a json-serializable dictionary of the decomposition.

Parameters:
skip_zerobool, optional

If True, only include nonzero components in the dictionary. Default is True.

verbosebool, optional

If True, print additional information. Default is True.

Returns:
dict

A dictionary with keys ‘mult’, ‘dim’, and ‘prime’, representing the multiplicity, dimension, and prime components of the decomposition, respectively.

class commutazzio.compute.decomposition_container.DecompositionCollection(*decompositions)

Bases: object

add(mult, dim, prime)
dim(dim)

Return all decompositions that was computed at a given dimension

mult(index=None)
prime(prime)

commutazzio.compute.precompute module

class commutazzio.compute.precompute.CommutativeGridPreCompute(m: int, n: int = 2)

Bases: object

c_ss_initializer()
cover_generator()

generate interval covers some values of c_ss is initialized

get_intervals()
get_variables()
interval_generator()

Generate intervals

save_intv_to_file(dirpath)

save intv to file

save_variables_to_file(dirpath)

save variables to file

Module contents