Skip to content

Commit 78db27e

Browse files
committed
During automatic partition, make chunksize a multiple of blocksize. Fixes #392.
1 parent 413a217 commit 78db27e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/blosc2/core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,11 @@ def compute_chunks_blocks( # noqa: C901
15621562
if chunks is None:
15631563
blocksize = math.prod(blocks) * itemsize
15641564
chunksize = get_chunksize(blocksize)
1565+
# Make chunksize to be a multiple of the blocksize. This allows for:
1566+
# 1. Avoid unnecessary padding in chunks
1567+
# 2. Avoid exceeding the maximum buffer size (see #392)
1568+
if chunksize % blocksize != 0:
1569+
chunksize = chunksize // blocksize * blocksize
15651570
chunks = compute_partition(chunksize // itemsize, shape, blocks)
15661571

15671572
return tuple(chunks), tuple(blocks)

0 commit comments

Comments
 (0)