From 21127c4f72db6b94502e9c35657162f539d049d0 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:15:27 -0700 Subject: [PATCH 1/3] convert compound dtype to list on read --- src/hdmf/backends/hdf5/h5tools.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hdmf/backends/hdf5/h5tools.py b/src/hdmf/backends/hdf5/h5tools.py index da7f78a91..36aeb7c8f 100644 --- a/src/hdmf/backends/hdf5/h5tools.py +++ b/src/hdmf/backends/hdf5/h5tools.py @@ -700,6 +700,10 @@ def __read_dataset(self, h5obj, name=None): kwargs['dtype'] = d.dtype elif h5obj.dtype.kind == 'V': # scalar compound data type kwargs['data'] = np.array(scalar, dtype=h5obj.dtype) + cpd_dt = h5obj.dtype + ref_cols = [check_dtype(ref=cpd_dt[i]) or check_dtype(vlen=cpd_dt[i]) for i in range(len(cpd_dt))] + d = BuilderH5TableDataset(h5obj, self, ref_cols) + kwargs['dtype'] = HDF5IO.__compound_dtype_to_list(h5obj.dtype, d.dtype) else: kwargs["data"] = scalar else: From 4ca90ced44e4af78fe64918af88cddcd30a53e68 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:15:55 -0700 Subject: [PATCH 2/3] revert dtype list checks in validator --- src/hdmf/validate/validator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hdmf/validate/validator.py b/src/hdmf/validate/validator.py index 2668da1ec..6ce211f96 100644 --- a/src/hdmf/validate/validator.py +++ b/src/hdmf/validate/validator.py @@ -147,7 +147,7 @@ def get_type(data, builder_dtype=None): # Case for h5py.Dataset and other I/O specific array types else: # Compound dtype - if builder_dtype and len(builder_dtype) > 1: + if builder_dtype and isinstance(builder_dtype, list): dtypes = [] string_formats = [] for i in range(len(builder_dtype)): @@ -441,7 +441,7 @@ def validate(self, **kwargs): except EmptyArrayError: # do not validate dtype of empty array. HDMF does not yet set dtype when writing a list/tuple pass - if builder.dtype is not None and len(builder.dtype) > 1 and len(np.shape(builder.data)) == 0: + if isinstance(builder.dtype, list) and len(np.shape(builder.data)) == 0: shape = () # scalar compound dataset elif isinstance(builder.dtype, list): shape = (len(builder.data), ) # only 1D datasets with compound types are supported From 402454f724f12d7ec9477c6ac5e0e9cd6a6b3397 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:04:47 -0700 Subject: [PATCH 3/3] update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d89e320..4898af91b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # HDMF Changelog +## HDMF 3.14.5 (Upcoming) + +### Bug fixes +- Fixed export of scalar datasets with a compound data type. @stephprince [#1185](https://github.com/hdmf-dev/hdmf/pull/1185) + ## HDMF 3.14.4 (August 22, 2024) ### Enhancements