Skip to content

Commit e0ecc01

Browse files
author
nsakr
committed
Validate that data_labels is not None when semi_supervised is True.
1 parent d71c9a9 commit e0ecc01

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fast_hdbscan/hdbscan.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def remap_single_linkage_tree(tree, internal_to_raw, outliers):
133133

134134
def fast_hdbscan(
135135
data,
136-
data_labels,
136+
data_labels=None,
137137
semi_supervised=False,
138138
ss_algorithm=None,
139139
min_samples=10,
@@ -145,6 +145,9 @@ def fast_hdbscan(
145145
):
146146
data = check_array(data)
147147

148+
if semi_supervised and data_labels is None:
149+
raise ValueError("data_labels must not be None when semi_supervised is set to True!")
150+
148151
if semi_supervised:
149152
label_indices = np.flatnonzero(data_labels > -1)
150153
label_values = data_labels[label_indices]
@@ -261,7 +264,8 @@ def fit(self, X, y=None, **fit_params):
261264
# We will later assign all non-finite points to the background -1 cluster
262265
finite_index = np.where(np.isfinite(X).sum(axis=1) == X.shape[1])[0]
263266
clean_data = X[finite_index]
264-
267+
clean_data_labels = y
268+
265269
if self.semi_supervised:
266270
clean_data_labels = y[finite_index]
267271

0 commit comments

Comments
 (0)