From 0413304d5354cf72dd6477f52ac9e99a14b2532b Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 26 Aug 2019 22:24:14 +0200 Subject: [PATCH] Nickometer: Use non-euclidian division as was originally intended. I accidentally broke it in 88c2c130cac98e478bc1966003f38e213e032e45, thinking the operands were both integers. --- plugins/Nickometer/plugin.py | 4 +--- plugins/Nickometer/test.py | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/Nickometer/plugin.py b/plugins/Nickometer/plugin.py index 686ee266b..59751cf95 100644 --- a/plugins/Nickometer/plugin.py +++ b/plugins/Nickometer/plugin.py @@ -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)) diff --git a/plugins/Nickometer/test.py b/plugins/Nickometer/test.py index 5029ca5c6..2b2f29542 100644 --- a/plugins/Nickometer/test.py +++ b/plugins/Nickometer/test.py @@ -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: