dict_from_parsed
Full name: ase2sprkkr.common.container_definitions.dict_from_parsed
- ase2sprkkr.common.container_definitions.dict_from_parsed(values, allowed_duplicates)[source]
Create a dictionary from the arguments. From duplicate arguments create numpy arrays. Moreover, if there is key of type (a,b), it will be transformed to subdictionary. Such a keys do not allow duplicates.
>>> dict_from_parsed( [ ('x', 'y'), (('a','b'), 1 ), (('a', 'c'), 2) ], [] ) {'x': 'y', 'a': {'b': 1, 'c': 2}} >>> dict_from_parsed( [ ('x', 1), ('x', '2') ], [] ) Traceback (most recent call last): pyparsing.exceptions.ParseException: There are non-unique keys: x >>> dict_from_parsed( [ ('x', 1), ('x', 2) ], ['x'] ) {'x': array([1, 2])}