def unique_row(array, use_columns=None, selected_columns_only=False):
if array.dtype.names is None:  <EOL><INDENT>if use_columns is not None:<EOL><INDENT>a_cut = array[:, use_columns]<EOL><DEDENT>else:<EOL><INDENT>a_cut = array<EOL><DEDENT>if len(use_columns) > <NUM_LIT:1>:<EOL><INDENT>b = np.ascontiguousarray(a_cut).view(np.dtype((np.void, a_cut.dtype.itemsize * a_cut.shape[<NUM_LIT:1>])))<EOL><DEDENT>else:<EOL><INDENT>b = np.ascontiguousarray(a_cut)<EOL><DEDENT>_, index = np.unique(b, return_index=True)<EOL>if not selected_columns_only:<EOL><INDENT>return array[np.sort(index)]  <EOL><DEDENT>else:<EOL><INDENT>return a_cut[np.sort(index)]  <EOL><DEDENT><DEDENT>else:  <EOL><INDENT>names = list(array.dtype.names)<EOL>if use_columns is not None:<EOL><INDENT>new_names = [names[i] for i in use_columns]<EOL><DEDENT>else:<EOL><INDENT>new_names = names<EOL><DEDENT>a_cut, index = np.unique(array[new_names], return_index=True)<EOL>if not selected_columns_only:<EOL><INDENT>return array[np.sort(index)]  <EOL><DEDENT>else:<EOL><INDENT>return array[np.sort(index)][new_names]<EOL><DEDENT><DEDENT>
Takes a numpy array and returns the array reduced to unique rows. If columns are defined only these columns are taken to define a unique row.
    The returned array can have all columns of the original array or only the columns defined in use_columns.
    Parameters
    ----------
    array : numpy.ndarray
    use_columns : list
        Index of columns to be used to define a unique row
    selected_columns_only : bool
        If true only the columns defined in use_columns are returned

    Returns
    -------
    numpy.ndarray