Merge pull request #43 from Polochon-street/minor-changes

Make distance functions coherent
This commit is contained in:
Polochon-street 2022-08-14 18:55:53 +02:00 committed by GitHub
commit c5ffb619bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

2
Cargo.lock generated
View file

@ -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",

View file

@ -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"

View file

@ -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.
/// ///