Skip to content

Commit d01b9a5

Browse files
authored
Update validity.py
Adding two lines to set vertices = [0] if vertices is empty. This issue occurs in the edge cases when cluster size = 2, and causes a ValueError due to zero-size array.
1 parent e55f957 commit d01b9a5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hdbscan/validity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ def internal_minimum_spanning_tree(mr_distances):
175175

176176
vertices = np.arange(mr_distances.shape[0])[
177177
np.bincount(min_span_tree.T[:2].flatten().astype(np.intp)) > 1]
178+
if not len(vertices):
179+
vertices = [0]
178180
# A little "fancy" we select from the flattened array reshape back
179181
# (Fortran format to get indexing right) and take the product to do an and
180182
# then convert back to boolean type.

0 commit comments

Comments
 (0)