def _reshape_clusters(clusters, sample_shape):
 if ((len(clusters) > 0) and isinstance(clusters[0], np.ndarray)):
  if (clusters[0].dtype == bool):
   clusters = [c.reshape(sample_shape) for c in clusters]
  else:
   clusters = [np.unravel_index(c, sample_shape) for c in clusters]
 return clusters

def _reshape_clusters ( clusters , sample_shape ) : if ( ( len ( clusters ) > 0 ) and isinstance ( clusters [ 0 ] , np . ndarray ) ) : if ( clusters [ 0 ] . dtype == bool ) : clusters = [ c . reshape ( sample_shape ) for c in clusters ] else : clusters = [ np . unravel_index ( c , sample_shape ) for c in clusters ] return clusters
reshape cluster masks or indices to be of the correct shape .