def format_slice(key_val, dim):
 if isinstance(key_val, slice):
  key_val = slice(to_int(key_val.start), to_int(key_val.stop), to_int(key_val.step))
  return key_val
 else:
  key_val = to_int(key_val)
  key_val = wrap_neg_index(key_val, dim)
  if (0 <= key_val < dim):
   return slice(key_val, (key_val + 1), 1)
  else:
   raise IndexError('Index/slice out of bounds.')

def format_slice ( key_val , dim ) : if isinstance ( key_val , slice ) : key_val = slice ( to_int ( key_val . start ) , to_int ( key_val . stop ) , to_int ( key_val . step ) ) return key_val else : key_val = to_int ( key_val ) key_val = wrap_neg_index ( key_val , dim ) if ( 0 <= key_val < dim ) : return slice ( key_val , ( key_val + 1 ) , 1 ) else : raise IndexError ( 'Index/slice out of bounds.' )
converts part of a key into a slice with a start and step .