Skip to content

Commit

Permalink
add test for compound data type with strings
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Aug 19, 2024
1 parent 5279c9c commit b636c3f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/unit/test_io_hdf5_h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from hdmf.data_utils import DataChunkIterator, GenericDataChunkIterator, InvalidDataIOError
from hdmf.spec.catalog import SpecCatalog
from hdmf.spec.namespace import NamespaceCatalog, SpecNamespace
from hdmf.spec.spec import GroupSpec
from hdmf.spec.spec import GroupSpec, DtypeSpec
from hdmf.testing import TestCase, remove_test_file
from hdmf.common.resources import HERD
from hdmf.term_set import TermSet, TermSetWrapper
Expand Down Expand Up @@ -172,6 +172,22 @@ def test_write_dataset_lol_strings(self):
for sublist in dset[:]]
self.assertTrue(decoded_dset == a)

def test_write_dataset_list_compound_datatype(self):
a = np.array([(1, 2, 0.5), (3, 4, 0.5)], dtype=[('x', 'int'), ('y', 'int'), ('z', 'float')])
dset_builder = DatasetBuilder(
name='test_dataset',
data=a.tolist(),
attributes={},
dtype=[
DtypeSpec('x', doc='x', dtype='int'),
DtypeSpec('y', doc='y', dtype='int'),
DtypeSpec('z', doc='z', dtype='float'),
],
)
self.io.write_dataset(self.f, dset_builder)
dset = self.f['test_dataset']
self.assertTrue(np.all(dset[:] == a))

def test_write_dataset_list_compress_gzip(self):
a = H5DataIO(np.arange(30).reshape(5, 2, 3),
compression='gzip',
Expand Down

0 comments on commit b636c3f

Please sign in to comment.