예제 #1
0
def test_root_split():
    maxEntries = 9
    items = some_data(9 + 1)
    tree = RBush(maxEntries)
    for i, item in enumerate(items):
        tree.insert(**item)
    assert tree.height == 2
예제 #2
0
def test_insert_none():
    # 'insert' raises exception if empty input
    tree = RBush()
    tree.load(data_array)

    with pytest.raises(TypeError):
        tree.insert()
예제 #3
0
def test_data_insert_empty_maxEntries():
    tree = RBush(4)

    for datum in empty_array:
        tree.insert(*datum)

    assert tree.height == 2
    items, _ = tree.all()
    assert sorted_equal(empty_array, items)
예제 #4
0
def test_load_insert():
    tree = RBush(8, 4)
    tree.load(data_array[:17])
    tree.load(data_array[17:20])

    tree2 = RBush(8, 4)
    tree2.load(data_array[:17])
    tree2.insert(*data_array[17])
    tree2.insert(*data_array[18])
    tree2.insert(*data_array[19])

    assert tree.to_json() == tree2.to_json()
예제 #5
0
def test_insert_numpy_vectors():
    numitems = 100
    import numpy as np
    xmin = np.random.randint(0, 100, numitems)
    ymin = np.random.randint(0, 100, numitems)
    xmax = xmin + np.random.randint(0, 100, numitems)
    ymax = ymin + np.random.randint(0, 100, numitems)

    tree = RBush()
    tree.insert(xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax)
    items, _ = tree.all()
    assert len(items) == numitems
예제 #6
0
def test_insert_items():
    tree1 = RBush(4)
    for i in range(len(data_array)):
        tree1.insert(*data_array[i])

    tree2 = RBush(4)
    tree2.load(data_array)

    items1, _ = tree1.all()
    items2, _ = tree2.all()

    assert 0 <= tree1.height - tree2.height <= 1
    assert sorted_equal(items1, items2)
예제 #7
0
def test_insert_item():
    data = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3],
            [1, 1, 2, 2]]
    data = np.asarray(data)

    tree = RBush(4)
    tree.load(data[0:3])

    tree.insert(*data[3])
    assert tree.height == 1
    items, _ = tree.all()
    assert sorted_equal(items, data[0:4])

    tree.insert(*data[4])
    assert tree.height == 2
    items, _ = tree.all()
    assert sorted_equal(items, data)