mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-26 04:32:51 +01:00
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:
parent
68de4f8ffd
commit
0413304d53
@ -45,8 +45,6 @@
|
|||||||
# #
|
# #
|
||||||
###
|
###
|
||||||
|
|
||||||
from __future__ import division
|
|
||||||
|
|
||||||
import supybot
|
import supybot
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@ -224,7 +222,7 @@ class Nickometer(callbacks.Plugin):
|
|||||||
|
|
||||||
# Use an appropriate function to map [0, +inf) to [0, 100)
|
# Use an appropriate function to map [0, +inf) to [0, 100)
|
||||||
percentage = 100 * (1 + math.tanh((score - 400.0) / 400.0)) * \
|
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
|
# if it's above 99.9%, show as many digits as is interesting
|
||||||
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',repr(percentage))
|
score_string=re.sub('(99\\.9*\\d|\\.\\d).*','\\1',repr(percentage))
|
||||||
|
@ -33,6 +33,12 @@ class NickometerTestCase(PluginTestCase):
|
|||||||
plugins = ('Nickometer',)
|
plugins = ('Nickometer',)
|
||||||
def testNickometer(self):
|
def testNickometer(self):
|
||||||
self.assertNotError('nickometer')
|
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:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
Reference in New Issue
Block a user