diff globalneighbors/distance.py @ 1:1b94f3bf97e5

* limit distance function * start gridding * improve unicode handling
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 14:02:14 -0700
parents 5dba84370182
children 49aae0c0293b
line wrap: on
line diff
--- a/globalneighbors/distance.py	Sat Jun 24 12:03:39 2017 -0700
+++ b/globalneighbors/distance.py	Sat Jun 24 14:02:14 2017 -0700
@@ -96,8 +96,8 @@
             # insert in order
             for i in (id1, id2):
                 distances = neighbors.setdefault(i, [])
-                if len(distances) == k and new_distance > distances[-1][-1]:
-                    break
+                if len(distances) == k and new_distance >= distances[-1][-1]:
+                    continue
 
                 # TODO: Binary Search Tree
                 for _index, (geoid, old_distance) in enumerate(distances):
@@ -109,9 +109,6 @@
                 else:
                     distances.append((i, new_distance))
 
-    print ("DONE")
-    sys.stdout.flush()
-    import pdb; pdb.set_trace()
     return neighbors
 
 
@@ -144,8 +141,6 @@
                                     output=options.output_counter)
 
     # output
-    print ("AFTER")
-    sys.stddout.flush()
     options.output.write(json.dumps(neighbors, indent=2))
 
 if __name__ == '__main__':