Suppose data, saved in .mat
file needs to be annotated or the meta-data of some file need to be stored:
x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
mdic = {"data": x,
"classes": {'name_of_class_1': 0,
'name_of_class_2': 1
}
}
When I save it with scipy.io.savemat()
and load it back with scipy.io.loadmat
I got not quite readdable structure:
{'__header__': b'MATLAB 5.0 MAT-file Platform: posix, Created on: Fri Jan 20 16:52:17 2023',
'__version__': '1.0',
'__globals__': [],
'data': array([[1, 2, 3],
[4, 5, 6]], dtype=int32),
'classes': array([[(array([[0]]), array([[1]]))]],
dtype=[('name_of_class_1', 'O'), ('name_of_class_2', 'O')])}
Is there a better way to store dict
of dict
/json
s in .mat
files?