def convertlabels(ys, indices=None):
 if (indices == None):
  ylabel = ys
 else:
  idx = np.array(indices)
  if ((idx.size > 1) and (ys.ndim == 2)):
   ylabel = np.array([('@%s@' % ii[:2].tostring()) for ii in ys])[:, np.newaxis]
  else:
   ylabel = ys
 (unil, unilinv) = np.unique(ylabel, return_index=False, return_inverse=True)
 return (unilinv, np.arange(len(unil)), unil)

def convertlabels ( ys , indices = None ) : if ( indices == None ) : ylabel = ys else : idx = np . array ( indices ) if ( ( idx . size > 1 ) and ( ys . ndim == 2 ) ) : ylabel = np . array ( [ ( '@%s@' % ii [ : 2 ] . tostring ( ) ) for ii in ys ] ) [ : , np . newaxis ] else : ylabel = ys ( unil , unilinv ) = np . unique ( ylabel , return_index = False , return_inverse = True ) return ( unilinv , np . arange ( len ( unil ) ) , unil )
convert labels based on multiple variables or string labels to unique index labels 0 .