Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tag cloud] Tag cloud emits fewer steps than expected (improvement) #1059

Closed
tofof opened this issue Sep 12, 2018 · 1 comment
Closed

[tag cloud] Tag cloud emits fewer steps than expected (improvement) #1059

tofof opened this issue Sep 12, 2018 · 1 comment

Comments

@tofof
Copy link

tofof commented Sep 12, 2018

Summary

In many cases where the max_count for any particular tag and the number of steps are of similar magnitude, tag_cloud will emit only n-1 steps even when it would be possible to emit n steps.

Expected behavior

Tag_cloud makes use of all n steps.

Example

min_count 1, max count 5, steps 4 -- assume tags exist for all possible sizes (1,2,3,4,5). Tag_cloud will emit tag-4, tag-2, and tag-1. No tags will be assigned tag-3, since the formula produces 2.7 for size 2 tags, which gets floored to 2.

size result floored rounded
1 4 4 4
2 2.71 2 3
3 1.95 1 2
4 1.42 1 1
5 1 1 1

Suggested resolution

If the formula used round instead of math.floor, this would naturally resolve the issue in most (though not all) cases:

min_count max_count steps steps used (floor) steps used (round) result
1 3 3 2 3 ✅ improved
1 3 4 3 3 👌 ok
1 4 4 3 4 ✅ improved
1 5 4 3 4 ✅ improved
1 6 4 3 4 ✅ improved
1 7 4 3 4 ✅ improved
1 8 4 4 4 👌 ok
1 4 5 4 4 👌 ok
1 5 5 4 4 ❌ bad in both
1 6 5 4 4 ❌ bad in both
1 7 5 4 5 ✅ improved
1 8 5 4 5 ✅ improved
1 9 5 4 5 ✅ improved
1 10 5 4 5 ✅ improved
1 11 5 4 5 ✅ improved
1 12 5 4 5 ✅ improved
1 13 5 4 5 ✅ improved
1 14 5 4 5 ✅ improved
1 15 5 4 5 ✅ improved
1 16 5 5 5 👌 ok
@tofof tofof changed the title [tag cloud] Tag cloud emits fewer steps than expected [tag cloud] Tag cloud emits fewer steps than expected (improvement) Sep 12, 2018
@justinmayer
Copy link
Member

@tofof: Many thanks for filing such detailed issues. If only everyone put this much care into their reports! Sincerely much appreciated. 💯

Fix applied and released in Tag Cloud 1.0.1: https://github.com/pelican-plugins/tag-cloud/releases/tag/1.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants