commutazzio.random package
Submodules
commutazzio.random.db_conversion_utils module
- commutazzio.random.db_conversion_utils.collect_data_from_db_files(dirnames, fn_pattern, db_2_df)
Loop through all files in the directory of form “{fn_pattern}_*.db”. For each file, read the database by applying the provided function (db_2_df), which returns a DataFrame. All DataFrames are then combined into one DataFrame.
- Args:
dirname (str): The directory containing the db files. fn_pattern (str): The filename pattern to match. db_2_df (function): Function to convert db data into DataFrame.
- Returns:
DataFrame: The combined data from all matched db files.
- commutazzio.random.db_conversion_utils.sqlite_to_df_cl4_pc(db)
Convert SQLite database records to a pandas DataFrame for CL(4) filtrations generated using the Point Cloud Model.
This function iterates over each record in the provided database, extracting specific information and organizing them into a structured DataFrame.
- Parameters:
- dbDatabase connection object
The database connection from which to retrieve CL(4) filtration data.
- Returns:
- pandas.DataFrame
A DataFrame containing the structured data from the CL4 filtration records. Columns include space dimension, homology dimension, number of points, critical radii number, ladder length, dots, lines, number of points removal, and decompositions.
- commutazzio.random.db_conversion_utils.sqlite_to_df_cln_pc(db)
Convert SQLite database records to a pandas DataFrame for CL(n) filtrations generated using the Point Cloud Model.
Similar to the CL4 conversion, this function processes records from a database containing CL(n) filtrations. Each record’s information is extracted and compiled into a DataFrame.
- Parameters:
- dbDatabase connection object
The database connection from which to retrieve CL(n) filtration data.
- Returns:
- pandas.DataFrame
A DataFrame representing the CL(n) database records. Columns include space dimension, homology dimension, number of points, critical radii number, ladder length, dots, lines, and number of points removed.
commutazzio.random.point_cloud_model module
- class commutazzio.random.point_cloud_model.RandomFiltrationPointCloudModel(num_pts=50, space_dim='random', ladder_length_min=4, ladder_length_max=50, enable_multi_processing=False, num_cores='auto', verbose=False)
Bases:
objectA class to generate random commutative ladder filtrations using the Point Cloud Model, aiming to facilitate the search for non-intervals.
- Parameters:
- num_ptsint, optional
The number of points in the generated point cloud. Defaults to 50.
- space_dimstr or int, optional
The dimensionality of the space for the point cloud. If “random”, chooses randomly between 2 and 3. Defaults to “random”.
- ladder_length_minint, optional
The minimum ladder length for the filtration. Defaults to 4.
- ladder_length_maxint, optional
The maximum ladder length for the filtration. Defaults to 50.
- enable_multi_processingbool, optional
Enables multiprocessing if True. Defaults to False.
- num_coresstr or int, optional
The number of cores to use for multiprocessing. “auto” for automatic selection. Defaults to “auto”.
- verbosebool, optional
Enables verbose output if True. Defaults to False.
Notes
The class dynamically generates point clouds based on specified parameters, computes filtrations for these clouds, and then analyzes them to produce connected persistence diagrams. It uses the SimplexTree structure for persistence computation and CLInvariants for decomposition analysis.
- Attributes:
- outputdict
A dictionary holding the generated CL(4) and CL(n) filtrations if any non-trivial decomposition or non-empty connected persistence diagrams are found.
- cPDpandas.DataFrame
The connected persistence diagram of the CL(n) filtration.
Methods
__init__(self, num_pts=50, space_dim=”random”, ladder_length_min=4,
ladder_length_max=50, enable_multi_processing=False, num_cores=”auto”, verbose=False) Initializes the RandomNISearch instance, generates point clouds, computes filtrations, and their connected persistence diagrams.
- commutazzio.random.point_cloud_model.join_and_unique(arr1, arr2, precision=3)
Join two arrays into a single, sorted array without duplicates, rounding to a specified precision.
- Parameters:
- arr1array_like
First input array.
- arr2array_like
Second input array.
- precisionint, optional
The decimal precision to round to before removing duplicates. Defaults to 3.
- Returns:
- numpy.ndarray
A sorted, unique array resulting from the concatenation of arr1 and arr2, with values rounded to the specified precision.