test_sampler.py 390 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
11
import torch

from torch_cluster import neighbor_sampler


def test_neighbor_sampler():
    torch.manual_seed(1234)

    start = torch.tensor([0, 1])
    cumdeg = torch.tensor([0, 3, 7])

rusty1s's avatar
rusty1s committed
12
    e_id = neighbor_sampler(start, cumdeg, size=1.0)
rusty1s's avatar
rusty1s committed
13
14
    assert e_id.tolist() == [0, 2, 1, 5, 6, 3, 4]

rusty1s's avatar
rusty1s committed
15
    e_id = neighbor_sampler(start, cumdeg, size=3)
rusty1s's avatar
rusty1s committed
16
    assert e_id.tolist() == [1, 0, 2, 4, 5, 6]