commutazzio.filtration package

Submodules

commutazzio.filtration.clfiltration module

Created on Thu Oct 28 22:01:47 2021

@author: kasumi

class commutazzio.filtration.clfiltration.CLFiltration(upper=a simplex tree with 0 simplices and 0 filtration values @ 0x7f7a4ea7d300, lower=a simplex tree with 0 simplices and 0 filtration values @ 0x7f7a4ea7d620, ladder_length=4, h_params=None, info={}, enable_validation=True, verbose=False)

Bases: object

Epsilon = 1e-10
dimension()

return both dimensions of the final simplicial complexes

from_database_item(item)
get_filtration_as_a_nested_list(layer)

return the filtration as a nested list

get_filtration_fv(layer: str)
get_filtration_with_custom_filtration_values(layer: str)

return the filtration with original filtration values by layer

get_simplicial_complex(x: int, y: int)

return the simplicial complex of the given coordinate (x,y) x: an ordinal number, 1,2,…,ladder_length

property h_params
incremental_filtration_creation(increments: list)

Create the filtration by adding simplices one by one. increments: a list of lists of simplices, can be the output of get_filtration_as_a_nested_list()

info_key_append(key, value)
info_update(kv_dict)
num_simplices()
plot()

Visualise the filtration, using networkx draw a commutative ladder graph, with number of simplicial complexes on each node which looks like below | | | | | |

random_cech_format_output_file(new_file=True, **kwargs)
random_cech_format_output_list()

print the filtration in the format as described in https://bitbucket.org/tda-homcloud/random-cech/src/master/ # dim birth n m v_0 .. v_dim (CECH_RANDOM) * 1番目のカラム: 単体の次元 * 2番目のカラム: その単体の発生時刻(h_params) * 3番目のカラム: n 0 or 1, corresponding to 1(lower) or 2(upper) here * 4番目のカラム: 0…ladder_length-1, corresponding to the index of the filtration value subtracted by 1 * 5番目以降のカラム: 頂点のインデックス,(dim + 1)個 ordered by birth time (h_params) ———————————– add the lines from left to right, lower then upper. for each fixed m, if a simplex is seen in the lower row first, do not need to add it from the upper row

resample_filtration(new_length, ordinal_filtration_values=None)

This method allows the user to refactor the length of the ladder. new_length shall be strictly shorter than the current length. ordinal_filtration_values: a list of length new_length consisting of integers between 1 and the current ladder length. new_h_params will be set to a random choice on [1,2,3,…,new_length] if not given.

serialize()

Convert the filtration to a dictionary.

set_info(info: dict)
validation()

Verify that the lower row is contained in the upper row for each filtration value

class commutazzio.filtration.clfiltration.ZigzagFiltration(*args)

Bases: object

all_time_sequences()

commutazzio.filtration.database module

class commutazzio.filtration.database.CLFiltrationDB(filename: str = 'clf_database.db', table_name: str = 'filtration', create_new_db: bool = False)

Bases: object

A class for creating and managing a SQLite database to store and retrieve instances of CLFiltration.

Parameters:
filenamestr, optional

The name of the database file to connect to. If ‘:memory:’, creates a temporary in-memory database. Defaults to ‘clf_database.db’.

table_namestr, optional

The name of the table within the database to create or use. Defaults to ‘filtration’.

create_new_dbbool, optional

If True, creates a new database file if one does not exist. Raises an exception if the file already exists. Defaults to False.

Raises:
Exception

If create_new_db is True and the database file already exists, or if the database file does not exist when create_new_db is False.

Attributes:
connsqlite3.Connection

The connection object to the database.

filenamestr

The name of the database file.

table_namestr

The name of the table used for storing filtration data.

add_filtration(clfiltration: CLFiltration, store_minimal_data: bool = False)

Adds a CLFiltration instance to the database.

Parameters:
clfiltrationCLFiltration

The CLFiltration instance to store in the database.

store_minimal_databool, optional

If True, only stores the ladder_length and info of the CLFiltration instance. Defaults to False.

close()

Closes the database connection.

create_table(table_name: str)

Creates a table in the database with a specified name if it doesn’t exist.

Parameters:
table_namestr

The name of the table to be created.

Notes

The table will have columns for id (primary key), ladder_length, upper, lower, horizontal_parameters, and info (stored in JSON format).

get_all()

Retrieves all CLFiltration instances from the database.

Returns:
generator of CLFiltration

A generator that yields CLFiltration instances for each record in the database table.

get_filtration_by_id(id: int)

Retrieves a CLFiltration instance from the database by its ID.

Parameters:
idint

The ID of the CLFiltration instance to retrieve.

Returns:
CLFiltration or None

The CLFiltration instance corresponding to the given ID, or None if no instance is found.

reset_table_name_for_legacy()

Resets the table name to the first table found in the database.

This method is intended for legacy support and updates the instance’s table name attribute to match the first table name found in the database schema.

commutazzio.filtration.points_to_clfiltration module

commutazzio.filtration.points_to_clfiltration.pointCloud2Filtration(*args, **kwargs)
commutazzio.filtration.points_to_clfiltration.points_to_clfiltration(pts: array, vertical_removal_input: list, radii: list, max_simplex_dim: int, method: str = 'cech')

Convert a point cloud to a commutative ladder filtration. pts: a numpy array of shape (num_pts, dim) vertical_removal_input: a list of list of simplices to be removed, notice that it is the name of the simplices, not the indices of the simplices radii: a list of radii max_simplex_dim: the maximum simplex dimension to be considered method: ‘cech’ or ‘rips’

commutazzio.filtration.points_to_clfiltration.points_to_clfiltration_chro(pts: array, labels: list, max_simplex_dim: int, radii='auto')

Convert a labeled point cloud to a commutative ladder filtration using chromatic alpha complexes.

pts: a numpy array of shape (num_pts, dim) labels: a list of binary labels for each point. 0 means lower layer, 1 means upper layer. radii: a list of radii max_simplex_dim: the maximum simplex dimension to be considered

commutazzio.filtration.points_to_clfiltration.random_vertical_removal_points_only(num_pts, ladder_length, max_removal_per_time=None)

commutazzio.filtration.simplex_tree module

class commutazzio.filtration.simplex_tree.SimplexTree(*args, **kwargs)

Bases: SimplexTree

Epsilon = 1e-10
critical_radii(dimension)
property filtration_values
from_point_cloud(pt_cloud, method='cech', sc_dim_ceil='auto', radius_max=inf)

Create a simplex tree from a point cloud.

from_random_point_cloud(nb_pts=100, space_dim=3, sc_dim_ceil='auto', radius_max=inf, method='alpha')

Generate a simplicial complex out of a random point cloud, using the given method.

Parameters:
nb_pts

Number of points in the point cloud. The default is 100.

space_dimTYPE, optional

Dimension of the point cloud. The default is 3.

sc_dim_ceilTYPE, optiona, the default is pc_dim - 1
methodTYPE, optional

Method to be used. Supported methods are ‘rips’, ‘alpha’, ‘weak-witness’ and ‘strong-witness’. Using gudhi library to generate the array of simplices. https://geometrica.saclay.inria.fr/team/Fred.Chazal/slides/Intro_TDA_with_GUDHI_Part_1.html

Returns:
A simplicial complex represented by a list of tuples.
insert(simplex, filtration_value)

This function inserts the given N-simplex and its subfaces with the given filtration value (default value is ‘0.0’). If some of those simplices are already present with a higher filtration value, their filtration value is lowered.

Parameters:
  • simplex (list of int) – The N-simplex to insert, represented by a list of vertex.

  • filtration (float) – The filtration value of the simplex.

Returns:

true if the simplex was not yet in the complex, false otherwise (whatever its original filtration value).

Return type:

bool

property maximum_simplicial_complex
ordered_simplices()

Generator that yields simplices ordered by filtration value, dimension, and then dictionary order.

prune_above_dimension(dimension)

Remove all simplices of dimension greater than a given value.

Parameters:

dimension (int) – Maximum dimension value.

Returns:

The modification information.

Return type:

bool

prune_above_filtration(filtration_value)

Prune above filtration value given as parameter.

Parameters:

filtration (float) – Maximum threshold value.

Returns:

The filtration modification information.

Return type:

bool

Note

Note that the dimension of the simplicial complex may be lower after calling prune_above_filtration() than it was before. However, upper_bound_dimension() will return the old value, which remains a valid upper bound. If you care, you can call dimension() method to recompute the exact dimension.

to_custom_filtration_values(fvs: list)

Rescale a simplex tree with ordinal number filtration values [1,2,…,n] to user input filtration values.

to_ordinal_number_indexing(fvs: list)

Rescale the filtration values to ordinal numbers, starting from 1. Based on the input fv=[t_1,t_2,…,t_n]

truncation(ceiling)

Return a simplicial complex of simplices with filtration values <= ceiling.

commutazzio.filtration.simplicial_complex module

Created on Wed Oct 27 16:21:47 2021

@author: kasumi

class commutazzio.filtration.simplicial_complex.SimplicialComplex

Bases: SimplexTree

add(simplex, inplace=False)

Add a simplex, together with all of its faces

betti_numbers()

This function returns the Betti numbers of the simplicial complex.

Returns:

The Betti numbers ([B0, B1, …, Bn]).

Return type:

list of int

Note:

betti_numbers function requires compute_persistence() function to be launched first.

deleteOne(simplex)
delete_simplices(simplices)
dimension()

Return the dimension of the simplicial complex

dionysus_form()
from_simplices(simplices)
get_faces(simplex, dim)

Generate all faces of a given simplex of a specific dimension.

info_node()
is_subcomplex_of(external_sc)
issimplicialComplex()
issuperset(external_sc)
property maximum_simplices

Returns a list of maximum simplices in the simplicial complex. A maximum simplex is not a proper face of any other simplex in the complex.

random_delete_vertices(num=None, inplace=False)
removeOne(simplex)

Delete one simplex, together with its superset

remove_simplices(simplices)

Delete vertices

property sc
static simplexify(simplex)

Normalize the representation of a simplex

property simplices
property vertices

Returns the list of 0-simplices (vertices).

Module contents