MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _access_structure

Function _access_structure

imperative/python/megengine/module/module.py:39–54  ·  view source on GitHub ↗
(obj, key, callback=None)

Source from the content-addressed store, hash-verified

37
38
39def _access_structure(obj, key, callback=None):
40 key_list = key.split(".")
41 cur = obj
42 parent = None
43 for k in key_list:
44 parent = cur
45 if isinstance(cur, (list, tuple)):
46 k = int(k)
47 cur = cur[k]
48 elif isinstance(cur, dict):
49 cur = cur[k]
50 else:
51 cur = getattr(cur, k)
52 if callable is None:
53 return cur
54 return callback(parent, k, cur)
55
56
57def _is_parameter(obj):

Callers 3

test_expand_structureFunction · 0.90
get_expand_structureFunction · 0.85
set_expand_structureFunction · 0.85

Calls 1

callbackFunction · 0.50

Tested by 1

test_expand_structureFunction · 0.72