Make distance functions coherent
This commit is contained in:
parent
89e389e1c9
commit
b3f9ef5fa3
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -85,7 +85,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||
|
||||
[[package]]
|
||||
name = "bliss-audio"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bliss-audio-aubio-rs",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "bliss-audio"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
authors = ["Polochon-street <polochonstreet@gmx.fr>"]
|
||||
edition = "2018"
|
||||
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
|
||||
/// 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)));
|
||||
}
|
||||
|
||||
|
@ -115,6 +119,8 @@ pub fn dedup_playlist_custom_distance(
|
|||
/// songs in `group`, discarding songs that don't belong to an album.
|
||||
/// 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
|
||||
/// necessarily - they are discarded from `pool` no matter what.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue
Block a user