MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / unflatten_nested_dict

Function unflatten_nested_dict

eval_code/recons/models/moge/utils/tools.py:101–113  ·  view source on GitHub ↗

Unflattens a single-level dictionary into a nested dictionary, with keys as tuples.

(d: Dict[str, Any])

Source from the content-addressed store, hash-verified

99
100
101def unflatten_nested_dict(d: Dict[str, Any]) -> Dict[str, Any]:
102 """
103 Unflattens a single-level dictionary into a nested dictionary, with keys as tuples.
104 """
105 result = {}
106 for k, v in d.items():
107 sub_dict = result
108 for k_ in k[:-1]:
109 if k_ not in sub_dict:
110 sub_dict[k_] = {}
111 sub_dict = sub_dict[k_]
112 sub_dict[k[-1]] = v
113 return result
114
115
116def read_jsonl(file):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected