Mercurial > hg > GlobalNeighbors
view tests/test_bisect.py @ 21:22c384fe954d
add locations to grid; not used or tested yet
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 25 Jun 2017 16:28:56 -0700 |
parents | 27925261c137 |
children |
line wrap: on
line source
#!/usr/bin/env python """ test bisection insert """ import random import unittest from globalneighbors import distance class TestBisectInsert(unittest.TestCase): def test_bisect_insert(self): """ensure our inserted points are in order""" values = [(random.random(), i) for i in range(15000)] for k in (10, 100, 1000, 10000): _distances = [] for value, i in values: distance.insert_distance_bisect(_distances, i, value, k) # since k is < 15000 assert len(_distances) == k ordered = [value[-1] for value in _distances] assert sorted(ordered) == ordered keys = [value[0] for value in _distances] assert len(set(keys)) == len(_distances) if __name__ == '__main__': unittest.main()