Skip to content

Commit 156097c

Browse files
committed
Migrate to uv
1 parent 6a26d5c commit 156097c

File tree

8 files changed

+2333
-2862
lines changed

8 files changed

+2333
-2862
lines changed

poetry.lock

Lines changed: 0 additions & 2673 deletions
This file was deleted.

pyproject.toml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
1-
[tool.poetry]
1+
[project]
22
name = "dect"
33
version = "0.1.0"
44
description = "A fast package to compute the Euler Characteristic Transform"
55
authors = [
6-
"Ernst Röell <ernst.roeell@helmholtz-munich.de>",
7-
"Bastian Rieck <bastian.grossenbacher@unifr.ch>",
6+
{ name = "Ernst Röell", email = "ernst.roeell@helmholtz-munich.de" },
7+
{ name = "Bastian Rieck", email = "bastian.grossenbacher@unifr.ch" },
88
]
9-
maintainers = ["Ernst Röell <ernst.roeell@helmholtz-munich.de>"]
9+
requires-python = ">=3.10.0"
1010
readme = "README.md"
11+
maintainers = [{ name = "Ernst Röell", email = "ernst.roeell@helmholtz-munich.de" }]
1112
classifiers = [
1213
"Development Status :: 4 - Beta",
1314
"Programming Language :: Python",
1415
]
16+
dependencies = [
17+
"torch>2.0.0",
18+
"pdoc>=15.0.1,<16",
19+
"torch-geometric>=2.6.1,<3",
20+
"geotorch>=0.3.0,<0.4",
21+
]
1522

16-
[tool.poetry.dependencies]
17-
python = ">=3.10.0"
18-
torch = ">2.0.0"
19-
pdoc = "^15.0.1"
20-
torch-geometric = "^2.6.1"
21-
geotorch = "^0.3.0"
22-
23-
24-
[tool.poetry.group.dev.dependencies]
25-
pytest = "^8.3.4"
26-
matplotlib = "^3.10.0"
27-
pytest-cov = "^6.0.0"
28-
ipykernel = "^6.29.5"
29-
30-
31-
[tool.poetry.group.test.dependencies]
32-
pytest-cov = "^6.0.0"
33-
pytest = "^8.3.4"
23+
[dependency-groups]
24+
dev = [
25+
"pytest>=8.3.4,<9",
26+
"matplotlib>=3.10.0,<4",
27+
"pytest-cov>=6.0.0,<7",
28+
"ipykernel>=6.29.5,<7",
29+
]
30+
test = [
31+
"pytest-cov>=6.0.0,<7",
32+
"pytest>=8.3.4,<9",
33+
]
3434

35+
[tool.uv]
36+
default-groups = [
37+
"dev",
38+
"test",
39+
]
3540

3641
[build-system]
37-
requires = ["poetry-core"]
38-
build-backend = "poetry.core.masonry.api"
42+
requires = ["hatchling"]
43+
build-backend = "hatchling.build"

tests/test_ect.py

Lines changed: 0 additions & 165 deletions
This file was deleted.

tests/test_ect_edges.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Tests the core functions for computing the
3+
ECT over a point cloud.
4+
"""
5+
6+
7+
def test_true():
8+
pass

tests/test_ect_faces.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Tests the core functions for computing the
3+
ECT over a point cloud.
4+
"""
5+
6+
7+
def test_true():
8+
pass

tests/test_ect_point_clouds.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Tests the core functions for computing the
3+
ECT over a point cloud. A point cloud is of
4+
shape [B,N,D] where the first dimension is the
5+
batch, the second is the number of points and the
6+
third is the ambient dimension.
7+
Note that in this format each point in the point
8+
cloud has to have the same cardinality.
9+
"""
10+
11+
import torch
12+
13+
from dect.directions import generate_2d_directions, generate_uniform_directions
14+
from dect.ect import compute_ect_point_cloud
15+
16+
17+
def test_compute_ect_point_cloud_case_cpu():
18+
"""
19+
Tests the ECT computation of a point cloud.
20+
Differs in that it expects an input shape of
21+
size [B,N,D], where B is the batch size,
22+
N is the number of points and D is the ambient
23+
dimension.
24+
"""
25+
ambient_dimension = 4
26+
num_pts = 100
27+
batch_size = 8
28+
num_thetas = 100
29+
seed = 0
30+
x = torch.rand(size=(batch_size, num_pts, ambient_dimension))
31+
v = generate_uniform_directions(
32+
num_thetas=num_thetas, d=ambient_dimension, device="cpu", seed=seed
33+
)
34+
35+
ect = compute_ect_point_cloud(x, v, radius=10, resolution=30, scale=500)
36+
37+
assert ect[0].max() == num_pts
38+
assert ect[0].min() == 0
39+
40+
41+
def test_compute_ect_point_cloud_case_cuda():
42+
"""
43+
Tests the ECT computation of a point cloud.
44+
Differs in that it expects an input shape of
45+
size [B,N,D], where B is the batch size,
46+
N is the number of points and D is the ambient
47+
dimension.
48+
"""
49+
ambient_dimension = 4
50+
num_pts = 100
51+
batch_size = 8
52+
num_thetas = 100
53+
seed = 0
54+
x = torch.rand(size=(batch_size, num_pts, ambient_dimension), device="cuda")
55+
v = generate_uniform_directions(
56+
num_thetas=num_thetas, d=ambient_dimension, device="cuda", seed=seed
57+
)
58+
59+
ect = compute_ect_point_cloud(x, v, radius=10, resolution=30, scale=500)
60+
61+
assert ect[0].max() == num_pts
62+
assert ect[0].min() == 0

tests/test_ect_points.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Tests the core functions for computing the
3+
ECT over a point cloud.
4+
"""
5+
6+
import torch
7+
8+
from dect.directions import generate_2d_directions, generate_uniform_directions
9+
from dect.ect import compute_ect_points
10+
11+
"""
12+
Test the ECT for
13+
"""
14+
15+
16+
def test_compute_ect_case_points():
17+
"""
18+
Test the `compute_ect` function for point clouds.
19+
"""
20+
device = "cpu"
21+
# 2D Case
22+
seed = 2024
23+
ambient_dimension = 5
24+
num_points = 10
25+
v = generate_uniform_directions(
26+
num_thetas=17, seed=seed, device=device, d=ambient_dimension
27+
).to(device)
28+
x = torch.rand(size=(num_points, ambient_dimension))
29+
ect = compute_ect_points(x, v=v, radius=1, resolution=13, scale=10)
30+
31+
assert ect.get_device() == -1
32+
33+
# Check that min and max are 0 and num_pts
34+
torch.testing.assert_close(ect.max(), torch.tensor(num_points, dtype=torch.float32))
35+
torch.testing.assert_close(ect.min(), torch.tensor(0.0, dtype=torch.float32))
36+
37+
38+
def test_compute_ect_case_points_cuda():
39+
"""
40+
Test the `compute_ect` function for point clouds on the gpu.
41+
"""
42+
if not torch.cuda.is_available():
43+
return
44+
45+
device = "cuda:0"
46+
# 2D Case
47+
num_points = 10
48+
v = generate_2d_directions(num_thetas=17).to(device)
49+
x = torch.rand(size=(num_points, 2), device=device)
50+
ect = compute_ect_points(x, v=v, radius=1, resolution=13, scale=10)
51+
52+
assert ect.get_device() == 0 # 0 indicates cuda.
53+
54+
# Check that min and max are 0 and num_pts
55+
torch.testing.assert_close(
56+
ect.max(), torch.tensor(num_points, dtype=torch.float32, device=device)
57+
)
58+
torch.testing.assert_close(
59+
ect.min(), torch.tensor(0.0, dtype=torch.float32, device=device)
60+
)

0 commit comments

Comments
 (0)