()
| 36 | |
| 37 | # test construction |
| 38 | def test_from_feature_kNN(): |
| 39 | import numpy as np |
| 40 | import scipy.spatial |
| 41 | import torch |
| 42 | |
| 43 | ft = np.random.rand(32, 8) |
| 44 | cdist = scipy.spatial.distance.cdist(ft, ft) |
| 45 | tk_mat = np.argsort(cdist, axis=1)[:, :3] |
| 46 | hg = eg.Hypergraph.from_feature_kNN(torch.tensor(ft), k=3) |
| 47 | assert tuple(sorted(tk_mat[0].tolist())) in hg.e[0] |
| 48 | assert tuple(sorted(tk_mat[8].tolist())) in hg.e[0] |
| 49 | assert tuple(sorted(tk_mat[13].tolist())) in hg.e[0] |
| 50 | assert tuple(sorted(tk_mat[26].tolist())) in hg.e[0] |
| 51 | |
| 52 | |
| 53 | def test_from_graph(): |
nothing calls this directly
no test coverage detected