Using isinstance will allow inheriting CfgNode and creating a tree of CustomCfgNode.
The other change (move to_dict into the class) is just a code simplification.
Also add some docs in __init__.
Test:
╰─$python3 yacs/tests.py
../home/yuxinwu/.local/lib/python3.7/site-packages/yaml/constructor.py:126: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
if not isinstance(key, collections.Hashable):
WARNING:yacs.config:Deprecated config key (ignoring): MODEL.DILATION
.WARNING:yacs.config:Deprecated config key (ignoring): FINAL_MSG
WARNING:yacs.config:Deprecated config key (ignoring): MODEL.DILATION
.DEBUG:yacs.config:Invalid type <class 'object'> for key INVALID_KEY_TYPE; valid types = {<class 'list'>, <class 'str'>, <class 'int'>, <class 'tuple'>, <class 'bool'>, <class 'float'>}
..DEBUG:yacs.config:Key FOO.BAR.QUUX with value <class 'NoneType'> is not a valid type; valid types: {<class 'list'>, <class 'str'>, <class 'int'>, <class 'tuple'>, <class 'bool'>, <class 'float'>}
.......DEBUG:yacs.config:Non-existent key: MODEL.DOES_NOT_EXIST
....
----------------------------------------------------------------------
Ran 17 tests in 0.023s
OK
Using
isinstance
will allow inheritingCfgNode
and creating a tree ofCustomCfgNode
.The other change (move to_dict into the class) is just a code simplification.
Also add some docs in
__init__
.Test: