def maybe_convert_indices(indices, n):
 if isinstance(indices, list):
  indices = np.array(indices)
  if (len(indices) == 0):
   return np.empty(0, dtype=np.int_)
 mask = (indices < 0)
 if mask.any():
  indices[mask] += n
 mask = ((indices >= n) | (indices < 0))
 if mask.any():
  raise IndexError('indices are out-of-bounds')
 return indices

def maybe_convert_indices ( indices , n ) : if isinstance ( indices , list ) : indices = np . array ( indices ) if ( len ( indices ) == 0 ) : return np . empty ( 0 , dtype = np . int_ ) mask = ( indices < 0 ) if mask . any ( ) : indices [ mask ] += n mask = ( ( indices >= n ) | ( indices < 0 ) ) if mask . any ( ) : raise IndexError ( 'indices are out-of-bounds' ) return indices
if we have negative indicies .