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

Function test_empty_query

tests/python/common/test_heterograph.py:544–591  ·  view source on GitHub ↗
(idtype)

Source from the content-addressed store, hash-verified

542
543@parametrize_idtype
544def test_empty_query(idtype):
545 g = dgl.graph(([1, 2, 3], [0, 4, 5]), idtype=idtype, device=F.ctx())
546 g.add_nodes(0)
547 g.add_edges([], [])
548 g.remove_edges([])
549 g.remove_nodes([])
550 assert F.shape(g.has_nodes([])) == (0,)
551 assert F.shape(g.has_edges_between([], [])) == (0,)
552 g.edge_ids([], [])
553 g.edge_ids([], [], return_uv=True)
554 g.find_edges([])
555
556 assert F.shape(g.in_edges([], form="eid")) == (0,)
557 u, v = g.in_edges([], form="uv")
558 assert F.shape(u) == (0,)
559 assert F.shape(v) == (0,)
560 u, v, e = g.in_edges([], form="all")
561 assert F.shape(u) == (0,)
562 assert F.shape(v) == (0,)
563 assert F.shape(e) == (0,)
564
565 assert F.shape(g.out_edges([], form="eid")) == (0,)
566 u, v = g.out_edges([], form="uv")
567 assert F.shape(u) == (0,)
568 assert F.shape(v) == (0,)
569 u, v, e = g.out_edges([], form="all")
570 assert F.shape(u) == (0,)
571 assert F.shape(v) == (0,)
572 assert F.shape(e) == (0,)
573
574 assert F.shape(g.in_degrees([])) == (0,)
575 assert F.shape(g.out_degrees([])) == (0,)
576
577 g = dgl.graph(([], []), idtype=idtype, device=F.ctx())
578 error_thrown = True
579 try:
580 g.in_degrees([0])
581 fail = False
582 except:
583 pass
584 assert error_thrown
585 error_thrown = True
586 try:
587 g.out_degrees([0])
588 fail = False
589 except:
590 pass
591 assert error_thrown
592
593
594@unittest.skipIf(

Callers

nothing calls this directly

Calls 15

remove_edgesMethod · 0.80
remove_nodesMethod · 0.80
graphMethod · 0.45
ctxMethod · 0.45
add_nodesMethod · 0.45
add_edgesMethod · 0.45
shapeMethod · 0.45
has_nodesMethod · 0.45
has_edges_betweenMethod · 0.45
edge_idsMethod · 0.45
find_edgesMethod · 0.45
in_edgesMethod · 0.45

Tested by

no test coverage detected