comparison tests/test_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 254195d0bac2
children
comparison
equal deleted inserted replaced
13:94af113e498a 14:27925261c137
122 122
123 # ensure you have no more neighbors than you ask for 123 # ensure you have no more neighbors than you ask for
124 assert max([len(value) for value in neighbors.values()]) <= k 124 assert max([len(value) for value in neighbors.values()]) <= k
125 125
126 # assert distances increase 126 # assert distances increase
127 for value in neighbors.values(): 127 for key, value in neighbors.items():
128 distances = [i[-1] for i in value] 128 distances = [i[-1] for i in value]
129 assert distances == sorted(distances) 129 assert distances == sorted(distances)
130 neighbors = [i[0] for i in value]
131 assert key not in neighbors
132 assert len(set(neighbors)) == len(neighbors)
130 133
131 def test_insert_distances(self): 134 def test_insert_distances(self):
132 """test insert distances algorithm""" 135 """test insert distances algorithm"""
133 136
134 values = [(i, random.random()) 137 values = [(i, random.random())