JuliaIO / HDF5.jl

Save and load data in the HDF5 file format from Julia
https://juliaio.github.io/HDF5.jl
MIT License
390 stars 140 forks source link

The H5T_BITFIELD class should not be directly mapped to Bool #1148

Open mkitti opened 5 months ago

mkitti commented 5 months ago

https://github.com/JuliaIO/HDF5.jl/pull/540 mapped H5T_NATIVE_B8 to Bool. However, this seems be an error. A Bool should bit a H5T_BITFIELD with a precision of 1 as described by PyTables.

H5T_BITFIELD: This class is used to represent the Bool type. Such a type must be build using a H5T_NATIVE_B8 datatype, followed by a HDF5 H5Tset_precision call to set its precision to be just 1 bit.

h5py chooses to read the class of H5T_BITFIELD as unsigned integers: https://github.com/h5py/h5py/pull/1889

@tamasgal I'm considering requiring the precision to be set to 1 to interpret the value as a Bool. Rather I think we should consider mapping H5T_NATIVE_B8 to a UInt8.

tamasgal commented 5 months ago

Oh, yes, I think you are right. Mapping H5T_NATIVE_B8 to a UInt8 would make most sense to me too.