Skip to content

Commit

Permalink
Allow null references as data (#37)
Browse files Browse the repository at this point in the history
* support null references as data

* fix pep8 violation
  • Loading branch information
ajtritt committed Apr 17, 2019
1 parent 7920c5f commit ba748b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/hdmf/backends/hdf5/h5tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,15 @@ def __list_fill__(cls, parent, name, data, options=None):
raise e
return dset

@docval({'name': 'container', 'type': (Builder, Container, ReferenceBuilder), 'doc': 'the object to reference'},
@docval({'name': 'container', 'type': (Builder, Container, ReferenceBuilder), 'doc': 'the object to reference',
'default': None},
{'name': 'region', 'type': (slice, list, tuple), 'doc': 'the region reference indexing object',
'default': None},
returns='the reference', rtype=Reference)
def __get_ref(self, **kwargs):
container, region = getargs('container', 'region', kwargs)
if container is None:
return None
if isinstance(container, Builder):
if isinstance(container, LinkBuilder):
builder = container.target_builder
Expand Down
5 changes: 4 additions & 1 deletion src/hdmf/build/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,10 @@ def build(self, **kwargs):
if self.__spec.dtype is None and self.__is_reftype(container.data):
bldr_data = list()
for d in container.data:
bldr_data.append(ReferenceBuilder(manager.build(d)))
if d is None:
bldr_data.append(None)
else:
bldr_data.append(ReferenceBuilder(manager.build(d)))
builder = DatasetBuilder(name, bldr_data, parent=parent, source=source,
dtype='object')
else:
Expand Down

0 comments on commit ba748b9

Please sign in to comment.