Merge pull request #126 from ericschief/cover-tree-fix

Fix issue with cover tree k-nearest neighbors
This commit is contained in:
VolodymyrOrlov
2022-05-09 15:34:10 -07:00
committed by GitHub
+4 -1
View File
@@ -179,7 +179,10 @@ impl<T: Debug + PartialEq, F: RealNumber, D: Distance<T, F>> CoverTree<T, F, D>
} }
} }
} }
if neighbors.len() > k {
neighbors.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
}
Ok(neighbors.into_iter().take(k).collect()) Ok(neighbors.into_iter().take(k).collect())
} }