Make distance functions coherent
This commit is contained in:
parent
89e389e1c9
commit
b3f9ef5fa3
3 changed files with 9 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -85,7 +85,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bliss-audio"
|
name = "bliss-audio"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bliss-audio-aubio-rs",
|
"bliss-audio-aubio-rs",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bliss-audio"
|
name = "bliss-audio"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
authors = ["Polochon-street <polochonstreet@gmx.fr>"]
|
authors = ["Polochon-street <polochonstreet@gmx.fr>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
|
@ -39,7 +39,11 @@ pub fn cosine_distance(a: &Array1<f32>, b: &Array1<f32>) -> f32 {
|
||||||
|
|
||||||
/// Sort `songs` in place by putting songs close to `first_song` first
|
/// Sort `songs` in place by putting songs close to `first_song` first
|
||||||
/// using the `distance` metric.
|
/// using the `distance` metric.
|
||||||
pub fn closest_to_first_song(first_song: &Song, songs: &mut [Song], distance: impl DistanceMetric) {
|
pub fn closest_to_first_song(
|
||||||
|
first_song: &Song,
|
||||||
|
#[allow(clippy::ptr_arg)] songs: &mut Vec<Song>,
|
||||||
|
distance: impl DistanceMetric,
|
||||||
|
) {
|
||||||
songs.sort_by_cached_key(|song| n32(first_song.custom_distance(song, &distance)));
|
songs.sort_by_cached_key(|song| n32(first_song.custom_distance(song, &distance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +119,8 @@ pub fn dedup_playlist_custom_distance(
|
||||||
/// songs in `group`, discarding songs that don't belong to an album.
|
/// songs in `group`, discarding songs that don't belong to an album.
|
||||||
/// It basically makes an "album" playlist from the `pool` of songs.
|
/// It basically makes an "album" playlist from the `pool` of songs.
|
||||||
///
|
///
|
||||||
|
/// `group` should be ordered by track number.
|
||||||
|
///
|
||||||
/// Songs from `group` would usually just be songs from an album, but not
|
/// Songs from `group` would usually just be songs from an album, but not
|
||||||
/// necessarily - they are discarded from `pool` no matter what.
|
/// necessarily - they are discarded from `pool` no matter what.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue