mercredi 20 juillet 2016

uniquify an array/list with a tolerance in python (uniquetol equivalent)

I want to find the unique elements of an array in a certain range of tolerance

For instance, for an array/list

[1.1 , 1.3 , 1.9 , 2.0 , 2.5 , 2.9]

Function will return

[1.1 , 1.9 , 2.5 , 2.9]

If the tolerance is 0.3

at bit like the MATLAB function http://mathworks.com/help/matlab/ref/uniquetol.html (but this function uses a relative tolerance, an absolute one can be sufficient) Way is the pythonic way to implement it ? (numpy is privilegied)

Aucun commentaire:

Enregistrer un commentaire