Saving mate files in different numeric data formats in scipy.io.savemat

I know that it is very simple, and I can’t believe that I didn’t find anything in this place, but here it is:

I have a large dimensional matrix in python that I want to save in .mat format (for matlab). I use the scipy.io.savemat method to save this matrix, but it is always saved as double. I would like to keep it as something of a lower accuracy, for example, single or 16-bit swimming.

I convert the array to a low current data type before saving, but it is always saved as double. Is there no way to save mat files in floating point mode with less accuracy?

.savemat does not seem to accept the dtype argument.

 import scipy as sp
 sp.io.savemat('test.mat', {'test': sp.array([0.001, 1, 1.004], dtype='Float16')})
+2
source share
1 answer

Apparently, it should be both single and double. scipy.io.savemat () does not support other floating point values, and it will casually double by default if it doesn't like your dtype without warning.

+2
source

Source: https://habr.com/ru/post/1614719/


All Articles