Skip to content

Commit 2e10d38

Browse files
committed
Apply simple NumPy 2 fixes and silence most warnings
1 parent 29d8286 commit 2e10d38

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

hdbscan/_hdbscan_linkage.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cpdef np.ndarray[np.double_t, ndim=2] mst_linkage_core(
3333
result = np.zeros((distance_matrix.shape[0] - 1, 3))
3434
node_labels = np.arange(distance_matrix.shape[0], dtype=np.intp)
3535
current_node = 0
36-
current_distances = np.infty * np.ones(distance_matrix.shape[0])
36+
current_distances = np.inf * np.ones(distance_matrix.shape[0])
3737
current_labels = node_labels
3838
for i in range(1, node_labels.shape[0]):
3939
label_filter = current_labels != current_node
@@ -100,7 +100,7 @@ cpdef np.ndarray[np.double_t, ndim=2] mst_linkage_core_vector(
100100
result_arr = np.zeros((dim - 1, 3))
101101
in_tree_arr = np.zeros(dim, dtype=np.int8)
102102
current_node = 0
103-
current_distances_arr = np.infty * np.ones(dim)
103+
current_distances_arr = np.inf * np.ones(dim)
104104
current_sources_arr = np.ones(dim)
105105

106106
result = (<np.double_t[:dim - 1, :3:1]> (<np.double_t *> result_arr.data))

hdbscan/_hdbscan_reachability.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ cpdef sparse_mutual_reachability(object lil_matrix, np.intp_t min_points=5,
7979
if min_points - 1 < len(sorted_row_data):
8080
core_distance[i] = sorted_row_data[min_points - 1]
8181
else:
82-
core_distance[i] = np.infty
82+
core_distance[i] = np.inf
8383

8484
if alpha != 1.0:
8585
lil_matrix = lil_matrix / alpha

hdbscan/_hdbscan_tree.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ cdef list bfs_from_cluster_tree(np.ndarray tree, np.intp_t bfs_root):
251251

252252
while to_process.shape[0] > 0:
253253
result.extend(to_process.tolist())
254-
to_process = tree['child'][np.in1d(tree['parent'], to_process)]
254+
to_process = tree['child'][np.isin(tree['parent'], to_process)]
255255

256256
return result
257257

hdbscan/plots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _bfs_from_cluster_tree(tree, bfs_root):
2828

2929
while to_process:
3030
result.extend(to_process)
31-
to_process = tree['child'][np.in1d(tree['parent'], to_process)].tolist()
31+
to_process = tree['child'][np.isin(tree['parent'], to_process)].tolist()
3232

3333
return result
3434

hdbscan/prediction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _clusters_below(self, cluster):
8181
while to_process:
8282
result.extend(to_process)
8383
to_process = \
84-
self.cluster_tree['child'][np.in1d(self.cluster_tree['parent'],
84+
self.cluster_tree['child'][np.isin(self.cluster_tree['parent'],
8585
to_process)]
8686
to_process = to_process.tolist()
8787

hdbscan/validity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def internal_minimum_spanning_tree(mr_distances):
180180
# A little "fancy" we select from the flattened array reshape back
181181
# (Fortran format to get indexing right) and take the product to do an and
182182
# then convert back to boolean type.
183-
edge_selection = np.prod(np.in1d(min_span_tree.T[:2], vertices).reshape(
183+
edge_selection = np.prod(np.isin(min_span_tree.T[:2], vertices).reshape(
184184
(min_span_tree.shape[0], 2), order='F'), axis=1).astype(bool)
185185

186186
# Density sparseness is not well defined if there are no

0 commit comments

Comments
 (0)