Skip to content

Commit d63a009

Browse files
committed
dbscan(): test #190
1 parent 2ed4387 commit d63a009

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/dbscan.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ end
6060
end
6161
end
6262

63+
@testset "detecting outliers (#190)" begin
64+
v = vcat([.828 .134 .821 .630 .784 .674 .436 .089 .777 .526 .200 .908 .929 .835 .553 .647 .672 .234 .536 .617])
65+
r = @inferred(dbscan(v, 0.075, min_cluster_size=3))
66+
@test nclusters(r) == 3
67+
@test findall(==(0), r.assignments) == [7]
68+
@test r.clusters[1].core_indices == [1, 3, 5, 9, 12, 13, 14]
69+
@test isempty(r.clusters[1].boundary_indices)
70+
@test r.clusters[2].core_indices == [2, 8, 11, 18]
71+
@test isempty(r.clusters[2].boundary_indices)
72+
@test r.clusters[3].core_indices == [4, 6, 10, 15, 16, 17, 19, 20]
73+
@test isempty(r.clusters[3].boundary_indices)
74+
75+
# outlier pt #7 assigned to a 3rd cluster when bigger radius is used
76+
r2 = @inferred(dbscan(v, 0.1, min_cluster_size=3))
77+
@test r2.assignments == setindex!(copy(r.assignments), 3, 7)
78+
end
79+
6380
@testset "normal points" begin
6481
p0 = randn(StableRNG(0), 3, 1000)
6582
p1 = randn(StableRNG(1), 3, 1000) .+ [3.0, 3.0, 0.0]

0 commit comments

Comments
 (0)