Skip to content

Commit

Permalink
Add get_chunk_shape to python dataset impl
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Feb 16, 2020
1 parent d8310ca commit 369deff
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/python/lib/dataset.cxx
Original file line number Diff line number Diff line change
@@ -146,6 +146,11 @@ namespace z5 {
.def("chunkExists", [](const Dataset & ds, const types::ShapeType & chunkIndices){
return ds.chunkExists(chunkIndices);
})
.def("getChunkShape", [](const Dataset & ds, const types::ShapeType & chunkIndices){
types::ShapeType chunkShape;
ds.getChunkShape(chunkIndices, chunkShape);
return chunkShape;
})

//
// shapes and stuff
13 changes: 13 additions & 0 deletions src/python/module/z5py/dataset.py
Original file line number Diff line number Diff line change
@@ -501,3 +501,16 @@ def read_chunk(self, chunk_indices):
return None
chunk_reader = getattr(_z5py, 'read_chunk_%s' % self._impl.dtype)
return chunk_reader(self._impl, chunk_indices)

def get_chunk_shape(self, chunk_indices):
""" Get the shape of chunk.
This returns the actual chunk shape, which can be different
from self.chunks for border chunks.
Args:
chunk_indices (tuple): indices of the chunk to write to
Returns:
tuple - shape of the chunk
"""
self._impl.getChunkShape(chunk_indices)

0 comments on commit 369deff

Please sign in to comment.