From e54ad0924908aec2a7970c957551787875317b2b Mon Sep 17 00:00:00 2001 From: SVN-Git Migration Date: Thu, 8 Oct 2015 11:51:53 -0700 Subject: Fix tag_weight when using logarithmic distribution When logarithmic distribution is used _calculate_tag_weight may return weight greater than maximum threshold. Because of this the attribute font_size of the most frequently used tag may be left unset. Upstream: http://code.google.com/p/django-tagging/issues/detail?id=91 Debian: #525770 Patch-Name: fix_calc_tag_weight --- tagging/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagging/utils.py b/tagging/utils.py index e89bab0..759e8d8 100644 --- a/tagging/utils.py +++ b/tagging/utils.py @@ -232,7 +232,7 @@ def _calculate_tag_weight(weight, max_weight, distribution): if distribution == LINEAR or max_weight == 1: return weight elif distribution == LOGARITHMIC: - return math.log(weight) * max_weight / math.log(max_weight) + return min((max_weight, math.log(weight) * max_weight / math.log(max_weight))) raise ValueError(_('Invalid distribution algorithm specified: %s.') % distribution) def calculate_cloud(tags, steps=4, distribution=LOGARITHMIC):