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

Function test_apply_edges

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

Source from the content-addressed store, hash-verified

334
335@parametrize_idtype
336def test_apply_edges(idtype):
337 def _upd(edges):
338 return {"w": edges.data["w"] * 2}
339
340 g = generate_graph(idtype)
341 old = g.edata["w"]
342 g.apply_edges(_upd)
343 assert F.allclose(old * 2, g.edata["w"])
344 u = F.tensor([0, 0, 0, 4, 5, 6], g.idtype)
345 v = F.tensor([1, 2, 3, 9, 9, 9], g.idtype)
346 g.apply_edges(lambda edges: {"w": edges.data["w"] * 0.0}, (u, v))
347 eid = F.tensor(g.edge_ids(u, v))
348 assert F.allclose(F.gather_row(g.edata["w"], eid), F.zeros((6, D)))
349
350
351@parametrize_idtype

Callers

nothing calls this directly

Calls 3

generate_graphFunction · 0.70
apply_edgesMethod · 0.45
edge_idsMethod · 0.45

Tested by

no test coverage detected