Skip to content

Commit

Permalink
add strdataset condition for dtype conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Nov 8, 2024
1 parent be602e5 commit 8d20b42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hdmf/build/objectmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ..query import ReferenceResolver
from ..spec import Spec, AttributeSpec, DatasetSpec, GroupSpec, LinkSpec, RefSpec
from ..spec.spec import BaseStorageSpec
from ..utils import docval, getargs, ExtenderMeta, get_docval, get_data_shape
from ..utils import docval, getargs, ExtenderMeta, get_docval, get_data_shape, StrDataset

_const_arg = '__constructor_arg'

Expand Down Expand Up @@ -212,7 +212,10 @@ def convert_dtype(cls, spec, value, spec_dtype=None): # noqa: C901
if (isinstance(value, np.ndarray) or
(hasattr(value, 'astype') and hasattr(value, 'dtype'))):
if spec_dtype_type is _unicode:
ret = value.astype('U')
if isinstance(value, StrDataset):
ret = value

Check warning on line 216 in src/hdmf/build/objectmapper.py

View check run for this annotation

Codecov / codecov/patch

src/hdmf/build/objectmapper.py#L216

Added line #L216 was not covered by tests
else:
ret = value.astype('U')
ret_dtype = "utf8"
elif spec_dtype_type is _ascii:
ret = value.astype('S')
Expand Down

0 comments on commit 8d20b42

Please sign in to comment.