summaryrefslogtreecommitdiffstats
path: root/python/python-django-tagging/patches/fix_calc_tag_weight
diff options
context:
space:
mode:
Diffstat (limited to 'python/python-django-tagging/patches/fix_calc_tag_weight')
-rw-r--r--python/python-django-tagging/patches/fix_calc_tag_weight19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/python-django-tagging/patches/fix_calc_tag_weight b/python/python-django-tagging/patches/fix_calc_tag_weight
new file mode 100644
index 0000000000..1b65164453
--- /dev/null
+++ b/python/python-django-tagging/patches/fix_calc_tag_weight
@@ -0,0 +1,19 @@
+Description: 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
+
+--- django-tagging.old/tagging/utils.py (revision 132)
++++ django-tagging/tagging/utils.py (working copy)
+@@ -230,7 +230,7 @@
+ 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):
+