This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def remove_duplicates(array_data, return_index=False, return_inverse=False): | |
"""Removes duplicate rows of a multi-dimensional array. Returns the | |
array with the duplicates removed. If return_index is True, also | |
returns the indices of array_data that result in the unique array. | |
If return_inverse is True, also returns the indices of the unique | |
array that can be used to reconstruct array_data.""" | |
unique_array_data, index_map, inverse_map = np.unique( | |
array_data.view([('', array_data.dtype)] * \ |