Skip to content

Commit

Permalink
Merge pull request #44 from NeurodataWithoutBorders/chunks-property
Browse files Browse the repository at this point in the history
implement chunks property
  • Loading branch information
magland authored Apr 16, 2024
2 parents f9c449d + b43b67a commit 0edd1bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lindi/LindiH5pyFile/LindiH5pyDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ def fletcher32(self):
else:
raise Exception(f'Unexpected dataset object type: {type(self._dataset_object)}')

@property
def chunks(self):
if isinstance(self._dataset_object, h5py.Dataset):
return self._dataset_object.chunks
elif isinstance(self._dataset_object, zarr.Array):
return self._dataset_object.chunks
else:
raise Exception(f'Unexpected dataset object type: {type(self._dataset_object)}')

def __repr__(self): # type: ignore
return f"<{self.__class__.__name__}: {self.name}>"

Expand Down
2 changes: 1 addition & 1 deletion lindi/LindiH5pyFile/LindiH5pyFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _recursive_copy(src_item: Union[h5py.Group, h5py.Dataset], dest: h5py.File,
dst_rfs['refs'][dst_ref_key] = _deep_copy(src_rfs['refs'][src_ref_key])
return

dst_item = dest.create_dataset(name, data=src_item[()])
dst_item = dest.create_dataset(name, data=src_item[()], chunks=src_item.chunks)
for k, v in src_item.attrs.items():
dst_item.attrs[k] = v
else:
Expand Down

0 comments on commit 0edd1bc

Please sign in to comment.