Commit cb190664 authored by Julien Jerphanion's avatar Julien Jerphanion

TST Add test for creation and deletion of KDTree

parent 27283fbb
......@@ -33,7 +33,7 @@ setup: clean
conda env create --force -f environment.yml
${PIP_EXECUTABLE} install -e . -v
## install: install the project in the env
## install: Install the project in the environment
.PHONY: install
install:
${PIP_EXECUTABLE} install -e . -v
......
......@@ -3,6 +3,18 @@ import pytest
import kdtree
from sklearn.neighbors import KDTree
@pytest.mark.parametrize("n", [10, 100, 1000, 10000])
@pytest.mark.parametrize("d", [10, 100])
@pytest.mark.parametrize("leaf_size", [256, 1024])
def test_creation_deletion(n, d, leaf_size):
np.random.seed(1)
X = np.random.rand(n, d)
tree = kdtree.KDTree(X, leaf_size=256)
del tree
@pytest.mark.skip(reason="The query is being refactored.")
@pytest.mark.parametrize("n", [10, 100, 1000, 10000])
@pytest.mark.parametrize("d", [10, 100])
@pytest.mark.parametrize("k", [1, 2, 5, 10])
......@@ -11,12 +23,11 @@ def test_against_sklearn(n, d, k, leaf_size):
np.random.seed(1)
X = np.random.rand(n, d)
query_points = np.random.rand(n, d)
tree = kdtree.KDTree(X, leaf_size=256)
skl_tree = KDTree(X, leaf_size=256)
closests = np.zeros((n, k), dtype=np.int32)
tree.query(query_points, closests)
skl_closests = skl_tree.query(query_points, k=k, return_distance=False).astype(np.int32)
np.testing.assert_equal(closests, skl_closests)
\ No newline at end of file
np.testing.assert_equal(closests, skl_closests)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment