[SciPy-user] remove duplicate points...

Emanuele Olivetti emanuele@relativita....
Wed Apr 23 11:32:48 CDT 2008


Pierre GM wrote:
> Er, that may sound silly, but why not using numpy.unique ?
> 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 ?
>

Very interesting solution. Could you explain line 2:

""" zr=z.view([('a',int),('b',int)]) """

in more detail? I understand you shrink 2 values in 1 single object
but I don't understand the syntax.

Thanks,

Emanuele



More information about the SciPy-user mailing list