File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 3535U = TypeVar ("U" )
3636
3737
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 ]:
48+ out .append (i )
49+ out .append (slice (i .start , i .stop if i .stop is not None else size , i .step ))
50+ return tuple (out )
51+
52+
3853def _unzip2 (iterable : Iterable [tuple [T , U ]]) -> tuple [list [T ], list [U ]]:
3954 out0 : list [T ] = []
4055 out1 : list [U ] = []
@@ -322,7 +337,9 @@ def _merge_chunk_array(
322337 for idx in range (chunk_spec .ndim )
323338 )
324339 chunk_value = chunk_value [item ]
325- chunk_array [chunk_selection ] = chunk_value
340+
341+ normalized_selection = normalize_slices (chunk_selection , chunk_array .shape )
342+ chunk_array [normalized_selection ] = chunk_value
326343 return chunk_array
327344
328345 async def write_batch (
You can’t perform that action at this time.
0 commit comments