Skip to content

Commit 05dc5c2

Browse files
committed
Change NNDescent import in utils tests
1 parent de4204f commit 05dc5c2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

test/utils_tests.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
using NearestNeighborDescent: sample_neighbors, make_knn_heaps
12

23
@testset "sample neighbors tests" begin
34
@testset "sample_rate = 1. tests" begin
45
points = collect(1:10)
56
n_neighbors = 4
67

78
# zero neighbors
8-
idxs = NNDescent.sample_neighbors(length(points), 0)
9+
idxs = sample_neighbors(length(points), 0)
910
@test length(idxs) == 0
1011

1112
# k < n
12-
idxs = NNDescent.sample_neighbors(length(points), n_neighbors)
13+
idxs = sample_neighbors(length(points), n_neighbors)
1314
@test length(idxs) == n_neighbors
1415
@test issubset(idxs, points)
1516

1617
# k > n
17-
idxs = NNDescent.sample_neighbors(length(points), length(points)+5)
18+
idxs = sample_neighbors(length(points), length(points)+5)
1819
@test length(idxs) == length(points)
1920
end
2021
@testset "sample_rate = .5 tests" begin
@@ -23,30 +24,30 @@
2324
ρ = .5
2425

2526
# zero neighbors
26-
idxs = NNDescent.sample_neighbors(length(points), 0, ρ)
27+
idxs = sample_neighbors(length(points), 0, ρ)
2728
@test length(idxs) == 0
2829

2930
# k < n
30-
idxs = NNDescent.sample_neighbors(length(points), n_neighbors, ρ)
31+
idxs = sample_neighbors(length(points), n_neighbors, ρ)
3132
@test ρ*n_neighbors length(idxs)
3233
@test issubset(idxs, points)
3334

3435
# k > n
35-
idxs = NNDescent.sample_neighbors(length(points), 2*length(points), ρ)
36+
idxs = sample_neighbors(length(points), 2*length(points), ρ)
3637
@test length(idxs) == length(points)
3738
end
3839
@testset "exclude set tests" begin
3940
points = collect(1:10)
4041

4142
# exclude 1
42-
idxs = NNDescent.sample_neighbors(length(points),
43+
idxs = sample_neighbors(length(points),
4344
length(points),
4445
exclude=[1])
4546
@test idxs points
4647
@test !(1 idxs)
4748

4849
# exclude all
49-
idxs = NNDescent.sample_neighbors(length(points),
50+
idxs = sample_neighbors(length(points),
5051
length(points),
5152
exclude=points)
5253
@test length(idxs) == 0
@@ -59,7 +60,7 @@ end
5960
data = [rand(3) for _ in 1:10]
6061
n_neighbors = 3
6162

62-
knn_heaps = NNDescent.make_knn_heaps(data, n_neighbors, Euclidean())
63+
knn_heaps = make_knn_heaps(data, n_neighbors, Euclidean())
6364

6465
@test length(knn_heaps) == length(data)
6566
for p in 1:length(knn_heaps)
@@ -75,7 +76,7 @@ end
7576
@testset "Int tests" begin
7677
data = [rand([0, 1], 3) for _ in 1:10]
7778
n_neighbors = 2
78-
knn_heaps = NNDescent.make_knn_heaps(data, n_neighbors, Hamming())
79+
knn_heaps = make_knn_heaps(data, n_neighbors, Hamming())
7980

8081
@test length(knn_heaps) == length(data)
8182
for p in 1:length(knn_heaps)

0 commit comments

Comments
 (0)