Skip to content

Commit 30e1c97

Browse files
committed
Add test for sample weighting
1 parent 78d582d commit 30e1c97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fast_hdbscan/tests/test_hdbscan.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def test_hdbscan_no_clusters():
104104
n_clusters_2 = len(set(labels)) - int(-1 in labels)
105105
assert n_clusters_2 == 0
106106

107+
def test_hdbscan_sample_weight():
108+
sample_weight = y.astype(np.float32)
109+
labels, p = fast_hdbscan(X, sample_weights=sample_weight)
110+
n_clusters_1 = len(set(labels)) - int(-1 in labels)
111+
assert n_clusters_1 == n_clusters - 1
112+
107113

108114
def test_hdbscan_min_cluster_size():
109115
for min_cluster_size in range(2, len(X) + 1, 1):
@@ -142,7 +148,7 @@ def test_hdbscan_badargs():
142148
def test_fhdbscan_allow_single_cluster_with_epsilon():
143149
np.random.seed(0)
144150
no_structure = np.random.rand(150, 2)
145-
# without epsilon we should see 65 noise points and 9 labels
151+
# without epsilon we should see 68 noise points and 9 labels
146152
c = HDBSCAN(
147153
min_cluster_size=5,
148154
cluster_selection_epsilon=0.0,

0 commit comments

Comments
 (0)