nanophotonics / nplab

Core functions and instrument scripts for the Nanophotonics lab experimental scripts
GNU General Public License v3.0
38 stars 15 forks source link

h5 string reading returns bytes in h5py>3.0 #141

Closed eoinell closed 3 years ago

eoinell commented 3 years ago

More of a curiosity than a real issue as i've implemented a quick fix for this. The issue seems to be that on newer (3.9) versions of python accessing a string saved in .h5 returns a bytes object, but in older versions returns a string. As saving timestamps saves encoded strings as attributes, they're now read as bytes. Apparently saving them as strings would read them as strings as this is the default behaviour for dataset attributes.

https://docs.h5py.org/en/latest/whatsnew/3.0.html "Variable-length UTF-8 strings in datasets are now read as bytes objects instead of str by default, for consistency with other kinds of strings. See Strings in HDF5 for more details."