'Finds radius neighbors from the candidates obtained.
Their distances from query are smaller than radius.
Returns radius neighbors and distances.'

def _get_radius_neighbors(self, query, max_depth, bin_queries, radius):

    ratio_within_radius = 1
    threshold = (1 - self.radius_cutoff_ratio)
    total_candidates = np.array([], dtype=int)
    total_neighbors = np.array([], dtype=int)
    total_distances = np.array([], dtype=float)
    while ((max_depth > self.min_hash_match) and (ratio_within_radius > threshold)):
        left_mask = self._left_mask[max_depth]
        right_mask = self._right_mask[max_depth]
        candidates = []
        for i in range(self.n_estimators):
            (start, stop) = _find_matching_indices(self.trees_[i], bin_queries[i], left_mask, right_mask)
            candidates.extend(self.original_indices_[i][start:stop].tolist())
        candidates = np.setdiff1d(candidates, total_candidates)
        total_candidates = np.append(total_candidates, candidates)
        (ranks, distances) = self._compute_distances(query, candidates)
        m = np.searchsorted(distances, radius, side='right')
        positions = np.searchsorted(total_distances, distances[:m])
        total_neighbors = np.insert(total_neighbors, positions, candidates[ranks[:m]])
        total_distances = np.insert(total_distances, positions, distances[:m])
        ratio_within_radius = (total_neighbors.shape[0] / float(total_candidates.shape[0]))
        max_depth = (max_depth - 1)
    return (total_neighbors, total_distances)
