code: def _set_shape(self, shape):
          
  
          # Delete each cell that is beyond new borders
  
          old_shape = self.shape
          deleted_cells = {}
  
          if any(new_axis < old_axis
                 for new_axis, old_axis in zip(shape, old_shape)):
              for key in self.dict_grid.keys():
                  if any(key_ele >= new_axis
                         for key_ele, new_axis in zip(key, shape)):
                      deleted_cells[key] = self.pop(key)
  
          # Set dict_grid shape attribute
          self.dict_grid.shape = shape
  
          self._adjust_rowcol(0, 0, 0)
          self._adjust_cell_attributes(0, 0, 0)
  
          # Undo actions
  
          yield "_set_shape"
  
          self.shape = old_shape
  
          for key in deleted_cells:
              self[key] = deleted_cells[key]
docs: Deletes all cells beyond new shape and sets dict_grid shape
  
          Parameters
          ----------
          shape: 3-tuple of Integer
          \tTarget shape for grid