Skip to content

Commit

Permalink
Have timbre similarity return error if mututal proximity fails
Browse files Browse the repository at this point in the history
  • Loading branch information
f0k committed Apr 26, 2017
1 parent e5560af commit cb06e9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libmusly/methods/timbre.cpp
Expand Up @@ -181,10 +181,10 @@ timbre::similarity(
other_positions[i] = idpool.position_of(trackids[i]);
}
// - call mp.normalize with these positions
mp.normalize(seed_position, other_positions, length, similarities);
int res = mp.normalize(seed_position, other_positions, length, similarities);
delete[] other_positions;

return 0;
return res;
}

int
Expand Down
4 changes: 2 additions & 2 deletions libmusly/mutualproximity.cpp
Expand Up @@ -149,14 +149,14 @@ mutualproximity::normalize(
int length,
float* sim)
{
if (seed_position >= (int)norm_facts.size()) {
if (seed_position < 0 || seed_position >= (int)norm_facts.size()) {
return -1;
}
float seed_mu = norm_facts[seed_position].mu;
float seed_std = norm_facts[seed_position].std;
for (int i = 0; i < length; i++) {
int pos = other_positions[i];
if (pos >= (int)norm_facts.size()) {
if (pos < 0 || pos >= (int)norm_facts.size()) {
return -1;
}
if (pos == seed_position) {
Expand Down

0 comments on commit cb06e9f

Please sign in to comment.