Created
March 19, 2014 21:30
-
-
Save alecbz/9651803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buckets = defaultdict(list) | |
for z, root in root_from.iteritems(): | |
closest = next((k for k in buckets if abs(k - root) < 1e-3), None) | |
if closest: | |
buckets[closest].append(z) | |
else: | |
buckets[root].append(z) | |
roots = buckets.keys() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment