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

Function test_mutation

tests/python/common/test_heterograph-misc.py:280–294  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

278
279
280def test_mutation():
281 g = dgl.graph([])
282 g = g.to(F.ctx())
283 # test add nodes with data
284 g.add_nodes(5)
285 g.add_nodes(5, {"h": F.ones((5, 2))})
286 ans = F.cat([F.zeros((5, 2)), F.ones((5, 2))], 0)
287 assert F.allclose(ans, g.ndata["h"])
288 g.ndata["w"] = 2 * F.ones((10, 2))
289 assert F.allclose(2 * F.ones((10, 2)), g.ndata["w"])
290 # test add edges with data
291 g.add_edges([2, 3], [3, 4])
292 g.add_edges([0, 1], [1, 2], {"m": F.ones((2, 2))})
293 ans = F.cat([F.zeros((2, 2)), F.ones((2, 2))], 0)
294 assert F.allclose(ans, g.edata["m"])
295
296
297def test_scipy_adjmat():

Callers 1

Calls 5

graphMethod · 0.45
toMethod · 0.45
ctxMethod · 0.45
add_nodesMethod · 0.45
add_edgesMethod · 0.45

Tested by

no test coverage detected