From f29e3026be8581fe375789643573a281cb5c4843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=9Al=C4=99zak?= <128084860+jaksle@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:39:36 +0100 Subject: [PATCH] Update src/clustering_quality.jl Co-authored-by: Alexey Stukalov --- src/clustering_quality.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clustering_quality.jl b/src/clustering_quality.jl index 772f1fb3..cd0e0965 100644 --- a/src/clustering_quality.jl +++ b/src/clustering_quality.jl @@ -65,8 +65,8 @@ function clustering_quality( (1 <= k <= n) || throw(ArgumentError("Number of clusters k must be from 1:n (n=$n), k=$k given.")) k >= 2 || throw(ArgumentError("Quality index not defined for the degenerated clustering with a single cluster.")) n == k && throw(ArgumentError("Quality index not defined for the degenerated clustering where each data point is its own cluster.")) - for i in eachindex(assignments) - (assignments[i] in axes(centers, 2)) || throw(ArgumentError("Bad assignments[$i]=$(assignments[i]) is not a valid index for `data`.")) + for (i, clu) in enumerate(assignments) + (clu in axes(centers, 2)) || throw(ArgumentError("Invalid cluster index: assignments[$i]=$(clu).")) end for i in 1:k i ∉ assignments && @warn "Cluster number $(i) is empty. Clustering quality calculation may not be reliable."