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

Function test_apply_nodes

tests/python/common/function/test_basics.py:322–332  ·  view source on GitHub ↗
(idtype)

Source from the content-addressed store, hash-verified

320
321@parametrize_idtype
322def test_apply_nodes(idtype):
323 def _upd(nodes):
324 return {"h": nodes.data["h"] * 2}
325
326 g = generate_graph(idtype)
327 old = g.ndata["h"]
328 g.apply_nodes(_upd)
329 assert F.allclose(old * 2, g.ndata["h"])
330 u = F.tensor([0, 3, 4, 6], g.idtype)
331 g.apply_nodes(lambda nodes: {"h": nodes.data["h"] * 0.0}, u)
332 assert F.allclose(F.gather_row(g.ndata["h"], u), F.zeros((4, D)))
333
334
335@parametrize_idtype

Callers

nothing calls this directly

Calls 2

apply_nodesMethod · 0.80
generate_graphFunction · 0.70

Tested by

no test coverage detected