Skip to content

Commit

Permalink
Merge pull request #47 from NeurodataWithoutBorders/dtype-meta-vlen
Browse files Browse the repository at this point in the history
Add metadata to dtype when kind is 'O'
  • Loading branch information
magland authored Apr 19, 2024
2 parents 3c4562f + d269450 commit 97e4b6e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lindi/LindiH5pyFile/LindiH5pyDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,26 @@ def dtype(self):
# return StrDataset(h5obj, None)
# return h5obj
# We cannot have a dtype with kind 'O' and no metadata
ret = np.dtype(str(ret), metadata={})
# There is also this section in pynwb validator.py
# if isinstance(received, np.dtype):
# if received.char == 'O':
# if 'vlen' in received.metadata:
# received = received.metadata['vlen']
# else:
# raise ValueError("Unrecognized type: '%s'" % received)
# received = 'utf' if received is str else 'ascii'
# elif received.char == 'U':
# received = 'utf'
# elif received.char == 'S':
# received = 'ascii'
# else:
# received = received.name
# ------------------------------------------
# I don't know how to figure out when vlen should be str or bytes
# but validate seems to work only when I put in vlen = bytes
#
vlen = bytes
ret = np.dtype(str(ret), metadata={'vlen': vlen})
return ret

@property
Expand Down

0 comments on commit 97e4b6e

Please sign in to comment.