topobench.data.utils package#
Init file for data/utils module.
- data2simplicial(data)#
Convert a data dictionary into a SimplicialComplex object.
- Parameters:
- datadict
A dictionary containing at least ‘incidence_0’, ‘adjacency_0’, ‘incidence_1’, ‘incidence_2’, and optionally ‘incidence_3’ tensors.
- Returns:
- SimplicialComplex
A SimplicialComplex object constructed from nodes, edges, triangles, and tetrahedrons.
- download_file_from_drive(file_link, path_to_save, dataset_name, file_format='tar.gz')#
Download a file from a Google Drive link and saves it to the specified path.
- Parameters:
- file_linkstr
The Google Drive link of the file to download.
- path_to_savestr
The path where the downloaded file will be saved.
- dataset_namestr
The name of the dataset.
- file_formatstr, optional
The format of the downloaded file. Defaults to “tar.gz”.
- Raises:
- None
- ensure_serializable(obj)#
Ensure that the object is serializable.
- Parameters:
- objobject
Object to ensure serializability.
- Returns:
- object
Object that is serializable.
- generate_zero_sparse_connectivity(m, n)#
Generate a zero sparse connectivity matrix.
- Parameters:
- mint
Number of rows.
- nint
Number of columns.
- Returns:
- torch.sparse_coo_tensor
Zero sparse connectivity matrix.
- get_combinatorial_complex_connectivity(complex, max_rank, neighborhoods=None)#
Get the connectivity matrices for the Combinatorial Complex.
- Parameters:
- complextopnetx.CombinatorialComplex
Cell complex.
- max_rankint
Maximum rank of the complex.
- neighborhoodslist, optional
List of neighborhoods of interest.
- Returns:
- dict
Dictionary containing the connectivity matrices.
- get_complex_connectivity(complex, max_rank, neighborhoods=None, signed=False)#
Get the connectivity matrices for the complex.
- Parameters:
- complextoponetx.CellComplex or toponetx.SimplicialComplex
Cell complex.
- max_rankint
Maximum rank of the complex.
- neighborhoodslist, optional
List of neighborhoods of interest.
- signedbool, optional
If True, returns signed connectivity matrices.
- Returns:
- dict
Dictionary containing the connectivity matrices.
- get_routes_from_neighborhoods(neighborhoods)#
Get the routes from the neighborhoods.
Combination of src_rank, dst_rank. ex: [[0, 0], [1, 0], [1, 1], [1, 1], [2, 1]].
- Parameters:
- neighborhoodslist
List of neighborhoods of interest.
- Returns:
- list
List of routes.
- load_cell_complex_dataset(cfg)#
Load cell complex datasets.
- Parameters:
- cfgDictConfig
Configuration parameters.
- load_coauthorship_hypergraph_splits(data, parameters, train_prop=0.5)#
Load the split generated by rand_train_test_idx function.
- Parameters:
- datatorch_geometric.data.Data
Graph dataset.
- parametersDictConfig
Configuration parameters.
- train_propfloat
Proportion of training data.
- Returns:
- torch_geometric.data.Data:
Graph dataset with the specified split.
- load_hypergraph_content_dataset(data_dir, data_name)#
Load hypergraph datasets from pickle files.
- Parameters:
- data_dirstr
Path to data.
- data_namestr
Name of the dataset.
- Returns:
- torch_geometric.data.Data
Hypergraph dataset.
- load_hypergraph_pickle_dataset(data_dir, data_name)#
Load hypergraph datasets from pickle files.
- Parameters:
- data_dirstr
Path to data.
- data_namestr
Name of the dataset.
- Returns:
- torch_geometric.data.Data
Hypergraph dataset.
- load_inductive_splits(dataset, parameters)#
Load multiple-graph datasets with the specified split.
- Parameters:
- datasettorch_geometric.data.Dataset
Graph dataset.
- parametersDictConfig
Configuration parameters.
- Returns:
- list:
List containing the train, validation, and test splits.
- load_manual_graph()#
Create a manual graph for testing purposes.
- Returns:
- torch_geometric.data.Data
Manual graph.
- load_simplicial_dataset(cfg)#
Load simplicial datasets.
- Parameters:
- cfgDictConfig
Configuration parameters.
- Returns:
- torch_geometric.data.Data
Simplicial dataset.
- load_transductive_splits(dataset, parameters)#
Load the graph dataset with the specified split.
- Parameters:
- datasettorch_geometric.data.Dataset
Graph dataset.
- parametersDictConfig
Configuration parameters.
- Returns:
- list:
List containing the train, validation, and test splits.
- make_hash(o)#
Make a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types.
- Parameters:
- odict, list, tuple, set
Object to hash.
- Returns:
- int
Hash of the object.
- read_us_county_demos(path, year=2012, y_col='Election')#
Load US County Demos dataset.
- Parameters:
- pathstr
Path to the dataset.
- yearint, optional
Year to load the features (default: 2012).
- y_colstr, optional
Column to use as label. Can be one of [‘Election’, ‘MedianIncome’, ‘MigraRate’, ‘BirthRate’, ‘DeathRate’, ‘BachelorRate’, ‘UnemploymentRate’] (default: “Election”).
- Returns:
- torch_geometric.data.Data
Data object of the graph for the US County Demos dataset.
- select_neighborhoods_of_interest(connectivity, neighborhoods)#
Select the neighborhoods of interest.
- Parameters:
- connectivitydict
Connectivity matrices generated by default.
- neighborhoodslist
List of neighborhoods of interest.
- Returns:
- dict
Connectivity matrices of interest.
Submodules#
- topobench.data.utils.io_utils module
DataData.__init__()Data.connected_components()Data.debug()Data.edge_subgraph()Data.from_dict()Data.get_all_edge_attrs()Data.get_all_tensor_attrs()Data.is_edge_attr()Data.is_node_attr()Data.stores_as()Data.subgraph()Data.to_dict()Data.to_heterogeneous()Data.to_namedtuple()Data.update()Data.validate()Data.batchData.edge_attrData.edge_indexData.edge_storesData.edge_weightData.faceData.node_storesData.num_edge_featuresData.num_edge_typesData.num_facesData.num_featuresData.num_node_featuresData.num_node_typesData.num_nodesData.posData.storesData.timeData.xData.y
SimplicialComplexSimplicialComplex.__init__()SimplicialComplex.add_elements_from_nx_graph()SimplicialComplex.add_node()SimplicialComplex.add_simplex()SimplicialComplex.add_simplices_from()SimplicialComplex.adjacency_matrix()SimplicialComplex.clone()SimplicialComplex.coadjacency_matrix()SimplicialComplex.coincidence_matrix()SimplicialComplex.dirac_operator_matrix()SimplicialComplex.down_laplacian_matrix()SimplicialComplex.from_gudhi()SimplicialComplex.from_nx()SimplicialComplex.from_spharapy()SimplicialComplex.from_spharpy()SimplicialComplex.from_trimesh()SimplicialComplex.get_all_maximal_simplices()SimplicialComplex.get_boundaries()SimplicialComplex.get_cofaces()SimplicialComplex.get_edges_from_matrix()SimplicialComplex.get_maximal_simplices_of_simplex()SimplicialComplex.get_node_attributes()SimplicialComplex.get_simplex_attributes()SimplicialComplex.get_star()SimplicialComplex.graph_skeleton()SimplicialComplex.hodge_laplacian_matrix()SimplicialComplex.incidence_matrix()SimplicialComplex.is_connected()SimplicialComplex.is_maximal()SimplicialComplex.is_triangular_mesh()SimplicialComplex.laplace_beltrami_operator()SimplicialComplex.load_mesh()SimplicialComplex.normalized_laplacian_matrix()SimplicialComplex.remove_maximal_simplex()SimplicialComplex.remove_nodes()SimplicialComplex.restrict_to_nodes()SimplicialComplex.restrict_to_simplices()SimplicialComplex.set_simplex_attributes()SimplicialComplex.simplicial_closure_of_hypergraph()SimplicialComplex.skeleton()SimplicialComplex.to_cell_complex()SimplicialComplex.to_combinatorial_complex()SimplicialComplex.to_hasse_graph()SimplicialComplex.to_hypergraph()SimplicialComplex.to_spharapy()SimplicialComplex.to_trimesh()SimplicialComplex.up_laplacian_matrix()SimplicialComplex.dimSimplicialComplex.maxdimSimplicialComplex.nodesSimplicialComplex.shapeSimplicialComplex.simplices
coalesce()download_file_from_drive()download_file_from_link()get_complex_connectivity()get_file_id_from_url()load_hypergraph_content_dataset()load_hypergraph_pickle_dataset()parse_qs()read_ndim_manifolds()read_us_county_demos()urlparse()
- topobench.data.utils.split_utils module
- topobench.data.utils.utils module
SimplicialComplexSimplicialComplex.__init__()SimplicialComplex.add_elements_from_nx_graph()SimplicialComplex.add_node()SimplicialComplex.add_simplex()SimplicialComplex.add_simplices_from()SimplicialComplex.adjacency_matrix()SimplicialComplex.clone()SimplicialComplex.coadjacency_matrix()SimplicialComplex.coincidence_matrix()SimplicialComplex.dirac_operator_matrix()SimplicialComplex.down_laplacian_matrix()SimplicialComplex.from_gudhi()SimplicialComplex.from_nx()SimplicialComplex.from_spharapy()SimplicialComplex.from_spharpy()SimplicialComplex.from_trimesh()SimplicialComplex.get_all_maximal_simplices()SimplicialComplex.get_boundaries()SimplicialComplex.get_cofaces()SimplicialComplex.get_edges_from_matrix()SimplicialComplex.get_maximal_simplices_of_simplex()SimplicialComplex.get_node_attributes()SimplicialComplex.get_simplex_attributes()SimplicialComplex.get_star()SimplicialComplex.graph_skeleton()SimplicialComplex.hodge_laplacian_matrix()SimplicialComplex.incidence_matrix()SimplicialComplex.is_connected()SimplicialComplex.is_maximal()SimplicialComplex.is_triangular_mesh()SimplicialComplex.laplace_beltrami_operator()SimplicialComplex.load_mesh()SimplicialComplex.normalized_laplacian_matrix()SimplicialComplex.remove_maximal_simplex()SimplicialComplex.remove_nodes()SimplicialComplex.restrict_to_nodes()SimplicialComplex.restrict_to_simplices()SimplicialComplex.set_simplex_attributes()SimplicialComplex.simplicial_closure_of_hypergraph()SimplicialComplex.skeleton()SimplicialComplex.to_cell_complex()SimplicialComplex.to_combinatorial_complex()SimplicialComplex.to_hasse_graph()SimplicialComplex.to_hypergraph()SimplicialComplex.to_spharapy()SimplicialComplex.to_trimesh()SimplicialComplex.up_laplacian_matrix()SimplicialComplex.dimSimplicialComplex.maxdimSimplicialComplex.nodesSimplicialComplex.shapeSimplicialComplex.simplices
data2simplicial()ensure_serializable()find_tetrahedrons()find_triangles()from_sparse()generate_zero_sparse_connectivity()get_combinatorial_complex_connectivity()get_complex_connectivity()get_routes_from_neighborhoods()load_cell_complex_dataset()load_manual_graph()load_manual_graph_second_structure()load_manual_hypergraph()load_manual_pointcloud()load_manual_points()load_manual_simplicial_complex()load_simplicial_dataset()make_hash()select_neighborhoods_of_interest()