Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Jul 10, 2024
1 parent 63e83e3 commit d5af631
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def resolve_ref(self, zarr_ref):
# Return the create path
return target_name, target_zarr_obj

def __get_ref(self, ref_object, path=None, source_file=None, export_source=None):
def __get_ref(self, ref_object, source_file=None, export_source=None):
"""
Create a ZarrReference object that points to the given container
If source_file is not None, use it to get the source_object_id.
Expand All @@ -758,10 +758,9 @@ def __get_ref(self, ref_object, path=None, source_file=None, export_source=None)
builder = ref_object.builder
else:
builder = self.manager.build(ref_object)
if path is None:
path = self.__get_path(builder)
else:
path = path

path = self.__get_path(builder)

# TODO Add to get region for region references.
# Also add {'name': 'region', 'type': (slice, list, tuple),
# 'doc': 'the region reference indexing object', 'default': None},
Expand Down
5 changes: 1 addition & 4 deletions src/hdmf_zarr/zarr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ def append(self, arg):
f_builder = self.invert().io.read_builder()
source_file = self.invert().io.manager.construct(f_builder)

# Get path
path = self.dataset[0]['path']

# Create ZarrReference
ref = self.invert().io._ZarrIO__get_ref(builder,path=path, source_file=source_file)
ref = self.invert().io._ZarrIO__get_ref(builder, source_file=source_file)
append_data(self.dataset, ref)


Expand Down
11 changes: 4 additions & 7 deletions tests/unit/test_zarrio.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def tearDown(self):
else:
warnings.warn("Could not remove: %s" % path)

def test_append_references_roundtrip(self):
def test_append_references(self):
# Setup a file container with references
num_bazs = 10
bazs = [] # set up dataset of references
Expand All @@ -218,16 +218,13 @@ def test_append_references_roundtrip(self):
with ZarrIO(self.store, manager=manager, mode='w') as writer:
writer.write(container=container)
# read from file and validate references
with ZarrIO(self.store, manager=manager, mode='a') as append_io:
with ZarrIO(self.store, manager=manager, mode='r+') as append_io:
read_container = append_io.read()
new_baz = Baz(name='baz0')
DoR = read_container.baz_data.data
DoR.append(new_baz)
DoR.append(DoR[0])

with ZarrIO(self.store, manager=manager, mode='a') as reader:
read_container = reader.read()
expected = {'source': '.', 'path': '/bazs/baz0',
'object_id': new_baz.object_id,
'object_id': DoR[0].object_id,
'source_object_id': container.object_id}

self.assertEqual(len(read_container.baz_data.data), 11)
Expand Down

0 comments on commit d5af631

Please sign in to comment.