Skip to content

Commit

Permalink
Fix pynwb validation errors related to reference and compound data types
Browse files Browse the repository at this point in the history
* Ref hdmf-dev#585
* This is just a workaround for checking the data_type of
  BuilderH5ReferenceDataset and BuilderH5TableDataset objects
* Plan to add unit tests after some discussion to validate the approach
  • Loading branch information
dsleiter committed Jun 8, 2021
1 parent bd4aada commit 9668b88
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/hdmf/validate/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from ..spec.spec import BaseStorageSpec, DtypeHelper
from ..utils import docval, getargs, call_docval_func, pystr, get_data_shape

from hdmf.backends.hdf5.h5_utils import BuilderH5ReferenceDataset, BuilderH5TableDataset


__synonyms = DtypeHelper.primary_dtype_synonyms

__additional = {
Expand Down Expand Up @@ -107,6 +110,8 @@ def get_type(data):
return 'region'
elif isinstance(data, ReferenceBuilder):
return 'object'
elif isinstance(data, BuilderH5ReferenceDataset):
return 'object'
elif isinstance(data, np.ndarray):
if data.size == 0:
raise EmptyArrayError()
Expand All @@ -117,6 +122,8 @@ def get_type(data):
return type(data).__name__
else:
if hasattr(data, 'dtype'):
if isinstance(data, BuilderH5TableDataset):
return data.dtype
if isinstance(data.dtype, list):
return [get_type(data[0][i]) for i in range(len(data.dtype))]
if data.dtype.metadata is not None and data.dtype.metadata.get('vlen') is not None:
Expand Down

0 comments on commit 9668b88

Please sign in to comment.