I am trying to create a numpy records array to match data that I am reading from an HDF5 file. The dtype of the HDF5 dataset (dataset) has a dtype of np.dtype(('u1', (3,))). The dtype of dataset[0] is dtype('uint8'). I am trying to write an HDF5 to match this as shown below:
import numpy as np
np.recarray((2,), dtype=('u1', (3,)))
However, this produces a result that looks it contains bytes rather than integers (which is how it looks when I read the HDF5 dataset):
records = rec.array([b'\xB0\xCE\x61', b'\x38\xD4\x01'], dtype=|V3)
When, I check the dtype of this array with records[0].dtype I get dtype(V3) instead of dtype('uint8') as I do when reading the HDF5 file.
How do I get the records to store these values as uint8 rather than bytes? I noticed that, if give the dtype a name, then the values are represented by numbers rather than bytes, but the HDF5 dataset does not have a dtype name.
>>>np.recarray((2,), dtype=[('test', 'u1', (3,))])
rec.array([([ 48, 26, 98],), ([ 56, 212, 1],)], dtype=[('test', 'u1', (3,))])