diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100755 index afb6e0e4..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3.11.3 - -WORKDIR /TopoBenchmarkX - -COPY . . - -RUN pip install --upgrade pip - -RUN pip install -e '.[all]' -RUN pip install --no-dependencies git+https://github.com/pyt-team/TopoNetX.git -RUN pip install --no-dependencies git+https://github.com/pyt-team/TopoModelX.git -RUN pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cu115 -RUN pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.1+cu115.html -RUN pip install torch-cluster -f https://data.pyg.org/whl/torch-2.0.0+cu115.html -RUN pip install lightning>=2.0.0 -RUN pip install numpy pre-commit jupyterlab notebook ipykernel \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100755 index 7a2a6bce..00000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,18 +0,0 @@ -//devcontainer.json -{ - "name": "TopoBenchmarkX:new", - "dockerFile": "./Dockerfile", - "customizations": { - "vscode": { - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-python.python", - "ms-python.isort", - "ms-python.vscode-pylance", - "ms-toolsai.jupyter" - ] - } - } -} \ No newline at end of file diff --git a/.devcontainer/pyproject.toml b/.devcontainer/pyproject.toml deleted file mode 100755 index e9439fe3..00000000 --- a/.devcontainer/pyproject.toml +++ /dev/null @@ -1,129 +0,0 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "TopoBenchmarkX" -version = "0.0.1" -authors = [ - {name = "PyT-Team Authors", email = "tlscabinet@gmail.com"} -] -readme = "README.md" -description = "Topological Deep Learning" -license = {file = "LICENSE.txt"} -classifiers = [ - "License :: OSI Approved :: MIT License", - "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Mathematics", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11" -] -requires-python = ">= 3.10" -dependencies=[ - "tqdm", - "numpy", - "scipy", - "requests", - "scikit-learn", - "matplotlib", - "networkx", - "pandas", - "pyg-nightly", - "decorator", - "hypernetx < 2.0.0", - "trimesh", - "spharapy", - "hydra-core==1.3.2", - "hydra-colorlog==1.2.0", - "hydra-optuna-sweeper==1.2.0", - "rich", - "rootutils", - "pytest", - -] - -[project.optional-dependencies] -doc = [ - "jupyter", - "nbsphinx", - "nbsphinx_link", - "sphinx", - "sphinx_gallery", - "pydata-sphinx-theme" -] -lint = [ - "black", - "black[jupyter]", - "flake8", - "flake8-docstrings", - "Flake8-pyproject", - "isort", - "pre-commit" -] -test = [ - "pytest", - "pytest-cov", - "coverage", - "jupyter", - "mypy" -] - -dev = ["TopoBenchmarkX[test, lint]"] -all = ["TopoBenchmarkX[dev, doc]"] - -[project.urls] -homepage="https://github.com/pyt-team/TopoBenchmarkX" -repository="https://github.com/pyt-team/TopoBenchmarkX" - -[tool.setuptools.dynamic] -version = {attr = "topobenchmarkx.__version__"} - -[tool.setuptools.packages.find] -include = [ - "topobenchmarkx", - "topobenchmarkx.*" -] - -[tool.mypy] -warn_redundant_casts = true -warn_unused_ignores = true -show_error_codes = true -plugins = "numpy.typing.mypy_plugin" - -[[tool.mypy.overrides]] -module = [ - "torch_cluster.*","networkx.*","scipy.spatial","scipy.sparse","toponetx.classes.simplicial_complex" -] -ignore_missing_imports = true - -[tool.pytest.ini_options] -addopts = "--capture=no" - -[tool.black] -line-length = 88 - -[tool.isort] -line_length = 88 -multi_line_output = 3 -include_trailing_comma = true -skip = [".gitignore", "__init__.py"] - -[tool.flake8] -max-line-length = 88 -application_import_names = "topobenchmarkx" -docstring-convention = "numpy" -exclude = [ - "topobenchmarkx/__init__.py", - "docs/conf.py" -] - -import_order_style = "smarkets" -extend-ignore = ["E501", "E203"] -per-file-ignores = [ - "*/__init__.py: D104, F401", -] diff --git a/env.bash b/env.bash index b4225bbf..39a413f8 100644 --- a/env.bash +++ b/env.bash @@ -1,33 +1,20 @@ # #!/bin/bash -# set -e - -# # Step 1: Upgrade pip -# pip install --upgrade pip - -# # Step 2: Install dependencies -# yes | pip install -e '.[all]' -# yes | pip install --no-dependencies git+https://github.com/pyt-team/TopoNetX.git -# yes | pip install --no-dependencies git+https://github.com/pyt-team/TopoModelX.git -# yes | pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cu115 -# yes | pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.1+cu115.html -# yes | pip install torch-cluster -f https://data.pyg.org/whl/torch-2.0.0+cu115.html -# yes | pip install lightning>=2.0.0 -# yes | pip install numpy pre-commit jupyterlab notebook ipykernel - - -yes | conda create -n topox python=3.11.3 -conda activate topox +#conda create -n topox python=3.11.3 +#conda activate topox +pip install --upgrade pip pip install -e '.[all]' -yes | pip install --no-dependencies git+https://github.com/pyt-team/TopoNetX.git -yes | pip install --no-dependencies git+https://github.com/pyt-team/TopoModelX.git +pip install git+https://github.com/pyt-team/TopoNetX.git +pip install git+https://github.com/pyt-team/TopoModelX.git +pip install git+https://github.com/pyt-team/TopoEmbedX.git -yes | pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cu115 -yes | pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.1+cu115.html -yes | pip install torch-cluster -f https://data.pyg.org/whl/torch-2.0.0+cu115.html -yes | pip install numpy pre-commit jupyterlab notebook ipykernel +CUDA="cu115" # if available, select the CUDA version suitable for your system + # e.g. cpu, cu102, cu111, cu113, cu115 +pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/${CUDA} +pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.1+${CUDA}.html +pip install torch-cluster -f https://data.pyg.org/whl/torch-2.0.0+${CUDA}.html pytest diff --git a/pyproject.toml b/pyproject.toml index caf89fad..a6564426 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,10 @@ dependencies=[ "lightning==2.2.1", "einops==0.7.0", "wandb==0.16.4", + "tabulate", + "ipykernel", + "notebook", + "jupyterlab", "rich", "rootutils", "pytest", @@ -167,4 +171,5 @@ checks = [ exclude = [ '\.undocumented_method$', '\.__init__$', + '\.__repr__$', ] \ No newline at end of file diff --git a/test/data/test_Dataloaders.py b/test/data/test_Dataloaders.py index c595ed13..42b6b17b 100644 --- a/test/data/test_Dataloaders.py +++ b/test/data/test_Dataloaders.py @@ -62,44 +62,67 @@ def test_lift_features(self): ---------- None """ + def check_shape(batch, elems, key): + """Check that the batched data has the expected shape.""" + if 'x_' in key or 'x'==key: + rows = 0 + for i in range(len(elems)): + rows += elems[i][key].shape[0] + assert batch[key].shape[0] == rows + assert batch[key].shape[1] == elems[0][key].shape[1] + elif 'edge_index' in key: + cols = 0 + for i in range(len(elems)): + cols += elems[i][key].shape[1] + assert batch[key].shape[0] == 2 + assert batch[key].shape[1] == cols + elif 'batch_' in key: + rows = 0 + n = int(key.split('_')[1]) + for i in range(len(elems)): + rows += elems[i][f'x_{n}'].shape[0] + assert batch[key].shape[0] == rows + elif key in elems[0].keys(): + for i in range(len(batch[key].shape)): + i_elems = 0 + for j in range(len(elems)): + i_elems += elems[j][key].shape[i] + assert batch[key].shape[i] == i_elems + def check_separation(matrix, n_elems_0_row, n_elems_0_col): """Check that the matrix is separated into two parts diagonally concatenated.""" assert torch.all(matrix[:n_elems_0_row, n_elems_0_col:] == 0) assert torch.all(matrix[n_elems_0_row:, :n_elems_0_col] == 0) + def check_values(matrix, m1, m2): + """Check that the values in the matrix are the same as the values in the original data.""" + assert torch.allclose(matrix[:m1.shape[0], :m1.shape[1]], m1) + assert torch.allclose(matrix[m1.shape[0]:, m1.shape[1]:], m2) + batch = next(iter(self.val_dataloader)) elems = [] for i in range(self.batch_size): elems.append(self.val_dataset.data_lst[i]) - # Check that the batched data has the expected shape + # Check shape for key in batch.keys(): - if key in elems[0].keys(): - if 'x_' in key or 'x'==key: - assert batch[key].shape[0] == elems[0][key].shape[0]+elems[1][key].shape[0] - assert batch[key].shape[1] == elems[0][key].shape[1] - elif 'edge_index' in key: - assert batch[key].shape[0] == 2 - assert batch[key].shape[1] == elems[0][key].shape[1]+elems[1][key].shape[1] - else: - for i in range(len(batch[key].shape)): - assert batch[key].shape[i] == elems[0][key].shape[i]+elems[1][key].shape[i] - else: - if 'batch_' in key: - i = int(key.split('_')[1]) - assert batch[key].shape[0] == elems[0][f'x_{i}'].shape[0]+elems[1][f'x_{i}'].shape[0] + check_shape(batch, elems, key) - # Check that the batched data is separated correctly - for key in batch.keys(): - if 'incidence_' in key: - i = int(key.split('_')[1]) - if i==0: - n0_row = 1 - else: - n0_row = torch.sum(batch[f'batch_{i-1}']==0) - n0_col = torch.sum(batch[f'batch_{i}']==0) - check_separation(batch[key].to_dense(), n0_row, n0_col) + # Check that the batched data is separated correctly and the values are correct + if self.batch_size == 2: + for key in batch.keys(): + if 'incidence_' in key: + i = int(key.split('_')[1]) + if i==0: + n0_row = 1 + else: + n0_row = torch.sum(batch[f'batch_{i-1}']==0) + n0_col = torch.sum(batch[f'batch_{i}']==0) + check_separation(batch[key].to_dense(), n0_row, n0_col) + check_values(batch[key].to_dense(), + elems[0][key].to_dense(), + elems[1][key].to_dense()) # Check that going back to a list of data gives the same data batch_list = to_data_list(batch) diff --git a/topobenchmarkx/=0.12.10 b/topobenchmarkx/=0.12.10 deleted file mode 100644 index 3afb89fd..00000000 --- a/topobenchmarkx/=0.12.10 +++ /dev/null @@ -1,44 +0,0 @@ -Collecting wandb - Downloading wandb-0.16.6-py3-none-any.whl.metadata (10 kB) -Collecting Click!=8.0.0,>=7.1 (from wandb) - Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB) -Collecting GitPython!=3.1.29,>=1.0.0 (from wandb) - Downloading GitPython-3.1.43-py3-none-any.whl.metadata (13 kB) -Requirement already satisfied: requests<3,>=2.0.0 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from wandb) (2.31.0) -Requirement already satisfied: psutil>=5.0.0 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from wandb) (5.9.8) -Collecting sentry-sdk>=1.0.0 (from wandb) - Downloading sentry_sdk-2.1.1-py2.py3-none-any.whl.metadata (10 kB) -Collecting docker-pycreds>=0.4.0 (from wandb) - Using cached docker_pycreds-0.4.0-py2.py3-none-any.whl.metadata (1.8 kB) -Requirement already satisfied: PyYAML in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from wandb) (6.0.1) -Collecting setproctitle (from wandb) - Using cached setproctitle-1.3.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.9 kB) -Requirement already satisfied: setuptools in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from wandb) (68.2.2) -Collecting appdirs>=1.4.3 (from wandb) - Using cached appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB) -Collecting protobuf!=4.21.0,<5,>=3.19.0 (from wandb) - Using cached protobuf-4.25.3-cp37-abi3-manylinux2014_x86_64.whl.metadata (541 bytes) -Requirement already satisfied: six>=1.4.0 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from docker-pycreds>=0.4.0->wandb) (1.16.0) -Collecting gitdb<5,>=4.0.1 (from GitPython!=3.1.29,>=1.0.0->wandb) - Using cached gitdb-4.0.11-py3-none-any.whl.metadata (1.2 kB) -Requirement already satisfied: charset-normalizer<4,>=2 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from requests<3,>=2.0.0->wandb) (3.3.2) -Requirement already satisfied: idna<4,>=2.5 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from requests<3,>=2.0.0->wandb) (3.7) -Requirement already satisfied: urllib3<3,>=1.21.1 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from requests<3,>=2.0.0->wandb) (2.2.1) -Requirement already satisfied: certifi>=2017.4.17 in /home/lev/miniconda3/envs/topox/lib/python3.11/site-packages (from requests<3,>=2.0.0->wandb) (2024.2.2) -Collecting smmap<6,>=3.0.1 (from gitdb<5,>=4.0.1->GitPython!=3.1.29,>=1.0.0->wandb) - Using cached smmap-5.0.1-py3-none-any.whl.metadata (4.3 kB) -Downloading wandb-0.16.6-py3-none-any.whl (2.2 MB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 35.5 MB/s eta 0:00:00 -Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB) -Using cached click-8.1.7-py3-none-any.whl (97 kB) -Using cached docker_pycreds-0.4.0-py2.py3-none-any.whl (9.0 kB) -Downloading GitPython-3.1.43-py3-none-any.whl (207 kB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 207.3/207.3 kB 59.8 MB/s eta 0:00:00 -Using cached protobuf-4.25.3-cp37-abi3-manylinux2014_x86_64.whl (294 kB) -Downloading sentry_sdk-2.1.1-py2.py3-none-any.whl (277 kB) - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 277.3/277.3 kB 66.9 MB/s eta 0:00:00 -Using cached setproctitle-1.3.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (31 kB) -Using cached gitdb-4.0.11-py3-none-any.whl (62 kB) -Using cached smmap-5.0.1-py3-none-any.whl (24 kB) -Installing collected packages: appdirs, smmap, setproctitle, sentry-sdk, protobuf, docker-pycreds, Click, gitdb, GitPython, wandb -Successfully installed Click-8.1.7 GitPython-3.1.43 appdirs-1.4.4 docker-pycreds-0.4.0 gitdb-4.0.11 protobuf-4.25.3 sentry-sdk-2.1.1 setproctitle-1.3.3 smmap-5.0.1 wandb-0.16.6