Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0e5c69

Browse files
terraputixd-v-b
andauthored
fix for failing numcodecs.zarr3 codecs (#3326)
* add array copy for array view* fix broken codecs without copying---------Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
1 parentb75aeb1 commitb0e5c69

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎src/zarr/core/codec_pipeline.py‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,22 @@ def _merge_chunk_array(
301301
is_complete_chunk:bool,
302302
drop_axes:tuple[int, ...],
303303
)->NDBuffer:
304+
if (
305+
is_complete_chunk
306+
andvalue.shape==chunk_spec.shape
307+
# Guard that this is not a partial chunk at the end with is_complete_chunk=True
308+
andvalue[out_selection].shape==chunk_spec.shape
309+
):
310+
returnvalue
311+
ifexisting_chunk_arrayisNone:
312+
chunk_array=chunk_spec.prototype.nd_buffer.create(
313+
shape=chunk_spec.shape,
314+
dtype=chunk_spec.dtype.to_native_dtype(),
315+
order=chunk_spec.order,
316+
fill_value=fill_value_or_default(chunk_spec),
317+
)
318+
else:
319+
chunk_array=existing_chunk_array.copy()# make a writable copy
304320
ifchunk_selection== ()oris_scalar(
305321
value.as_ndarray_like(),chunk_spec.dtype.to_native_dtype()
306322
):
@@ -316,20 +332,6 @@ def _merge_chunk_array(
316332
foridxinrange(chunk_spec.ndim)
317333
)
318334
chunk_value=chunk_value[item]
319-
ifis_complete_chunkandchunk_value.shape==chunk_spec.shape:
320-
# TODO: For the last chunk, we could have is_complete_chunk=True
321-
# that is smaller than the chunk_spec.shape but this throws
322-
# an error in the _decode_single
323-
returnchunk_value
324-
ifexisting_chunk_arrayisNone:
325-
chunk_array=chunk_spec.prototype.nd_buffer.create(
326-
shape=chunk_spec.shape,
327-
dtype=chunk_spec.dtype.to_native_dtype(),
328-
order=chunk_spec.order,
329-
fill_value=fill_value_or_default(chunk_spec),
330-
)
331-
else:
332-
chunk_array=existing_chunk_array.copy()# make a writable copy
333335
chunk_array[chunk_selection]=chunk_value
334336
returnchunk_array
335337

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp