xloft 0.1.25__py3-none-any.whl → 0.3.1__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/__init__.py +2 -0
- xloft/errors.py +2 -0
- xloft/humanism.py +2 -0
- xloft/namedtuple.py +2 -0
- xloft/quantum.py +29 -18
- {xloft-0.1.25.dist-info → xloft-0.3.1.dist-info}/METADATA +3 -1
- xloft-0.3.1.dist-info/RECORD +10 -0
- xloft-0.1.25.dist-info/RECORD +0 -10
- {xloft-0.1.25.dist-info → xloft-0.3.1.dist-info}/WHEEL +0 -0
- {xloft-0.1.25.dist-info → xloft-0.3.1.dist-info}/licenses/LICENSE +0 -0
xloft/__init__.py
CHANGED
xloft/errors.py
CHANGED
xloft/humanism.py
CHANGED
xloft/namedtuple.py
CHANGED
xloft/quantum.py
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
"""A set of tools for quantum calculations.
|
|
2
2
|
|
|
3
|
+
A Qubit in a regular computer is quantum of algorithm that is executed in
|
|
4
|
+
one iteration of a cycle in a separate processor thread.
|
|
5
|
+
|
|
6
|
+
Quantum is a function with an algorithm of task for data processing.
|
|
7
|
+
|
|
8
|
+
In this case, the Qubit is not a single information,
|
|
9
|
+
but it is a concept of the principle of operation of quantum calculations on a regular computer.
|
|
10
|
+
|
|
3
11
|
The module contains the following tools:
|
|
4
12
|
|
|
5
|
-
- `count_qubits()` - Counting the number of qubits of your computer.
|
|
6
13
|
- `LoopMode` - Quantum loop mode.
|
|
7
|
-
- `
|
|
14
|
+
- `count_qubits()` - Counting the number of conceptual qubits of your computer.
|
|
15
|
+
- `QuantumLoop` - Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
8
16
|
"""
|
|
9
17
|
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
10
20
|
import concurrent.futures
|
|
11
21
|
import multiprocessing
|
|
22
|
+
from collections.abc import Callable, Iterable
|
|
12
23
|
from enum import Enum
|
|
13
|
-
from typing import Any,
|
|
24
|
+
from typing import Any, Never, assert_never
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class LoopMode(Enum):
|
|
28
|
+
"""Quantum loop mode."""
|
|
29
|
+
|
|
30
|
+
PROCESS_POOL = 1
|
|
31
|
+
THREAD_POOL = 2
|
|
14
32
|
|
|
15
33
|
|
|
16
34
|
def count_qubits() -> int:
|
|
17
|
-
"""Counting the number of qubits of your computer.
|
|
35
|
+
"""Counting the number of conceptual qubits of your computer.
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
Conceptual qubit is quantum of algorithm (task) that is executed in
|
|
38
|
+
iterations of a cycle in a separate processor thread.
|
|
21
39
|
|
|
22
|
-
Quantum is a function
|
|
40
|
+
Quantum of algorithm is a function for data processing.
|
|
23
41
|
|
|
24
42
|
Examples:
|
|
25
43
|
>>> from xloft.quantum import count_qubits
|
|
@@ -27,20 +45,13 @@ def count_qubits() -> int:
|
|
|
27
45
|
16
|
|
28
46
|
|
|
29
47
|
Returns:
|
|
30
|
-
The number of qubits.
|
|
48
|
+
The number of conceptual qubits.
|
|
31
49
|
"""
|
|
32
50
|
return multiprocessing.cpu_count()
|
|
33
51
|
|
|
34
52
|
|
|
35
|
-
class LoopMode(Enum):
|
|
36
|
-
"""Quantum loop mode."""
|
|
37
|
-
|
|
38
|
-
PROCESS_POOL = 1
|
|
39
|
-
THREAD_POOL = 2
|
|
40
|
-
|
|
41
|
-
|
|
42
53
|
class QuantumLoop:
|
|
43
|
-
"""Separation of the cycle into
|
|
54
|
+
"""Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
44
55
|
|
|
45
56
|
Args:
|
|
46
57
|
quantum: Function with a task algorithm.
|
|
@@ -92,7 +103,7 @@ class QuantumLoop:
|
|
|
92
103
|
chunksize=self.chunksize,
|
|
93
104
|
),
|
|
94
105
|
)
|
|
95
|
-
return results
|
|
106
|
+
return results # noqa: RET504
|
|
96
107
|
|
|
97
108
|
def thread_pool(self) -> list[Any]:
|
|
98
109
|
"""More suitable for tasks related to input-output
|
|
@@ -107,7 +118,7 @@ class QuantumLoop:
|
|
|
107
118
|
chunksize=self.chunksize,
|
|
108
119
|
),
|
|
109
120
|
)
|
|
110
|
-
return results
|
|
121
|
+
return results # noqa: RET504
|
|
111
122
|
|
|
112
123
|
def run(self) -> list[Any]:
|
|
113
124
|
"""Run the quantum loop."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.3.1
|
|
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
|
|
@@ -174,6 +174,7 @@ print(s) # => 1023.999 KB
|
|
|
174
174
|
```python
|
|
175
175
|
from xloft.quantum import LoopMode, QuantumLoop, count_qubits
|
|
176
176
|
|
|
177
|
+
# Counting the number of conceptual qubits of your computer.
|
|
177
178
|
num = count_qubits()
|
|
178
179
|
print(num) # => 16
|
|
179
180
|
|
|
@@ -183,6 +184,7 @@ def quantum(item):
|
|
|
183
184
|
|
|
184
185
|
data = range(10)
|
|
185
186
|
|
|
187
|
+
# Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
186
188
|
qloop = QuantumLoop(quantum, data)
|
|
187
189
|
results = qloop.run()
|
|
188
190
|
print(results) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=oYQan7jqPh5XKw9msdT290f6fPo4c53p6OkFcCoqi_s,409
|
|
2
|
+
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
+
xloft/humanism.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=6Na7_4JrcWIjgst-mfpKeahyWanreocLKqxd87I9AGU,4721
|
|
7
|
+
xloft-0.3.1.dist-info/METADATA,sha256=jV8OFpQnScSwWVwMZ2x1GugwayQw0yzm_omagriIoA8,7235
|
|
8
|
+
xloft-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
xloft-0.3.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
+
xloft-0.3.1.dist-info/RECORD,,
|
xloft-0.1.25.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=FZ2m329mXkIm4ETgl0ERwEzRzsFvd-_1ug2Eo1kSVo0,371
|
|
2
|
-
xloft/errors.py,sha256=GYXvi2l01VUDQSs6skiOfQsKLF6tFuUhJMqNkL7BJNI,857
|
|
3
|
-
xloft/humanism.py,sha256=I6q56MhviapBSWF4B_1xd77TDwQMM1jrkbl1N-fOURc,1068
|
|
4
|
-
xloft/namedtuple.py,sha256=OkAHqMaV4hN6Qj_oaOYQ9-y9x4Muv4mNrBn48T6RpiI,6818
|
|
5
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xloft/quantum.py,sha256=0c6-vz6SilbKxtz6vJvL-9MpsByGVb4mWZvo67fwFBU,4159
|
|
7
|
-
xloft-0.1.25.dist-info/METADATA,sha256=nP-9CLu5N_XLg1p8mQYxxmZC0Va7II49LgP2gOieVYE,7088
|
|
8
|
-
xloft-0.1.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
xloft-0.1.25.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
-
xloft-0.1.25.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|