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

Function _test3

tests/python/common/sampling/test_sampling.py:662–688  ·  view source on GitHub ↗
(p, replace)

Source from the content-addressed store, hash-verified

660 _test2(prob, False) # w/o replacement, uniform
661
662 def _test3(p, replace):
663 subg = sample_neighbors_fusing_mode[fused](
664 hg, {"user": [0, 1], "game": 0}, -1, prob=p, replace=replace
665 )
666 if not fused:
667 assert len(subg.ntypes) == 3
668 assert len(subg.srctypes) == 3
669 assert len(subg.dsttypes) == 3
670 assert len(subg.etypes) == 4
671 assert subg["follow"].num_edges() == 6 if p is None else 4
672 assert subg["play"].num_edges() == 1
673 assert subg["liked-by"].num_edges() == 4
674 assert subg["flips"].num_edges() == 0
675
676 for i in range(10):
677 subg = sample_neighbors_fusing_mode[fused](
678 hg, {"user": [0, 1], "game": 0}, 2, prob=p, replace=replace
679 )
680 if not fused:
681 assert len(subg.ntypes) == 3
682 assert len(subg.srctypes) == 3
683 assert len(subg.dsttypes) == 3
684 assert len(subg.etypes) == 4
685 assert subg["follow"].num_edges() == 4
686 assert subg["play"].num_edges() == 2 if replace else 1
687 assert subg["liked-by"].num_edges() == 4 if replace else 3
688 assert subg["flips"].num_edges() == 0
689
690 _test3(prob, True) # w/ replacement, uniform
691 _test3(prob, False) # w/o replacement, uniform

Callers 5

_test_sample_neighborsFunction · 0.85
_test_sample_laborsFunction · 0.85

Calls 4

asnumpyMethod · 0.80
num_edgesMethod · 0.45
edgesMethod · 0.45
edge_idsMethod · 0.45

Tested by

no test coverage detected