@@ -882,23 +882,19 @@ class PartialChunkIterator:
882
882
"""
883
883
884
884
def __init__ (self , selection , arr_shape ):
885
- ## TODO: self.selection seem to be unused outside of this
886
- # and seem to be mutated; which might not be expected
887
- # self.selection seem to be expected to be part of the external API of
888
- # this iterator; so not sure we can make it a local variable.
889
- self .selection = make_slice_selection (selection )
885
+ selection = make_slice_selection (selection )
890
886
self .arr_shape = arr_shape
891
887
892
888
# number of selection dimensions can't be greater than the number of chunk dimensions
893
- if len (self . selection ) > len (self .arr_shape ):
889
+ if len (selection ) > len (self .arr_shape ):
894
890
raise ValueError (
895
891
"Selection has more dimensions then the array:\n "
896
- "selection dimensions = {len(self. selection)\n "
892
+ "selection dimensions = {len(selection)\n "
897
893
"array dimensions = {len(self.arr_shape)}"
898
894
)
899
895
900
896
# any selection can not be out of the range of the chunk
901
- selection_shape = np .empty (self .arr_shape )[tuple (self . selection )].shape
897
+ selection_shape = np .empty (self .arr_shape )[tuple (selection )].shape
902
898
if any (
903
899
[
904
900
selection_dim < 0 or selection_dim > arr_dim
@@ -911,16 +907,16 @@ def __init__(self, selection, arr_shape):
911
907
912
908
for i , dim_size in enumerate (self .arr_shape [::- 1 ]):
913
909
index = len (self .arr_shape ) - (i + 1 )
914
- if index <= len (self . selection ) - 1 :
910
+ if index <= len (selection ) - 1 :
915
911
slice_size = selection_shape [index ]
916
912
if slice_size == dim_size and index > 0 :
917
- self . selection .pop ()
913
+ selection .pop ()
918
914
else :
919
915
break
920
916
921
917
chunk_loc_slices = []
922
- last_dim_slice = None if self . selection [- 1 ].step > 1 else self . selection .pop ()
923
- for i , sl in enumerate (self . selection ):
918
+ last_dim_slice = None if selection [- 1 ].step > 1 else selection .pop ()
919
+ for i , sl in enumerate (selection ):
924
920
dim_chunk_loc_slices = []
925
921
for i , x in enumerate (slice_to_range (sl , arr_shape [i ])):
926
922
dim_chunk_loc_slices .append (slice (x , x + 1 , 1 ))
0 commit comments