Skip to content

Commit

Permalink
added catch for byte strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Sep 9, 2024
1 parent 0187665 commit 2d837cc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,13 @@ def __list_fill__(self, parent, name, data, options=None): # noqa: C901
except ValueError:
for i in range(len(data)):
dset[i] = data[i]
except TypeError: # If data is an h5py.Dataset with strings, they may need to be decoded
for c in np.ndindex(data_shape):
o = data
for i in c:
o = o[i]
# bytes are not JSON serializable
dset[c] = o if not isinstance(o, (bytes, np.bytes_)) else o.decode("utf-8")
return dset

def __scalar_fill__(self, parent, name, data, options=None):
Expand Down

0 comments on commit 2d837cc

Please sign in to comment.