From 70663f1a760818c5b6f2ce5c7a6c2347c2c15eee Mon Sep 17 00:00:00 2001 From: Leon Wabeke Date: Fri, 3 Jan 2025 15:08:14 +0200 Subject: [PATCH] Added test case of dbscan running with no points --- test/dbscan.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/dbscan.jl b/test/dbscan.jl index 58959cdb..9f317098 100644 --- a/test/dbscan.jl +++ b/test/dbscan.jl @@ -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 @@ -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) @@ -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)