| 1 | import torch |
| 2 | |
| 3 | from torch_cluster import neighbor_sampler |
| 4 | |
| 5 | |
| 6 | def test_neighbor_sampler(): |
| 7 | torch.manual_seed(1234) |
| 8 | |
| 9 | start = torch.tensor([0, 1]) |
| 10 | cumdeg = torch.tensor([0, 3, 7]) |
| 11 | |
| 12 | e_id = neighbor_sampler(start, cumdeg, size=1.0) |
| 13 | assert e_id.tolist() == [0, 2, 1, 5, 6, 3, 4] |
| 14 | |
| 15 | e_id = neighbor_sampler(start, cumdeg, size=3) |
| 16 | assert e_id.tolist() == [1, 0, 2, 4, 5, 6] |