Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose chunk shape in write nodes #160

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions gunpowder/nodes/hdf5like_write_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class Hdf5LikeWrite(BatchFilter):
A dictionary from array keys to datatype (eg. ``np.int8``). If
given, arrays are stored using this type. The original arrays
within the pipeline remain unchanged.

chunks (``tuple`` of ``int``, or ``bool``):

Chunk shape for output datasets. Set to ``True`` for auto-chunking,
set to ``False`` to obtain a chunk equal to the dataset size.
Defaults to ``True``.
'''

def __init__(
Expand All @@ -49,7 +55,8 @@ def __init__(
output_dir='.',
output_filename='output.hdf',
compression_type=None,
dataset_dtypes=None):
dataset_dtypes=None,
chunks=True):

self.dataset_names = dataset_names
self.output_dir = output_dir
Expand All @@ -59,6 +66,7 @@ def __init__(
self.dataset_dtypes = {}
else:
self.dataset_dtypes = dataset_dtypes
self.chunks = chunks

self.dataset_offsets = {}

Expand Down Expand Up @@ -149,10 +157,12 @@ def init_datasets(self, batch):
offset, voxel_size)

dataset = data_file.create_dataset(
name=dataset_name,
shape=data_shape,
compression=self.compression_type,
dtype=dtype)
name=dataset_name,
shape=data_shape,
compression=self.compression_type,
dtype=dtype,
chunks=self.chunks
)

self._set_offset(dataset, offset)
self._set_voxel_size(dataset, voxel_size)
Expand Down