diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 11:51:53 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 11:51:53 -0700 |
commit | e54ad0924908aec2a7970c957551787875317b2b (patch) | |
tree | b90b9263252b9edccd29cf05c9948d4584d48bf6 | |
parent | 29425a36c920e9b54e5860429ef3e3ce639fb155 (diff) | |
download | python-django-tagging-e54ad0924908aec2a7970c957551787875317b2b.tar python-django-tagging-e54ad0924908aec2a7970c957551787875317b2b.tar.gz |
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
-rw-r--r-- | tagging/utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
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): |