The Dictionary class is designed to behave as much as possible like a true Python dictionary, but since it is implemented in Fortran it can only store a restricted range of data types. Keys much be strings and values must be one of the following types:
Trying to store any other type of data will raise a ValueError.
For Atoms.params entries, there are further restrictions imposed by the implementation of the XYZ and NetCDF I/O routines. The only types of data that can be stored here are:
A Dictionary can be created from a standard Python dictionary, and easily converted back:
>>> py_dict = {'a':1, 'b':2}
>>> fortran_dict = Dictionary(py_dict)
>>> py_dict == dict(fortran_dict)
True
It also supports all the standard dictionary operations and methods:
>>> fortran_dict['c'] = 3
>>> fortran_dict.keys()
['a', 'b', 'c']
An additional feature of the quippy Dictionary is that it can read and write itself to a string in the format used within XYZ files:
>>> str(fortran_dict)
'a=1 b=2 c=3'
>>> d2 = Dictionary('a=1 b=2 c=3')
>>> d2.keys(), d2.values()
(['a', 'b', 'c'], [1, 2, 3])