diff --git a/README.md b/README.md index 4e959c44..1979d84e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ from topomodelx.nn.simplicial.san import SAN from topomodelx.utils.sparse import from_sparse # Step 1: Load the Karate Club dataset -dataset = tnx.karate_club(complex_type="simplicial") +dataset = tnx.datasets.karate_club(complex_type="simplicial") # Step 2: Prepare Laplacians and node/edge features laplacian_down = from_sparse(dataset.down_laplacian_matrix(rank=1)) diff --git a/test/nn/simplicial/test_dist2cycle.py b/test/nn/simplicial/test_dist2cycle.py index d7a96005..216e582e 100644 --- a/test/nn/simplicial/test_dist2cycle.py +++ b/test/nn/simplicial/test_dist2cycle.py @@ -1,7 +1,8 @@ """Unit tests for Dist2Cycke Model.""" + import numpy as np +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.dist2cycle import Dist2Cycle @@ -15,7 +16,7 @@ def test_forward(self): face_set = [[2, 3, 4], [2, 4, 5]] torch.manual_seed(42) - simplicial_complex = SimplicialComplex(edge_set + face_set) + simplicial_complex = tnx.SimplicialComplex(edge_set + face_set) laplacian_down_1 = simplicial_complex.down_laplacian_matrix(rank=1).todense() adjacency_1 = simplicial_complex.adjacency_matrix(rank=1).todense() laplacian_down_1_inv = np.linalg.pinv( diff --git a/test/nn/simplicial/test_hsn.py b/test/nn/simplicial/test_hsn.py index 0ed83c9b..1eb549ac 100644 --- a/test/nn/simplicial/test_hsn.py +++ b/test/nn/simplicial/test_hsn.py @@ -1,7 +1,8 @@ """Unit tests for HSN Model.""" + import numpy as np +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.hsn import HSN @@ -15,7 +16,7 @@ def test_forward(self): face_set = [[2, 3, 4], [2, 4, 5]] torch.manual_seed(42) - simplicial_complex = SimplicialComplex(edge_set + face_set) + simplicial_complex = tnx.SimplicialComplex(edge_set + face_set) laplacian_down_1 = simplicial_complex.down_laplacian_matrix(rank=1).todense() adjacency_1 = simplicial_complex.adjacency_matrix(rank=1).todense() laplacian_down_1_inv = np.linalg.pinv( diff --git a/test/nn/simplicial/test_san.py b/test/nn/simplicial/test_san.py index d99c613e..855c195d 100644 --- a/test/nn/simplicial/test_san.py +++ b/test/nn/simplicial/test_san.py @@ -1,9 +1,10 @@ """Unit tests for SAN Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.san import SAN from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) x_1 = torch.randn(35, 2) diff --git a/test/nn/simplicial/test_sca_cmps.py b/test/nn/simplicial/test_sca_cmps.py index 448d039d..8789039c 100644 --- a/test/nn/simplicial/test_sca_cmps.py +++ b/test/nn/simplicial/test_sca_cmps.py @@ -1,9 +1,10 @@ """Unit tests for SCA Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.sca_cmps import SCACMPS from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) diff --git a/test/nn/simplicial/test_sccn.py b/test/nn/simplicial/test_sccn.py index 17800356..ed47dacd 100644 --- a/test/nn/simplicial/test_sccn.py +++ b/test/nn/simplicial/test_sccn.py @@ -1,9 +1,10 @@ """Unit tests for SCCN Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.sccn import SCCN from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) diff --git a/test/nn/simplicial/test_sccnn.py b/test/nn/simplicial/test_sccnn.py index 6a67e1b6..086a0fac 100644 --- a/test/nn/simplicial/test_sccnn.py +++ b/test/nn/simplicial/test_sccnn.py @@ -1,9 +1,10 @@ """Unit tests for SCCNN Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.sccnn import SCCNN from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) # Some nodes might not be selected at all in the combinations above diff --git a/test/nn/simplicial/test_scconv.py b/test/nn/simplicial/test_scconv.py index a1034933..baa48d66 100644 --- a/test/nn/simplicial/test_scconv.py +++ b/test/nn/simplicial/test_scconv.py @@ -1,9 +1,10 @@ """Unit tests for SCCNN Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.scconv import SCConv from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) # Some nodes might not be selected at all in the combinations above diff --git a/test/nn/simplicial/test_scn2.py b/test/nn/simplicial/test_scn2.py index 6e56bf65..e3a8b8a1 100644 --- a/test/nn/simplicial/test_scn2.py +++ b/test/nn/simplicial/test_scn2.py @@ -1,9 +1,10 @@ """Unit tests for SCN2 Model.""" + import itertools import random +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.scn2 import SCN2 from topomodelx.utils.sparse import from_sparse @@ -28,7 +29,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) diff --git a/test/nn/simplicial/test_scnn.py b/test/nn/simplicial/test_scnn.py index d0edc632..51a4f4bf 100644 --- a/test/nn/simplicial/test_scnn.py +++ b/test/nn/simplicial/test_scnn.py @@ -1,10 +1,11 @@ """Unit tests for SCNN Model.""" + import itertools import random import numpy as np +import toponetx as tnx import torch -from toponetx.classes import SimplicialComplex from topomodelx.nn.simplicial.scnn import SCNN from topomodelx.utils.sparse import from_sparse @@ -29,7 +30,7 @@ def test_forward(self): ) random.shuffle(all_combinations) selected_combinations = all_combinations[:faces] - simplicial_complex = SimplicialComplex() + simplicial_complex = tnx.SimplicialComplex() for simplex in selected_combinations: simplicial_complex.add_simplex(simplex) x_1 = torch.randn(simplicial_complex.shape[1], 2) diff --git a/topomodelx/nn/simplicial/scone.py b/topomodelx/nn/simplicial/scone.py index 11c1d1af..bc533eaa 100644 --- a/topomodelx/nn/simplicial/scone.py +++ b/topomodelx/nn/simplicial/scone.py @@ -1,12 +1,13 @@ """Neural network implementation of classification using SCoNe.""" + import random from itertools import product import networkx as nx import numpy as np +import toponetx as tnx import torch from scipy.spatial import Delaunay, distance -from toponetx.classes.simplicial_complex import SimplicialComplex from torch import nn from torch.utils.data.dataset import Dataset @@ -15,7 +16,7 @@ def generate_complex( N: int = 100, *, rng: np.random.Generator | None = None -) -> tuple[SimplicialComplex, np.ndarray]: +) -> tuple[tnx.SimplicialComplex, np.ndarray]: """Generate a simplicial complex as described. Generate a simplicial complex of dimension 2 as follows: @@ -58,13 +59,13 @@ def generate_complex( for j in range(3): simplices[i][j] = idx_dict[simplices[i][j]] - sc = SimplicialComplex(simplices) + sc = tnx.SimplicialComplex(simplices) coords = points[list(indices_included)] return sc, coords def generate_trajectories( - sc: SimplicialComplex, coords: np.ndarray, n_max: int = 1000 + sc: tnx.SimplicialComplex, coords: np.ndarray, n_max: int = 1000 ) -> list[list[int]]: """Generate trajectories from nodes in the lower left corner to the upper right corner connected through a node in the middle.""" # Get indices for start points in the lower left corner, mid points in the center region and end points in the upper right corner. @@ -98,7 +99,9 @@ def generate_trajectories( class TrajectoriesDataset(Dataset): """Create a dataset of trajectories.""" - def __init__(self, sc: SimplicialComplex, trajectories: list[list[int]]) -> None: + def __init__( + self, sc: tnx.SimplicialComplex, trajectories: list[list[int]] + ) -> None: self.trajectories = trajectories self.sc = sc self.adjacency = torch.Tensor(sc.adjacency_matrix(0).toarray()) diff --git a/tutorials/cell/can_train.ipynb b/tutorials/cell/can_train.ipynb index 0cc2cd63..b9957dc4 100644 --- a/tutorials/cell/can_train.ipynb +++ b/tutorials/cell/can_train.ipynb @@ -126,9 +126,9 @@ ], "source": [ "import numpy as np\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", - "from toponetx.classes.cell_complex import CellComplex\n", "from torch_geometric.datasets import TUDataset\n", "from torch_geometric.utils.convert import to_networkx\n", "\n", @@ -218,7 +218,7 @@ "x_1_list = []\n", "y_list = []\n", "for graph in dataset:\n", - " cell_complex = CellComplex(to_networkx(graph))\n", + " cell_complex = tnx.CellComplex(to_networkx(graph))\n", " cc_list.append(cell_complex)\n", " x_0_list.append(graph.x)\n", " x_1_list.append(graph.edge_attr)\n", diff --git a/tutorials/cell/ccxn_train.ipynb b/tutorials/cell/ccxn_train.ipynb index a58c1d41..2005fa75 100644 --- a/tutorials/cell/ccxn_train.ipynb +++ b/tutorials/cell/ccxn_train.ipynb @@ -58,7 +58,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -132,7 +132,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", diff --git a/tutorials/cell/cwn_train.ipynb b/tutorials/cell/cwn_train.ipynb index 2eb9b991..55959c8d 100644 --- a/tutorials/cell/cwn_train.ipynb +++ b/tutorials/cell/cwn_train.ipynb @@ -66,7 +66,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -152,7 +152,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", diff --git a/tutorials/combinatorial/hmc_train.ipynb b/tutorials/combinatorial/hmc_train.ipynb index 14d464fa..9a6254df 100644 --- a/tutorials/combinatorial/hmc_train.ipynb +++ b/tutorials/combinatorial/hmc_train.ipynb @@ -133,8 +133,8 @@ "outputs": [], "source": [ "import numpy as np\n", + "import toponetx as tnx\n", "import torch\n", - "from toponetx.datasets.mesh import shrec_16\n", "from torch.utils.data import DataLoader, Dataset\n", "\n", "from topomodelx.nn.combinatorial.hmc import HMC" @@ -338,7 +338,7 @@ } ], "source": [ - "shrec_training, shrec_testing = shrec_16()" + "shrec_training, shrec_testing = tnx.datasets.shrec_16()" ] }, { @@ -839,9 +839,9 @@ ], "metadata": { "kernelspec": { - "display_name": "venv_modelx", + "display_name": "venv", "language": "python", - "name": "venv_modelx" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -853,7 +853,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/tutorials/hypergraph/dhgcn_train.ipynb b/tutorials/hypergraph/dhgcn_train.ipynb index cf629929..a15d0a74 100644 --- a/tutorials/hypergraph/dhgcn_train.ipynb +++ b/tutorials/hypergraph/dhgcn_train.ipynb @@ -22,7 +22,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -98,7 +98,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.mesh.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", diff --git a/tutorials/hypergraph/hypergat_train.ipynb b/tutorials/hypergraph/hypergat_train.ipynb index d0e7f881..cc7bdf59 100644 --- a/tutorials/hypergraph/hypergat_train.ipynb +++ b/tutorials/hypergraph/hypergat_train.ipynb @@ -55,7 +55,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -112,7 +112,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", diff --git a/tutorials/hypergraph/unigcn_train.ipynb b/tutorials/hypergraph/unigcn_train.ipynb index 54aafc77..40c55387 100644 --- a/tutorials/hypergraph/unigcn_train.ipynb +++ b/tutorials/hypergraph/unigcn_train.ipynb @@ -7,9 +7,9 @@ "metadata": {}, "outputs": [], "source": [ + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", - "from toponetx.classes.simplicial_complex import SimplicialComplex\n", "from torch_geometric.datasets import TUDataset\n", "from torch_geometric.utils.convert import to_networkx\n", "\n", @@ -83,7 +83,7 @@ "x_1_list = []\n", "y_list = []\n", "for graph in dataset:\n", - " hg = SimplicialComplex(to_networkx(graph)).to_hypergraph()\n", + " hg = tnx.SimplicialComplex(to_networkx(graph)).to_hypergraph()\n", " hg_list.append(hg)\n", " x_1_list.append(graph.x.to(device))\n", " y_list.append(graph.y.to(device))\n", diff --git a/tutorials/hypergraph/unigin_train.ipynb b/tutorials/hypergraph/unigin_train.ipynb index 559df1fe..b8293db8 100644 --- a/tutorials/hypergraph/unigin_train.ipynb +++ b/tutorials/hypergraph/unigin_train.ipynb @@ -6,9 +6,9 @@ "metadata": {}, "outputs": [], "source": [ + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", - "from toponetx.classes.simplicial_complex import SimplicialComplex\n", "from torch_geometric.datasets import TUDataset\n", "from torch_geometric.utils.convert import to_networkx\n", "\n", @@ -78,7 +78,7 @@ "x_1_list = []\n", "y_list = []\n", "for graph in dataset:\n", - " hg = SimplicialComplex(to_networkx(graph)).to_hypergraph()\n", + " hg = tnx.SimplicialComplex(to_networkx(graph)).to_hypergraph()\n", " hg_list.append(hg)\n", " x_1_list.append(graph.x.to(device))\n", " y_list.append(graph.y.to(device))\n", diff --git a/tutorials/simplicial/dist2cycle_train.ipynb b/tutorials/simplicial/dist2cycle_train.ipynb index 0e39a8db..94c85ef7 100644 --- a/tutorials/simplicial/dist2cycle_train.ipynb +++ b/tutorials/simplicial/dist2cycle_train.ipynb @@ -34,7 +34,7 @@ "source": [ "import numpy as np\n", "import numpy.linalg as npla\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "\n", "from topomodelx.nn.simplicial.dist2cycle import Dist2Cycle\n", @@ -72,7 +72,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/hsn_train.ipynb b/tutorials/simplicial/hsn_train.ipynb index f8ae367b..5c6fdc96 100644 --- a/tutorials/simplicial/hsn_train.ipynb +++ b/tutorials/simplicial/hsn_train.ipynb @@ -38,7 +38,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "\n", "from topomodelx.nn.simplicial.hsn import HSN\n", @@ -75,7 +75,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/san_train.ipynb b/tutorials/simplicial/san_train.ipynb index f06209da..290d440e 100644 --- a/tutorials/simplicial/san_train.ipynb +++ b/tutorials/simplicial/san_train.ipynb @@ -86,7 +86,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "\n", "from topomodelx.nn.simplicial.san import SAN\n", @@ -149,7 +149,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/sca_cmps_train.ipynb b/tutorials/simplicial/sca_cmps_train.ipynb index 085ddb1e..343cf5a4 100644 --- a/tutorials/simplicial/sca_cmps_train.ipynb +++ b/tutorials/simplicial/sca_cmps_train.ipynb @@ -38,7 +38,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "\n", "from topomodelx.nn.simplicial.sca_cmps import SCACMPS\n", @@ -100,7 +100,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/sccn_train.ipynb b/tutorials/simplicial/sccn_train.ipynb index 6bce969c..e12635c1 100644 --- a/tutorials/simplicial/sccn_train.ipynb +++ b/tutorials/simplicial/sccn_train.ipynb @@ -40,7 +40,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "\n", "from topomodelx.nn.simplicial.sccn import SCCN\n", @@ -79,7 +79,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\", feat_dim=2)\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\", feat_dim=2)\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/sccnn_train.ipynb b/tutorials/simplicial/sccnn_train.ipynb index 43506207..27c14178 100644 --- a/tutorials/simplicial/sccnn_train.ipynb +++ b/tutorials/simplicial/sccnn_train.ipynb @@ -73,7 +73,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -112,7 +112,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", "x_1s = shrec[\"edge_feat\"]\n", @@ -499,8 +499,6 @@ } ], "source": [ - "import toponetx.datasets.graph as graph\n", - "\n", "%load_ext autoreload\n", "%autoreload 2" ] @@ -533,7 +531,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)\n", "max_rank = dataset.dim\n", "print(max_rank)" diff --git a/tutorials/simplicial/scconv_train.ipynb b/tutorials/simplicial/scconv_train.ipynb index cca34b9a..45204349 100644 --- a/tutorials/simplicial/scconv_train.ipynb +++ b/tutorials/simplicial/scconv_train.ipynb @@ -74,7 +74,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets.graph as graph\n", + "import toponetx as tnx\n", "import torch\n", "from scipy.sparse import coo_matrix, diags\n", "\n", @@ -138,7 +138,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)" ] }, diff --git a/tutorials/simplicial/scn2_train.ipynb b/tutorials/simplicial/scn2_train.ipynb index e9b17530..b42778f5 100644 --- a/tutorials/simplicial/scn2_train.ipynb +++ b/tutorials/simplicial/scn2_train.ipynb @@ -35,7 +35,7 @@ ], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -91,7 +91,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "x_0s = shrec[\"node_feat\"]\n", diff --git a/tutorials/simplicial/scnn_train.ipynb b/tutorials/simplicial/scnn_train.ipynb index e5f960cd..9c518696 100644 --- a/tutorials/simplicial/scnn_train.ipynb +++ b/tutorials/simplicial/scnn_train.ipynb @@ -63,7 +63,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import toponetx.datasets as datasets\n", + "import toponetx as tnx\n", "import torch\n", "from sklearn.model_selection import train_test_split\n", "\n", @@ -102,7 +102,7 @@ } ], "source": [ - "shrec, _ = datasets.mesh.shrec_16(size=\"small\")\n", + "shrec, _ = tnx.datasets.shrec_16(size=\"small\")\n", "\n", "shrec = {key: np.array(value) for key, value in shrec.items()}\n", "\n", @@ -381,15 +381,6 @@ "# 2. Node Classification " ] }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "import toponetx.datasets.graph as graph" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -413,7 +404,7 @@ } ], "source": [ - "dataset = graph.karate_club(complex_type=\"simplicial\")\n", + "dataset = tnx.datasets.karate_club(complex_type=\"simplicial\")\n", "print(dataset)\n", "\n", "# Maximal simplex order\n", diff --git a/tutorials/simplicial/scone_train.ipynb b/tutorials/simplicial/scone_train.ipynb index be5b6e5e..3d8b023a 100644 --- a/tutorials/simplicial/scone_train.ipynb +++ b/tutorials/simplicial/scone_train.ipynb @@ -55,10 +55,10 @@ "import matplotlib.pyplot as plt\n", "import networkx as nx\n", "import numpy as np\n", + "import toponetx as tnx\n", "import torch\n", "import torch.nn as nn\n", "from scipy.spatial import Delaunay, distance\n", - "from toponetx.classes.simplicial_complex import SimplicialComplex\n", "from torch.optim import Adam\n", "from torch.utils.data import DataLoader, random_split\n", "from torch.utils.data.dataset import Dataset\n", @@ -112,7 +112,7 @@ }, "outputs": [], "source": [ - "def generate_complex(N: int = 100) -> tuple[SimplicialComplex, np.ndarray]:\n", + "def generate_complex(N: int = 100) -> tuple[tnx.SimplicialComplex, np.ndarray]:\n", " \"\"\"\n", " Generate a simplicial complex of dimension 2 as follows:\n", " 1. Uniformly sample N random points form the unit square and build the Delaunay triangulation.\n", @@ -145,7 +145,7 @@ " for j in range(3):\n", " simplices[i][j] = idx_dict[simplices[i][j]]\n", "\n", - " sc = SimplicialComplex(simplices)\n", + " sc = tnx.SimplicialComplex(simplices)\n", " coords = points[list(indices_included)]\n", " return sc, coords" ] @@ -185,7 +185,7 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_complex(sc: SimplicialComplex, coords: np.ndarray) -> None:\n", + "def plot_complex(sc: tnx.SimplicialComplex, coords: np.ndarray) -> None:\n", " \"\"\"\n", " Given a simplicial complex of dimension 1 or 2, plot the simplices in the plane using the coordinates of the 0-simplices in coords.\n", " \"\"\"\n", @@ -251,7 +251,7 @@ "outputs": [], "source": [ "def generate_trajectories(\n", - " sc: SimplicialComplex, coords: np.ndarray, n_max: int = 1000\n", + " sc: tnx.SimplicialComplex, coords: np.ndarray, n_max: int = 1000\n", ") -> list[list[int]]:\n", " \"\"\"\n", " Generate trajectories from nodes in the lower left corner to the upper right corner connected through a node in the middle.\n", @@ -387,7 +387,9 @@ "outputs": [], "source": [ "class TrajectoriesDataset(Dataset):\n", - " def __init__(self, sc: SimplicialComplex, trajectories: list[list[int]]) -> None:\n", + " def __init__(\n", + " self, sc: tnx.SimplicialComplex, trajectories: list[list[int]]\n", + " ) -> None:\n", " self.trajectories = trajectories\n", " self.sc = sc\n", " self.adjacency = torch.Tensor(sc.adjacency_matrix(0).toarray())\n",