aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/fix_calc_tag_weight
blob: b7def1925e042c72e055c0e963dd3b6f7f1e15dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From e54ad0924908aec2a7970c957551787875317b2b Mon Sep 17 00:00:00 2001
From: SVN-Git Migration <python-modules-team@lists.alioth.debian.org>
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):