@@ -899,7 +899,7 @@ def __delitem__(self, index):
899899 self [index :- 1 ] = self [index + 1 :]
900900 np .ndarray .resize (self , new_shape , refcheck = False )
901901
902- def _resize_for_index (self , index ):
902+ def _resize_for_index (self , index , set_default = True ):
903903 """
904904 Resize the array so that the (multidimensional) index is not OOB.
905905
@@ -954,14 +954,12 @@ def _resize_for_index(self, index):
954954 new_shape .append (next_shape )
955955 new_shape = new_shape + shape
956956 view_index = tuple (slice (x , None ) for x in np .shape (self ))
957- try :
958- np .ndarray .resize (self , new_shape , refcheck = False )
959- except ValueError as e :
960- raise ValueError (type (self ).__name__ , self , str (e ))
961- arr = np .ndarray .view (self , np .ndarray )
962- view_shape = arr [view_index ].shape
963- new_data = self ._DEFAULT (view_shape )
964- arr [view_index ] = new_data
957+ np .ndarray .resize (self , new_shape , refcheck = False )
958+ if set_default :
959+ arr = np .ndarray .view (self , np .ndarray )
960+ view_shape = arr [view_index ].shape
961+ new_data = self ._DEFAULT (view_shape )
962+ arr [view_index ] = new_data
965963
966964 def _return_delayed (self , index ):
967965 if not isinstance (index , tuple ):
@@ -974,7 +972,7 @@ def _return_delayed(self, index):
974972 # later if the caller did not mess up their syntax, so there's
975973 # not much wasted performance.
976974 shape = self .shape
977- self ._resize_for_index (index )
975+ self ._resize_for_index (index , set_default = False )
978976
979977 # NOTE
980978 # Ensure that the indexed view is an array, not a single item.
0 commit comments