From 94474477892f8d28974804f46578a24126ee2b91 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Thu, 11 Jan 2024 16:47:35 -0800 Subject: [PATCH] Write strings as objects in compound reference datasets --- src/hdmf_zarr/backend.py | 3 ++- tests/unit/base_tests_zarrio.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hdmf_zarr/backend.py b/src/hdmf_zarr/backend.py index fa8cab43..fbdf91f3 100644 --- a/src/hdmf_zarr/backend.py +++ b/src/hdmf_zarr/backend.py @@ -1033,7 +1033,8 @@ def write_dataset(self, **kwargs): # noqa: C901 if field['dtype'] is str or field['dtype'] in ( 'str', 'text', 'utf', 'utf8', 'utf-8', 'isodatetime' ): - new_dtype.append((field['name'], 'U25')) + # Zarr does not support variable length strings + new_dtype.append((field['name'], 'O')) elif isinstance(field['dtype'], dict): # eg. for some references, dtype will be of the form # {'target_type': 'Baz', 'reftype': 'object'} diff --git a/tests/unit/base_tests_zarrio.py b/tests/unit/base_tests_zarrio.py index 81ab9416..ec1758cd 100644 --- a/tests/unit/base_tests_zarrio.py +++ b/tests/unit/base_tests_zarrio.py @@ -436,7 +436,7 @@ def test_read_reference_compound(self): read_builder = self.root['ref_dataset'] # ensure the array was written as a compound array - ref_dtype = np.dtype([('id', '