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

Function test_mean_zero_degree

tests/python/common/test_heterograph-kernel.py:402–408  ·  view source on GitHub ↗
(g, idtype)

Source from the content-addressed store, hash-verified

400@parametrize_idtype
401@pytest.mark.parametrize("g", get_cases(["homo-zero-degree"]))
402def test_mean_zero_degree(g, idtype):
403 g = g.astype(idtype).to(F.ctx())
404 g.ndata["h"] = F.ones((g.num_nodes(), 3))
405 g.update_all(fn.copy_u("h", "m"), fn.mean("m", "x"))
406 deg = F.asnumpy(g.in_degrees())
407 v = F.tensor(np.where(deg == 0)[0])
408 assert F.allclose(F.gather_row(g.ndata["x"], v), F.zeros((len(v), 3)))
409
410
411if __name__ == "__main__":

Callers

nothing calls this directly

Calls 7

update_allMethod · 0.80
asnumpyMethod · 0.80
toMethod · 0.45
astypeMethod · 0.45
ctxMethod · 0.45
num_nodesMethod · 0.45
in_degreesMethod · 0.45

Tested by

no test coverage detected