Skip to content

Commit 1cabca6

Browse files
committed
hdbscan: add support to other types of input integers
Both attributes like min_samples and min_cluster_size can be defined using other types of integer like Numpy's int16, int32 and int64. This should be also supported by HDBSCAN. This commit only extendes the check to other types of integers. Signed-off-by: Julio Faracco <[email protected]>
1 parent 7a6a095 commit 1cabca6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hdbscan/hdbscan_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ def hdbscan(
674674
if min_samples is None:
675675
min_samples = min_cluster_size
676676

677-
if type(min_samples) is not int or type(min_cluster_size) is not int:
677+
if not np.issubdtype(type(min_samples), np.integer) or \
678+
not np.issubdtype(type(min_cluster_size), np.integer):
678679
raise ValueError("Min samples and min cluster size must be integers!")
679680

680681
if min_samples <= 0 or min_cluster_size <= 0:
@@ -685,7 +686,7 @@ def hdbscan(
685686
if min_cluster_size == 1:
686687
raise ValueError("Min cluster size must be greater than one")
687688

688-
if type(cluster_selection_epsilon) is int:
689+
if np.issubdtype(type(cluster_selection_epsilon), np.integer):
689690
cluster_selection_epsilon = float(cluster_selection_epsilon)
690691

691692
if type(cluster_selection_epsilon) is not float or cluster_selection_epsilon < 0.0:

0 commit comments

Comments
 (0)