aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2021-10-03 15:21:17 +0100
committerGravatar GitHub <[email protected]>2021-10-03 15:21:17 +0100
commit813f59cec9f76f315a8841b9258e27db18c957c6 (patch)
treeaeaf324b4f7dcbb430cae14e7f7f0b17ec7babaf
parentMerge pull request #891 from python-discord/spooky-ignore-bots (diff)
parentMerge branch 'main' into main (diff)
Merge pull request #785 from PythonTryHard/main
Correct an off-by-one bug due to bisect.bisect()
-rw-r--r--bot/exts/holidays/valentines/lovecalculator.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/bot/exts/holidays/valentines/lovecalculator.py b/bot/exts/holidays/valentines/lovecalculator.py
index 3999db2b..a53014e5 100644
--- a/bot/exts/holidays/valentines/lovecalculator.py
+++ b/bot/exts/holidays/valentines/lovecalculator.py
@@ -74,7 +74,8 @@ class LoveCalculator(Cog):
# We need the -1 due to how bisect returns the point
# see the documentation for further detail
# https://docs.python.org/3/library/bisect.html#bisect.bisect
- index = bisect.bisect(LOVE_DATA, (love_percent,)) - 1
+ love_threshold = [threshold for threshold, _ in LOVE_DATA]
+ index = bisect.bisect(love_threshold, love_percent) - 1
# We already have the nearest "fit" love level
# We only need the dict, so we can ditch the first element
_, data = LOVE_DATA[index]