fyrizi commited on
Commit
22ad0f1
·
verified ·
1 Parent(s): 369a289

Delete main/src/number_formatting.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. main/src/number_formatting.py +0 -57
main/src/number_formatting.py DELETED
@@ -1,57 +0,0 @@
1
- from typing import Union
2
-
3
-
4
- def bytes2human(n: Union[int, float]) -> str:
5
- """
6
- Format large number of bytes into readable string for a human
7
-
8
- Examples:
9
- >>> bytes2human(10000)
10
- '9.8K'
11
-
12
- >>> bytes2human(100001221)
13
- '95.4M'
14
-
15
- """
16
- # http://code.activestate.com/recipes/578019
17
- # >>> bytes2human(10000)
18
- # '9.8K'
19
- # >>> bytes2human(100001221)
20
- # '95.4M'
21
- symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
22
- prefix = {}
23
- for i, s in enumerate(symbols):
24
- prefix[s] = 1 << (i + 1) * 10
25
- for s in reversed(symbols):
26
- if n >= prefix[s]:
27
- value = float(n) / prefix[s]
28
- return '%.1f%s' % (value, s)
29
- return "%.2f" % n
30
-
31
-
32
- def number2human(n: Union[int, float]) -> str:
33
- """
34
- Format large number into readable string for a human
35
-
36
- Examples:
37
- >>> number2human(1000)
38
- '1.0K'
39
-
40
- >>> number2human(1200000)
41
- '1.2M'
42
-
43
- """
44
- # http://code.activestate.com/recipes/578019
45
- # >>> bytes2human(10000)
46
- # '9.8K'
47
- # >>> bytes2human(100001221)
48
- # '95.4M'
49
- symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
50
- prefix = {}
51
- for i, s in enumerate(symbols):
52
- prefix[s] = (10 ** 3) ** (i + 1)
53
- for s in reversed(symbols):
54
- if n >= prefix[s]:
55
- value = float(n) / prefix[s]
56
- return '%.1f%s' % (value, s)
57
- return "%.2f" % n