[Numpy-discussion] Efficient removal of duplicates
Mon Dec 15 13:58:20 CST 2008
On Mon, Dec 15, 2008 at 10:27, Hanno Klemm <firstname.lastname@example.org> wrote:
> I the following problem: I have a relatively long array of points
> [(x0,y0), (x1,y1), ...]. Apparently, I have some duplicate entries, which
> prevents the Delaunay triangulation algorithm from completing its task.
> Question, is there an efficent way, of getting rid of the duplicate
> All I can think of involves loops.
Besides transforming to tuples and using sets as Alan suggests, you
can also cast your [N,2] array to a [N] structured array and use
unique1d(). If you are doing interpolation and need to deal with the
associated Z values, use the return_indices=True argument to get the
indices of the unique values, too.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion