#NEWLINE# def combine_indices( groups , prefix = '' , sep = '.' , return_labels = False ) : #NEWLINE# #INDENT# 'use np.unique to get integer group indices for product, intersection\n\n    ' #NEWLINE# if isinstance ( groups , tuple ) : #NEWLINE# #INDENT# groups = np . column_stack ( groups ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# groups = np . asarray ( groups ) #NEWLINE# #UNINDENT# dt = groups . dtype #NEWLINE# is2d = ( groups . ndim == 2 ) #NEWLINE# if is2d : #NEWLINE# #INDENT# ncols = groups . shape [ 1 ] #NEWLINE# if ( not groups . flags . c_contiguous ) : #NEWLINE# #INDENT# groups = np . array ( groups , order = 'C' ) #NEWLINE# #UNINDENT# groups_ = groups . view ( ( [ ( '' , groups . dtype ) ] * groups . shape [ 1 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# groups_ = groups #NEWLINE# #UNINDENT# ( uni , uni_idx , uni_inv ) = npc_unique ( groups_ , return_index = True , return_inverse = True ) #NEWLINE# if is2d : #NEWLINE# #INDENT# uni = uni . view ( dt ) . reshape ( ( - 1 ) , ncols ) #NEWLINE# #UNINDENT# if return_labels : #NEWLINE# #INDENT# label = [ ( ( prefix + sep . join ( ( [ '%s' ] * len ( uni [ 0 ] ) ) ) ) % tuple ( ii ) ) for ii in uni ] #NEWLINE# return ( uni_inv , uni_idx , uni , label ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( uni_inv , uni_idx , uni )