Open GoogleCodeExporter opened 9 years ago
I just encountered this myself. There is a subtle rounding error that leads to
the
condition as described by recalcitrare. A very cursory analysis shows that this
happens around 10% of the time (at least up through tag counts of up to 1000).
Original comment by luftyl...@gmail.com
on 24 Feb 2008 at 2:38
I experienced this myself. Say that in utils._calculate_tag_weight(weight,
max_weight, distribution) you have weight = 6.0, max_weight = 6.0 then the
expression
math.log(weight) * max_weight / math.log(max_weight) would return
6.000000000000009
which is greater than 6.0 and it would fail to compare True in calculate_cloud.
Original comment by fd.calab...@gmail.com
on 10 Mar 2008 at 10:48
Just ran into this issue. To clarify for others in case they see it too: this
originated as an AttributeError
exception in one of my views.
AttributeError: 'Tag' object has no attribute 'font_size'
This occurred after doing Tag.objects.cloud_for_model(Model, min_count=2) and
then trying to sort the
results by 'font_size' attribute.
The patch does the trick. Thanks!
Original comment by jesse.l...@gmail.com
on 6 May 2008 at 7:33
I've hit this too. I had come up with this patch to fix it though I think I like
recalcitrare's patch better.
{{{
--- utils.py (revision 132)
+++ utils.py (working copy)
@@ -252,10 +252,19 @@
max_weight = float(max(counts))
thresholds = _calculate_thresholds(min_weight, max_weight, steps)
for tag in tags:
- font_set = False
tag_weight = _calculate_tag_weight(tag.count, max_weight, distribution)
for i in range(steps):
- if not font_set and tag_weight <= thresholds[i]:
+ if tag_weight <= thresholds[i]:
tag.font_size = i + 1
- font_set = True
+ break
+ else:
+ # With a logarithmic distribution, it is possible with
+ # to get a tag_weight that is *slight* greater-than
+ # thresholds[-1], e.g.:
+ # counts = [1, 2, 6, 1]
+ # thresholds = [2.25, 3.5, 4.75, 6.0]
+ # tag_weight for count 6 = 6.0000000000000009
+ # The result is an unexpected `tag.font_size = None`.
+ # Guard against that.
+ tag.font_size = steps
return tags
}}}
Jonathan or Jacob, would it be possible to get recalcitrare's patch commited?
Original comment by tre...@gmail.com
on 25 Jun 2008 at 10:42
i ran into this problem to, after spending hours trying to figure out what i am
doing
wrong i realized to problem must be inside django-tagging.
i attached an extremly simple patch ;-)
Original comment by initcr...@gmail.com
on 27 Jun 2008 at 8:08
Attachments:
I ran into this problem too, thought it was in my own code initially but using
werkzeug traced it down to the _calculate_tag_weight just as recalcitrare found.
There's a couple of patches here, but I think I like recalcitrare's one as
well. Any
chance to get this committed? Thanks.
Original comment by rob...@gmail.com
on 11 Sep 2008 at 7:01
Just hit this one myself. +1 to a patch being committed.
Original comment by giles.th...@gmail.com
on 23 Oct 2008 at 2:12
Just hit this one myself
Original comment by pierrer...@yahoo.fr
on 31 Oct 2008 at 11:03
I've also encoutered this issue.
Both "dtcw.patch" and "missing_size_fix.patch" are good solutions, although
"dtcw.patch" has the least lines of code, so +1 to "dtcw.patch".
Original comment by zera...@gmail.com
on 17 Nov 2008 at 2:15
My apologies for posting several times on this topic, but I believe something
needs
to be done about this bug. This bug was first reported in Jan 2008, which
makes it
over a year old. There is a patch "dtcw.patch", which several people, including
myself have tested without any problems. The bug is classed as medium priority,
however I get this bug so often I believe it should really be classed as a high
priority bug. At the moment for me, django-tagging is not usable in any of my
apps
unless this patch is manually applied.
Please anyone, apply this patch and close this bug if possible.
Original comment by rob...@gmail.com
on 27 Feb 2009 at 7:25
Yes, please apply this patch already :)
Original comment by real.hu...@mrmachine.net
on 17 Apr 2009 at 8:12
I also encoutered this issue too, and spend a while until I realised it was a
bug on
django-tagging.
"dtcw.patch" is a nice fix, please go ahead and commit it.
Thanks.
Original comment by mcampo85@gmail.com
on 10 Aug 2009 at 3:44
I've encoutered this issue too. I open a new issue (sorry for that) and added a
new
patch on issue #223.
Original comment by arthur.furlan
on 18 Nov 2009 at 2:59
Just ran into this issue.
For me, a repeatable test condition is:
>>> import tagging.utils as utils
>>> utils._calculate_tag_weight(weight=26, max_weight=26,
distribution=tagging.utils.LOGARITHMIC)
26.000000000000004
And since that tag's weight is never <= the last threshold (if the endpoint
threshold
is at 26), the font_size never gets set and the tag cloud blows up the
page/application. This bug is particularly insidious in that all my test cases,
even
ones testing tags, succeeded just fine because the bug only shows up with how
various
numbers handle conversion into floating point numbers.
Original comment by wamc...@gmail.com
on 23 Dec 2009 at 5:43
I just ran into this. dtcw.patch fixed it for me.
Original comment by audr...@gmail.com
on 14 Jan 2010 at 12:09
Faced to the same issue. dtcw.patch solved the problem.
Original comment by sli...@gmail.com
on 17 Feb 2010 at 8:16
I'm a bit disappointed how long it has taken for this patch to be approved, a
fix was released 2 years that works perfectly for so many people, yet it hasn't
been committed. please commit dtcw.patch
Original comment by rob...@gmail.com
on 30 Aug 2010 at 10:52
This issue is fixed in the Ubuntu repository (Oneiric at least) version of
python-django-tagging, but not here on Google Code, I was really hoping this
could be patched here too.
Original comment by rob...@gmail.com
on 3 Mar 2012 at 4:07
Original issue reported on code.google.com by
recalcit...@gmail.com
on 30 Jan 2008 at 5:07Attachments: