Skip to content

Commit b78625b

Browse files
stephprincerly
andauthored
Fix scalar dataset with compound dtype for export (#1185)
* convert compound dtype to list on read * revert dtype list checks in validator * update CHANGELOG.md --------- Co-authored-by: Ryan Ly <rly@lbl.gov>
1 parent b5235a7 commit b78625b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
# HDMF Changelog
22

3-
## HDMF 3.14.6 (Upcoming)
4-
5-
### Bug fixes
6-
- Fixed mamba-related error in conda-based GitHub Actions. @rly [#1194](https://github.com/hdmf-dev/hdmf/pull/1194)
7-
8-
## HDMF 3.14.5 (September 17, 2024)
3+
## HDMF 3.14.5 (Upcoming)
94

105
### Enhancements
116
- Added support for overriding backend configurations of `h5py.Dataset` objects in `Container.set_data_io`. @pauladkisson [#1172](https://github.com/hdmf-dev/hdmf/pull/1172)
127

138
### Bug fixes
149
- Fixed bug in writing of string arrays to an HDF5 file that were read from an HDF5 file that was introduced in 3.14.4. @rly @stephprince
1510
[#1189](https://github.com/hdmf-dev/hdmf/pull/1189)
11+
- Fixed export of scalar datasets with a compound data type. @stephprince [#1185](https://github.com/hdmf-dev/hdmf/pull/1185)
12+
- Fixed mamba-related error in conda-based GitHub Actions. @rly [#1194](https://github.com/hdmf-dev/hdmf/pull/1194)
1613

1714
## HDMF 3.14.4 (September 4, 2024)
1815

src/hdmf/backends/hdf5/h5tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,10 @@ def __read_dataset(self, h5obj, name=None):
700700
kwargs['dtype'] = d.dtype
701701
elif h5obj.dtype.kind == 'V': # scalar compound data type
702702
kwargs['data'] = np.array(scalar, dtype=h5obj.dtype)
703+
cpd_dt = h5obj.dtype
704+
ref_cols = [check_dtype(ref=cpd_dt[i]) or check_dtype(vlen=cpd_dt[i]) for i in range(len(cpd_dt))]
705+
d = BuilderH5TableDataset(h5obj, self, ref_cols)
706+
kwargs['dtype'] = HDF5IO.__compound_dtype_to_list(h5obj.dtype, d.dtype)
703707
else:
704708
kwargs["data"] = scalar
705709
else:

src/hdmf/validate/validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_type(data, builder_dtype=None):
147147
# Case for h5py.Dataset and other I/O specific array types
148148
else:
149149
# Compound dtype
150-
if builder_dtype and len(builder_dtype) > 1:
150+
if builder_dtype and isinstance(builder_dtype, list):
151151
dtypes = []
152152
string_formats = []
153153
for i in range(len(builder_dtype)):
@@ -441,7 +441,7 @@ def validate(self, **kwargs):
441441
except EmptyArrayError:
442442
# do not validate dtype of empty array. HDMF does not yet set dtype when writing a list/tuple
443443
pass
444-
if builder.dtype is not None and len(builder.dtype) > 1 and len(np.shape(builder.data)) == 0:
444+
if isinstance(builder.dtype, list) and len(np.shape(builder.data)) == 0:
445445
shape = () # scalar compound dataset
446446
elif isinstance(builder.dtype, list):
447447
shape = (len(builder.data), ) # only 1D datasets with compound types are supported

0 commit comments

Comments
 (0)