xloft 0.4.4__py3-none-any.whl → 0.4.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xloft might be problematic. Click here for more details.
- xloft/human.py +26 -5
- xloft/quantum.py +3 -4
- {xloft-0.4.4.dist-info → xloft-0.4.6.dist-info}/METADATA +2 -3
- xloft-0.4.6.dist-info/RECORD +10 -0
- xloft-0.4.4.dist-info/RECORD +0 -10
- {xloft-0.4.4.dist-info → xloft-0.4.6.dist-info}/WHEEL +0 -0
- {xloft-0.4.4.dist-info → xloft-0.4.6.dist-info}/licenses/LICENSE +0 -0
xloft/human.py
CHANGED
|
@@ -7,10 +7,26 @@ The module contains the following functions:
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
__all__ = (
|
|
11
|
+
"to_human_size",
|
|
12
|
+
"get_cach_human_size",
|
|
13
|
+
)
|
|
14
|
+
|
|
10
15
|
import math
|
|
11
16
|
|
|
17
|
+
# To caching the results from to_human_size method.
|
|
18
|
+
_cach_human_size: dict[int, str] = {}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_cach_human_size() -> dict[int, str]:
|
|
22
|
+
"""Get a copy of the variable _cach_human_size.
|
|
23
|
+
|
|
24
|
+
Hint: To tests.
|
|
25
|
+
"""
|
|
26
|
+
return _cach_human_size.copy()
|
|
27
|
+
|
|
12
28
|
|
|
13
|
-
def to_human_size(
|
|
29
|
+
def to_human_size(n_bytes: int) -> str:
|
|
14
30
|
"""Convert number of bytes to readable format.
|
|
15
31
|
|
|
16
32
|
Examples:
|
|
@@ -23,15 +39,20 @@ def to_human_size(size: int) -> str:
|
|
|
23
39
|
1023.999 KB
|
|
24
40
|
|
|
25
41
|
Args:
|
|
26
|
-
|
|
42
|
+
n_bytes: The number of bytes.
|
|
27
43
|
|
|
28
44
|
Returns:
|
|
29
45
|
Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
|
|
30
46
|
"""
|
|
31
|
-
|
|
47
|
+
result: str | None = _cach_human_size.get(n_bytes)
|
|
48
|
+
if result is not None:
|
|
49
|
+
return result
|
|
50
|
+
idx: int = math.floor(math.log(n_bytes) / math.log(1024))
|
|
32
51
|
ndigits: int = [0, 3, 6, 9, 12][idx]
|
|
33
|
-
human_size: int | float =
|
|
52
|
+
human_size: int | float = n_bytes if n_bytes < 1024 else abs(round(n_bytes / pow(1024, idx), ndigits))
|
|
34
53
|
order = ["bytes", "KB", "MB", "GB", "TB"][idx]
|
|
35
54
|
if math.modf(human_size)[0] == 0.0:
|
|
36
55
|
human_size = int(human_size)
|
|
37
|
-
|
|
56
|
+
result = f"{human_size} {order}"
|
|
57
|
+
_cach_human_size[n_bytes] = result
|
|
58
|
+
return result
|
xloft/quantum.py
CHANGED
|
@@ -40,7 +40,7 @@ def count_qubits() -> int:
|
|
|
40
40
|
Quantum of algorithm is a function for data processing.
|
|
41
41
|
|
|
42
42
|
Examples:
|
|
43
|
-
>>> from quantum import count_qubits
|
|
43
|
+
>>> from xloft.quantum import count_qubits
|
|
44
44
|
>>> count_qubits()
|
|
45
45
|
16
|
|
46
46
|
|
|
@@ -54,12 +54,11 @@ class QuantumLoop:
|
|
|
54
54
|
"""Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
55
55
|
|
|
56
56
|
Examples:
|
|
57
|
-
>>> from quantum import QuantumLoop
|
|
57
|
+
>>> from xloft.quantum import QuantumLoop
|
|
58
58
|
>>> def task(item):
|
|
59
59
|
... return item * item
|
|
60
60
|
>>> data = range(10)
|
|
61
|
-
>>>
|
|
62
|
-
>>> qloop.run()
|
|
61
|
+
>>> QuantumLoop(task, data).run()
|
|
63
62
|
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
64
63
|
|
|
65
64
|
Args:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: (XLOFT) X-Library of tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/xloft
|
|
6
6
|
Project-URL: Repository, https://github.com/kebasyaty/xloft
|
|
@@ -186,8 +186,7 @@ def task(item):
|
|
|
186
186
|
data = range(10)
|
|
187
187
|
|
|
188
188
|
# Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
189
|
-
|
|
190
|
-
results = qloop.run()
|
|
189
|
+
results = QuantumLoop(task, data).run()
|
|
191
190
|
print(results) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
192
191
|
```
|
|
193
192
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=UL4IR8EcFjgWoQFayl6FrK2u8QmZytGCwa_E1jDiCmE,475
|
|
2
|
+
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
+
xloft/human.py,sha256=2Jg69412ocJpsOxNyTgaTEwiKTEdHbEOuSQM0LNUEa0,1625
|
|
4
|
+
xloft/namedtuple.py,sha256=a_l3bZF-L2I7MGxuF2CXzAHgNai-Vyj6SY1ODwxs7TU,6856
|
|
5
|
+
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
xloft/quantum.py,sha256=ZkFqqFROC9j5JbwJmej3yL9VJcqElPrrimFTz0Pe3Mk,4679
|
|
7
|
+
xloft-0.4.6.dist-info/METADATA,sha256=MmWF-_pRdZp8ytxmPVZE3JX9p4tLmf0K9G8tjXuNzS0,7241
|
|
8
|
+
xloft-0.4.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
xloft-0.4.6.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
+
xloft-0.4.6.dist-info/RECORD,,
|
xloft-0.4.4.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=UL4IR8EcFjgWoQFayl6FrK2u8QmZytGCwa_E1jDiCmE,475
|
|
2
|
-
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
-
xloft/human.py,sha256=odRbUF_58YuFWC_VQeRDZ-6ifHDiiAH2HNb5G5K6JIM,1106
|
|
4
|
-
xloft/namedtuple.py,sha256=a_l3bZF-L2I7MGxuF2CXzAHgNai-Vyj6SY1ODwxs7TU,6856
|
|
5
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xloft/quantum.py,sha256=-if8m-gX-lydiFpGgg6dXj3RBijpP2dcXbBfPmJ3N_E,4694
|
|
7
|
-
xloft-0.4.4.dist-info/METADATA,sha256=n8av4ZnoCfSsd3PCFu74hFvnNwb1VYws6eLHKFqHG9c,7255
|
|
8
|
-
xloft-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
xloft-0.4.4.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
-
xloft-0.4.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|