Skip to content

Instantly share code, notes, and snippets.

View lordi's full-sized avatar

Hannes Gräuler lordi

  • Osnabrück, Germany
View GitHub Profile
@jterrace
jterrace / remove_dup_tris.py
Created November 3, 2011 19:27
Removing duplicate triangles with numpy
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)] * \