MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / test_from_feature_kNN

Function test_from_feature_kNN

easygraph/classes/tests/test_hypergraph.py:38–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37# test construction
38def 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
53def test_from_graph():

Callers

nothing calls this directly

Calls 1

from_feature_kNNMethod · 0.80

Tested by

no test coverage detected