Skip to content

Commit 00701b9

Browse files
committed
Homogeneity computation
1 parent db0d54d commit 00701b9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hdbscan/tests/test_hdbscan.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,18 @@ def homogeneity(labels1, labels2):
131131
num_missed = 0.0
132132
for label in set(labels1):
133133
matches = labels2[labels1 == label]
134-
match_mode, mode_count = mode(matches)
134+
try:
135+
match_mode, mode_count = mode(matches, keepdims=True)
136+
except:
137+
match_mode, mode_count = mode(matches)
135138
num_missed += np.sum(matches != match_mode[0])
136139

137140
for label in set(labels2):
138141
matches = labels1[labels2 == label]
139-
match_mode, mode_count = mode(matches)
142+
try:
143+
match_mode, mode_count = mode(matches, keepdims=True)
144+
except:
145+
match_mode, mode_count = mode(matches)
140146
num_missed += np.sum(matches != match_mode[0])
141147

142148
return num_missed / 2.0

0 commit comments

Comments
 (0)