mdacli
mdacli copied to clipboard
Keep logical order when saving results
If you want to plot data from a file stored in columns it is convention that x values have a lower column index compared to the y values. Currently this is not guaranteed. The current results handling proposed in #17 and #29 handle every possible type appearing in an MDAanalysis AnalysisClass. In our approach 1D arrays are stacked into 2D arrays and saved as CSV files. The logical structure is usually encoded inside the class docstring. For example, in lineardensity.py the docstring has the following structure
"""
results.x.pos : numpy.ndarray
mass density in [xyz] direction
results.x.pos_std : numpy.ndarray
standard deviation of the mass density in [xyz] direction
results.x.char : numpy.ndarray
charge density in [xyz] direction
results.x.char_std : numpy.ndarray
standard deviation of the charge density in [xyz] direction
"""
Saving these 1D arrays stacked into a 2D array keep this order.
If you keep this order in the results dictionary. Won't it be kept on the side of mdacli ?
But we don't know if the order in the results dictionary is the same as in the docstring. The order is based on how the developer of the module decides to initialize the attributes of results. See simple example below
a = {}
a["a"] = 1
a["b"] = 4
print(a.keys())
returns dict_keys(['a', 'b']) compared to
b = {}
b["b"] = 1
b["a"] = 4
print(b.keys())
which returns dict_keys(['b', 'a'])