-
Notifications
You must be signed in to change notification settings - Fork 25
Description
import h5py
import pyfive
import numpy as np
f = h5py.File('enum_attrs.hdf5', 'w')
attrs = f.attrs
# Define an enum dtype
enum_dtype = h5py.special_dtype(
enum=(np.int32, {'one': 1, 'two': 2, 'three': 3})
)
# Create an attribute with that enum dtype
attrs.create('enum', 2, dtype=enum_dtype)
f.close()
with pyfive.File('enum_attrs.hdf5') as hfile:
import h5py
enum_attr = hfile.attrs['enum']
assert enum_attr == 2
assert enum_attr.dtype == enum_dtype
)Traceback (most recent call last):
File "/home/kai/mambaforge/envs/xr_312_np2/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-4c07ea7bf2a5>", line 20, in <module>
enum_attr = hfile.attrs['enum']
^^^^^^^^^^^
File "/home/kai/PycharmProjects/pyfive/pyfive/high_level.py", line 158, in attrs
self._attrs = self._dataobjects.get_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kai/PycharmProjects/pyfive/pyfive/dataobjects.py", line 147, in get_attributes
name, value = self.unpack_attribute(offset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kai/PycharmProjects/pyfive/pyfive/dataobjects.py", line 187, in unpack_attribute
return self._parse_attribute_msg(self.msg_data, offset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kai/PycharmProjects/pyfive/pyfive/dataobjects.py", line 240, in _parse_attribute_msg
value = value[0]
~~~~~^^^
KeyError: 'There are no fields in dtype int32.'I traced this back to a mismatch in DataObjects._attr_value, where instead of the value, the datatype of an enum is returned.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels