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

Method __getitem__

python/dgl/view.py:24–44  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

22 self._typeid_getter = typeid_getter
23
24 def __getitem__(self, key):
25 if isinstance(key, slice):
26 # slice
27 if not (
28 key.start is None and key.stop is None and key.step is None
29 ):
30 raise DGLError('Currently only full slice ":" is supported')
31 nodes = ALL
32 ntype = None
33 elif isinstance(key, tuple):
34 nodes, ntype = key
35 elif key is None or isinstance(key, str):
36 nodes = ALL
37 ntype = key
38 else:
39 nodes = key
40 ntype = None
41 ntid = self._typeid_getter(ntype)
42 return NodeSpace(
43 data=HeteroNodeDataView(self._graph, ntype, ntid, nodes)
44 )
45
46 def __call__(self, ntype=None):
47 """Return the nodes."""

Callers

nothing calls this directly

Calls 2

DGLErrorClass · 0.85
HeteroNodeDataViewClass · 0.85

Tested by

no test coverage detected