Skip to content

Commit 25373b5

Browse files
docs: add docstring to logSliderToSize function in server_utils.py
1 parent c377fc5 commit 25373b5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/server_utils.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import math
22

3-
## Rate Limiter
43
from slowapi import Limiter
54
from slowapi.util import get_remote_address
65

6+
# Initialize a rate limiter
77
limiter = Limiter(key_func=get_remote_address)
88

99

10-
## Logarithmic slider to file size conversion
1110
def logSliderToSize(position: int) -> int:
12-
"""Convert slider position to file size in KB"""
11+
"""
12+
Convert a slider position to a file size in bytes using a logarithmic scale.
13+
14+
Parameters
15+
----------
16+
position : int
17+
Slider position ranging from 0 to 500.
18+
19+
Returns
20+
-------
21+
int
22+
File size in bytes corresponding to the slider position.
23+
"""
1324
maxp = 500
1425
minv = math.log(1)
15-
maxv = math.log(102400)
16-
26+
maxv = math.log(102_400)
1727
return round(math.exp(minv + (maxv - minv) * pow(position / maxp, 1.5))) * 1024
1828

1929

0 commit comments

Comments
 (0)