comparison globalneighbors/distance.py @ 14:27925261c137

fix broken tests including an aggregious case where we add ourselves as a neighbor to ourself
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 14:29:18 -0700
parents 638fad06e556
children 811adc9736eb
comparison
equal deleted inserted replaced
13:94af113e498a 14:27925261c137
145 args = [deg_to_rad(i) for i in 145 args = [deg_to_rad(i) for i in
146 (lat1, lon1, lat2, lon2)] 146 (lat1, lon1, lat2, lon2)]
147 new_distance = haversine(*args, r=Rearth) 147 new_distance = haversine(*args, r=Rearth)
148 148
149 # insert in order 149 # insert in order
150 for i in (id1, id2): 150 ids = (id1, id2)
151 distances = neighbors.setdefault(i, []) 151 for i in (0, 1):
152 152 distances = neighbors.setdefault(ids[i], [])
153 insert_distance_bisect(distances, i, new_distance, k) 153 insert_distance_bisect(distances,
154 ids[i-1],
155 new_distance,
156 k)
154 157
155 return neighbors 158 return neighbors
156 159
157 160
158 def main(args=sys.argv[1:]): 161 def main(args=sys.argv[1:]):