[SciPy-user] remove duplicate points...

Stéfan van der Walt stefan at sun.ac.za
Wed Apr 23 12:43:35 EDT 2008


2008/4/23 Pierre GM <pgmdevlist at gmail.com>:
>  1. Transform your nx4 array into a n record array
>  2. use numpy.unique on the record array
>  3. revert to a nx4 array.
>
>  For example:
>  z=np.array([[1,1],[1,2],[1,2],[1,3]])
>  zr=z.view([('a',int),('b',int)])
>  zs = numpy.unique(zr).view((int,2))
>
>  Am I missing something ?

Beautiful!  I didn't even think of that; should be much faster, too.

Thanks
Stéfan



More information about the SciPy-User mailing list