atizo/PyTagCloud — Issue #4: Evenly distributed tagset (all counts the same) cause div/0 error in defscale
Author: mindsocket
Created: 2012-02-14 01:29:01+00:00
State: open

The default scaling function has this expression:
1.0 / (maxcount - mincount)

When maxcount == mincount, things blow up. As a workaround I've used a hacky alternative that avoids this well enough for my needs...

def tagscale(count, mincount, maxcount, minsize, maxsize):
if maxcount == mincount:
return defscale(count, mincount, maxcount + 1, minsize, maxsize)
return defscale(count, mincount, maxcount, minsize, maxsize)

There's probably a better way though