def _compute_distances(self, query, candidates):
        if candidates.shape == (0,):
            # needed since _fit_X[np.array([])] doesn't work if _fit_X sparse
            return np.empty(0, dtype=np.int), np.empty(0, dtype=float)

        if sparse.issparse(self._fit_X):
            candidate_X = self._fit_X[candidates]
        else:
            candidate_X = self._fit_X.take(candidates, axis=0, mode='clip')
        distances = pairwise_distances(query, candidate_X,
                                       metric='cosine')[0]
        distance_positions = np.argsort(distances)
        distances = distances.take(distance_positions, mode='clip', axis=0)
        return distance_positions, distances
Computes the cosine distance.
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/neighbors/approximate.py/LSHForest._compute_distances