Skip to content

Commit

Permalink
Added test case of dbscan running with no points
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon Wabeke committed Jan 3, 2025
1 parent 56cd07f commit 70663f1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/dbscan.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Test
using Clustering
using Distances
include("test_helpers.jl")
#include("test_helpers.jl") # Already included in previous tests, but might need to be added back if test order is changed

@testset "dbscan() (DBSCAN clustering)" begin

Expand Down Expand Up @@ -33,8 +33,8 @@ end
R = dbscan(X, 1.0)
@test nclusters(R) == 2
end
@testset "Simple 2D test case with limited points trivial case" begin
X = zeros(2,1) # At minimum dbscan needs a matrix and will not work with just a vector, but matrix could be Nx1
@testset "Trivial 2D test case with one point" begin
X = zeros(2,1) # At minimum dbscan needs a matrix and will not work with just a vector, but matrix could be Dx1
X[:,1] = [10.0 ;
0.0 ]
R = dbscan(X, 20)
Expand All @@ -43,6 +43,12 @@ end
@test nclusters(R) == 1
end

@testset "Trvial 2D test case with no points" begin
X = zeros(2,0) # At minimum dbscan needs a matrix and will not work with just a vector, but matrix could be Dx0
R = dbscan(X, 20)
@test nclusters(R) == 0
end

@testset "clustering synthetic data with 3 clusters" begin
Random.seed!(34568)

Expand Down

0 comments on commit 70663f1

Please sign in to comment.