File: test_delaunay.py

package info (click to toggle)
pytorch-geometric 2.6.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,904 kB
  • sloc: python: 127,155; sh: 338; cpp: 27; makefile: 18; javascript: 16
file content (34 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import torch

from torch_geometric.data import Data
from torch_geometric.testing import withPackage
from torch_geometric.transforms import Delaunay


@withPackage('scipy')
def test_delaunay():
    assert str(Delaunay()) == 'Delaunay()'

    pos = torch.tensor([[-1, -1], [-1, 1], [1, 1], [1, -1]], dtype=torch.float)
    data = Data(pos=pos)
    data = Delaunay()(data)
    assert len(data) == 2
    assert data.face.tolist() == [[3, 1], [1, 3], [0, 2]]

    pos = torch.tensor([[-1, -1], [-1, 1], [1, 1]], dtype=torch.float)
    data = Data(pos=pos)
    data = Delaunay()(data)
    assert len(data) == 2
    assert data.face.tolist() == [[0], [1], [2]]

    pos = torch.tensor([[-1, -1], [1, 1]], dtype=torch.float)
    data = Data(pos=pos)
    data = Delaunay()(data)
    assert len(data) == 2
    assert data.edge_index.tolist() == [[0, 1], [1, 0]]

    pos = torch.tensor([[-1, -1]], dtype=torch.float)
    data = Data(pos=pos)
    data = Delaunay()(data)
    assert len(data) == 2
    assert data.edge_index.tolist() == [[], []]