Skip to content

Commit 0fb946b

Browse files
authored
Merge pull request TutteInstitute#34 from JelmerBot/dev/subcluster-fixes
Subcluster fixes
2 parents 15cb7dc + d7946fd commit 0fb946b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

fast_hdbscan/core_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def select_components(distances, indices, indptr, point_components):
109109
# Find the best edges from each component
110110
for parent, from_component in enumerate(point_components):
111111
start = indptr[parent]
112-
if indices[start] == -1:
112+
if start == len(indices) or indices[start] == -1:
113113
continue
114114

115115
neighbor = indices[start]

fast_hdbscan/sub_clusters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def find_sub_clusters(
314314
f"Invalid cluster_selection_method: {cluster_selection_method}\n"
315315
f'Should be one of: "eom", "leaf"\n'
316316
)
317+
if np.all(cluster_labels == -1):
318+
raise ValueError("Input contains only noise points.")
317319

318320
# Recover finite data points
319321
data = clusterer._raw_data
@@ -449,7 +451,7 @@ def __init__(
449451
*,
450452
lens_values=None,
451453
min_cluster_size=None,
452-
max_cluster_size=np.inf,
454+
max_cluster_size=None,
453455
allow_single_cluster=False,
454456
cluster_selection_method="eom",
455457
cluster_selection_epsilon=0.0,

fast_hdbscan/tests/test_sub_clusters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@ def test_badargs():
192192
c,
193193
cluster_selection_method="something_else",
194194
)
195+
with pytest.raises(ValueError):
196+
find_sub_clusters(c, cluster_labels=np.full_like(c.labels_, -1))

0 commit comments

Comments
 (0)