MCPcopy
hub / github.com/pyg-team/pytorch_geometric / test_geodesic_distance

Function test_geodesic_distance

test/utils/test_geodesic.py:10–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9@withPackage('gdist')
10def test_geodesic_distance():
11 pos = torch.tensor([
12 [0.0, 0.0, 0.0],
13 [2.0, 0.0, 0.0],
14 [0.0, 2.0, 0.0],
15 [2.0, 2.0, 0.0],
16 ])
17 face = torch.tensor([[0, 1, 3], [0, 2, 3]]).t()
18
19 out = geodesic_distance(pos, face)
20 expected = torch.tensor([
21 [0.0, 1.0, 1.0, sqrt(2)],
22 [1.0, 0.0, sqrt(2), 1.0],
23 [1.0, sqrt(2), 0.0, 1.0],
24 [sqrt(2), 1.0, 1.0, 0.0],
25 ])
26 assert torch.allclose(out, expected)
27 assert torch.allclose(out, geodesic_distance(pos, face, num_workers=-1))
28
29 out = geodesic_distance(pos, face, norm=False)
30 expected = torch.tensor([
31 [0, 2, 2, 2 * sqrt(2)],
32 [2, 0, 2 * sqrt(2), 2],
33 [2, 2 * sqrt(2), 0, 2],
34 [2 * sqrt(2), 2, 2, 0],
35 ])
36 assert torch.allclose(out, expected)
37
38 src = torch.tensor([0, 0, 0, 0])
39 dst = torch.tensor([0, 1, 2, 3])
40 out = geodesic_distance(pos, face, src=src, dst=dst)
41 expected = torch.tensor([0.0, 1.0, 1.0, sqrt(2)])
42 assert torch.allclose(out, expected)
43
44 out = geodesic_distance(pos, face, dst=dst)
45 expected = torch.tensor([0.0, 0.0, 0.0, 0.0])
46 assert torch.allclose(out, expected)

Callers

nothing calls this directly

Calls 2

geodesic_distanceFunction · 0.90
tMethod · 0.80

Tested by

no test coverage detected