def unique_rows(ar):
 if (ar.ndim != 2):
  raise ValueError(('unique_rows() only makes sense for 2D arrays, got %dd' % ar.ndim))
 ar = np.ascontiguousarray(ar)
 ar_row_view = ar.view(('|S%d' % (ar.itemsize * ar.shape[1])))
 (_, unique_row_indices) = np.unique(ar_row_view, return_index=True)
 ar_out = ar[unique_row_indices]
 return ar_out

def unique_rows ( ar ) : if ( ar . ndim != 2 ) : raise ValueError ( ( 'unique_rows() only makes sense for 2D arrays, got %dd' % ar . ndim ) ) ar = np . ascontiguousarray ( ar ) ar_row_view = ar . view ( ( '|S%d' % ( ar . itemsize * ar . shape [ 1 ] ) ) ) ( _ , unique_row_indices ) = np . unique ( ar_row_view , return_index = True ) ar_out = ar [ unique_row_indices ] return ar_out
remove repeated rows from a 2d array .