[SciPy-user] remove duplicate points...

Stéfan van der Walt stefan@sun.ac...
Wed Apr 23 11:43:35 CDT 2008


2008/4/23 Pierre GM <pgmdevlist@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