don't duplicate penalty names in max_rec section

This is for maintanability: in the future, when we add new distance penalty
components, now we won't have to list them twice in the default config.
This commit is contained in:
Adrian Sampson 2013-06-10 15:59:41 -07:00
parent 82991ce614
commit b1ea90a724
4 changed files with 10 additions and 27 deletions

View file

@ -295,14 +295,16 @@ def _recommendation(results):
if isinstance(results[0], hooks.AlbumMatch):
for track_dist in min_dist.tracks.values():
keys.update(track_dist.keys())
max_rec_view = config['match']['max_rec']
for key in keys:
max_rec = config['match']['max_rec'][key].as_choice({
'strong': recommendation.strong,
'medium': recommendation.medium,
'low': recommendation.low,
'none': recommendation.none,
})
rec = min(rec, max_rec)
if key in max_rec_view.keys():
max_rec = max_rec_view[key].as_choice({
'strong': recommendation.strong,
'medium': recommendation.medium,
'low': recommendation.low,
'none': recommendation.none,
})
rec = min(rec, max_rec)
return rec

View file

@ -68,25 +68,8 @@ match:
medium_rec_thresh: 0.25
rec_gap_thresh: 0.25
max_rec:
source: strong
artist: strong
album: strong
media: strong
mediums: strong
year: strong
country: strong
label: strong
catalognum: strong
albumdisambig: strong
album_id: strong
tracks: strong
missing_tracks: medium
unmatched_tracks: medium
track_title: strong
track_artist: strong
track_index: strong
track_length: strong
track_id: strong
distance_weights:
source: 2.0
artist: 3.0

View file

@ -430,8 +430,6 @@ penalty names here are:
* track_title
* track_artist
* track_index
* track_length_grace
* track_length_max
* track_length
* track_id

View file

@ -245,7 +245,7 @@ class DistanceTest(_common.TestCase):
dist = Distance()
dist.add('album', 0.375)
dist.add('medium', 0.75)
self.assertEqual(dist.items, [('album', 0.25), ('medium', 0.25)])
self.assertEqual(dist.items(), [('album', 0.25), ('medium', 0.25)])
def test_update(self):
dist1 = Distance()