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

Function test_pickling_subgraph

tests/python/common/test_heterograph-pickle.py:156–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154 reason="GPU edge_subgraph w/ relabeling not implemented",
155)
156def test_pickling_subgraph():
157 f1 = io.BytesIO()
158 f2 = io.BytesIO()
159 g = dgl.rand_graph(10000, 100000)
160 g.ndata["x"] = F.randn((10000, 4))
161 g.edata["x"] = F.randn((100000, 5))
162 pickle.dump(g, f1)
163 sg = g.subgraph([0, 1])
164 sgx = sg.ndata["x"] # materialize
165 pickle.dump(sg, f2)
166 # TODO(BarclayII): How should I test that the size of the subgraph pickle file should not
167 # be as large as the size of the original pickle file?
168 assert f1.tell() > f2.tell() * 50
169
170 f2.seek(0)
171 f2.truncate()
172 sgx = sg.edata["x"] # materialize
173 pickle.dump(sg, f2)
174 assert f1.tell() > f2.tell() * 50
175
176 f2.seek(0)
177 f2.truncate()
178 sg = g.edge_subgraph([0])
179 sgx = sg.edata["x"] # materialize
180 pickle.dump(sg, f2)
181 assert f1.tell() > f2.tell() * 50
182
183 f2.seek(0)
184 f2.truncate()
185 sgx = sg.ndata["x"] # materialize
186 pickle.dump(sg, f2)
187 assert f1.tell() > f2.tell() * 50
188
189 f1.close()
190 f2.close()
191
192
193@unittest.skipIf(F._default_context_str != "gpu", reason="Need GPU for pin")

Callers

nothing calls this directly

Calls 3

dumpMethod · 0.80
edge_subgraphMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected