Merge branch 'march-2023-improvements' into kmeans-with-fastpair

This commit is contained in:
Lorenzo (Mec-iS)
2023-03-24 12:09:55 +09:00
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -181,12 +181,15 @@ impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
///
/// Return order dissimilarities from closest to furthest
///
///
#[allow(dead_code)]
pub fn ordered_pairs(&self) -> std::vec::IntoIter<&PairwiseDistance<T>> {
// improvement: implement this to return `impl Iterator<Item = &PairwiseDistance<T>>`
// need to implement trait `Iterator` for `Vec<&PairwiseDistance<T>>`
let mut distances = self.distances.values().collect::<Vec<&PairwiseDistance<T>>>();
let mut distances = self
.distances
.values()
.collect::<Vec<&PairwiseDistance<T>>>();
distances.sort_by(|a, b| a.partial_cmp(b).unwrap());
distances.into_iter()
}
@@ -631,7 +634,7 @@ mod tests_fastpair {
if previous == -1.0 {
previous = p.distance.unwrap();
} else {
let current = p.distance.unwrap();
let current = p.distance.unwrap();
assert!(current >= previous);
previous = current;
}
+1 -1
View File
@@ -1570,7 +1570,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
mean
}
/// copy coumn as a vector
/// copy column as a vector
fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>) {
for (r, result_r) in result.iter_mut().enumerate().take(self.shape().0) {
*result_r = *self.get((r, col));