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

Function test_reverse_shared_frames

tests/python/common/transforms/test_transform.py:362–375  ·  view source on GitHub ↗
(idtype)

Source from the content-addressed store, hash-verified

360
361@parametrize_idtype
362def test_reverse_shared_frames(idtype):
363 g = dgl.graph([])
364 g = g.astype(idtype).to(F.ctx())
365 g.add_nodes(3)
366 g.add_edges([0, 1, 2], [1, 2, 1])
367 g.ndata["h"] = F.tensor([[0.0], [1.0], [2.0]])
368 g.edata["h"] = F.tensor([[3.0], [4.0], [5.0]])
369
370 rg = g.reverse(copy_ndata=True, copy_edata=True)
371 assert F.allclose(g.ndata["h"], rg.ndata["h"])
372 assert F.allclose(g.edata["h"], rg.edata["h"])
373 assert F.allclose(
374 g.edges[[0, 2], [1, 1]].data["h"], rg.edges[[1, 1], [0, 2]].data["h"]
375 )
376
377
378@unittest.skipIf(F._default_context_str == "gpu", reason="GPU not implemented")

Callers

nothing calls this directly

Calls 7

reverseMethod · 0.80
graphMethod · 0.45
toMethod · 0.45
astypeMethod · 0.45
ctxMethod · 0.45
add_nodesMethod · 0.45
add_edgesMethod · 0.45

Tested by

no test coverage detected