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

Function test_csrsum

tests/python/common/test_sparse_ops-csr.py:116–130  ·  view source on GitHub ↗
(idtype, dtype, return_edge_ids)

Source from the content-addressed store, hash-verified

114@pytest.mark.parametrize("dtype", [F.float32, F.float64])
115@pytest.mark.parametrize("return_edge_ids", [True, False])
116def test_csrsum(idtype, dtype, return_edge_ids):
117 a, A = _random_simple_graph(
118 idtype, dtype, F.ctx(), 500, 600, 9000, "A", "B", "AB"
119 )
120 b, B = _random_simple_graph(
121 idtype, dtype, F.ctx(), 500, 600, 9000, "A", "B", "AB"
122 )
123 C, C_weights = dgl._sparse_ops._csrsum(
124 [A._graph, B._graph], [A.edata["w"], B.edata["w"]]
125 )
126 C_adj = C.adjacency_matrix_scipy(0, False, "csr", return_edge_ids)
127 C_adj.data = F.asnumpy(C_weights)
128 C_adj = F.tensor(C_adj.todense(), dtype=dtype)
129 c = F.tensor((a + b).todense(), dtype=dtype)
130 assert F.allclose(C_adj, c)
131
132
133@parametrize_idtype

Callers 1

Calls 4

_random_simple_graphFunction · 0.85
asnumpyMethod · 0.80
ctxMethod · 0.45

Tested by

no test coverage detected