예제 #1
0
def test_search_1D():
	tree = KDTree([1])
	right = KDTree([2])
	left = KDTree([0])
	tree.right = right
	tree.left = left
	assert tree.search([2]) == right
	assert tree.search([0]) == left
	assert tree.search([3]) is None
	assert tree.search([-1]) is None
예제 #2
0
def test_init():
    tree = KDTree(0)
    assert tree.value == 0
    assert tree.k == 1
    assert tree.axis == 0
    assert tree.left == None
    assert tree.right == None
    assert tree.nodes == 1
예제 #3
0
def test_init_with_params():
    tree = KDTree([0, 0], k=2, axis=1)
    assert tree.value == [0, 0]
    assert tree.k == 2
    assert tree.axis == 1
    assert tree.left == None
    assert tree.right == None
    assert tree.nodes == 1
예제 #4
0
def test_search_accept():
	tree = KDTree(KDSubType(1,1), accept=KDSubType)
	left = KDTree(KDSubType(1,0), accept=KDSubType)
	tree.left = left
	assert tree.search(KDSubType(1,0)) == left
	assert tree.search(KDSubType(1,3)) is None
예제 #5
0
def test_search_2D():
	tree = KDTree([1,1], k=2)
	right = KDTree([1,2], k=2, axis=1)
	tree.right = right
	assert tree.search([1,2]) == right
	assert tree.search([1,0]) is None