Skip to content

Commit cdec7db

Browse files
committed
Use exponent variable for short numeric abbreviations
1 parent 81cbebf commit cdec7db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ def short_numeric_filter(value):
7878
"ND",
7979
"V",
8080
]
81-
i = 0
81+
exponent = 0
8282
mantissa = value
8383
while mantissa >= 1000:
8484
mantissa /= 1000
85-
i += 1
86-
return f"{mantissa:.3g}{units[i]}" if value >= 1000 else f"{value:.0f}"
85+
exponent += 1
86+
return f"{mantissa:.3g}{units[exponent]}" if value >= 1000 else f"{value:.0f}"
8787

8888

8989
app.jinja_env.filters["short_numeric"] = short_numeric_filter

0 commit comments

Comments
 (0)