Skip to content

Commit 25fc9ca

Browse files
committed
use write_empty_chunks from config in write_batch
1 parent 7d5d8fb commit 25fc9ca

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/zarr/codecs/pipeline.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ async def write_batch(
331331
value: NDBuffer,
332332
drop_axes: tuple[int, ...] = (),
333333
) -> None:
334+
write_empty_chunks = config.get("array.write_empty_chunks") == True # noqa: E712
334335
if self.supports_partial_encode:
335336
await self.encode_partial_batch(
336337
[
@@ -377,15 +378,16 @@ async def _read_key(
377378
chunk_array_batch, batch_info, strict=False
378379
)
379380
]
380-
381-
chunk_array_batch = [
382-
None
383-
if chunk_array is None or chunk_array.all_equal(chunk_spec.fill_value)
384-
else chunk_array
385-
for chunk_array, (_, chunk_spec, _, _) in zip(
386-
chunk_array_batch, batch_info, strict=False
387-
)
388-
]
381+
for chunk_array, (_, chunk_spec, _, _) in zip(
382+
chunk_array_batch, batch_info, strict=False
383+
):
384+
if chunk_array is None:
385+
chunk_array_batch.append(None)
386+
else:
387+
if not write_empty_chunks and chunk_array.all_equal(chunk_spec.fill_value):
388+
chunk_array_batch.append(None)
389+
else:
390+
chunk_array_batch.append(chunk_array)
389391

390392
chunk_bytes_batch = await self.encode_batch(
391393
[

0 commit comments

Comments
 (0)