Skip to content

Commit 267ec3c

Browse files
authored
Handle nested dictionaries when merging configs (#493)
1 parent c461790 commit 267ec3c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ml3d/utils/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ def _merge_a_into_b(a, b):
170170
# from mmcv mmcv/utils/config.py
171171
b = b.copy()
172172
for k, v in a.items():
173-
if isinstance(v, dict) and k in b:
174-
if not isinstance(b[k], dict):
173+
if isinstance(v, dict):
174+
if k in b and not isinstance(b[k], dict):
175175
raise TypeError(
176176
"{}={} in child config cannot inherit from base ".
177177
format(k, v) +
178178
"because {} is a dict in the child config but is of ".
179179
format(k) +
180180
"type {} in base config. ".format(type(b[k])))
181-
b[k] = Config._merge_a_into_b(v, b[k])
181+
b[k] = Config._merge_a_into_b(v, b.get(k, ConfigDict()))
182182
else:
183183
if v is None:
184184
continue

0 commit comments

Comments
 (0)