Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@ jobs:

strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Install `poetry`
- uses: actions/checkout@v4

- name: Install uv
run: |
pipx install poetry
poetry --version
curl -Ls https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Install package
run: |
poetry install
run: uv sync

- name: Run linter
run: |
poetry run flake8 torch_topological
source .venv/bin/activate
flake8 torch_topological

- name: Run tests
run: |
poetry run pytest
source .venv/bin/activate
pytest
55 changes: 53 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
*~

*.pyc
*.swp

/data/
/dist/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
*$py.class

# Distribution / packaging
build/
dist/
wheels/
*.egg-info/
*.egg

# Unit test
.pytest_cache/

# Sphinx documentation
docs/build/

# Jupyter Notebook
.ipynb_checkpoints

# Environments
.envrc
.venv

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
.vscode/*
!*.code-workspace
# Built Visual Studio Code Extensions
*.vsix

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc

# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore

1 change: 0 additions & 1 deletion .python-version

This file was deleted.

1,462 changes: 0 additions & 1,462 deletions poetry.lock

This file was deleted.

42 changes: 25 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,38 @@ authors = [
]
license = "BSD-3-Clause"
readme = "README.md"
include = ["README.md"]
requires-python = ">=3.9,<4"

[tool.poetry.dependencies]
python = ">=3.9"
matplotlib = "^3.5.0"
giotto-ph = "^0.2.0"
torch = ">=1.12.0"
gudhi = "^3.4.1"
POT = "^0.9.0"
dependencies = [
"matplotlib>=3.5",
"giotto-ph>=0.2",
"torch>=1.12",
"gudhi>=3.4",
"POT>=0.9",
]

[tool.uv]
prerelease = "allow"
index-strategy = "unsafe-best-match"
dev-dependencies = [
"pytest>=5.2",
"Sphinx>=4.3",
"sphinx-rtd-theme>=1.0",
"tqdm>=4.62",
"torchvision>=0.11",
"flake8>=4.0",
]

[tool.poetry.dev-dependencies]
pytest = ">=5.2"
Sphinx = ">=4.3.1"
sphinx-rtd-theme = "^1.0.0"
tqdm = "^4.62.3"
torchvision = ">=0.11.2"
flake8 = "^4.0.1"

[tool.black]
line-length = 79

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
py-modules = ['torch_topological']

[project.urls]
homepage = "https://github.com/aidos-lab/pytorch-topological"
Expand Down
4 changes: 2 additions & 2 deletions torch_topological/examples/alpha_complex_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
pers_info = alpha_complex(X)
pers_info = selector(pers_info)

data=pers_info[0].diagram
data = pers_info[0].diagram
data = data.detach().cpu().numpy()
ax.clear()
plt.xlabel("Birth")
plt.ylabel("Death")
ax.plot(data[:, 0], data[:, 1], 'ro', [0,0.8], [0,0.8], 'k-')
ax.plot(data[:, 0], data[:, 1], 'ro', [0, 0.8], [0, 0.8], 'k-')
plt.pause(0.2)

# Evaluate the loss; notice that we want to *maximise* it in
Expand Down
12 changes: 6 additions & 6 deletions torch_topological/nn/weighted_euler_characteristic_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def _obtainDirection(self):
return torch.tensor([x, y, z], dtype=torch.double)

def _genSquares(self, x):
"""Obtains coordinates and values of the adjacent squares in the 3D tensor
Input: x - 3D tensor"""
"""Obtains coordinates and values of the adjacent squares in the 3D
tensor. Input: x - 3D tensor"""
device = x.device
arr = torch.clone(x)
arr = arr.unsqueeze(0).float()
Expand Down Expand Up @@ -311,8 +311,8 @@ def _genSquares(self, x):
return coords.float(), sqVals

def _genCubes(self, x):
"""Obtains coordinates and values of the adjacent cubes in the 3D tensor
Input: x - 3D tensor"""
"""Obtains coordinates and values of the adjacent cubes in the 3D
tensor. Input: x - 3D tensor"""
device = x.device
x_ = torch.clone(x)
x_ = x_.unsqueeze(0).unsqueeze(0).float()
Expand Down Expand Up @@ -387,8 +387,8 @@ def _genVertices(self, x):
return torch.transpose(torch.nonzero(x), 0, 1).float()

def _genEdges(self, x):
"""Obtains coordinates and values of the adjacent edges in the 3D tensor
Input: x - 3D tensor"""
"""Obtains coordinates and values of the adjacent edges in the 3D
tensor. Input: x - 3D tensor"""
device = x.device
arr = torch.clone(x)
arr = arr.unsqueeze(0).float()
Expand Down
Loading