Skip to content

Commit

Permalink
Fix #160. Resolve bytes dtype on export
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Feb 13, 2024
1 parent 52d6472 commit c0dd0bc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ def write_dataset(self, **kwargs): # noqa: C901
"utf8": str,
"utf-8": str,
"ascii": bytes,
"bytes": bytes,
"str": str,
"isodatetime": str,
"string_": bytes,
Expand Down Expand Up @@ -1193,7 +1194,9 @@ def __resolve_dtype_helper__(cls, dtype):
@classmethod
def get_type(cls, data):
if isinstance(data, str):
return str
return cls.__dtypes.get("str")
elif isinstance(data, bytes):
return cls.__dtypes.get("bytes")
elif not hasattr(data, '__len__'):
return type(data)
else:
Expand Down Expand Up @@ -1230,8 +1233,8 @@ def __list_fill__(self, parent, name, data, options=None): # noqa: C901
# which Zarr does not allow for dataset shape. Check for the shape attribute first before falling
# back on get_data_shape
if hasattr(data, 'shape') and data.shape is not None:
data_shape = data.shape
# This is a fall-back just in case. However this should not happen for standard numpy and h5py arrays
data_shape = data.shape
# This is a fall-back just in case. However this should not happen for standard numpy and h5py arrays
else: # pragma: no cover
data_shape = get_data_shape(data) # pragma: no cover
# Deal with object dtype
Expand Down

0 comments on commit c0dd0bc

Please sign in to comment.