HDFView 3.1.0 error displaying dataset with np.float16 data

I know np.float16 is not commonly used…has anyone ever tested HDFView with a dataset (np.array) of np.float16? I created 3 datasets each shape=(10,10), 1 each of np.float64, np.float32, and np.float16. When I open with HDFView, the 64 and 32 bit datasets can be viewed. I get an error message when I try to open the 16 bit set. Error is: “An error occurred while loading data for the table: data value is null”. I can open with h5py and print the data for all 3 datasets. Any ideas?

Code below if you are interested. Note: the code shows 2 ways to cast the original array to float32 and float16. I get the same result no matter how I do this.

import numpy as np
import h5py

with h5py.File('test_floats.h5', 'w') as f:
    data = np.random.random((10,10))
    print (data)
# create 3 data sets
    dset64 = f.create_dataset('dset64', data=data)
    #data = np.random.random((10,10)).astype(np.float32)
    dset32 = f.create_dataset('dset32', data=data.astype(np.float32))
    #data = np.random.random((10,10)).astype(np.float16)
    dset16 = f.create_dataset('dset16', data=data.astype(np.float16))

# check data
with h5py.File('test_floats.h5', 'r') as f:
    print(f['dset64'].dtype)
    print(f['dset64'][:])
    print(f['dset32'].dtype)
    print(f['dset32'][:])
    print(f['dset16'].dtype)
    print(f['dset16'][:])

I can reproduce this issue in v3.1.3. h5dump, h5ls, and python’s h5py read the data back OK.

Unfortunately, half-precision (16-bit) and quad-precision(128-bit) float types are not currently supported by hdf5/hdfview. I think the reason h5dump works is because it interrogates the properties of the datatype and hdf5 finds a container for it. Last I checked, th Java language does not support those types either.
Can we add something to HDFView to work around this limitation, probably because we did add a way to display 128-bit floats, I think.

Allen

1 Like