@@ -309,9 +309,8 @@ def nbytes_stored(self):
309
309
310
310
@property
311
311
def _cdata_shape (self ):
312
- return tuple (
313
- int (np .ceil (s / c )) for s , c in zip (self ._shape , self ._chunks )
314
- )
312
+ return tuple (int (np .ceil (s / c ))
313
+ for s , c in zip (self ._shape , self ._chunks ))
315
314
316
315
@property
317
316
def cdata_shape (self ):
@@ -917,6 +916,7 @@ def _resize_nosync(self, *args):
917
916
# normalize new shape argument
918
917
old_shape = self ._shape
919
918
new_shape = normalize_resize_args (old_shape , * args )
919
+ old_cdata_shape = self ._cdata_shape
920
920
921
921
# update metadata
922
922
self ._shape = new_shape
@@ -928,17 +928,16 @@ def _resize_nosync(self, *args):
928
928
for s , c in zip (new_shape , chunks ))
929
929
930
930
# remove any chunks not within range
931
- for key in listdir (self ._chunk_store , self ._path ):
932
- if key not in [array_meta_key , attrs_key ]:
931
+ for cidx in itertools .product (* [range (n ) for n in old_cdata_shape ]):
932
+ if all (i < c for i , c in zip (cidx , new_cdata_shape )):
933
+ pass # keep the chunk
934
+ else :
935
+ key = self ._chunk_key (cidx )
933
936
try :
934
- cidx = list (map (int , key .split ('.' )))
935
- except ValueError as e :
936
- raise RuntimeError ('unexpected key: %r' % key )
937
- else :
938
- if all (i < c for i , c in zip (cidx , new_cdata_shape )):
939
- pass # keep the chunk
940
- else :
941
- del self ._chunk_store [self ._key_prefix + key ]
937
+ del self ._chunk_store [key ]
938
+ except KeyError :
939
+ # chunk not initialized
940
+ pass
942
941
943
942
def append (self , data , axis = 0 ):
944
943
"""Append `data` to `axis`.
0 commit comments