diff --git a/README.md b/README.md index bd8313e2..31426324 100644 --- a/README.md +++ b/README.md @@ -85,64 +85,53 @@ pre-commit install ## Example 1: creating a simplicial complex ```python -from toponetx.classes import SimplicialComplex +import toponetx as tnx # Instantiate a SimplicialComplex object with a few simplices - -sc = SimplicialComplex([[1, 2, 3], [2, 3, 4], [0, 1]]) +sc = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 4], [0, 1]]) # Compute the incidence matrix between 1-skeleton and 0-skeleton - B1 = sc.incidence_matrix(1) # Compute the incidence matrix between 2-skeleton and 1-skeleton - B2 = sc.incidence_matrix(2) ``` ## Example 2: creating a cell complex ```python -from toponetx.classes import CellComplex +import toponetx as tnx # Instantiate a CellComplex object with a few cells - -cx = CellComplex([[1, 2, 3, 4], [3, 4, 5, 6, 7, 8]], ranks=2) +cx = tnx.CellComplex([[1, 2, 3, 4], [3, 4, 5, 6, 7, 8]], ranks=2) # Add an edge (cell of rank 1) after initialization - cx.add_edge(0, 1) # Compute the Hodge Laplacian matrix of dimension 1 - L1 = cx.hodge_laplacian_matrix(1) # Compute the Hodge Laplacian matrix of dimension 2 - L2 = cx.hodge_laplacian_matrix(2) ``` ## Example 3: creating a combinatorial complex ```python -from toponetx.classes import CombinatorialComplex +import toponetx as tnx # Instantiate a combinatorial complex object with a few cells - -cc = CombinatorialComplex() +cc = tnx.CombinatorialComplex() # Add some cells of different ranks after initialization - cc.add_cell([1, 2, 3], rank=2) cc.add_cell([3, 4, 5], rank=2) cc.add_cells_from([[2, 3, 4, 5], [3, 4, 5, 6, 7]], ranks=3) # Compute the incidence matrix between cells of rank 0 and 2 - B02 = cc.incidence_matrix(0, 2) # Compute the incidence matrix between cells of rank 0 and 3 - B03 = cc.incidence_matrix(0, 3) ``` diff --git a/conftest.py b/conftest.py new file mode 100644 index 00000000..44a69185 --- /dev/null +++ b/conftest.py @@ -0,0 +1,25 @@ +import networkx +import numpy +import pytest + +import toponetx + + +@pytest.fixture(autouse=True) +def doctest_default_imports(doctest_namespace): + """Add default imports to the doctest namespace. + + This fixture adds the following default imports to every doctest, so that their use + is consistent across all doctests without boilerplate imports polluting the + doctests themselves: + + .. code-block:: python + + import numpy as np + import networkx as nx + import toponetx as tnx + + """ + doctest_namespace["np"] = numpy + doctest_namespace["nx"] = networkx + doctest_namespace["tnx"] = toponetx diff --git a/toponetx/__init__.py b/toponetx/__init__.py index 08eb00d0..6e1c207c 100644 --- a/toponetx/__init__.py +++ b/toponetx/__init__.py @@ -1,4 +1,14 @@ """Initialize the library with modules and other content.""" + __version__ = "0.0.2" -__all__ = ["algorithms", "classes", "datasets", "generators", "transform", "utils"] +from toponetx.algorithms import * +from toponetx.classes import * +from toponetx.exception import * +from toponetx.generators import * +from toponetx.readwrite import * +from toponetx.transform import * +from toponetx.utils import * + +# Do not import the contents of the following modules into the global namespace: +# from toponetx.datasets import * diff --git a/toponetx/algorithms/components.py b/toponetx/algorithms/components.py index 93d04811..f9a94f6f 100644 --- a/toponetx/algorithms/components.py +++ b/toponetx/algorithms/components.py @@ -1,4 +1,5 @@ """Module to compute connected components on topological domains.""" + from collections.abc import Generator, Hashable from typing import Literal, TypeVar, overload @@ -87,20 +88,20 @@ def s_connected_components( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(s_connected_components(CC, s=1, cells=False)) + >>> list(tnx.s_connected_components(CC, s=1, cells=False)) [{2, 3, 4}, {5, 6, 7}] - >>> list(s_connected_components(CC, s=1, cells=True)) + >>> list(tnx.s_connected_components(CC, s=1, cells=True)) [{(2, 3), (2, 3, 4), (2, 4), (3, 4)}, {(5, 6), (5, 6, 7), (5, 7), (6, 7)}] >>> CHG = CC.to_colored_hypergraph() - >>> list(s_connected_components(CHG, s=1, cells=False)) + >>> list(tnx.s_connected_components(CHG, s=1, cells=False)) >>> CC.add_cell([4, 5], rank=1) - >>> list(s_connected_components(CC, s=1, cells=False)) + >>> list(tnx.s_connected_components(CC, s=1, cells=False)) [{2, 3, 4, 5, 6, 7}] >>> CCC = CC.to_combinatorial_complex() - >>> list(s_connected_components(CCC, s=1, cells=False)) + >>> list(tnx.s_connected_components(CCC, s=1, cells=False)) """ if cells: cell_dict, A = domain.all_cell_to_node_coadjacency_matrix(s=s, index=True) @@ -160,16 +161,16 @@ def s_component_subcomplexes( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(s_component_subcomplexes(CC, 1, cells=False)) + >>> list(tnx.s_component_subcomplexes(CC, 1, cells=False)) >>> CCC = CC.to_combinatorial_complex() - >>> list(s_component_subcomplexes(CCC, s=1, cells=False)) + >>> list(tnx.s_component_subcomplexes(CCC, s=1, cells=False)) >>> CHG = CC.to_colored_hypergraph() - >>> list(s_component_subcomplexes(CHG, s=1, cells=False)) + >>> list(tnx.s_component_subcomplexes(CHG, s=1, cells=False)) >>> CC.add_cell([4, 5], rank=1) - >>> list(s_component_subcomplexes(CC, s=1, cells=False)) + >>> list(tnx.s_component_subcomplexes(CC, s=1, cells=False)) """ for c in s_connected_components( domain, s=s, cells=cells, return_singletons=return_singletons @@ -232,12 +233,12 @@ def connected_components( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(connected_components(CC, cells=False)) + >>> list(tnx.connected_components(CC, cells=False)) >>> CC.add_cell([4, 5], rank=1) - >>> list(CC.connected_components(CC, cells=False)) + >>> list(tnx.CC.connected_components(CC, cells=False)) """ yield from s_connected_components( domain, s=1, cells=cells, return_singletons=return_singletons @@ -270,11 +271,11 @@ def connected_component_subcomplexes( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(connected_component_subcomplexes(CC)) + >>> list(tnx.connected_component_subcomplexes(CC)) >>> CC.add_cell([4, 5], rank=1) - >>> list(connected_component_subcomplexes(CC)) + >>> list(tnx.connected_component_subcomplexes(CC)) """ yield from s_component_subcomplexes(domain, return_singletons=return_singletons) diff --git a/toponetx/algorithms/distance.py b/toponetx/algorithms/distance.py index a69fb606..75d20041 100644 --- a/toponetx/algorithms/distance.py +++ b/toponetx/algorithms/distance.py @@ -1,4 +1,5 @@ """Module to compute distance between nodes or cells on topological domains.""" + from collections.abc import Hashable, Iterable import networkx as nx @@ -61,14 +62,14 @@ def distance( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(node_diameters(CC)) + >>> list(tnx.node_diameters(CC)) >>> CCC = CC.to_combinatorial_complex() - >>> list(node_diameters(CCC)) + >>> list(tnx.node_diameters(CCC)) >>> CHG = CC.to_colored_hypergraph() - >>> list(node_diameters(CHG)) + >>> list(tnx.node_diameters(CHG)) """ if not isinstance(domain, CellComplex | CombinatorialComplex | ColoredHyperGraph): raise TypeError(f"Input complex {domain} is not supported.") @@ -137,15 +138,15 @@ def cell_distance( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) >>> CC.add_cell([5, 2], rank=1) - >>> cell_distance(CC, [2, 3], [6, 7]) + >>> tnx.cell_distance(CC, [2, 3], [6, 7]) >>> CHG = CC.to_colored_hypergraph() - >>> cell_distance(CHG, (frozenset({2, 3}), 0), (frozenset({6, 7}), 0)) + >>> tnx.cell_distance(CHG, (frozenset({2, 3}), 0), (frozenset({6, 7}), 0)) >>> CCC = CC.to_combinatorial_complex() - >>> cell_distance(CCC, frozenset({2, 3}), frozenset({6, 7})) + >>> tnx.cell_distance(CCC, frozenset({2, 3}), frozenset({6, 7})) """ if not isinstance(domain, CellComplex | CombinatorialComplex | ColoredHyperGraph): raise TypeError(f"Input complex {domain} is not supported.") diff --git a/toponetx/algorithms/distance_measures.py b/toponetx/algorithms/distance_measures.py index 7d3e6f30..6247dbce 100644 --- a/toponetx/algorithms/distance_measures.py +++ b/toponetx/algorithms/distance_measures.py @@ -1,4 +1,5 @@ """Module to distance measures on topological domains.""" + from collections.abc import Hashable import networkx as nx @@ -31,14 +32,14 @@ def node_diameters(domain: ComplexType) -> tuple[list[int], list[set[Hashable]]] Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(node_diameters(CC)) + >>> tnx.node_diameters(CC) >>> CCC = CC.to_combinatorial_complex() - >>> list(node_diameters(CCC)) + >>> tnx.node_diameters(CCC) >>> CHG = CC.to_colored_hypergraph() - >>> list(node_diameters(CHG)) + >>> tnx.node_diameters(CHG) """ node_dict, A = domain.node_to_all_cell_adjacnecy_matrix(index=True) node_dict = {v: k for k, v in node_dict.items()} @@ -79,11 +80,11 @@ def cell_diameters(domain: ComplexType, s: int = 1) -> tuple[list[int], list[set >>> CC = CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) - >>> list(cell_diameters(CC)) + >>> tnx.cell_diameters(CC) >>> CCC = CC.to_combinatorial_complex() - >>> list(cell_diameters(CCC)) + >>> tnx.cell_diameters(CCC) >>> CHG = CC.to_colored_hypergraph() - >>> list(cell_diameters(CHG)) + >>> tnx.cell_diameters(CHG) """ if not isinstance(domain, CellComplex | CombinatorialComplex | ColoredHyperGraph): raise TypeError(f"Input complex {domain} is not supported.") @@ -130,15 +131,15 @@ def diameter(domain: ComplexType) -> int: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) >>> CC.add_cell([2, 5], rank=2) - >>> diameter(CC) + >>> tnx.diameter(CC) >>> CCC = CC.to_combinatorial_complex() - >>> diameter(CCC) + >>> tnx.diameter(CCC) >>> CHG = CC.to_colored_hypergraph() - >>> diameter(CHG) + >>> tnx.diameter(CHG) """ if not isinstance(domain, CellComplex | CombinatorialComplex | ColoredHyperGraph): raise TypeError(f"Input complex {domain} is not supported.") @@ -178,15 +179,15 @@ def cell_diameter(domain: ComplexType, s: int | None = None) -> int: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([2, 3, 4], rank=2) >>> CC.add_cell([5, 6, 7], rank=2) >>> CC.add_cell([2, 5], rank=1) - >>> cell_diameter(CC) + >>> tnx.cell_diameter(CC) >>> CCC = CC.to_combinatorial_complex() - >>> cell_diameter(CCC) + >>> tnx.cell_diameter(CCC) >>> CHG = CC.to_colored_hypergraph() - >>> cell_diameter(CHG) + >>> tnx.cell_diameter(CHG) """ if not isinstance(domain, CellComplex | CombinatorialComplex | ColoredHyperGraph): raise TypeError(f"Input complex {domain} is not supported.") diff --git a/toponetx/algorithms/spectrum.py b/toponetx/algorithms/spectrum.py index e6dae5be..23906484 100644 --- a/toponetx/algorithms/spectrum.py +++ b/toponetx/algorithms/spectrum.py @@ -1,4 +1,5 @@ """Module to compute spectra.""" + from typing import Any, Literal import numpy as np @@ -70,10 +71,9 @@ def hodge_laplacian_eigenvectors( Examples -------- - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) >>> L1 = SC.hodge_laplacian_matrix(1) - >>> vals, vecs = hodge_laplacian_eigenvectors(L1, 2) + >>> vals, vecs = tnx.hodge_laplacian_eigenvectors(L1, 2) """ Diag = diags(hodge_laplacian.diagonal()) if Diag.shape[0] > 10: @@ -117,9 +117,8 @@ def set_hodge_laplacian_eigenvector_attrs( Examples -------- - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) - >>> set_hodge_laplacian_eigenvector_attrs(SC, 1, 2, "down") + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> tnx.set_hodge_laplacian_eigenvector_attrs(SC, 1, 2, "down") >>> SC.get_simplex_attributes("0.th_eigen", 1) """ index = SC.skeleton(dim) @@ -163,8 +162,8 @@ def laplacian_beltrami_eigenvectors( Examples -------- - >>> SC = stanford_bunny() - >>> eigenvectors, eigenvalues = laplacian_beltrami_eigenvectors(SC) + >>> SC = tnx.datasets.stanford_bunny("simplicial") + >>> eigenvectors, eigenvalues = tnx.laplacian_beltrami_eigenvectors(SC) """ mesh = SC.to_spharapy() sphara_basis = sb.SpharaBasis(mesh, mode=mode) @@ -182,9 +181,8 @@ def set_laplacian_beltrami_eigenvectors(SC: SimplicialComplex) -> None: Examples -------- - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex.load_mesh("bunny.obj") - >>> set_laplacian_beltrami_eigenvectors(SC) + >>> SC = tnx.datasets.stanford_bunny() + >>> tnx.set_laplacian_beltrami_eigenvectors(SC) >>> vec1 = SC.get_simplex_attributes("1.laplacian_beltrami_eigenvectors") """ index = SC.skeleton(0) @@ -231,12 +229,11 @@ def cell_complex_hodge_laplacian_spectrum( Examples -------- - >>> from toponetx.classes import CellComplex - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 5], rank=2) >>> CC.add_cell([5, 6, 7, 8], rank=2) - >>> cell_complex_hodge_laplacian_spectrum(CC, 1) + >>> tnx.cell_complex_hodge_laplacian_spectrum(CC, 1) """ return laplacian_spectrum(CC.hodge_laplacian_matrix(rank=rank, weight=weight)) @@ -262,9 +259,8 @@ def simplicial_complex_hodge_laplacian_spectrum( Examples -------- - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) - >>> spectrum = simplicial_complex_hodge_laplacian_spectrum(SC, 1) + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> spectrum = tnx.simplicial_complex_hodge_laplacian_spectrum(SC, 1) """ return laplacian_spectrum(SC.hodge_laplacian_matrix(rank=rank)) @@ -314,12 +310,11 @@ def cell_complex_adjacency_spectrum(CC: CellComplex, rank: int): Examples -------- - >>> from toponetx.classes import CellComplex - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 5], rank=2) >>> CC.add_cell([5, 6, 7, 8], rank=2) - >>> cell_complex_adjacency_spectrum(CC, 1) + >>> tnx.cell_complex_adjacency_spectrum(CC, 1) """ return laplacian_spectrum(CC.adjacency_matrix(rank=rank)) @@ -387,8 +382,7 @@ def combinatorial_complex_adjacency_spectrum( Examples -------- - >>> from toponetx.classes import CombinatorialComplex - >>> CCC = CombinatorialComplex(cells=[[1, 2, 3], [2, 3], [0]], ranks=[2, 1, 0]) - >>> s = laplacian_spectrum(CCC.adjacency_matrix(0, 2)) + >>> CCC = tnx.CombinatorialComplex(cells=[[1, 2, 3], [2, 3], [0]], ranks=[2, 1, 0]) + >>> tnx.combinatorial_complex_adjacency_spectrum(CCC, 0, 2) """ return laplacian_spectrum(CCC.adjacency_matrix(rank, via_rank)) diff --git a/toponetx/classes/cell.py b/toponetx/classes/cell.py index 9e557a08..06ee0ba2 100644 --- a/toponetx/classes/cell.py +++ b/toponetx/classes/cell.py @@ -42,16 +42,16 @@ class Cell(Atom[tuple[Hashable]]): Examples -------- - >>> cell1 = Cell((1, 2, 3)) - >>> cell2 = Cell((1, 2, 4, 5), weight=1) - >>> cell3 = Cell(("a", "b", "c")) + >>> cell1 = tnx.Cell((1, 2, 3)) + >>> cell2 = tnx.Cell((1, 2, 4, 5), weight=1) + >>> cell3 = tnx.Cell(("a", "b", "c")) >>> # create geometric cell: >>> v0 = (0, 0) >>> v1 = (1, 0) >>> v2 = (1, 1) >>> v3 = (0, 1) # create the cell with the vertices and edges - >>> cell = Cell([v0, v1, v2, v3], type="square") + >>> cell = tnx.Cell([v0, v1, v2, v3], type="square") >>> cell["type"] >>> list(cell.boundary) [((0, 0), (1, 0)), ((1, 0), (1, 1)), ((1, 1), (0, 1)), diff --git a/toponetx/classes/cell_complex.py b/toponetx/classes/cell_complex.py index cf2e2f27..7046ac55 100644 --- a/toponetx/classes/cell_complex.py +++ b/toponetx/classes/cell_complex.py @@ -95,8 +95,7 @@ class CellComplex(Complex): -------- Iteratively construct a cell complex: - >>> from toponetx.classes import CellComplex - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> # the cell [1, 2, 3, 4] consists of the cycle (1,2), (2,3), (3,4), (4,5) >>> # tnx creates these edges automatically if they are not inserted in the underlying graph @@ -105,32 +104,29 @@ class CellComplex(Complex): You can also pass a list of cells to the constructor: - >>> c1 = Cell((1, 2, 3)) # a cell here is always assumed to be 2d - >>> c2 = Cell((1, 2, 3, 4)) - >>> CC = CellComplex([c1, c2]) + >>> c1 = tnx.Cell((1, 2, 3)) # a cell here is always assumed to be 2d + >>> c2 = tnx.Cell((1, 2, 3, 4)) + >>> CC = tnx.CellComplex([c1, c2]) TopoNetX is also compatible with NetworkX, allowing users to create a cell complex from a NetworkX graph: - >>> from toponetx.classes import CellComplex - >>> import networkx as nx >>> g = nx.Graph() >>> g.add_edge(1, 0) >>> g.add_edge(2, 0) >>> g.add_edge(1, 2) - >>> CC = CellComplex(g) + >>> CC = tnx.CellComplex(g) >>> CC.add_cells_from([[1, 2, 4], [1, 2, 7]], rank=2) >>> CC.cells By default, a regular cell complex is constructed. You can change this behaviour using the `regular` parameter when constructing the complex. - >>> from toponetx.classes import CellComplex >>> # non-regular cell complex >>> # by default CellComplex constructor assumes regular cell complex - >>> CC = CellComplex(regular=False) + >>> CC = tnx.CellComplex(regular=False) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 5, 2, 3, 4, 5], rank=2) # non-regular 2-cell - >>> c1 = Cell((1, 2, 3, 4, 5, 1, 2, 3, 4, 5), regular=False) + >>> c1 = tnx.Cell((1, 2, 3, 4, 5, 1, 2, 3, 4, 5), regular=False) >>> CC.add_cell(c1) >>> CC.add_cell([5, 6, 7, 8], rank=2) >>> CC.is_regular @@ -278,13 +274,14 @@ def is_regular(self) -> bool: Examples -------- - >>> CC = CellComplex(regular=False) + >>> CC = tnx.CellComplex(regular=False) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 5, 2, 3, 4, 5], rank=2) # non-regular 2-cell - >>> c1 = Cell((1, 2, 3, 4, 5, 1, 2, 3, 4, 5), regular=False) + >>> c1 = tnx.Cell((1, 2, 3, 4, 5, 1, 2, 3, 4, 5), regular=False) >>> CC.add_cell(c1) >>> CC.add_cell([5, 6, 7, 8], rank=2) >>> CC.is_regular + False """ return all(cell.is_regular for cell in self.cells) @@ -417,7 +414,7 @@ def _cell_equivalence_class(self) -> dict[Cell, set[Cell]]: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell((1, 2, 3, 4), rank=2) >>> CC.add_cell((2, 3, 4, 1), rank=2) >>> CC.add_cell((1, 2, 3, 4), rank=2) @@ -425,7 +422,7 @@ def _cell_equivalence_class(self) -> dict[Cell, set[Cell]]: >>> CC.add_cell((3, 4, 1, 2), rank=2) >>> CC.add_cell((4, 3, 2, 1), rank=2) >>> CC.add_cell((1, 2, 7, 3), rank=2) - >>> c1 = Cell((1, 2, 3, 4, 5)) + >>> c1 = tnx.Cell((1, 2, 3, 4, 5)) >>> CC.add_cell(c1, rank=2) >>> CC._cell_equivalence_class() """ @@ -449,7 +446,7 @@ def _remove_equivalent_cells(self) -> None: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell((1, 2, 3, 4), rank=2) >>> CC.add_cell((2, 3, 4, 1), rank=2) >>> CC.add_cell((1, 2, 3, 4), rank=2) @@ -457,7 +454,7 @@ def _remove_equivalent_cells(self) -> None: >>> CC.add_cell((3, 4, 1, 2), rank=2) >>> CC.add_cell((4, 3, 2, 1), rank=2) >>> CC.add_cell((1, 2, 7, 3), rank=2) - >>> c1 = Cell((1, 2, 3, 4, 5)) + >>> c1 = tnx.Cell((1, 2, 3, 4, 5)) >>> CC.add_cell(c1, rank=2) >>> CC._remove_equivalent_cells() >>> CC @@ -747,8 +744,8 @@ def add_cell( Examples -------- - >>> CC = CellComplex() - >>> c1 = Cell((2, 3, 4), color="black") + >>> CC = tnx.CellComplex() + >>> c1 = tnx.Cell((2, 3, 4), color="black") >>> CC.add_cell(c1, weight=3) >>> CC.add_cell([1, 2, 3, 4], rank=2, color="red") >>> CC.add_cell([2, 3, 4, 5], rank=2, color="blue") @@ -896,7 +893,7 @@ def set_filtration( Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> d = {0: 1, 1: 0, 2: 2, (0, 1): 1, (1, 2): 3} >>> CC.set_filtration(d, "f") """ @@ -938,7 +935,7 @@ def get_filtration(self, name: str) -> dict[Hashable, Any]: Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> d = {0: 1, 1: 0, 2: 2, (0, 1): 1, (1, 2): 3} >>> CC.set_filtration(d, "f") >>> CC.get_filtration("f") @@ -970,7 +967,7 @@ def set_node_attributes( Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> d = {1: {"color": "red", "attr2": 1}, 2: {"color": "blue", "attr2": 3}} >>> CC.set_node_attributes(d) @@ -995,7 +992,7 @@ def get_node_attributes(self, name: str) -> dict[tuple, Any]: Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> d = {1: {"color": "red", "attr2": 1}, 2: {"color": "blue", "attr2": 3}} >>> CC.set_node_attributes(d) @@ -1023,7 +1020,7 @@ def set_edge_attributes( Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> d = { ... (1, 2): {"color": "red", "attr2": 1}, @@ -1051,7 +1048,7 @@ def get_edge_attributes(self, name: str) -> dict[tuple, Any]: Examples -------- >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> d = { ... (1, 2): {"color": "red", "attr2": 1}, @@ -1095,12 +1092,9 @@ def set_cell_attributes( to assign a cell attribute to store the value of that property for each cell: - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) - >>> CC.add_cell( - ... [1, 2, 4], - ... rank=2, - ... ) + >>> CC.add_cell([1, 2, 4], rank=2) >>> CC.add_cell([3, 4, 8], rank=2) >>> d = {(1, 2, 3, 4): "red", (1, 2, 4): "blue"} >>> CC.set_cell_attributes(d, name="color", rank=2) @@ -1111,13 +1105,10 @@ def set_cell_attributes( the entire dictionary will be used to update cell attributes:: >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([1, 2, 3, 4], rank=2) - >>> CC.add_cell( - ... [1, 2, 4], - ... rank=2, - ... ) + >>> CC.add_cell([1, 2, 4], rank=2) >>> CC.add_cell([3, 4, 8], rank=2) >>> d = { ... (1, 2, 3, 4): {"color": "red", "attr2": 1}, @@ -1196,14 +1187,12 @@ def get_cell_attributes( Examples -------- - >>> import networkx as nx - >>> from toponetx.classes import CellComplex >>> G = nx.path_graph(3) >>> d = { ... ((1, 2, 3, 4), 0): {"color": "red", "attr2": 1}, ... (1, 2, 4): {"color": "blue", "attr2": 3}, ... } - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([1, 2, 4], rank=2) @@ -1341,17 +1330,12 @@ def remove_equivalent_cells(self) -> None: Examples -------- - >>> import networkx as nx - >>> from toponetx.classes import CellComplex >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 1], rank=2) - >>> CC.add_cell( - ... [1, 2, 4], - ... rank=2, - ... ) + >>> CC.add_cell([1, 2, 4], rank=2) >>> CC.add_cell([3, 4, 8], rank=2) >>> print(CC.cells) >>> CC.remove_equivalent_cells() @@ -1474,7 +1458,7 @@ def node_to_all_cell_adjacnecy_matrix( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> CC.node_to_all_cell_adjacnecy_matrix().todense() @@ -1533,7 +1517,7 @@ def all_cell_to_node_coadjacency_matrix( Examples -------- - >>> CX = CellComplex([[1, 2, 3, 4], [2, 3, 6]]) + >>> CX = tnx.CellComplex([[1, 2, 3, 4], [2, 3, 6]]) >>> index, m = CX.all_cell_to_node_coadjacency_matrix(s=1, index=True) >>> # m_ij iff cell i is coadjacency to cell j. Dimension of cells i,j are arbirary >>> print(m.todense(), index) @@ -1580,7 +1564,7 @@ def incidence_matrix( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> B0 = CC.incidence_matrix(0) @@ -1592,16 +1576,12 @@ def incidence_matrix( Note that in this example, the first three cells are equivalent and hence they have similar incidence to lower edges they are incident to. - >>> import networkx as nx >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([4, 3, 2, 1], rank=2) >>> CC.add_cell([2, 3, 4, 1], rank=2) - >>> CC.add_cell( - ... [1, 2, 4], - ... rank=2, - ... ) + >>> CC.add_cell([1, 2, 4], rank=2) >>> CC.add_cell([3, 4, 8], rank=2) >>> B1 = CC.incidence_matrix(1) >>> B2 = CC.incidence_matrix(2) @@ -1609,7 +1589,7 @@ def incidence_matrix( Non-regular cell complex example: - >>> CC = CellComplex(regular=False) + >>> CC = tnx.CellComplex(regular=False) >>> CC.add_cell([1, 2, 3, 2], rank=2) >>> CC.add_cell([3, 4, 5, 3, 4, 5], rank=2) >>> B1 = CC.incidence_matrix(1) @@ -1617,7 +1597,7 @@ def incidence_matrix( >>> print(B2.todense()) # observe the non-unit entries >>> B1.dot(B2).todense() - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> row, column, B1 = CC.incidence_matrix(1, index=True) @@ -1734,7 +1714,7 @@ def hodge_laplacian_matrix( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> CC.hodge_laplacian_matrix(1) @@ -1824,12 +1804,12 @@ def up_laplacian_matrix( Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> L1_up = CC.up_laplacian_matrix(1) - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3], rank=2) >>> CC.add_cell([3, 4, 5], rank=2) >>> index, L1_up = CC.up_laplacian_matrix(1, index=True) @@ -1886,9 +1866,8 @@ def down_laplacian_matrix( Examples -------- - >>> import networkx as nx >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.add_cell([2, 3, 4, 1], rank=2) @@ -2021,9 +2000,8 @@ def dirac_operator_matrix( Examples -------- - >>> import networkx as nx >>> G = nx.path_graph(3) - >>> CC = CellComplex(G) + >>> CC = tnx.CellComplex(G) >>> CC.add_cell([1, 2, 3, 4], rank=2) >>> CC.dirac_operator_matrix() """ @@ -2072,15 +2050,14 @@ def restrict_to_cells( Examples -------- - >>> CC = CellComplex() - >>> c1 = Cell((1, 2, 3)) - >>> c2 = Cell((1, 2, 4)) - >>> c3 = Cell((1, 2, 5)) - >>> CC = CellComplex([c1, c2, c3]) + >>> c1 = tnx.Cell((1, 2, 3)) + >>> c2 = tnx.Cell((1, 2, 4)) + >>> c3 = tnx.Cell((1, 2, 5)) + >>> CC = tnx.CellComplex([c1, c2, c3]) >>> CC.add_edge(1, 0) >>> cx1 = CC.restrict_to_cells([c1, (0, 1)]) >>> cx1.cells - CellView([Cell(1, 2, 3)]) + CellView([Cell((1, 2, 3))]) """ CC = CellComplex(cells=self._G.copy()) @@ -2138,11 +2115,10 @@ def restrict_to_nodes(self, node_set: Iterable[Hashable]): Examples -------- - >>> CC = CellComplex() - >>> c1 = Cell((1, 2, 3)) - >>> c2 = Cell((1, 2, 4)) - >>> c3 = Cell((1, 2, 5)) - >>> CC = CellComplex([c1, c2, c3]) + >>> c1 = tnx.Cell((1, 2, 3)) + >>> c2 = tnx.Cell((1, 2, 4)) + >>> c3 = tnx.Cell((1, 2, 5)) + >>> CC = tnx.CellComplex([c1, c2, c3]) >>> CC.add_edge(1, 0) >>> CC.restrict_to_nodes([1, 2, 3, 0]) """ @@ -2169,7 +2145,7 @@ def to_combinatorial_complex(self): Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2, weight=1) >>> CC.add_cell([2, 3, 4, 5], rank=2, weight=4) >>> CC.add_cell([5, 6, 7, 8], rank=2, weight=0) @@ -2201,7 +2177,7 @@ def to_colored_hypergraph(self): Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2, weight=1) >>> CC.add_cell([2, 3, 4, 5], rank=2, weight=4) >>> CC.add_cell([5, 6, 7, 8], rank=2, weight=0) @@ -2229,12 +2205,11 @@ def to_hypergraph(self): Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2, color="red") >>> CC.add_cell([2, 3, 4, 5], rank=2) >>> CC.add_cell([5, 6, 7, 8], rank=2) - >>> HG = CC.to_hypergraph() - >>> HG + >>> CC.to_hypergraph() """ from hypernetx.classes.entity import EntitySet @@ -2289,6 +2264,7 @@ def singletons(self): >>> CC.add_node(0) >>> CC.add_node(10) >>> CC.singletons() + [0, 10] """ return [node for node in self.nodes if self.degree(node) == 0] @@ -2302,12 +2278,12 @@ def clone(self) -> Self: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2, weight=5) >>> CC.add_cell([2, 3, 4, 5], rank=2) >>> CC.add_cell([5, 6, 7, 8], rank=2) >>> CC.add_node(0) - >>> CX2 = CC.clone() + >>> CC.clone() """ _G = self._G.copy() CC = self.__class__(_G) @@ -2355,9 +2331,9 @@ def get_linegraph(self, s: int = 1, cells: bool = True) -> nx.Graph: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([0, 1, 2, 3, 4], rank=2) - >>> G = CC.get_linegraph() + >>> CC.get_linegraph() """ if not isinstance(s, int) or s < 1: raise ValueError(f"'s' must be a positive integer, got {s}.") @@ -2382,9 +2358,9 @@ def to_hasse_graph(self) -> nx.DiGraph: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell([1, 2, 3, 4], rank=2) - >>> G = CC.to_hasse_graph() + >>> CC.to_hasse_graph() """ G = nx.DiGraph() for n in self.nodes: @@ -2413,9 +2389,9 @@ def from_networkx_graph(self, G: nx.Graph) -> None: Examples -------- - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cells_from([[1, 2, 4], [1, 2, 7]], rank=2) - >>> G = Graph([(0, 1), (0, 2), (1, 2)]) + >>> G = nx.Graph([(0, 1), (0, 2), (1, 2)]) >>> CC.from_networkx_graph(G) >>> CC.edges """ @@ -2441,10 +2417,12 @@ def from_trimesh(cls, mesh) -> Self: Examples -------- >>> import trimesh - >>> mesh = trimesh.Trimesh(vertices=[[0, 0, 0], [0, 0, 1], [0, 1, 0]], - faces=[[0, 1, 2]], - process=False) - >>> CC = CellComplex.from_trimesh(mesh) + >>> mesh = trimesh.Trimesh( + ... vertices=[[0, 0, 0], [0, 0, 1], [0, 1, 0]], + ... faces=[[0, 1, 2]], + ... process=False, + ... ) + >>> CC = tnx.CellComplex.from_trimesh(mesh) >>> CC[0]["position"] """ CC = cls(mesh.faces) @@ -2487,7 +2465,7 @@ def load_mesh(cls, file_path, process: bool = False) -> Self: Examples -------- - >>> CC = CellComplex.load_mesh("bunny.obj") + >>> CC = tnx.CellComplex.load_mesh("bunny.obj") """ import trimesh diff --git a/toponetx/classes/colored_hypergraph.py b/toponetx/classes/colored_hypergraph.py index 049c4001..c695cb46 100644 --- a/toponetx/classes/colored_hypergraph.py +++ b/toponetx/classes/colored_hypergraph.py @@ -50,12 +50,11 @@ class ColoredHyperGraph(Complex): -------- Define an empty colored hypergraph: - >>> CHG = ColoredHyperGraph() + >>> CHG = tnx.ColoredHyperGraph() Add cells to the colored hypergraph: - >>> from toponetx.classes.colored_hypergraph import ColoredHyperGraph - >>> CHG = ColoredHyperGraph() + >>> CHG = tnx.ColoredHyperGraph() >>> CHG.add_cell([1, 2], rank=1) >>> CHG.add_cell([3, 4], rank=1) >>> CHG.add_cell([1, 2, 3, 4], rank=2) @@ -64,7 +63,7 @@ class ColoredHyperGraph(Complex): Create a Colored Hypergraph and add groups of friends with corresponding ranks: - >>> CHG = ColoredHyperGraph() + >>> CHG = tnx.ColoredHyperGraph() >>> CHG.add_cell( ... ["Alice", "Bob"], rank=1 ... ) # Alice and Bob are in a close-knit group. @@ -727,7 +726,7 @@ def set_cell_attributes(self, values, name: str | None = None) -> None: to assign a cell attribute to store the value of that property for each cell: - >>> CHG = ColoredHyperGraph() + >>> CHG = tnx.ColoredHyperGraph() >>> CHG.add_cell([1, 2, 3, 4], rank=2) >>> CHG.add_cell([1, 2, 4], rank=2) >>> CHG.add_cell([3, 4], rank=2) @@ -740,7 +739,7 @@ def set_cell_attributes(self, values, name: str | None = None) -> None: the entire dictionary will be used to update edge attributes: >>> G = nx.path_graph(3) - >>> CHG = ColoredHyperGraph(G) + >>> CHG = tnx.ColoredHyperGraph(G) >>> d = { ... ((1, 2), 0): {"color": "red", "attr2": 1}, ... ((0, 1), 0): {"color": "blue", "attr2": 3}, @@ -748,7 +747,6 @@ def set_cell_attributes(self, values, name: str | None = None) -> None: >>> CHG.set_cell_attributes(d) >>> CHG.cells[((0, 1), 0)]["color"] 'blue' - 3 Note that if the dict contains cells that are not in `self.cells`, they are silently ignored. @@ -779,7 +777,7 @@ def get_node_attributes(self, name: str): Examples -------- >>> G = nx.path_graph(3) - >>> CHG = ColoredHyperGraph(G) + >>> CHG = tnx.ColoredHyperGraph(G) >>> d = {0: {"color": "red", "attr2": 1}, 1: {"color": "blue", "attr2": 3}} >>> CHG.set_node_attributes(d) >>> CHG.get_node_attributes("color") @@ -787,7 +785,7 @@ def get_node_attributes(self, name: str): >>> G = nx.Graph() >>> G.add_nodes_from([1, 2, 3], color="blue") - >>> CHG = ColoredHyperGraph(G) + >>> CHG = tnx.ColoredHyperGraph(G) >>> nodes_color = CHG.get_node_attributes("color") >>> nodes_color[1] 'blue' @@ -817,7 +815,7 @@ def get_cell_attributes(self, name: str, rank=None): Examples -------- >>> G = nx.path_graph(3) - >>> CHG = ColoredHyperGraph(G) + >>> CHG = tnx.ColoredHyperGraph(G) >>> d = { ... ((1, 2), 0): {"color": "red", "attr2": 1}, ... ((0, 1), 0): {"color": "blue", "attr2": 3}, @@ -1251,14 +1249,12 @@ def adjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False): Examples -------- - >>> import networkx as nx - >>> from toponetx.classes.colored_hypergraph import ColoredHyperGraph >>> G = nx.Graph() # networkx graph >>> G.add_edge(0, 1) >>> G.add_edge(0, 3) >>> G.add_edge(0, 4) >>> G.add_edge(1, 4) - >>> CHG = ColoredHyperGraph(cells=G) + >>> CHG = tnx.ColoredHyperGraph(cells=G) >>> CHG.adjacency_matrix(0, 1) """ if index: @@ -1449,7 +1445,7 @@ def from_trimesh(cls, mesh: trimesh.Trimesh): ... faces=[[0, 1, 2]], ... process=False, ... ) - >>> CHG = ColoredHyperGraph.from_trimesh(mesh) + >>> CHG = tnx.ColoredHyperGraph.from_trimesh(mesh) >>> CHG.nodes """ raise NotImplementedError() @@ -1520,14 +1516,14 @@ def from_networkx_graph(self, G) -> None: Examples -------- - >>> from networkx import Graph - >>> G = Graph() + >>> G = nx.Graph() >>> G.add_edge(0, 1) >>> G.add_edge(0, 4) >>> G.add_edge(0, 7) - >>> CHG = ColoredHyperGraph() + >>> CHG = tnx.ColoredHyperGraph() >>> CHG.from_networkx_graph(G) >>> CHG.nodes + NodeView([(0,), (1,), (4,), (7,)]) """ for node in G.nodes: # cells is a networkx graph self.add_node(node, **G.nodes[node]) diff --git a/toponetx/classes/combinatorial_complex.py b/toponetx/classes/combinatorial_complex.py index 0ca1efa4..55ef1b2a 100644 --- a/toponetx/classes/combinatorial_complex.py +++ b/toponetx/classes/combinatorial_complex.py @@ -67,11 +67,11 @@ class CombinatorialComplex(ColoredHyperGraph): -------- Define an empty combinatorial complex: - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() Add cells to the combinatorial complex: - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() >>> CCC.add_cell([1, 2], rank=1) >>> CCC.add_cell([3, 4], rank=1) >>> CCC.add_cell([1, 2, 3, 4], rank=2) @@ -393,7 +393,7 @@ def set_cell_attributes(self, values, name: str | None = None) -> None: to assign a cell attribute to store the value of that property for each cell: - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() >>> CCC.add_cell([1, 2, 3, 4], rank=2) >>> CCC.add_cell([1, 2, 4], rank=2) >>> CCC.add_cell([3, 4], rank=2) @@ -406,7 +406,7 @@ def set_cell_attributes(self, values, name: str | None = None) -> None: the entire dictionary will be used to update edge attributes: >>> G = nx.path_graph(3) - >>> CCC = CombinatorialComplex(G) + >>> CCC = tnx.CombinatorialComplex(G) >>> d = { ... (1, 2): {"color": "red", "attr2": 1}, ... (0, 1): {"color": "blue", "attr2": 3}, @@ -437,7 +437,7 @@ def get_node_attributes(self, name: str) -> dict[Hashable, Any]: Examples -------- >>> G = nx.path_graph(3) - >>> CCC = CombinatorialComplex(G) + >>> CCC = tnx.CombinatorialComplex(G) >>> d = {0: {"color": "red", "attr2": 1}, 1: {"color": "blue", "attr2": 3}} >>> CCC.set_node_attributes(d) >>> CCC.get_node_attributes("color") @@ -445,7 +445,7 @@ def get_node_attributes(self, name: str) -> dict[Hashable, Any]: >>> G = nx.Graph() >>> G.add_nodes_from([1, 2, 3], color="blue") - >>> CCC = CombinatorialComplex(G) + >>> CCC = tnx.CombinatorialComplex(G) >>> nodes_color = CCC.get_node_attributes("color") >>> nodes_color[1] 'blue' @@ -470,7 +470,7 @@ def get_cell_attributes(self, name: str, rank: int | None = None): Examples -------- >>> G = nx.path_graph(3) - >>> CCC = CombinatorialComplex(G) + >>> CCC = tnx.CombinatorialComplex(G) >>> d = { ... (1, 2): {"color": "red", "attr2": 1}, ... (0, 1): {"color": "blue", "attr2": 3}, @@ -862,7 +862,7 @@ def adjacency_matrix(self, rank, via_rank, s: int = 1, index: bool = False): Examples -------- - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() >>> CCC.add_cell([1, 2], rank=1) >>> CCC.add_cell([3, 4], rank=1) >>> CCC.add_cell([1, 2, 3, 4], rank=2) @@ -926,8 +926,7 @@ def dirac_operator_matrix(self, weight: str | None = None, index: bool = False): Examples -------- - >>> from toponetx.classes import CombinatorialComplex - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() >>> CCC.add_cell([1, 2, 3, 4], rank=2) >>> CCC.add_cell([1, 2], rank=1) >>> CCC.add_cell([2, 3], rank=1) @@ -1108,11 +1107,12 @@ def singletons(self): Examples -------- - >>> CCC = CombinatorialComplex() + >>> CCC = tnx.CombinatorialComplex() >>> CCC.add_cell([1, 2], rank=1) >>> CCC.add_cell([3, 4], rank=1) >>> CCC.add_cell([9], rank=0) >>> CCC.singletons() + [frozenset({9})] """ return [k for k in self.skeleton(0) if self.degree(next(iter(k)), None) == 0] diff --git a/toponetx/classes/hyperedge.py b/toponetx/classes/hyperedge.py index dc00a42d..74eb7d40 100644 --- a/toponetx/classes/hyperedge.py +++ b/toponetx/classes/hyperedge.py @@ -1,6 +1,5 @@ """HyperEdge classes.""" - from collections.abc import Collection, Hashable from toponetx.classes.complex import Atom @@ -26,10 +25,10 @@ class HyperEdge(Atom[frozenset[Hashable]]): Examples -------- - >>> ac1 = HyperEdge((1, 2, 3)) - >>> ac2 = HyperEdge((1, 2, 4, 5)) - >>> ac3 = HyperEdge(("a", "b", "c")) - >>> ac3 = HyperEdge(("a", "b", "c"), rank=10) + >>> ac1 = tnx.HyperEdge((1, 2, 3)) + >>> ac2 = tnx.HyperEdge((1, 2, 4, 5)) + >>> ac3 = tnx.HyperEdge(("a", "b", "c")) + >>> ac3 = tnx.HyperEdge(("a", "b", "c"), rank=10) """ def __init__(self, elements: Collection, rank=None, **kwargs) -> None: diff --git a/toponetx/classes/path.py b/toponetx/classes/path.py index 1356a5f5..64f4bf76 100644 --- a/toponetx/classes/path.py +++ b/toponetx/classes/path.py @@ -59,18 +59,18 @@ class Path(Atom[tuple[Hashable]]): Examples -------- - >>> path1 = Path((1, 2, 3)) + >>> path1 = tnx.Path((1, 2, 3)) >>> list(path1.boundary) [] - >>> path2 = Path((1, 2, 3), construct_boundaries=True) + >>> path2 = tnx.Path((1, 2, 3), construct_boundaries=True) >>> list(path2.boundary) [(2, 3), (1, 3), (1, 2)] - >>> path3 = Path( + >>> path3 = tnx.Path( ... (1, 2, 3), construct_boundaries=True, allowed_paths=[(1, 2), (2, 3)] ... ) >>> list(path3.boundary) [(2, 3), (1, 2)] - >>> path4 = Path( + >>> path4 = tnx.Path( ... (1, 2, 3), construct_boundaries=True, allowed_paths=[(1, 3), (2, 3)] ... ) >>> list(path4.boundary) @@ -135,9 +135,9 @@ def construct_path_boundaries( Examples -------- - >>> Path.construct_path_boundaries((1, 2, 3), reserve_sequence_order=False) + >>> tnx.Path.construct_path_boundaries((1, 2, 3), reserve_sequence_order=False) [(2, 3), (1, 3), (1, 2)] - >>> Path.construct_path_boundaries( + >>> tnx.Path.construct_path_boundaries( ... (1, 2, 3), reserve_sequence_order=False, allowed_paths=[(1, 2), (2, 3)] ... ) [(2, 3), (1, 2)] diff --git a/toponetx/classes/path_complex.py b/toponetx/classes/path_complex.py index f1470b1c..8a582840 100644 --- a/toponetx/classes/path_complex.py +++ b/toponetx/classes/path_complex.py @@ -68,7 +68,7 @@ class PathComplex(Complex): Examples -------- - >>> PC = PathComplex([(1, 2, 3)]) + >>> PC = tnx.PathComplex([(1, 2, 3)]) >>> PC.paths PathView([(1,), (2,), (3,), (1, 2), (2, 3), (1, 2, 3)]) >>> PC.add_paths_from([(1, 2, 4), (1, 2, 5), (4, 5)]) @@ -76,7 +76,7 @@ class PathComplex(Complex): PathView([(1,), (2,), (3,), (4,), (5,), (1, 2), (2, 3), (2, 4), (2, 5), (4, 5), (1, 2, 3), (1, 2, 4), (1, 2, 5)]) >>> G = nx.Graph() >>> G.add_edges_from([(1, 2), (2, 3), (1, 3)]) - >>> PC = PathComplex(G) + >>> PC = tnx.PathComplex(G) >>> PC.paths PathView([(1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 3, 2), (1, 2, 3), (2, 1, 3)]) """ @@ -159,7 +159,7 @@ def add_paths_from(self, paths: Iterable[Sequence[Hashable] | Path]) -> None: Examples -------- - >>> PC = PathComplex([(1, 2, 3)]) + >>> PC = tnx.PathComplex([(1, 2, 3)]) >>> PC.paths PathView([(1,), (2,), (3,), (1, 2), (2, 3), (1, 2, 3)]) >>> PC.add_paths_from([(1, 2, 4), (1, 2, 5), (4, 5)]) @@ -188,7 +188,7 @@ def add_path(self, path: Hashable | Sequence[Hashable] | Path, **attr) -> None: Examples -------- - >>> PC = PathComplex([(1, 2, 3)]) + >>> PC = tnx.PathComplex([(1, 2, 3)]) >>> PC.paths PathView([(1,), (2,), (3,), (1, 2), (2, 3), (1, 2, 3)]) >>> PC.add_path((1, 2, 4)) @@ -707,7 +707,7 @@ def restrict_to_nodes(self, node_set: Iterable[Hashable]): Examples -------- - >>> PC = PathComplex( + >>> PC = tnx.PathComplex( ... [[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3], [0, 1, 2], [0, 1, 3]] ... ) >>> PC = PC.restrict_to_nodes([0, 1, 3]) @@ -737,7 +737,7 @@ def restrict_to_paths(self, path_set: Iterable[Sequence[Hashable]]): Examples -------- - >>> PC = PathComplex( + >>> PC = tnx.PathComplex( ... [[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3], [0, 1, 2], [0, 1, 3]] ... ) >>> PC = PC.restrict_to_paths([[1, 2, 3]]) @@ -766,7 +766,7 @@ def get_node_attributes(self, name: str) -> dict[tuple[Hashable], Any]: Examples -------- - >>> PC = PathComplex() + >>> PC = tnx.PathComplex() >>> PC.add_node(0) >>> PC.add_node(1, heat=55) >>> PC.add_node(2, heat=66) @@ -774,9 +774,9 @@ def get_node_attributes(self, name: str) -> dict[tuple[Hashable], Any]: >>> PC.add_node(2, color="blue") >>> PC.add_paths_from([[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3]]) >>> PC.get_node_attributes("heat") - {(1, ): 55, (2, ): 66} + {(1,): 55, (2,): 66} >>> PC.get_node_attributes("color") - {(2, ): "blue", (3, ): "red"} + {(2,): 'blue', (3,): 'red'} """ return {tuple(n): self[n][name] for n in self.skeleton(0) if name in self[n]} @@ -796,7 +796,7 @@ def set_node_attributes( Examples -------- - >>> PC = PathComplex() + >>> PC = tnx.PathComplex() >>> PC.add_paths_from([[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3]]) >>> PC.set_node_attributes( ... { @@ -856,7 +856,7 @@ def get_edge_attributes(self, name: str) -> dict[tuple[Hashable], Any]: Examples -------- - >>> PC = PathComplex() + >>> PC = tnx.PathComplex() >>> PC.add_paths_from([[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3]]) >>> PC.add_path([0, 1], weight=32) >>> PC.add_path([1, 2], weight=98) @@ -865,7 +865,7 @@ def get_edge_attributes(self, name: str) -> dict[tuple[Hashable], Any]: >>> PC.get_edge_attributes("weight") {(0, 1): 32, (1, 2): 98} >>> PC.get_edge_attributes("color") - {(1, 3): "red", (2, 3): "blue"} + {(1, 3): 'red', (2, 3): 'blue'} """ return {tuple(e): self[e][name] for e in self.skeleton(1) if name in self[e]} @@ -885,7 +885,7 @@ def set_edge_attributes( Examples -------- - >>> PC = PathComplex() + >>> PC = tnx.PathComplex() >>> PC.add_paths_from([[0, 1], [1, 2, 3], [1, 3, 2], [2, 1, 3]]) >>> PC.add_path([0, 1], weight=32) >>> PC.add_path([1, 2], weight=98) @@ -943,7 +943,7 @@ def get_path_attributes(self, name: str) -> dict[tuple[Hashable], Any]: Examples -------- - >>> PC = PathComplex() + >>> PC = tnx.PathComplex() >>> PC.add_paths_from([[0, 1]]) >>> PC.add_path([0, 1, 2], weight=43) >>> PC.add_path([0, 1, 3], weight=98) @@ -953,7 +953,7 @@ def get_path_attributes(self, name: str) -> dict[tuple[Hashable], Any]: >>> PC.get_path_attributes("weight") {(0, 1, 2): 43, (0, 1, 3): 98} >>> PC.get_path_attributes("color") - {(1, 2, 3): "red", (1, 3, 2): "blue", (2, 1, 3): "green"} + {(1, 2, 3): 'red', (1, 3, 2): 'blue', (2, 1, 3): 'green'} """ return { tuple(p): self[p][name] @@ -978,7 +978,7 @@ def set_path_attributes( Examples -------- - >>> PC = PathComplex( + >>> PC = tnx.PathComplex( ... [[0, 1], [0, 1, 2], [0, 1, 3], [1, 2, 3], [1, 3, 2], [2, 1, 3]] ... ) >>> PC.set_path_attributes( @@ -990,7 +990,7 @@ def set_path_attributes( >>> PC.get_path_attributes("weight") {(0, 1, 2): 43, (0, 1, 3): 98} >>> PC.get_path_attributes("color") - {(0, 1, 2): "red", (0, 1, 3): "blue"} + {(0, 1, 2): 'red', (0, 1, 3): 'blue'} >>> PC.set_path_attributes({0: 55}, "weight") >>> PC.get_path_attributes("weight") {(0,): 55, (0, 1, 2): 43, (0, 1, 3): 98} @@ -1193,7 +1193,7 @@ def compute_allowed_paths( -------- >>> G = nx.Graph() >>> G.add_edges_from([(1, 2), (2, 3), (1, 3), (0, 1)]) - >>> allowed_paths = PathComplex.compute_allowed_paths(G, max_rank=2) + >>> allowed_paths = tnx.PathComplex.compute_allowed_paths(G, max_rank=2) >>> allowed_paths {(0, 1), (1, 3), (1, 2), (2,), (1, 3, 2), (0, 1, 2), (0, 1, 3), (1, 2, 3), (2, 1, 3), (2, 3), (1,), (0,), (3,)} """ diff --git a/toponetx/classes/reportviews.py b/toponetx/classes/reportviews.py index 02de1d2b..4dc80909 100644 --- a/toponetx/classes/reportviews.py +++ b/toponetx/classes/reportviews.py @@ -261,7 +261,7 @@ class ColoredHyperEdgeView(AtomView): Examples -------- - >>> hev = ColoredHyperEdgeView() + >>> hev = tnx.ColoredHyperEdgeView() """ def __init__(self) -> None: @@ -513,7 +513,7 @@ class HyperEdgeView(AtomView): Examples -------- - >>> hev = HyperEdgeView() + >>> hev = tnx.HyperEdgeView() """ def __init__(self) -> None: @@ -895,7 +895,7 @@ def __contains__(self, atom: Any) -> bool: -------- Check if a node is in the simplex view: - >>> view = SimplexView() + >>> view = tnx.SimplexView() >>> view.faces_dict.append({frozenset({1}): {"weight": 1}}) >>> view.max_dim = 0 >>> 1 in view diff --git a/toponetx/classes/simplex.py b/toponetx/classes/simplex.py index 98664d7e..9d5713e6 100644 --- a/toponetx/classes/simplex.py +++ b/toponetx/classes/simplex.py @@ -30,14 +30,14 @@ class Simplex(Atom[frozenset[Hashable]]): Examples -------- >>> # Create a 0-dimensional simplex (point) - >>> s = Simplex((1,)) + >>> s = tnx.Simplex((1,)) >>> # Create a 1-dimensional simplex (line segment) - >>> s = Simplex((1, 2)) + >>> s = tnx.Simplex((1, 2)) >>> # Create a 2-dimensional simplex (triangle) - >>> simplex1 = Simplex((1, 2, 3)) - >>> simplex2 = Simplex(("a", "b", "c")) + >>> simplex1 = tnx.Simplex((1, 2, 3)) + >>> simplex2 = tnx.Simplex(("a", "b", "c")) >>> # Create a 3-dimensional simplex (tetrahedron) - >>> simplex3 = Simplex((1, 2, 4, 5), weight=1) + >>> simplex3 = tnx.Simplex((1, 2, 4, 5), weight=1) """ def __init__( @@ -78,7 +78,7 @@ def __contains__(self, item: Any) -> bool: Examples -------- - >>> s = Simplex((1, 2, 3)) + >>> s = tnx.Simplex((1, 2, 3)) >>> 1 in s True >>> 4 in s diff --git a/toponetx/classes/simplicial_complex.py b/toponetx/classes/simplicial_complex.py index 7e0d9871..bc247b15 100644 --- a/toponetx/classes/simplicial_complex.py +++ b/toponetx/classes/simplicial_complex.py @@ -87,7 +87,7 @@ class SimplicialComplex(Complex): -------- Define a simplicial complex using a set of maximal simplices: - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) TopoNetX is also compatible with NetworkX, allowing users to create a simplicial complex from a NetworkX graph. Existing node and edge attributes are copied to the simplicial complex: @@ -95,7 +95,7 @@ class SimplicialComplex(Complex): >>> G = nx.Graph() >>> G.add_edge(0, 1, weight=4) >>> G.add_edges_from([(0, 3), (0, 4), (1, 4)]) - >>> SC = SimplicialComplex(simplices=G) + >>> SC = tnx.SimplicialComplex(simplices=G) >>> SC.add_simplex([1, 2, 3]) >>> SC.simplices SimplexView([(0,), (1,), (3,), (4,), (2,), (0, 1), (0, 3), (0, 4), (1, 4), (1, 2), (1, 3), (2, 3), (1, 2, 3)]) @@ -215,7 +215,7 @@ def is_maximal(self, simplex: Iterable) -> bool: Examples -------- - >>> SC = SimplicialComplex([[1, 2, 3]]) + >>> SC = tnx.SimplicialComplex([[1, 2, 3]]) >>> SC.is_maximal([1, 2, 3]) True >>> SC.is_maximal([1, 2]) @@ -450,7 +450,7 @@ def remove_maximal_simplex(self, simplex: Collection) -> None: Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex((1, 2, 3, 4), weight=1) >>> SC.add_simplex((1, 2, 3, 4, 5)) >>> SC.remove_maximal_simplex((1, 2, 3, 4, 5)) @@ -505,7 +505,7 @@ def remove_nodes(self, node_set: Iterable[Hashable]) -> None: Examples -------- - >>> SC = SimplicialComplex([(1, 2), (2, 3), (3, 4)]) + >>> SC = tnx.SimplicialComplex([(1, 2), (2, 3), (3, 4)]) >>> SC.remove_nodes([1]) >>> SC.simplices SimplexView([(2,), (3,), (4,), (2, 3), (3, 4)]) @@ -678,7 +678,7 @@ def set_simplex_attributes(self, values, name: str | None = None) -> None: to assign a simplex attribute to store the value of that property for each simplex: - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -690,7 +690,7 @@ def set_simplex_attributes(self, values, name: str | None = None) -> None: If you provide a dictionary of dictionaries as the second argument, the entire dictionary will be used to update simplex attributes: - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 3, 4]) >>> SC.add_simplex([1, 2, 3]) >>> SC.add_simplex([1, 2, 4]) @@ -727,7 +727,7 @@ def get_node_attributes(self, name: str) -> dict[Hashable, Any]: Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -756,7 +756,7 @@ def get_simplex_attributes( Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -837,7 +837,7 @@ def incidence_matrix( Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -967,7 +967,7 @@ def hodge_laplacian_matrix( Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -1036,8 +1036,7 @@ def dirac_operator_matrix( Examples -------- - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -1106,7 +1105,7 @@ def normalized_laplacian_matrix(self, rank: int, weight: str | None = None): Examples -------- - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) >>> SC.normalized_laplacian_matrix(1) """ import scipy as sp @@ -1155,7 +1154,7 @@ def up_laplacian_matrix( Examples -------- - >>> SC = SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) + >>> SC = tnx.SimplicialComplex([[1, 2, 3], [2, 3, 5], [0, 1]]) >>> SC.up_laplacian_matrix(1) """ if weight is not None: @@ -1246,7 +1245,7 @@ def adjacency_matrix( Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([1, 2, 3, 4]) >>> SC.add_simplex([1, 2, 4]) >>> SC.add_simplex([3, 4, 8]) @@ -1333,10 +1332,10 @@ def restrict_to_simplices(self, cell_set) -> Self: Examples -------- - >>> c1 = Simplex((1, 2, 3)) - >>> c2 = Simplex((1, 2, 4)) - >>> c3 = Simplex((1, 2, 5)) - >>> SC = SimplicialComplex([c1, c2, c3]) + >>> c1 = tnx.Simplex((1, 2, 3)) + >>> c2 = tnx.Simplex((1, 2, 4)) + >>> c3 = tnx.Simplex((1, 2, 5)) + >>> SC = tnx.SimplicialComplex([c1, c2, c3]) >>> SC1 = SC.restrict_to_simplices([c1, (2, 4)]) >>> SC1.simplices SimplexView([(1,), (2,), (3,), (4,), (1, 2), (1, 3), (2, 3), (2, 4), (1, 2, 3)]) @@ -1361,10 +1360,10 @@ def restrict_to_nodes(self, node_set): Examples -------- - >>> c1 = Simplex((1, 2, 3)) - >>> c2 = Simplex((1, 2, 4)) - >>> c3 = Simplex((1, 2, 5)) - >>> SC = SimplicialComplex([c1, c2, c3]) + >>> c1 = tnx.Simplex((1, 2, 3)) + >>> c2 = tnx.Simplex((1, 2, 4)) + >>> c3 = tnx.Simplex((1, 2, 5)) + >>> SC = tnx.SimplicialComplex([c1, c2, c3]) >>> new_complex = SC.restrict_to_nodes([1, 2, 3, 4]) >>> new_complex.simplices SimplexView([(1,), (2,), (3,), (4,), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (1, 2, 3), (1, 2, 4)]) @@ -1392,7 +1391,7 @@ def get_all_maximal_simplices(self): Examples -------- - >>> SC = SimplicialComplex([(1, 2), (1, 2, 3), (1, 2, 4), (2, 5)]) + >>> SC = tnx.SimplicialComplex([(1, 2), (1, 2, 3), (1, 2, 4), (2, 5)]) >>> SC.get_all_maximal_simplices() [(2, 5), (1, 2, 3), (1, 2, 4)] """ @@ -1421,7 +1420,7 @@ def from_spharpy(cls, mesh) -> Self: ... [[0, 1, 2]], [[1.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 3.0]] ... ) - >>> SC = SimplicialComplex.from_spharpy(mesh) + >>> SC = tnx.SimplicialComplex.from_spharpy(mesh) """ vertices = np.array(mesh.vertlist) SC = cls(mesh.trilist) @@ -1448,7 +1447,7 @@ def to_hasse_graph(self) -> nx.DiGraph: Examples -------- - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex([0, 1, 2]) >>> G = SC.to_hasse_graph() """ @@ -1481,7 +1480,7 @@ def from_gudhi(cls, tree: SimplexTree) -> Self: >>> from gudhi import SimplexTree >>> tree = SimplexTree() >>> _ = tree.insert([1, 2, 3, 5]) - >>> SC = SimplicialComplex.from_gudhi(tree) + >>> SC = tnx.SimplicialComplex.from_gudhi(tree) """ SC = cls() for simplex, _ in tree.get_skeleton(tree.dimension()): @@ -1510,7 +1509,7 @@ def from_trimesh(cls, mesh) -> Self: ... faces=[[0, 1, 2]], ... process=False, ... ) - >>> SC = SimplicialComplex.from_trimesh(mesh) + >>> SC = tnx.SimplicialComplex.from_trimesh(mesh) >>> print(SC.nodes) >>> print(SC.simplices) >>> SC[(0)]["position"] @@ -1554,7 +1553,7 @@ def load_mesh(cls, file_path, process: bool = False) -> Self: Examples -------- - >>> SC = SimplicialComplex.load_mesh("C:/temp/stanford-bunny.obj") + >>> SC = tnx.SimplicialComplex.load_mesh("C:/temp/stanford-bunny.obj") >>> SC.nodes """ import trimesh @@ -1628,7 +1627,7 @@ def to_spharapy(self, vertex_position_name: str = "position"): >>> import spharapy.spharabasis as sb >>> import spharapy.datasets as sd >>> mesh = tm.TriMesh([[0, 1, 2]], [[0, 0, 0], [0, 0, 1], [0, 1, 0]]) - >>> SC = SimplicialComplex.from_spharpy(mesh) + >>> SC = tnx.SimplicialComplex.from_spharpy(mesh) >>> mesh2 = SC.to_spharapy() >>> mesh2.vertlist == mesh.vertlist >>> mesh2.trilist == mesh.trilist @@ -1695,7 +1694,7 @@ def from_nx(cls, G: nx.Graph) -> Self: >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_edge(1, 2, weight=2) >>> G.add_edge(3, 4, weight=4) - >>> SC = SimplicialComplex.from_nx(G) + >>> SC = tnx.SimplicialComplex.from_nx(G) >>> SC[(1, 2)]["weight"] 2 """ @@ -1738,7 +1737,7 @@ def simplicial_closure_of_hypergraph(cls, H) -> Self: -------- >>> import hypernetx as hnx >>> hg = hnx.Hypergraph([[1, 2, 3, 4], [1, 2, 3]], static=True) - >>> sc = SimplicialComplex.simplicial_closure_of_hypergraph(hg) + >>> sc = tnx.SimplicialComplex.simplicial_closure_of_hypergraph(hg) >>> sc.simplices SimplexView([(1,), (2,), (3,), (4,), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4), (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4), (1, 2, 3, 4)]) """ @@ -1756,10 +1755,10 @@ def to_cell_complex(self): Examples -------- - >>> c1 = Simplex((1, 2, 3)) - >>> c2 = Simplex((1, 2, 4)) - >>> c3 = Simplex((2, 5)) - >>> SC = SimplicialComplex([c1, c2, c3]) + >>> c1 = tnx.Simplex((1, 2, 3)) + >>> c2 = tnx.Simplex((1, 2, 4)) + >>> c3 = tnx.Simplex((2, 5)) + >>> SC = tnx.SimplicialComplex([c1, c2, c3]) >>> SC.to_cell_complex() """ from toponetx.classes.cell_complex import CellComplex @@ -1776,10 +1775,10 @@ def to_hypergraph(self) -> Hypergraph: Examples -------- - >>> c1 = Simplex((1, 2, 3)) - >>> c2 = Simplex((1, 2, 4)) - >>> c3 = Simplex((2, 5)) - >>> SC = SimplicialComplex([c1, c2, c3]) + >>> c1 = tnx.Simplex((1, 2, 3)) + >>> c2 = tnx.Simplex((1, 2, 4)) + >>> c3 = tnx.Simplex((2, 5)) + >>> SC = tnx.SimplicialComplex([c1, c2, c3]) >>> SC.to_hypergraph() Hypergraph({'e0': [1, 2], 'e1': [1, 3], 'e2': [1, 4], 'e3': [2, 3], 'e4': [2, 4], 'e5': [2, 5], 'e6': [1, 2, 3], 'e7': [1, 2, 4]},name=) """ @@ -1800,10 +1799,10 @@ def to_combinatorial_complex(self): Examples -------- - >>> c1 = Simplex((1, 2, 3)) - >>> c2 = Simplex((1, 2, 3)) - >>> c3 = Simplex((1, 2, 4)) - >>> SC = SimplicialComplex([c1, c2, c3]) + >>> c1 = tnx.Simplex((1, 2, 3)) + >>> c2 = tnx.Simplex((1, 2, 3)) + >>> c3 = tnx.Simplex((1, 2, 4)) + >>> SC = tnx.SimplicialComplex([c1, c2, c3]) >>> CCC = SC.to_combinatorial_complex() """ from toponetx.classes.combinatorial_complex import CombinatorialComplex diff --git a/toponetx/readwrite/atomlist.py b/toponetx/readwrite/atomlist.py index 55bea675..43da18a9 100644 --- a/toponetx/readwrite/atomlist.py +++ b/toponetx/readwrite/atomlist.py @@ -1,4 +1,5 @@ """Read and write complexes as a list of their atoms.""" + from collections.abc import Generator, Hashable, Iterable from itertools import combinations from typing import Literal, overload @@ -127,19 +128,17 @@ def generate_atomlist( -------- Generate a list of atoms from a simplicial complex: - >>> from toponetx.classes import SimplicialComplex - >>> SC = SimplicialComplex() + >>> SC = tnx.SimplicialComplex() >>> SC.add_simplex((1,), weight=1.0) >>> SC.add_simplex((1, 2, 3), weight=4.0) - >>> list(generate_atomlist(SC)) + >>> list(tnx.generate_atomlist(SC)) ["1 {'weight': 1.0}", "1 2 3 {'weight': 4.0}"] Generate a list of atoms from a cell complex: - >>> from toponetx.classes import CellComplex - >>> CC = CellComplex() + >>> CC = tnx.CellComplex() >>> CC.add_cell((1, 2, 3), rank=2, weight=4.0) - >>> list(generate_atomlist(CC)) + >>> list(tnx.generate_atomlist(CC)) ["1 2 3 {'weight': 4.0}"] """ if isinstance(domain, SimplicialComplex): diff --git a/tutorials/01_simplicial_complexes.ipynb b/tutorials/01_simplicial_complexes.ipynb index 8fc1731d..425005d2 100644 --- a/tutorials/01_simplicial_complexes.ipynb +++ b/tutorials/01_simplicial_complexes.ipynb @@ -21,24 +21,12 @@ "execution_count": 1, "id": "1d48b70e", "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAETCAIAAACay3XvAAAACXBIWXMAAC4jAAAuIwF4pT92AAAgAElEQVR4nO2de3wTVf73owRa2tKE3tK00EnKreVSgoDcJAlUflxEGkB2QVgIi664Lx6psrviuq5B1/X2AIGHR2QRCSwsrCwSxAVchQaQqyAplLZySZMIlPRGWto0hSq/V3vY6ZC0c8vMZGZy3n/wygyTmcmkn5xzPt9zvt9H7t+/L4FAWMPZCvbscrlco9EI/YlLeXAPELHh9Xqtrdhsttra2nY/nU6nM7SiUqmE+PFhmwNhEqfTaTKZtmzZQv6cOp3OZDLp9XphfRFQORBm8Hq9JpNpzZo19M6m0+nMZrOAenFQORAGsNvtBoPB5XKFeKrVq1fn5+cL4huByoGEisViWbhwYfBJphlmakaOycwepEBU0TFx6H6P2+EoLrpWfHHTx+uC37VgwQKLxcL/LwUqBxIS7cpmzjzjxFlzkeyB+Gf2VnkO7d65buV7AfsFIR6oHAh9gmWDIKoVazcSagaLt8rz2UfmHdsekgr/xdPJZDLx4DYgwsNut8+ePbupqQm982mGmSs2bE1K60Hps0THxA3VPZkil584WoDuLCwslMvlI0eO5O1jgW0OhCYajaawsBB976LFS55ZvBQ7nqGK/eihl5+bh75JJpPZ7XbeRnse5cE9QISHyWTCymaaYWaIsmmRojZ3ybLl6GZtba3RaOTtk4FtDoQyXq9XpVKhkwMQRGXeYZUnKRh5kqv/sOQL6250s6CggJ9BUtjmQChjsViwc2peWPYaU7KRSCQL//AGdpO343CoHAhlzGYz+hatVj9q0jQGn6E8SY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Emr+AaENoYjUaNRmM0GlG3DQXrleGj0+ksFouIs7BjYWDeWtdY+gF+7mnX5BVlCViqaDQau91usVhMJhMaJCUJgiAmk0n0PTQsLOYhCC+hRAkjGWMrFovFarUGTORtl7y8PKPRGAndswBoKkelUqHLCq4UXWB21hMlsCYvU1FCCNCP1+u12Wz2VrAjW1Ur+lYi9lHRVw76uqH+DnP3E8iJY22d7JSeyownNNxECSEtv0RyuaEV+DCCoZmpUKNpm0P+hXW331fPxs153A6sgZMzdhgybkj6qAEyVSqUDSS8MKCc4AWATOEoLsKeKZL7BhC+QVM5KpUKQRB084ztGzY+18F/7UBf63Q6Ni4BgdCDfl5prAW5Y5vFVVKEezhlXCVF2EhCRDmeEP7DjHJaMqrs2t7xsXT4dGXb/E6ZTAbHqRBeQV85KpVqwYIF6OaObZaTB79g6qMVfL4D2+Dk5+fL5cKY6wmJEEJaTe10OtVqNXbPzm+Oh56CqOTsqd8+25YVRCaTOZ1OqBwIrwipfo5KpXrzzTexe15dNNfjdoRyTo/b8f5rL2P3mEwmKBsI32Agx6dGo8FOE0QQ1Yq1G+lVbLUfPWR++0/YGE5eXp4oq0xChA4DyglI5QH483urRk16mnxmAr+v/vDunegKUMDgwYNtNhtscCA8hJm80qAiV4B4tFr99PnPZQ0bga8fsKhwCyblAADKBsJnmFEOEE+7qzsQRPX0M7N7ZQ9UqtRY88DjdpQ7y4rOntr0cTvJiqBsIDyHMeWAbpvRaCQzNR2fBQsWmM1mKBsIn2FSOQCr1Zqfn091aRQAQRCwshf+zUB4DvNV3Q0Gg91uX716NXZiGyEIgmzevNnpdELZQAQB820OFpvNZrVabTZb8PgHMHjwYL1eDxbBwz8YiIBgVzlYAtYVyuVyqBaIQJFIJP8LA4bz02ZipToAAAAASUVORK5CYII=", - "text/plain": [ - "" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "from IPython import display\n", "\n", "display.Image(\"sc.png\")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -69,12 +57,11 @@ "execution_count": 2, "id": "c9a65d5a-0e1a-4405-a913-a6c2a28cb206", "metadata": {}, - "outputs": [], "source": [ "import numpy as np\n", - "\n", - "from toponetx.classes import SimplicialComplex as sc" - ] + "import toponetx as tnx" + ], + "outputs": [] }, { "cell_type": "markdown", @@ -185,11 +172,11 @@ "execution_count": 3, "id": "ac159722-ef65-4132-a4d0-47383cff4492", "metadata": {}, - "outputs": [], "source": [ "edge_set = [[1, 2], [2, 3], [2, 4], [3, 4], [2, 5], [5, 6], [5, 7], [6, 7]]\n", - "ex1_sc = sc(edge_set)" - ] + "ex1_sc = tnx.SimplicialComplex(edge_set)" + ], + "outputs": [] }, { "cell_type": "markdown", @@ -204,21 +191,10 @@ "execution_count": 4, "id": "f49c211e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "SimplexView([(1,), (2,), (3,), (4,), (5,), (6,), (7,), (1, 2), (2, 3), (2, 4), (3, 4), (2, 5), (5, 6), (5, 7), (6, 7)])" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "ex1_sc.simplices" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -266,13 +242,13 @@ "execution_count": 5, "id": "b2b165cd", "metadata": {}, - "outputs": [], "source": [ "edge_set = [[1, 2], [1, 3]]\n", "face_set = [[2, 3, 4], [2, 4, 5]]\n", "\n", - "ex2_sc = sc(edge_set + face_set)" - ] + "ex2_sc = tnx.SimplicialComplex(edge_set + face_set)" + ], + "outputs": [] }, { "cell_type": "markdown", @@ -287,21 +263,10 @@ "execution_count": 6, "id": "22d1fa43", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "SimplexView([(1,), (2,), (3,), (4,), (5,), (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (2, 5), (4, 5), (2, 3, 4), (2, 4, 5)])" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "ex2_sc.simplices" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -379,12 +344,12 @@ "execution_count": 7, "id": "f7701230-2e26-4722-be4b-50d1f81f3332", "metadata": {}, - "outputs": [], "source": [ "ex2_incidence1_rows, ex2_incidence1_cols, ex2_incidence1 = ex2_sc.incidence_matrix(\n", " rank=1, index=True\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -399,18 +364,10 @@ "execution_count": 8, "id": "fdd10897-1dca-47fa-a338-5d66f0512700", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(5, 7)\n" - ] - } - ], "source": [ "print(ex2_incidence1.shape)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -425,20 +382,11 @@ "execution_count": 9, "id": "70b2618d-fe12-49ac-a342-4e2e7f38edc8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{(1,): 0, (2,): 1, (3,): 2, (4,): 3, (5,): 4}\n", - "{(1, 2): 0, (1, 3): 1, (2, 3): 2, (2, 4): 3, (2, 5): 4, (3, 4): 5, (4, 5): 6}\n" - ] - } - ], "source": [ "print(ex2_incidence1_rows)\n", "print(ex2_incidence1_cols)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -463,22 +411,10 @@ "execution_count": 10, "id": "aef05c8f-f0ea-49e7-b592-9d11dead86bf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[1. 1. 0. 0. 0. 0. 0.]\n", - " [1. 0. 1. 1. 1. 0. 0.]\n", - " [0. 1. 1. 0. 0. 1. 0.]\n", - " [0. 0. 0. 1. 0. 1. 1.]\n", - " [0. 0. 0. 0. 1. 0. 1.]]\n" - ] - } - ], "source": [ "print(np.abs(ex2_incidence1.todense()))" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -515,22 +451,10 @@ "execution_count": 11, "id": "2889f192-e2a0-4d72-b981-a38de3aa3867", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[-1. -1. 0. 0. 0. 0. 0.]\n", - " [ 1. 0. -1. -1. -1. 0. 0.]\n", - " [ 0. 1. 1. 0. 0. -1. 0.]\n", - " [ 0. 0. 0. 1. 0. 1. -1.]\n", - " [ 0. 0. 0. 0. 1. 0. 1.]]\n" - ] - } - ], "source": [ "print(ex2_incidence1.todense())" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -545,12 +469,12 @@ "execution_count": 12, "id": "6012451f", "metadata": {}, - "outputs": [], "source": [ "ex2_incidence2_rows, ex2_incidence2_cols, ex2_incidence2 = ex2_sc.incidence_matrix(\n", " rank=2, index=True\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -565,18 +489,10 @@ "execution_count": 13, "id": "9abbd82a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(7, 2)\n" - ] - } - ], "source": [ "print(ex2_incidence2.shape)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -591,20 +507,11 @@ "execution_count": 14, "id": "f866ebb8-f629-4109-ae12-d5c83b4a5b71", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{(1, 2): 0, (1, 3): 1, (2, 3): 2, (2, 4): 3, (2, 5): 4, (3, 4): 5, (4, 5): 6}\n", - "{(2, 3, 4): 0, (2, 4, 5): 1}\n" - ] - } - ], "source": [ "print(ex2_incidence2_rows)\n", "print(ex2_incidence2_cols)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -631,24 +538,10 @@ "execution_count": 15, "id": "fce5d9b8-2312-426d-af38-fbd58ccb2be8", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[0. 0.]\n", - " [0. 0.]\n", - " [1. 0.]\n", - " [1. 1.]\n", - " [0. 1.]\n", - " [1. 0.]\n", - " [0. 1.]]\n" - ] - } - ], "source": [ "print(np.abs(ex2_incidence2.todense()))" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -663,24 +556,10 @@ "execution_count": 16, "id": "a2dd61c9-2d6f-4235-a77b-ba07574f7c02", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 0. 0.]\n", - " [ 0. 0.]\n", - " [ 1. 0.]\n", - " [-1. 1.]\n", - " [ 0. -1.]\n", - " [ 1. 0.]\n", - " [ 0. 1.]]\n" - ] - } - ], "source": [ "print(ex2_incidence2.todense())" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -738,24 +617,12 @@ "execution_count": 17, "id": "b0129ffe", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. -1. -1. 0. 0.]\n", - " [-1. 4. -1. -1. -1.]\n", - " [-1. -1. 3. -1. 0.]\n", - " [ 0. -1. -1. 3. -1.]\n", - " [ 0. -1. 0. -1. 2.]]\n" - ] - } - ], "source": [ "# up-Laplacian rank 0: incidence between vertices via edges\n", "up_laplacian_0 = ex2_sc.up_laplacian_matrix(rank=0).todense()\n", "print(up_laplacian_0)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -776,26 +643,12 @@ "execution_count": 18, "id": "35e68379", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 0. 0. 0. 0. 0. 0. 0.]\n", - " [ 0. 0. 0. 0. 0. 0. 0.]\n", - " [ 0. 0. 1. -1. 0. 1. 0.]\n", - " [ 0. 0. -1. 2. -1. -1. 1.]\n", - " [ 0. 0. 0. -1. 1. 0. -1.]\n", - " [ 0. 0. 1. -1. 0. 1. 0.]\n", - " [ 0. 0. 0. 1. -1. 0. 1.]]\n" - ] - } - ], "source": [ "# up laplacian rank 1: edge to incident faces to incident edges\n", "up_laplacian_1 = ex2_sc.up_laplacian_matrix(rank=1).todense()\n", "print(up_laplacian_1)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -885,27 +738,13 @@ "execution_count": 19, "id": "4b52fdbe", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. 1. -1. -1. -1. 0. 0.]\n", - " [ 1. 2. 1. 0. 0. -1. 0.]\n", - " [-1. 1. 2. 1. 1. -1. 0.]\n", - " [-1. 0. 1. 2. 1. 1. -1.]\n", - " [-1. 0. 1. 1. 2. 0. 1.]\n", - " [ 0. -1. -1. 1. 0. 2. -1.]\n", - " [ 0. 0. 0. -1. 1. -1. 2.]]\n" - ] - } - ], "source": [ "# down laplacian rank 1: edges to incident nodes to incident edges\n", "down_laplacian_1 = ex2_sc.down_laplacian_matrix(rank=1).todense()\n", "\n", "print(down_laplacian_1)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -922,22 +761,13 @@ "execution_count": 20, "id": "48db5dcc-29b2-48ce-bec6-28d01d2dbe3c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 3. -1.]\n", - " [-1. 3.]]\n" - ] - } - ], "source": [ "# down laplacian rank 2: face to incident edges to incident faces\n", "down_laplacian_2 = ex2_sc.down_laplacian_matrix(rank=2).todense()\n", "\n", "print(down_laplacian_2)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -998,24 +828,12 @@ "execution_count": 21, "id": "8d9e01a3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. -1. -1. 0. 0.]\n", - " [-1. 4. -1. -1. -1.]\n", - " [-1. -1. 3. -1. 0.]\n", - " [ 0. -1. -1. 3. -1.]\n", - " [ 0. -1. 0. -1. 2.]]\n" - ] - } - ], "source": [ "hodge_laplacian_0 = ex2_sc.hodge_laplacian_matrix(rank=0).todense()\n", "\n", "print(hodge_laplacian_0)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1030,26 +848,12 @@ "execution_count": 22, "id": "1479bc66-7fa5-4cae-9cea-64642031e393", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. 1. -1. -1. -1. 0. 0.]\n", - " [ 1. 2. 1. 0. 0. -1. 0.]\n", - " [-1. 1. 3. 0. 1. 0. 0.]\n", - " [-1. 0. 0. 4. 0. 0. 0.]\n", - " [-1. 0. 1. 0. 3. 0. 0.]\n", - " [ 0. -1. 0. 0. 0. 3. -1.]\n", - " [ 0. 0. 0. 0. 0. -1. 3.]]\n" - ] - } - ], "source": [ "hodge_laplacian_1 = ex2_sc.hodge_laplacian_matrix(rank=1).todense()\n", "\n", "print(hodge_laplacian_1)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1064,21 +868,12 @@ "execution_count": 23, "id": "c3e471f4-5461-42c7-bbf0-e069ca2f6154", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 3. -1.]\n", - " [-1. 3.]]\n" - ] - } - ], "source": [ "hodge_laplacian_2 = ex2_sc.hodge_laplacian_matrix(rank=2).todense()\n", "\n", "print(hodge_laplacian_2)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1113,12 +908,12 @@ "execution_count": 24, "id": "a21a398d", "metadata": {}, - "outputs": [], "source": [ "# setting what data we want to attach to which faces. order here is important.\n", "face_data = {(2, 3, 4): {\"weight\": 1}, (2, 4, 5): {\"weight\": 5}}\n", "ex2_sc.set_simplex_attributes(face_data)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1135,23 +930,14 @@ "execution_count": 25, "id": "e1ed8daf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{frozenset({2, 3, 4}): 1, frozenset({2, 4, 5}): 5}\n", - "[1 5]\n" - ] - } - ], "source": [ "face_weights = ex2_sc.get_simplex_attributes(\"weight\")\n", "example2_face_values = np.array(list(face_weights.values()))\n", "\n", "print(face_weights)\n", "print(example2_face_values)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1183,29 +969,11 @@ "execution_count": 26, "id": "9e66a464", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(7, 2)\n" - ] - }, - { - "data": { - "text/plain": [ - "array([ 0., 0., 1., 4., -5., 1., 5.])" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "print(ex2_incidence2.shape)\n", "ex2_incidence2.dot(example2_face_values)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -1229,15 +997,6 @@ "execution_count": 27, "id": "1a8711fb", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ 6. 14.]\n" - ] - } - ], "source": [ "edge_data = {\n", " (1, 2): {\"attr\": 6},\n", @@ -1257,7 +1016,8 @@ "new_face_feature = ex2_incidence2.T.dot(example2_edge_values)\n", "\n", "print(new_face_feature)" - ] + ], + "outputs": [] }, { "cell_type": "markdown", diff --git a/tutorials/02_cell_complexes.ipynb b/tutorials/02_cell_complexes.ipynb index 418cba64..3f5449c5 100644 --- a/tutorials/02_cell_complexes.ipynb +++ b/tutorials/02_cell_complexes.ipynb @@ -21,22 +21,12 @@ "execution_count": 1, "id": "b4b84db3", "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAESCAIAAABRl6ZKAAAACXBIWXMAAC4jAAAuIwF4pT92AAAgAElEQVR4nO2de1wTV/73U4kSwiWRW7gok6AiKEoUq6IVYtUVe8GobVdad40/3Wpbn4rr7trur9ZY263dfayx62vVrS5xV6u7rTVqt9qnUlJaRa3WURHxUkiwiOEiiUIMQu3zCuNrGCYwt8xMJsl5/+ErEydzC5+cc77f7/mcR37++WcRAMABMAybzWaLxQLDMPbocrlcrVZruvDf5w6UA2AZi8Vi7MJqtRIfWSaTabVanU7njxICygGwht1uLyoq2rVrF90D5uXl6fV6/9IPUA6AHQwGg16vdzgcjI82e/Zso9Eol8v94hsBygF4C3FTU7hAN0g1JCw8HH3nWsWFE9+YrVaL584QBJlMJrVaLfwvBSgH4BV2u12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CEDJvKQYpqdTodwRI6pGRlZRmNRlBoAxA4LK/qjkxq37RpEzbgRhGZTLZp0yYYhoFsAMKH5TYHi7ELrJ1XXyAZG9A9A/gRHCoHwW63m81mGIax1gUIGo1GrVZrNJpgMHwABBIikej/A0kDE9EMFordAAAAAElFTkSuQmCC", - "text/plain": [ - "" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from IPython import display\n", "\n", + "import toponetx\n", + "\n", "display.Image(\"cc.png\")" ] }, @@ -54,9 +44,7 @@ "id": "87af1a10", "metadata": {}, "outputs": [], - "source": [ - "from toponetx.classes import CellComplex as CC" - ] + "source": [] }, { "cell_type": "markdown", @@ -156,19 +144,9 @@ "execution_count": 2, "id": "a48e579f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cell Complex with 0 nodes, 0 edges and 0 2-cells \n", - "Cell Complex with 2 nodes, 1 edges and 0 2-cells \n", - "Cell Complex with 5 nodes, 6 edges and 0 2-cells \n" - ] - } - ], + "outputs": [], "source": [ - "example_1 = CC()\n", + "example_1 = toponetx.CellComplex()\n", "print(example_1)\n", "\n", "example_1.add_cell([1, 2], rank=1)\n", @@ -205,19 +183,9 @@ "execution_count": 3, "id": "866efb53", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cell Complex with 0 nodes, 0 edges and 0 2-cells \n", - "Cell Complex with 3 nodes, 3 edges and 1 2-cells \n", - "Cell Complex with 5 nodes, 6 edges and 2 2-cells \n" - ] - } - ], + "outputs": [], "source": [ - "example_2 = CC()\n", + "example_2 = toponetx.CellComplex()\n", "print(example_2)\n", "\n", "example_2.add_cell([1, 2, 3], rank=2)\n", @@ -264,18 +232,7 @@ "execution_count": 4, "id": "609e6a6d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "edges:\n", - "{(1, 2): 0, (1, 3): 1, (2, 3): 2, (2, 4): 3, (3, 5): 4, (4, 5): 5}\n", - "2-cells:\n", - "{(1, 2, 3): 0, (2, 4, 5, 3): 1}\n" - ] - } - ], + "outputs": [], "source": [ "row, column, incidence_2 = example_2.incidence_matrix(rank=2, index=True)\n", "print(\"edges:\")\n", @@ -368,20 +325,7 @@ "execution_count": 5, "id": "99113d72", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 1. -1. 1. 0. 0. 0.]\n", - " [-1. 1. -1. 0. 0. 0.]\n", - " [ 1. -1. 2. -1. 1. -1.]\n", - " [ 0. 0. -1. 1. -1. 1.]\n", - " [ 0. 0. 1. -1. 1. -1.]\n", - " [ 0. 0. -1. 1. -1. 1.]]\n" - ] - } - ], + "outputs": [], "source": [ "laplacian_up_1 = example_2.up_laplacian_matrix(rank=1).todense()\n", "print(laplacian_up_1)" @@ -406,19 +350,7 @@ "execution_count": 6, "id": "160bd5e3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. -1. -1. 0. 0.]\n", - " [-1. 3. -1. -1. 0.]\n", - " [-1. -1. 3. 0. -1.]\n", - " [ 0. -1. 0. 2. -1.]\n", - " [ 0. 0. -1. -1. 2.]]\n" - ] - } - ], + "outputs": [], "source": [ "up_laplacian_0 = example_2.up_laplacian_matrix(rank=0).todense()\n", "print(up_laplacian_0)" @@ -504,20 +436,7 @@ "execution_count": 7, "id": "0f8a7393", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. 1. -1. -1. 0. 0.]\n", - " [ 1. 2. 1. 0. -1. 0.]\n", - " [-1. 1. 2. 1. -1. 0.]\n", - " [-1. 0. 1. 2. 0. -1.]\n", - " [ 0. -1. -1. 0. 2. 1.]\n", - " [ 0. 0. 0. -1. 1. 2.]]\n" - ] - } - ], + "outputs": [], "source": [ "down_laplacian_1 = example_2.down_laplacian_matrix(rank=1).todense()\n", "print(down_laplacian_1)" @@ -578,19 +497,7 @@ "execution_count": 8, "id": "ea4559bf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 2. -1. -1. 0. 0.]\n", - " [-1. 3. -1. -1. 0.]\n", - " [-1. -1. 3. 0. -1.]\n", - " [ 0. -1. 0. 2. -1.]\n", - " [ 0. 0. -1. -1. 2.]]\n" - ] - } - ], + "outputs": [], "source": [ "hodge_laplacian_0 = example_2.hodge_laplacian_matrix(rank=0).todense()\n", "print(hodge_laplacian_0)" @@ -609,20 +516,7 @@ "execution_count": 9, "id": "b4db4148", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 3. 0. 0. -1. 0. 0.]\n", - " [ 0. 3. 0. 0. -1. 0.]\n", - " [ 0. 0. 4. 0. 0. -1.]\n", - " [-1. 0. 0. 3. -1. 0.]\n", - " [ 0. -1. 0. -1. 3. 0.]\n", - " [ 0. 0. -1. 0. 0. 3.]]\n" - ] - } - ], + "outputs": [], "source": [ "hodge_laplacian_1 = example_2.hodge_laplacian_matrix(rank=1).todense()\n", "print(hodge_laplacian_1)" @@ -643,16 +537,7 @@ "execution_count": 10, "id": "449df978", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 3. -1.]\n", - " [-1. 4.]]\n" - ] - } - ], + "outputs": [], "source": [ "hodge_laplacian_2 = example_2.hodge_laplacian_matrix(rank=2).todense()\n", "print(hodge_laplacian_2)" diff --git a/tutorials/03_combinatorial_complexes.ipynb b/tutorials/03_combinatorial_complexes.ipynb index 849c0d64..2c658d22 100644 --- a/tutorials/03_combinatorial_complexes.ipynb +++ b/tutorials/03_combinatorial_complexes.ipynb @@ -37,6 +37,8 @@ "source": [ "from IPython import display\n", "\n", + "import toponetx\n", + "\n", "display.Image(\"ccc.png\")" ] }, @@ -54,9 +56,7 @@ "id": "24d69d5e", "metadata": {}, "outputs": [], - "source": [ - "from toponetx.classes import CombinatorialComplex as CCC" - ] + "source": [] }, { "cell_type": "markdown", @@ -152,7 +152,7 @@ } ], "source": [ - "example = CCC()\n", + "example = toponetx.CombinatorialComplex()\n", "\n", "example.add_cell([1, 2], rank=1)\n", "print(example)\n", diff --git a/tutorials/04_colored_hypergraphs.ipynb b/tutorials/04_colored_hypergraphs.ipynb index 5f5d2800..c3f8e346 100644 --- a/tutorials/04_colored_hypergraphs.ipynb +++ b/tutorials/04_colored_hypergraphs.ipynb @@ -54,9 +54,7 @@ "id": "24d69d5e", "metadata": {}, "outputs": [], - "source": [ - "from toponetx.classes import ColoredHyperGraph as chg" - ] + "source": "import toponetx as tnx" }, { "cell_type": "markdown", @@ -167,7 +165,7 @@ } ], "source": [ - "example = chg()\n", + "example = tnx.ColoredHyperGraph()\n", "\n", "example.add_cell([1, 2], rank=1)\n", "print(example)\n",