Nickometer: Use non-euclidian division as was originally intended.

I accidentally broke it in 88c2c130ca,
thinking the operands were both integers.
This commit is contained in:
Valentin Lorentz 2019-08-26 22:24:14 +02:00
parent 68de4f8ffd
commit 0413304d53
2 changed files with 8 additions and 4 deletions

View File

@ -45,8 +45,6 @@
# #
###
from __future__ import division
import supybot
import re
@ -224,7 +222,7 @@ class Nickometer(callbacks.Plugin):
# Use an appropriate function to map [0, +inf) to [0, 100)
percentage = 100 * (1 + math.tanh((score - 400.0) / 400.0)) * \
(1 - 1 / (1 + score / 5.0)) // 2
(1 - 1 / (1 + score / 5.0)) / 2
# if it's above 99.9%, show as many digits as is interesting
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',repr(percentage))

View File

@ -33,6 +33,12 @@ class NickometerTestCase(PluginTestCase):
plugins = ('Nickometer',)
def testNickometer(self):
self.assertNotError('nickometer')
self.assertNotError('nickometer jemfinch')
self.assertResponse(
'nickometer jemfinch',
'The "lame nick-o-meter" reading for "jemfinch" is 0.0%.')
nick = 'xXReallyObnoxious1337NickXx'
self.assertResponse(
'nickometer %s' % nick,
'The "lame nick-o-meter" reading for "%s" is 99.96%%.' % nick)
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: