|
35 | 35 | U = TypeVar("U") |
36 | 36 |
|
37 | 37 |
|
38 | | -def normalize_slices( |
39 | | - idxr: tuple[int | slice, ...], shape: tuple[int, ...] |
40 | | -) -> tuple[int | slice, ...]: |
41 | | - # replace slice objects with stop==None with size |
42 | | - out = [] |
43 | | - for i, size in zip(idxr, shape, strict=False): |
44 | | - if not isinstance(i, slice): |
45 | | - out.append(i) |
46 | | - continue |
47 | | - if i.step not in [1, None] or i.start not in [0, None]: |
48 | | - out.append(i) |
49 | | - continue |
50 | | - out.append(slice(i.start, i.stop if i.stop is not None else size, i.step)) |
51 | | - return tuple(out) |
52 | | - |
53 | | - |
54 | 38 | def _unzip2(iterable: Iterable[tuple[T, U]]) -> tuple[list[T], list[U]]: |
55 | 39 | out0: list[T] = [] |
56 | 40 | out1: list[U] = [] |
@@ -295,10 +279,7 @@ async def read_batch( |
295 | 279 | chunk_array_batch, batch_info, strict=False |
296 | 280 | ): |
297 | 281 | if chunk_array is not None: |
298 | | - normalized_selection = normalize_slices( |
299 | | - chunk_selection, out[out_selection].shape |
300 | | - ) |
301 | | - tmp = chunk_array[normalized_selection] |
| 282 | + tmp = chunk_array[chunk_selection] |
302 | 283 | if drop_axes != (): |
303 | 284 | tmp = tmp.squeeze(axis=drop_axes) |
304 | 285 | out[out_selection] = tmp |
@@ -341,9 +322,7 @@ def _merge_chunk_array( |
341 | 322 | for idx in range(chunk_spec.ndim) |
342 | 323 | ) |
343 | 324 | chunk_value = chunk_value[item] |
344 | | - |
345 | | - normalized_selection = normalize_slices(chunk_selection, chunk_value.shape) |
346 | | - chunk_array[normalized_selection] = chunk_value |
| 325 | + chunk_array[chunk_selection] = chunk_value |
347 | 326 | return chunk_array |
348 | 327 |
|
349 | 328 | async def write_batch( |
|
0 commit comments