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

Function test_partition_with_halo

tests/python/common/transforms/test_transform.py:698–716  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

696# Disabled since everything will be on heterogeneous graphs
697@unittest.skipIf(F._default_context_str == "gpu", reason="GPU not implemented")
698def test_partition_with_halo():
699 g = create_large_graph(1000)
700 node_part = np.random.choice(4, g.num_nodes())
701 subgs, _, _ = dgl.transforms.partition_graph_with_halo(
702 g, node_part, 2, reshuffle=True
703 )
704 for part_id, subg in subgs.items():
705 node_ids = np.nonzero(node_part == part_id)[0]
706 lnode_ids = np.nonzero(F.asnumpy(subg.ndata["inner_node"]))[0]
707 orig_nids = F.asnumpy(subg.ndata["orig_id"])[lnode_ids]
708 assert np.all(np.sort(orig_nids) == node_ids)
709 assert np.all(
710 F.asnumpy(subg.in_degrees(lnode_ids))
711 == F.asnumpy(g.in_degrees(orig_nids))
712 )
713 assert np.all(
714 F.asnumpy(subg.out_degrees(lnode_ids))
715 == F.asnumpy(g.out_degrees(orig_nids))
716 )
717
718
719@unittest.skipIf(os.name == "nt", reason="Do not support windows yet")

Callers 1

test_transform.pyFile · 0.85

Calls 7

create_large_graphFunction · 0.85
nonzeroMethod · 0.80
asnumpyMethod · 0.80
num_nodesMethod · 0.45
itemsMethod · 0.45
in_degreesMethod · 0.45
out_degreesMethod · 0.45

Tested by

no test coverage detected