|
25 | 25 | kd_tree=KDTree.valid_metrics, |
26 | 26 | # The following list comes from the |
27 | 27 | # sklearn.metrics.pairwise doc string |
28 | | - brute=(PAIRWISE_DISTANCE_FUNCTIONS.keys() + |
| 28 | + brute=(list(PAIRWISE_DISTANCE_FUNCTIONS.keys()) + |
29 | 29 | ['braycurtis', 'canberra', 'chebyshev', |
30 | 30 | 'correlation', 'cosine', 'dice', 'hamming', |
31 | 31 | 'jaccard', 'kulsinski', 'mahalanobis', |
|
39 | 39 | kd_tree=[], |
40 | 40 | brute=PAIRWISE_DISTANCE_FUNCTIONS.keys()) |
41 | 41 |
|
| 42 | + |
42 | 43 | class NeighborsWarning(UserWarning): |
43 | 44 | pass |
44 | 45 |
|
| 46 | + |
45 | 47 | # Make sure that NeighborsWarning are displayed more than once |
46 | 48 | warnings.simplefilter("always", NeighborsWarning) |
47 | 49 |
|
@@ -196,9 +198,9 @@ def _fit(self, X): |
196 | 198 | # A tree approach is better for small number of neighbors, |
197 | 199 | # and KDTree is generally faster when available |
198 | 200 | if (self.n_neighbors is None |
199 | | - or self.n_neighbors < self._fit_X.shape[0] // 2): |
| 201 | + or self.n_neighbors < self._fit_X.shape[0] // 2): |
200 | 202 | if (callable(self.effective_metric_) |
201 | | - or self.effective_metric_ in VALID_METRICS['kd_tree']): |
| 203 | + or self.effective_metric_ in VALID_METRICS['kd_tree']): |
202 | 204 | self._fit_method = 'kd_tree' |
203 | 205 | else: |
204 | 206 | self._fit_method = 'ball_tree' |
|
0 commit comments