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

Allow creation of expandable external datasets #2398

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions h5py/_hl/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,13 @@ def rq_tuple(tpl, name):
external = _normalize_external(external)
# End argument validation

if (chunks is True) or \
(chunks is None and any((shuffle, fletcher32, compression, maxshape,
scaleoffset is not None))):
if (chunks is True) or (chunks is None and any((
shuffle,
fletcher32,
compression,
(maxshape and not len(external)),
scaleoffset is not None,
))):
chunks = guess_chunk(shape, maxshape, dtype.itemsize)

if maxshape is True:
Expand Down
12 changes: 12 additions & 0 deletions h5py/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,18 @@ def test_invalid(self):
with self.assertRaises(exc_type):
self.f.create_dataset('foo', shape, external=external)

def test_create_expandable(self):
""" Create expandable external dataset """

ext_file = self.mktemp()
shape = (128, 64)
maxshape = (None, 64)
exp_dset = self.f.create_dataset('foo', shape=shape, maxshape=maxshape,
external=ext_file)
assert exp_dset.chunks is None
assert exp_dset.shape == shape
assert exp_dset.maxshape == maxshape


class TestAutoCreate(BaseDataset):

Expand Down