geqie 1.0.0__tar.gz

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.
Files changed (70) hide show
  1. geqie-1.0.0/MANIFEST.in +1 -0
  2. geqie-1.0.0/PKG-INFO +357 -0
  3. geqie-1.0.0/README.md +246 -0
  4. geqie-1.0.0/pyproject.toml +26 -0
  5. geqie-1.0.0/requirements/requirements.txt +147 -0
  6. geqie-1.0.0/requirements/requirements_dev.txt +159 -0
  7. geqie-1.0.0/setup.cfg +4 -0
  8. geqie-1.0.0/src/geqie/__init__.py +1 -0
  9. geqie-1.0.0/src/geqie/backends/__init__.py +0 -0
  10. geqie-1.0.0/src/geqie/backends/ibm_qp.py +45 -0
  11. geqie-1.0.0/src/geqie/cli.py +211 -0
  12. geqie-1.0.0/src/geqie/encodings/__init__.py +40 -0
  13. geqie-1.0.0/src/geqie/encodings/frqci/__init__.py +4 -0
  14. geqie-1.0.0/src/geqie/encodings/frqci/data.py +11 -0
  15. geqie-1.0.0/src/geqie/encodings/frqci/init.py +8 -0
  16. geqie-1.0.0/src/geqie/encodings/frqci/map.py +29 -0
  17. geqie-1.0.0/src/geqie/encodings/frqci/retrieve.py +56 -0
  18. geqie-1.0.0/src/geqie/encodings/frqi/__init__.py +20 -0
  19. geqie-1.0.0/src/geqie/encodings/frqi/data.py +11 -0
  20. geqie-1.0.0/src/geqie/encodings/frqi/init.py +8 -0
  21. geqie-1.0.0/src/geqie/encodings/frqi/map.py +13 -0
  22. geqie-1.0.0/src/geqie/encodings/frqi/retrieve.py +40 -0
  23. geqie-1.0.0/src/geqie/encodings/ifrqi/__init__.py +20 -0
  24. geqie-1.0.0/src/geqie/encodings/ifrqi/data.py +11 -0
  25. geqie-1.0.0/src/geqie/encodings/ifrqi/init.py +10 -0
  26. geqie-1.0.0/src/geqie/encodings/ifrqi/map.py +33 -0
  27. geqie-1.0.0/src/geqie/encodings/ifrqi/retrieve.py +61 -0
  28. geqie-1.0.0/src/geqie/encodings/lpiqe/data.py +2 -0
  29. geqie-1.0.0/src/geqie/encodings/lpiqe/map.py +2 -0
  30. geqie-1.0.0/src/geqie/encodings/mcqi/__init__.py +4 -0
  31. geqie-1.0.0/src/geqie/encodings/mcqi/data.py +11 -0
  32. geqie-1.0.0/src/geqie/encodings/mcqi/init.py +8 -0
  33. geqie-1.0.0/src/geqie/encodings/mcqi/map.py +33 -0
  34. geqie-1.0.0/src/geqie/encodings/mcqi/retrieve.py +54 -0
  35. geqie-1.0.0/src/geqie/encodings/mfrqi/__init__.py +4 -0
  36. geqie-1.0.0/src/geqie/encodings/mfrqi/data.py +12 -0
  37. geqie-1.0.0/src/geqie/encodings/mfrqi/init.py +8 -0
  38. geqie-1.0.0/src/geqie/encodings/mfrqi/map.py +13 -0
  39. geqie-1.0.0/src/geqie/encodings/mfrqi/retrieve.py +29 -0
  40. geqie-1.0.0/src/geqie/encodings/ncqi/__init__.py +4 -0
  41. geqie-1.0.0/src/geqie/encodings/ncqi/data.py +9 -0
  42. geqie-1.0.0/src/geqie/encodings/ncqi/init.py +9 -0
  43. geqie-1.0.0/src/geqie/encodings/ncqi/map.py +40 -0
  44. geqie-1.0.0/src/geqie/encodings/ncqi/retrieve.py +38 -0
  45. geqie-1.0.0/src/geqie/encodings/neqr/__init__.py +20 -0
  46. geqie-1.0.0/src/geqie/encodings/neqr/data.py +9 -0
  47. geqie-1.0.0/src/geqie/encodings/neqr/init.py +11 -0
  48. geqie-1.0.0/src/geqie/encodings/neqr/map.py +40 -0
  49. geqie-1.0.0/src/geqie/encodings/neqr/retrieve.py +36 -0
  50. geqie-1.0.0/src/geqie/encodings/qrci/__init__.py +4 -0
  51. geqie-1.0.0/src/geqie/encodings/qrci/data.py +8 -0
  52. geqie-1.0.0/src/geqie/encodings/qrci/init.py +10 -0
  53. geqie-1.0.0/src/geqie/encodings/qrci/map.py +46 -0
  54. geqie-1.0.0/src/geqie/encodings/qrci/retrieve.py +44 -0
  55. geqie-1.0.0/src/geqie/encodings/qualpi/__init__.py +20 -0
  56. geqie-1.0.0/src/geqie/encodings/qualpi/data.py +9 -0
  57. geqie-1.0.0/src/geqie/encodings/qualpi/init.py +9 -0
  58. geqie-1.0.0/src/geqie/encodings/qualpi/map.py +30 -0
  59. geqie-1.0.0/src/geqie/encodings/qualpi/retrieve.py +37 -0
  60. geqie-1.0.0/src/geqie/logging_utils/__init__.py +0 -0
  61. geqie-1.0.0/src/geqie/logging_utils/levels.py +35 -0
  62. geqie-1.0.0/src/geqie/logging_utils/logger.py +48 -0
  63. geqie-1.0.0/src/geqie/logging_utils/tabulate.py +6 -0
  64. geqie-1.0.0/src/geqie/main.py +199 -0
  65. geqie-1.0.0/src/geqie.egg-info/PKG-INFO +357 -0
  66. geqie-1.0.0/src/geqie.egg-info/SOURCES.txt +70 -0
  67. geqie-1.0.0/src/geqie.egg-info/dependency_links.txt +1 -0
  68. geqie-1.0.0/src/geqie.egg-info/entry_points.txt +2 -0
  69. geqie-1.0.0/src/geqie.egg-info/requires.txt +104 -0
  70. geqie-1.0.0/src/geqie.egg-info/top_level.txt +1 -0
@@ -0,0 +1 @@
1
+ prune tests
geqie-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,357 @@
1
+ Metadata-Version: 2.4
2
+ Name: geqie
3
+ Version: 1.0.0
4
+ Summary: General Equation of Quantum Image Encoding Framework
5
+ License: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: annotated-types==0.8.0
9
+ Requires-Dist: antlr4-python3-runtime==4.13.2
10
+ Requires-Dist: certifi==2026.7.22
11
+ Requires-Dist: cffi==2.1.0
12
+ Requires-Dist: charset-normalizer==3.4.9
13
+ Requires-Dist: click==8.4.2
14
+ Requires-Dist: cloup==3.1.0
15
+ Requires-Dist: colorama==0.4.6
16
+ Requires-Dist: contourpy==1.3.3
17
+ Requires-Dist: cryptography==49.0.0
18
+ Requires-Dist: cycler==0.12.1
19
+ Requires-Dist: dill==0.4.1
20
+ Requires-Dist: fonttools==4.63.0
21
+ Requires-Dist: ibm-cloud-sdk-core==3.26.0
22
+ Requires-Dist: ibm-platform-services==0.77.0
23
+ Requires-Dist: ibm-quantum-schemas==0.10.20260723
24
+ Requires-Dist: idna==3.18
25
+ Requires-Dist: kiwisolver==1.5.0
26
+ Requires-Dist: matplotlib==3.11.1
27
+ Requires-Dist: numpy==2.4.6
28
+ Requires-Dist: openqasm3==1.0.1
29
+ Requires-Dist: orjson==3.11.9
30
+ Requires-Dist: packaging==26.2
31
+ Requires-Dist: pillow==12.0.0
32
+ Requires-Dist: psutil==7.2.2
33
+ Requires-Dist: pybase64==1.4.3
34
+ Requires-Dist: pycparser==3.0
35
+ Requires-Dist: pydantic==2.13.4
36
+ Requires-Dist: pydantic-core==2.46.4
37
+ Requires-Dist: pyjwt==2.13.0
38
+ Requires-Dist: pyparsing==3.3.2
39
+ Requires-Dist: pyspnego==0.12.1
40
+ Requires-Dist: python-dateutil==2.9.0.post0
41
+ Requires-Dist: qiskit==2.5.1
42
+ Requires-Dist: qiskit-aer==0.17.2
43
+ Requires-Dist: qiskit-ibm-runtime==0.48.0
44
+ Requires-Dist: qiskit-qasm3-import==0.6.0
45
+ Requires-Dist: requests==2.34.2
46
+ Requires-Dist: requests-ntlm==1.3.0
47
+ Requires-Dist: rustworkx==0.18.1
48
+ Requires-Dist: samplomatic==0.20.0
49
+ Requires-Dist: scipy==1.15.3
50
+ Requires-Dist: six==1.17.0
51
+ Requires-Dist: sspilib==0.5.0
52
+ Requires-Dist: stevedore==5.9.0
53
+ Requires-Dist: tabulate==0.10.0
54
+ Requires-Dist: typing-extensions==4.16.0
55
+ Requires-Dist: typing-inspection==0.4.2
56
+ Requires-Dist: urllib3==2.7.0
57
+ Provides-Extra: dev
58
+ Requires-Dist: annotated-types==0.8.0; extra == "dev"
59
+ Requires-Dist: antlr4-python3-runtime==4.13.2; extra == "dev"
60
+ Requires-Dist: certifi==2026.7.22; extra == "dev"
61
+ Requires-Dist: cffi==2.1.0; extra == "dev"
62
+ Requires-Dist: charset-normalizer==3.4.9; extra == "dev"
63
+ Requires-Dist: click==8.4.2; extra == "dev"
64
+ Requires-Dist: cloup==3.1.0; extra == "dev"
65
+ Requires-Dist: colorama==0.4.6; extra == "dev"
66
+ Requires-Dist: contourpy==1.3.3; extra == "dev"
67
+ Requires-Dist: cryptography==49.0.0; extra == "dev"
68
+ Requires-Dist: cycler==0.12.1; extra == "dev"
69
+ Requires-Dist: dill==0.4.1; extra == "dev"
70
+ Requires-Dist: fonttools==4.63.0; extra == "dev"
71
+ Requires-Dist: ibm-cloud-sdk-core==3.26.0; extra == "dev"
72
+ Requires-Dist: ibm-platform-services==0.77.0; extra == "dev"
73
+ Requires-Dist: ibm-quantum-schemas==0.10.20260723; extra == "dev"
74
+ Requires-Dist: idna==3.18; extra == "dev"
75
+ Requires-Dist: iniconfig==2.3.0; extra == "dev"
76
+ Requires-Dist: kiwisolver==1.5.0; extra == "dev"
77
+ Requires-Dist: matplotlib==3.11.1; extra == "dev"
78
+ Requires-Dist: numpy==2.4.6; extra == "dev"
79
+ Requires-Dist: openqasm3==1.0.1; extra == "dev"
80
+ Requires-Dist: orjson==3.11.9; extra == "dev"
81
+ Requires-Dist: packaging==26.2; extra == "dev"
82
+ Requires-Dist: pillow==12.0.0; extra == "dev"
83
+ Requires-Dist: pluggy==1.6.0; extra == "dev"
84
+ Requires-Dist: psutil==7.2.2; extra == "dev"
85
+ Requires-Dist: pybase64==1.4.3; extra == "dev"
86
+ Requires-Dist: pycparser==3.0; extra == "dev"
87
+ Requires-Dist: pydantic==2.13.4; extra == "dev"
88
+ Requires-Dist: pydantic-core==2.46.4; extra == "dev"
89
+ Requires-Dist: pygments==2.20.0; extra == "dev"
90
+ Requires-Dist: pyjwt==2.13.0; extra == "dev"
91
+ Requires-Dist: pyparsing==3.3.2; extra == "dev"
92
+ Requires-Dist: pyspnego==0.12.1; extra == "dev"
93
+ Requires-Dist: pytest==9.1.1; extra == "dev"
94
+ Requires-Dist: python-dateutil==2.9.0.post0; extra == "dev"
95
+ Requires-Dist: qiskit==2.5.1; extra == "dev"
96
+ Requires-Dist: qiskit-aer==0.17.2; extra == "dev"
97
+ Requires-Dist: qiskit-ibm-runtime==0.48.0; extra == "dev"
98
+ Requires-Dist: qiskit-qasm3-import==0.6.0; extra == "dev"
99
+ Requires-Dist: requests==2.34.2; extra == "dev"
100
+ Requires-Dist: requests-ntlm==1.3.0; extra == "dev"
101
+ Requires-Dist: rustworkx==0.18.1; extra == "dev"
102
+ Requires-Dist: samplomatic==0.20.0; extra == "dev"
103
+ Requires-Dist: scipy==1.15.3; extra == "dev"
104
+ Requires-Dist: six==1.17.0; extra == "dev"
105
+ Requires-Dist: sspilib==0.5.0; extra == "dev"
106
+ Requires-Dist: stevedore==5.9.0; extra == "dev"
107
+ Requires-Dist: tabulate==0.10.0; extra == "dev"
108
+ Requires-Dist: typing-extensions==4.16.0; extra == "dev"
109
+ Requires-Dist: typing-inspection==0.4.2; extra == "dev"
110
+ Requires-Dist: urllib3==2.7.0; extra == "dev"
111
+
112
+ # geqie <!-- omit in toc -->
113
+
114
+ Core quantum image encoding library.
115
+
116
+ ## Table of contents <!-- omit in toc -->
117
+
118
+ - [API](#api)
119
+ - [Quick start](#quick-start)
120
+ - [Encodings](#encodings)
121
+ - [`geqie.encode`](#geqieencode)
122
+ - [`geqie.simulate`](#geqiesimulate)
123
+ - [`geqie.execute`](#geqieexecute)
124
+ - [`geqie.retrieve`](#geqieretrieve)
125
+ - [Examples](#examples)
126
+ - [CLI](#cli)
127
+ - [`geqie list-encodings`](#geqie-list-encodings)
128
+ - [`geqie simulate`](#geqie-simulate)
129
+ - [`geqie execute`](#geqie-execute)
130
+
131
+
132
+ ## API
133
+
134
+ ### Quick start
135
+
136
+ ```python
137
+ import numpy as np
138
+ from PIL import Image
139
+
140
+ import geqie
141
+ from geqie.encodings import frqi
142
+
143
+ image = np.asarray(Image.open("assets/test_images/grayscale/test_image_4x4.png"))
144
+
145
+ circuit = geqie.encode(frqi.init_function, frqi.data_function, frqi.map_function, image)
146
+ counts = geqie.simulate(circuit, n_shots=1024)
147
+ reconstructed = geqie.retrieve(frqi.retrieve_function, counts)
148
+ ```
149
+
150
+ ### Encodings
151
+
152
+ Each encoding lives in `geqie.encodings.<name>` (e.g., `frqi`, `neqr`, `mcqi`) and exposes:
153
+
154
+ | Function | Signature | Returns | Description |
155
+ | ------------------- | --------------------------------------------- | ------------- | --------------------------------------------------- |
156
+ | `init_function` | `(n_qubits, **encoding_params)` | `Statevector` | Initial state of the circuit |
157
+ | `data_function` | `(*coords, R, image, **encoding_params)` | `Statevector` | Data (pixel position) state for the given pixel |
158
+ | `map_function` | `(*coords, R, image, **encoding_params)` | `Operator` | Map (pixel value) operator for the given pixel |
159
+ | `retrieve_function` | `(results, **encoding_params)` | `np.ndarray` | Reconstructs the image from measurement counts |
160
+
161
+ `coords` are pixel indices (e.g., `u, v` for 2D images) and `R = ceil(log2(max(image.shape)))`. Custom encodings can be created by providing your own functions with the same signatures.
162
+
163
+ ### `geqie.encode`
164
+
165
+ Builds a quantum circuit encoding the image using the provided encoding functions.
166
+
167
+ ```python
168
+ geqie.encode(
169
+ init_function, data_function, map_function, image,
170
+ image_dimensionality=2,
171
+ perform_measurement=True,
172
+ logging_level=None,
173
+ encoding_params={},
174
+ ) -> QuantumCircuit
175
+ ```
176
+
177
+ | Parameter | Description |
178
+ | ---------------------- | ------------------------------------------------------------------------------------- |
179
+ | `init_function` | Function returning the initial `Statevector` |
180
+ | `data_function` | Function returning the data `Statevector` for a pixel |
181
+ | `map_function` | Function returning the map `Operator` for a pixel |
182
+ | `image` | Image as a NumPy array |
183
+ | `image_dimensionality` | Number of leading image axes treated as spatial coordinates (rest are e.g. channels) |
184
+ | `perform_measurement` | Append measurement of all qubits to the circuit |
185
+ | `logging_level` | Logging level (see `geqie.logging_utils.levels`) |
186
+ | `encoding_params` | Extra keyword arguments passed to the encoding functions (e.g., `{"bitrate": 4}`) |
187
+
188
+ ### `geqie.simulate`
189
+
190
+ Simulates the circuit locally with Qiskit Aer.
191
+
192
+ ```python
193
+ geqie.simulate(
194
+ circuit, n_shots,
195
+ return_qiskit_result=False,
196
+ return_padded_counts=False,
197
+ device="CPU",
198
+ method="automatic",
199
+ noise_model=None,
200
+ logging_level=None,
201
+ ) -> dict[str, int] | qiskit.result.Result
202
+ ```
203
+
204
+ | Parameter | Description |
205
+ | ---------------------- | ------------------------------------------------------------------- |
206
+ | `circuit` | Circuit returned by `geqie.encode` |
207
+ | `n_shots` | Number of simulation shots |
208
+ | `return_qiskit_result` | Return the raw Qiskit `Result` instead of counts |
209
+ | `return_padded_counts` | Include zero-count states in the returned counts |
210
+ | `device` | Aer simulator device (`"CPU"` or `"GPU"`) |
211
+ | `method` | Aer simulation method (e.g., `"automatic"`, `"statevector"`) |
212
+ | `noise_model` | Optional `qiskit_aer.noise.NoiseModel` |
213
+ | `logging_level` | Logging level |
214
+
215
+ ### `geqie.execute`
216
+
217
+ Executes the circuit on real hardware via IBM Quantum Platform (Qiskit Runtime `SamplerV2`).
218
+
219
+ ```python
220
+ geqie.execute(
221
+ circuit, n_shots,
222
+ circuit_param_values={},
223
+ return_qiskit_result=False,
224
+ return_padded_counts=False,
225
+ dry_run=False,
226
+ api_token="",
227
+ instance_crn="",
228
+ credentials_name="",
229
+ backend="",
230
+ channel="ibm_quantum_platform",
231
+ ibm_qp_runtime_args={},
232
+ transpiler_args={},
233
+ logging_level=None,
234
+ ) -> dict[str, int] | PrimitiveResult | None
235
+ ```
236
+
237
+ | Parameter | Description |
238
+ | ---------------------- | ----------------------------------------------------------------------------------- |
239
+ | `circuit` | Circuit returned by `geqie.encode` |
240
+ | `n_shots` | Number of shots |
241
+ | `circuit_param_values` | Values for parametrized circuits |
242
+ | `return_qiskit_result` | Return the raw Qiskit Runtime result instead of counts |
243
+ | `return_padded_counts` | Include zero-count states in the returned counts |
244
+ | `dry_run` | Set up the backend and transpile, but don't submit the job (returns `None`) |
245
+ | `api_token` | IBM Quantum API token (used with `instance_crn`) |
246
+ | `instance_crn` | IBM Quantum instance CRN |
247
+ | `credentials_name` | Name of saved `QiskitRuntimeService` credentials (alternative to `api_token`) |
248
+ | `backend` | Backend name; if empty, the least busy backend with enough qubits is selected |
249
+ | `channel` | Qiskit Runtime channel |
250
+ | `ibm_qp_runtime_args` | Extra keyword arguments for `QiskitRuntimeService` |
251
+ | `transpiler_args` | Extra keyword arguments for `qiskit.transpile` |
252
+ | `logging_level` | Logging level |
253
+
254
+ **Example**
255
+
256
+ ```python
257
+ counts = geqie.execute(circuit, n_shots=1024, credentials_name="my-ibm-credentials")
258
+ ```
259
+
260
+ ### `geqie.retrieve`
261
+
262
+ Reconstructs the image from measurement counts using the encoding's retrieve function.
263
+
264
+ ```python
265
+ geqie.retrieve(
266
+ retrieve_function, results,
267
+ image_dimensionality=2,
268
+ encoding_params={},
269
+ ) -> np.ndarray
270
+ ```
271
+
272
+ | Parameter | Description |
273
+ | ---------------------- | ------------------------------------------------------------------------------------ |
274
+ | `retrieve_function` | Encoding's `retrieve_function` (e.g., `frqi.retrieve_function`) |
275
+ | `results` | Measurement counts returned by `geqie.simulate` or `geqie.execute` |
276
+ | `image_dimensionality` | Number of spatial image dimensions (used by encodings that support it, e.g. `mfrqi`) |
277
+ | `encoding_params` | Extra keyword arguments passed to the retrieve function (e.g., `{"bitrate": 4}`) |
278
+
279
+ ## Examples
280
+
281
+ See the [`examples/`](../examples/) directory for notebooks covering individual encodings and CLI workflows.
282
+
283
+ ## CLI
284
+
285
+ ### `geqie list-encodings`
286
+
287
+ ```bash
288
+ geqie list-encodings
289
+ ```
290
+
291
+ ### `geqie simulate`
292
+
293
+ ```txt
294
+ Usage: geqie simulate [OPTIONS]
295
+
296
+ Options:
297
+ --encoding TEXT Name of the encoding from 'encodings'
298
+ directory [required]
299
+ --image-path TEXT Path to the image file [required]
300
+ --image-dimensionality INTEGER Number of image dimensions to consider
301
+ [default: 2]
302
+ --bitrate INTEGER Number of color bits for encodings that
303
+ support it [default: 8]
304
+ --verbosity-level TEXT Set verbosity level, 0-6 (higher means more
305
+ verbose)
306
+ --n-shots INTEGER Number of simulation shots
307
+ --return-qiskit-result BOOLEAN Return results directly from qiskit
308
+ [default: False]
309
+ --return-padded-counts BOOLEAN Return state counts including zero-count
310
+ states [default: False]
311
+ --output-path TEXT Path to where the results will be written
312
+ -e, --encoding-params KEY=VALUE
313
+ Arbitrary extra parameters as key=value
314
+ pairs. May be repeated, e.g.,
315
+ -e bitrate=4 -e custom_flag=true
316
+ --help Show this message and exit.
317
+ ```
318
+
319
+ **Example**
320
+
321
+ ```bash
322
+ geqie simulate --encoding frqi --image-path assets/test_image.png --n-shots 1024 --return-padded-counts true
323
+ ```
324
+
325
+ ### `geqie execute`
326
+
327
+ ```txt
328
+ Usage: geqie execute [OPTIONS]
329
+
330
+ Options:
331
+ --encoding TEXT Name of the encoding from 'encodings'
332
+ directory [required]
333
+ --image-path TEXT Path to the image file [required]
334
+ --image-dimensionality INTEGER Number of image dimensions to consider
335
+ [default: 2]
336
+ --bitrate INTEGER Number of color bits for encodings that
337
+ support it [default: 8]
338
+ --verbosity-level TEXT Set verbosity level, 0-6 (higher means more
339
+ verbose)
340
+ --n-shots INTEGER Number of simulation shots
341
+ --return-qiskit-result BOOLEAN Return results directly from qiskit
342
+ [default: False]
343
+ --return-padded-counts BOOLEAN Return state counts including zero-count
344
+ states [default: False]
345
+ --output-path TEXT Path to where the results will be written
346
+ -e, --encoding-params KEY=VALUE
347
+ Arbitrary extra parameters as key=value
348
+ pairs. May be repeated, e.g.,
349
+ -e bitrate=4 -e custom_flag=true
350
+ --help Show this message and exit.
351
+ ```
352
+
353
+ **Example**
354
+
355
+ ```bash
356
+ geqie execute --encoding frqi --image-path assets/test_image.png --n-shots 1024
357
+ ```
geqie-1.0.0/README.md ADDED
@@ -0,0 +1,246 @@
1
+ # geqie <!-- omit in toc -->
2
+
3
+ Core quantum image encoding library.
4
+
5
+ ## Table of contents <!-- omit in toc -->
6
+
7
+ - [API](#api)
8
+ - [Quick start](#quick-start)
9
+ - [Encodings](#encodings)
10
+ - [`geqie.encode`](#geqieencode)
11
+ - [`geqie.simulate`](#geqiesimulate)
12
+ - [`geqie.execute`](#geqieexecute)
13
+ - [`geqie.retrieve`](#geqieretrieve)
14
+ - [Examples](#examples)
15
+ - [CLI](#cli)
16
+ - [`geqie list-encodings`](#geqie-list-encodings)
17
+ - [`geqie simulate`](#geqie-simulate)
18
+ - [`geqie execute`](#geqie-execute)
19
+
20
+
21
+ ## API
22
+
23
+ ### Quick start
24
+
25
+ ```python
26
+ import numpy as np
27
+ from PIL import Image
28
+
29
+ import geqie
30
+ from geqie.encodings import frqi
31
+
32
+ image = np.asarray(Image.open("assets/test_images/grayscale/test_image_4x4.png"))
33
+
34
+ circuit = geqie.encode(frqi.init_function, frqi.data_function, frqi.map_function, image)
35
+ counts = geqie.simulate(circuit, n_shots=1024)
36
+ reconstructed = geqie.retrieve(frqi.retrieve_function, counts)
37
+ ```
38
+
39
+ ### Encodings
40
+
41
+ Each encoding lives in `geqie.encodings.<name>` (e.g., `frqi`, `neqr`, `mcqi`) and exposes:
42
+
43
+ | Function | Signature | Returns | Description |
44
+ | ------------------- | --------------------------------------------- | ------------- | --------------------------------------------------- |
45
+ | `init_function` | `(n_qubits, **encoding_params)` | `Statevector` | Initial state of the circuit |
46
+ | `data_function` | `(*coords, R, image, **encoding_params)` | `Statevector` | Data (pixel position) state for the given pixel |
47
+ | `map_function` | `(*coords, R, image, **encoding_params)` | `Operator` | Map (pixel value) operator for the given pixel |
48
+ | `retrieve_function` | `(results, **encoding_params)` | `np.ndarray` | Reconstructs the image from measurement counts |
49
+
50
+ `coords` are pixel indices (e.g., `u, v` for 2D images) and `R = ceil(log2(max(image.shape)))`. Custom encodings can be created by providing your own functions with the same signatures.
51
+
52
+ ### `geqie.encode`
53
+
54
+ Builds a quantum circuit encoding the image using the provided encoding functions.
55
+
56
+ ```python
57
+ geqie.encode(
58
+ init_function, data_function, map_function, image,
59
+ image_dimensionality=2,
60
+ perform_measurement=True,
61
+ logging_level=None,
62
+ encoding_params={},
63
+ ) -> QuantumCircuit
64
+ ```
65
+
66
+ | Parameter | Description |
67
+ | ---------------------- | ------------------------------------------------------------------------------------- |
68
+ | `init_function` | Function returning the initial `Statevector` |
69
+ | `data_function` | Function returning the data `Statevector` for a pixel |
70
+ | `map_function` | Function returning the map `Operator` for a pixel |
71
+ | `image` | Image as a NumPy array |
72
+ | `image_dimensionality` | Number of leading image axes treated as spatial coordinates (rest are e.g. channels) |
73
+ | `perform_measurement` | Append measurement of all qubits to the circuit |
74
+ | `logging_level` | Logging level (see `geqie.logging_utils.levels`) |
75
+ | `encoding_params` | Extra keyword arguments passed to the encoding functions (e.g., `{"bitrate": 4}`) |
76
+
77
+ ### `geqie.simulate`
78
+
79
+ Simulates the circuit locally with Qiskit Aer.
80
+
81
+ ```python
82
+ geqie.simulate(
83
+ circuit, n_shots,
84
+ return_qiskit_result=False,
85
+ return_padded_counts=False,
86
+ device="CPU",
87
+ method="automatic",
88
+ noise_model=None,
89
+ logging_level=None,
90
+ ) -> dict[str, int] | qiskit.result.Result
91
+ ```
92
+
93
+ | Parameter | Description |
94
+ | ---------------------- | ------------------------------------------------------------------- |
95
+ | `circuit` | Circuit returned by `geqie.encode` |
96
+ | `n_shots` | Number of simulation shots |
97
+ | `return_qiskit_result` | Return the raw Qiskit `Result` instead of counts |
98
+ | `return_padded_counts` | Include zero-count states in the returned counts |
99
+ | `device` | Aer simulator device (`"CPU"` or `"GPU"`) |
100
+ | `method` | Aer simulation method (e.g., `"automatic"`, `"statevector"`) |
101
+ | `noise_model` | Optional `qiskit_aer.noise.NoiseModel` |
102
+ | `logging_level` | Logging level |
103
+
104
+ ### `geqie.execute`
105
+
106
+ Executes the circuit on real hardware via IBM Quantum Platform (Qiskit Runtime `SamplerV2`).
107
+
108
+ ```python
109
+ geqie.execute(
110
+ circuit, n_shots,
111
+ circuit_param_values={},
112
+ return_qiskit_result=False,
113
+ return_padded_counts=False,
114
+ dry_run=False,
115
+ api_token="",
116
+ instance_crn="",
117
+ credentials_name="",
118
+ backend="",
119
+ channel="ibm_quantum_platform",
120
+ ibm_qp_runtime_args={},
121
+ transpiler_args={},
122
+ logging_level=None,
123
+ ) -> dict[str, int] | PrimitiveResult | None
124
+ ```
125
+
126
+ | Parameter | Description |
127
+ | ---------------------- | ----------------------------------------------------------------------------------- |
128
+ | `circuit` | Circuit returned by `geqie.encode` |
129
+ | `n_shots` | Number of shots |
130
+ | `circuit_param_values` | Values for parametrized circuits |
131
+ | `return_qiskit_result` | Return the raw Qiskit Runtime result instead of counts |
132
+ | `return_padded_counts` | Include zero-count states in the returned counts |
133
+ | `dry_run` | Set up the backend and transpile, but don't submit the job (returns `None`) |
134
+ | `api_token` | IBM Quantum API token (used with `instance_crn`) |
135
+ | `instance_crn` | IBM Quantum instance CRN |
136
+ | `credentials_name` | Name of saved `QiskitRuntimeService` credentials (alternative to `api_token`) |
137
+ | `backend` | Backend name; if empty, the least busy backend with enough qubits is selected |
138
+ | `channel` | Qiskit Runtime channel |
139
+ | `ibm_qp_runtime_args` | Extra keyword arguments for `QiskitRuntimeService` |
140
+ | `transpiler_args` | Extra keyword arguments for `qiskit.transpile` |
141
+ | `logging_level` | Logging level |
142
+
143
+ **Example**
144
+
145
+ ```python
146
+ counts = geqie.execute(circuit, n_shots=1024, credentials_name="my-ibm-credentials")
147
+ ```
148
+
149
+ ### `geqie.retrieve`
150
+
151
+ Reconstructs the image from measurement counts using the encoding's retrieve function.
152
+
153
+ ```python
154
+ geqie.retrieve(
155
+ retrieve_function, results,
156
+ image_dimensionality=2,
157
+ encoding_params={},
158
+ ) -> np.ndarray
159
+ ```
160
+
161
+ | Parameter | Description |
162
+ | ---------------------- | ------------------------------------------------------------------------------------ |
163
+ | `retrieve_function` | Encoding's `retrieve_function` (e.g., `frqi.retrieve_function`) |
164
+ | `results` | Measurement counts returned by `geqie.simulate` or `geqie.execute` |
165
+ | `image_dimensionality` | Number of spatial image dimensions (used by encodings that support it, e.g. `mfrqi`) |
166
+ | `encoding_params` | Extra keyword arguments passed to the retrieve function (e.g., `{"bitrate": 4}`) |
167
+
168
+ ## Examples
169
+
170
+ See the [`examples/`](../examples/) directory for notebooks covering individual encodings and CLI workflows.
171
+
172
+ ## CLI
173
+
174
+ ### `geqie list-encodings`
175
+
176
+ ```bash
177
+ geqie list-encodings
178
+ ```
179
+
180
+ ### `geqie simulate`
181
+
182
+ ```txt
183
+ Usage: geqie simulate [OPTIONS]
184
+
185
+ Options:
186
+ --encoding TEXT Name of the encoding from 'encodings'
187
+ directory [required]
188
+ --image-path TEXT Path to the image file [required]
189
+ --image-dimensionality INTEGER Number of image dimensions to consider
190
+ [default: 2]
191
+ --bitrate INTEGER Number of color bits for encodings that
192
+ support it [default: 8]
193
+ --verbosity-level TEXT Set verbosity level, 0-6 (higher means more
194
+ verbose)
195
+ --n-shots INTEGER Number of simulation shots
196
+ --return-qiskit-result BOOLEAN Return results directly from qiskit
197
+ [default: False]
198
+ --return-padded-counts BOOLEAN Return state counts including zero-count
199
+ states [default: False]
200
+ --output-path TEXT Path to where the results will be written
201
+ -e, --encoding-params KEY=VALUE
202
+ Arbitrary extra parameters as key=value
203
+ pairs. May be repeated, e.g.,
204
+ -e bitrate=4 -e custom_flag=true
205
+ --help Show this message and exit.
206
+ ```
207
+
208
+ **Example**
209
+
210
+ ```bash
211
+ geqie simulate --encoding frqi --image-path assets/test_image.png --n-shots 1024 --return-padded-counts true
212
+ ```
213
+
214
+ ### `geqie execute`
215
+
216
+ ```txt
217
+ Usage: geqie execute [OPTIONS]
218
+
219
+ Options:
220
+ --encoding TEXT Name of the encoding from 'encodings'
221
+ directory [required]
222
+ --image-path TEXT Path to the image file [required]
223
+ --image-dimensionality INTEGER Number of image dimensions to consider
224
+ [default: 2]
225
+ --bitrate INTEGER Number of color bits for encodings that
226
+ support it [default: 8]
227
+ --verbosity-level TEXT Set verbosity level, 0-6 (higher means more
228
+ verbose)
229
+ --n-shots INTEGER Number of simulation shots
230
+ --return-qiskit-result BOOLEAN Return results directly from qiskit
231
+ [default: False]
232
+ --return-padded-counts BOOLEAN Return state counts including zero-count
233
+ states [default: False]
234
+ --output-path TEXT Path to where the results will be written
235
+ -e, --encoding-params KEY=VALUE
236
+ Arbitrary extra parameters as key=value
237
+ pairs. May be repeated, e.g.,
238
+ -e bitrate=4 -e custom_flag=true
239
+ --help Show this message and exit.
240
+ ```
241
+
242
+ **Example**
243
+
244
+ ```bash
245
+ geqie execute --encoding frqi --image-path assets/test_image.png --n-shots 1024
246
+ ```
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "geqie"
3
+ version = "1.0.0"
4
+ description = "General Equation of Quantum Image Encoding Framework"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = {text = "Apache-2.0"}
8
+ dynamic = ["dependencies", "optional-dependencies"]
9
+
10
+ [build-system]
11
+ requires = ["setuptools>=68", "wheel"]
12
+ build-backend = "setuptools.build_meta"
13
+
14
+ [tool.setuptools.dynamic]
15
+ dependencies = {file = ["./requirements/requirements.txt"]}
16
+ optional-dependencies.dev = {file = ["./requirements/requirements_dev.txt"]}
17
+
18
+ [tool.setuptools]
19
+ package-dir = {"" = "src"}
20
+
21
+ [tool.setuptools.packages.find]
22
+ where = ["src"]
23
+ exclude = ["tests*"]
24
+
25
+ [project.scripts]
26
+ geqie = "geqie.cli:cli"