Hello, On 07/17/2014 12:05 AM, Alan Gauld wrote:
Just throwing this idea in without really thinking about it... Would itertools.groupby work? It takes a sorted collection and groups the items found based on a key function. If the key function deemed two items identical if they were within distance X of each other then groupby might help. The itertools functions are generally space efficient and therefore good for large volumes of data.
Thanks for the suggestion, I didn't know about groupby. I gave it a try. The key function argument is optional; if we don't supply one, grouby groups *equal* list elements. But I want to group *close enough* elements (close enough meaning that their distance is less than some reference value), and I didn't manage to specify a key function in a form suitable for use with groubpy. I should spend some more time studying the examples.
Anyway, thanks a lot, it's always good to know a new module in the standard library.
Ze _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor