nixpy icon indicating copy to clipboard operation
nixpy copied to clipboard

Catch exception for old boolean type

Open achilleas-k opened this issue 5 years ago • 1 comments

Since v1.2 (2016) the file representation for boolean types has changed. Files created before this version can't be read using h5py; the old representation is not compatible with h5py at all. This hasn't been an issue in general, but it came up recently (https://github.com/G-Node/nix-odML-converter/issues/26) during some old file conversions. The way to fix these would be to use NIX (C++) or HDF5 directly to change the format of older files. Since we can't automate that with NIXPy, we should catch the exception and provide a more useful error message.

achilleas-k avatar Oct 22 '20 13:10 achilleas-k

Since h5py 2.10, bitfields can be read but the type needs to be explicitly set: https://docs.h5py.org/en/latest/whatsnew/2.10.html#new-features

with dset.astype(numpy.bool):
    arr = dset[:]

achilleas-k avatar Nov 12 '20 20:11 achilleas-k