MCPcopy
hub / github.com/dmlc/dgl / test_inc

Function test_inc

tests/python/common/test_heterograph.py:768–788  ·  view source on GitHub ↗
(idtype)

Source from the content-addressed store, hash-verified

766
767@parametrize_idtype
768def test_inc(idtype):
769 g = create_test_heterograph(idtype)
770 adj = F.sparse_to_numpy(g["follows"].inc("in"))
771 assert np.allclose(adj, np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]))
772 adj = F.sparse_to_numpy(g["follows"].inc("out"))
773 assert np.allclose(adj, np.array([[1.0, 0.0], [0.0, 1.0], [0.0, 0.0]]))
774 adj = F.sparse_to_numpy(g["follows"].inc("both"))
775 assert np.allclose(adj, np.array([[-1.0, 0.0], [1.0, -1.0], [0.0, 1.0]]))
776 adj = F.sparse_to_numpy(g.inc("in", etype="plays"))
777 assert np.allclose(
778 adj, np.array([[1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0]])
779 )
780 adj = F.sparse_to_numpy(g.inc("out", etype="plays"))
781 assert np.allclose(
782 adj,
783 np.array(
784 [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0]]
785 ),
786 )
787 adj = F.sparse_to_numpy(g.inc("both", etype="follows"))
788 assert np.allclose(adj, np.array([[-1.0, 0.0], [1.0, -1.0], [0.0, 1.0]]))
789
790
791@parametrize_idtype

Callers

nothing calls this directly

Calls 2

incMethod · 0.80
create_test_heterographFunction · 0.70

Tested by

no test coverage detected