@@ -198,14 +198,13 @@ def _hdbscan_sparse_distance_matrix(X, min_samples=5, alpha=1.0,
198198def _hdbscan_prims_kdtree (X , min_samples = 5 , alpha = 1.0 ,
199199 metric = 'minkowski' , p = 2 , leaf_size = 40 ,
200200 gen_min_span_tree = False , ** kwargs ):
201+ if X .dtype != np .float64 :
202+ X = X .astype (np .float64 )
201203
202204 # The Cython routines used require contiguous arrays
203205 if not X .flags ['C_CONTIGUOUS' ]:
204206 X = np .array (X , dtype = np .double , order = 'C' )
205207
206- if X .dtype != np .float64 :
207- X = X .astype (np .float64 , order = 'C' )
208-
209208 tree = KDTree (X , metric = metric , leaf_size = leaf_size , ** kwargs )
210209
211210 # TO DO: Deal with p for minkowski appropriately
@@ -232,14 +231,13 @@ def _hdbscan_prims_kdtree(X, min_samples=5, alpha=1.0,
232231def _hdbscan_prims_balltree (X , min_samples = 5 , alpha = 1.0 ,
233232 metric = 'minkowski' , p = 2 , leaf_size = 40 ,
234233 gen_min_span_tree = False , ** kwargs ):
234+ if X .dtype != np .float64 :
235+ X = X .astype (np .float64 )
235236
236237 # The Cython routines used require contiguous arrays
237238 if not X .flags ['C_CONTIGUOUS' ]:
238239 X = np .array (X , dtype = np .double , order = 'C' )
239240
240- if X .dtype != np .float64 :
241- X = X .astype (np .float64 )
242-
243241 tree = BallTree (X , metric = metric , leaf_size = leaf_size , ** kwargs )
244242
245243 dist_metric = DistanceMetric .get_metric (metric , ** kwargs )
@@ -274,7 +272,7 @@ def _hdbscan_boruvka_kdtree(X, min_samples=5, alpha=1.0,
274272 core_dist_n_jobs = max (cpu_count () + 1 + core_dist_n_jobs , 1 )
275273
276274 if X .dtype != np .float64 :
277- X = X .astype (np .float64 , order = 'C' )
275+ X = X .astype (np .float64 )
278276
279277 tree = KDTree (X , metric = metric , leaf_size = leaf_size , ** kwargs )
280278 alg = KDTreeBoruvkaAlgorithm (tree , min_samples , metric = metric ,
0 commit comments