diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2020-04-12 21:57:51 +0200 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2020-04-12 21:57:51 +0200 |
commit | 83a1bc1fb6124a35d515f4836d2e830f3dbdf0e7 (patch) | |
tree | 09f15b27fac2f7279788c1d0db3c03cdeb12b4f7 /src/python/test/test_knn.py | |
parent | f9a933862050ca95b3a96d7a8572d62f7f2205a9 (diff) |
Parallelize the "precomputed" case of knn
It is supposed to be possible to compile numpy with openmp, but it looks
like it isn't done in any of the usual packages.
It may be possible to refactor that code so there is less redundancy.
Diffstat (limited to 'src/python/test/test_knn.py')
-rwxr-xr-x | src/python/test/test_knn.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/python/test/test_knn.py b/src/python/test/test_knn.py index 6aac2006..6269df54 100755 --- a/src/python/test/test_knn.py +++ b/src/python/test/test_knn.py @@ -52,6 +52,14 @@ def test_knn_explicit(): r = knn.fit_transform(dist) assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]]) assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]]) + # Second time in parallel + knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=False, n_jobs=2) + r = knn.fit_transform(dist) + assert np.array_equal(r, [[0, 1], [1, 0], [2, 0]]) + knn = KNearestNeighbors(2, metric="precomputed", return_index=True, return_distance=True, n_jobs=2) + r = knn.fit_transform(dist) + assert np.array_equal(r[0], [[0, 1], [1, 0], [2, 0]]) + assert np.array_equal(r[1], [[0, 3], [0, 1], [0, 1]]) def test_knn_compare(): |