classiq 0.39.0__py3-none-any.whl → 0.41.0__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.
- classiq/__init__.py +5 -2
- classiq/_internals/api_wrapper.py +3 -21
- classiq/applications/chemistry/chemistry_model_constructor.py +87 -101
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +7 -26
- classiq/applications/combinatorial_helpers/optimization_model.py +7 -6
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +33 -55
- classiq/applications/combinatorial_optimization/__init__.py +4 -0
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +29 -26
- classiq/applications/finance/finance_model_constructor.py +23 -26
- classiq/applications/grover/grover_model_constructor.py +37 -38
- classiq/applications/qsvm/qsvm.py +1 -2
- classiq/applications/qsvm/qsvm_model_constructor.py +15 -16
- classiq/execution/__init__.py +4 -0
- classiq/execution/execution_session.py +151 -0
- classiq/execution/qnn.py +80 -0
- classiq/executor.py +2 -109
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +11 -0
- classiq/interface/applications/qsvm.py +0 -8
- classiq/interface/ast_node.py +12 -2
- classiq/interface/backend/backend_preferences.py +30 -6
- classiq/interface/backend/quantum_backend_providers.py +11 -11
- classiq/interface/executor/execution_preferences.py +7 -67
- classiq/interface/executor/execution_result.py +22 -1
- classiq/interface/generator/application_apis/chemistry_declarations.py +2 -4
- classiq/interface/generator/application_apis/finance_declarations.py +1 -1
- classiq/interface/generator/arith/binary_ops.py +88 -25
- classiq/interface/generator/arith/unary_ops.py +28 -19
- classiq/interface/generator/expressions/atomic_expression_functions.py +6 -2
- classiq/interface/generator/expressions/enums/__init__.py +10 -0
- classiq/interface/generator/expressions/enums/classical_enum.py +5 -1
- classiq/interface/generator/expressions/expression.py +9 -2
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +89 -0
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +20 -0
- classiq/interface/generator/expressions/qmod_sized_proxy.py +22 -0
- classiq/interface/generator/expressions/sympy_supported_expressions.py +10 -1
- classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +8 -6
- classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +10 -4
- classiq/interface/generator/functions/builtins/internal_operators.py +7 -62
- classiq/interface/generator/functions/builtins/open_lib_functions.py +1627 -271
- classiq/interface/generator/functions/classical_type.py +27 -17
- classiq/interface/generator/model/preferences/preferences.py +4 -2
- classiq/interface/generator/synthesis_metadata/synthesis_duration.py +0 -4
- classiq/interface/model/bind_operation.py +3 -1
- classiq/interface/model/call_synthesis_data.py +2 -13
- classiq/interface/model/classical_if.py +3 -1
- classiq/interface/model/classical_parameter_declaration.py +13 -0
- classiq/interface/model/control.py +6 -8
- classiq/interface/model/inplace_binary_operation.py +3 -1
- classiq/interface/model/invert.py +3 -1
- classiq/interface/model/port_declaration.py +8 -1
- classiq/interface/model/power.py +3 -1
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +4 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -1
- classiq/interface/model/quantum_expressions/quantum_expression.py +11 -1
- classiq/interface/model/quantum_function_call.py +4 -10
- classiq/interface/model/quantum_function_declaration.py +26 -4
- classiq/interface/model/quantum_lambda_function.py +1 -20
- classiq/interface/model/quantum_statement.py +9 -2
- classiq/interface/model/quantum_type.py +6 -5
- classiq/interface/model/repeat.py +3 -1
- classiq/interface/model/resolvers/function_call_resolver.py +0 -5
- classiq/interface/model/statement_block.py +19 -16
- classiq/interface/model/validations/handles_validator.py +8 -2
- classiq/interface/model/variable_declaration_statement.py +3 -1
- classiq/interface/model/within_apply_operation.py +3 -1
- classiq/interface/server/routes.py +0 -5
- classiq/qmod/__init__.py +5 -2
- classiq/qmod/builtins/classical_execution_primitives.py +22 -2
- classiq/qmod/builtins/classical_functions.py +30 -35
- classiq/qmod/builtins/functions.py +263 -153
- classiq/qmod/builtins/operations.py +50 -26
- classiq/qmod/builtins/structs.py +50 -48
- classiq/qmod/declaration_inferrer.py +32 -27
- classiq/qmod/native/__init__.py +9 -0
- classiq/qmod/native/expression_to_qmod.py +8 -4
- classiq/qmod/native/pretty_printer.py +11 -18
- classiq/qmod/pretty_print/__init__.py +9 -0
- classiq/qmod/pretty_print/expression_to_python.py +221 -0
- classiq/qmod/pretty_print/pretty_printer.py +421 -0
- classiq/qmod/qmod_constant.py +7 -7
- classiq/qmod/qmod_parameter.py +57 -33
- classiq/qmod/qmod_struct.py +2 -2
- classiq/qmod/qmod_variable.py +40 -29
- classiq/qmod/quantum_callable.py +8 -4
- classiq/qmod/quantum_expandable.py +22 -15
- classiq/qmod/quantum_function.py +15 -4
- classiq/qmod/symbolic.py +73 -68
- classiq/qmod/symbolic_expr.py +1 -1
- classiq/qmod/symbolic_type.py +1 -4
- classiq/qmod/utilities.py +29 -0
- classiq/synthesis.py +15 -16
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/METADATA +5 -4
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/RECORD +95 -94
- classiq/interface/executor/error_mitigation.py +0 -6
- classiq/interface/generator/functions/builtins/core_library/chemistry_functions.py +0 -0
- classiq/interface/model/common_model_types.py +0 -23
- classiq/interface/model/quantum_expressions/control_state.py +0 -38
- classiq/interface/model/quantum_if_operation.py +0 -94
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/WHEEL +0 -0
classiq/qmod/symbolic.py
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
import sys
|
2
|
-
from typing import
|
2
|
+
from typing import (
|
3
|
+
TYPE_CHECKING,
|
4
|
+
Any,
|
5
|
+
List,
|
6
|
+
Optional,
|
7
|
+
Tuple,
|
8
|
+
Type,
|
9
|
+
TypeVar,
|
10
|
+
overload,
|
11
|
+
)
|
3
12
|
|
4
13
|
from classiq.exceptions import ClassiqValueError
|
5
14
|
from classiq.qmod import model_state_container
|
6
15
|
from classiq.qmod.declaration_inferrer import python_type_to_qmod
|
7
|
-
from classiq.qmod.qmod_parameter import
|
16
|
+
from classiq.qmod.qmod_parameter import CParam, CParamScalar, create_param
|
8
17
|
from classiq.qmod.symbolic_expr import SymbolicExpr
|
9
18
|
from classiq.qmod.symbolic_type import SymbolicTypes
|
10
19
|
|
@@ -15,20 +24,18 @@ GoldenRatio = SymbolicExpr("GoldenRatio")
|
|
15
24
|
EulerGamma = SymbolicExpr("EulerGamma")
|
16
25
|
Catalan = SymbolicExpr("Catalan")
|
17
26
|
|
27
|
+
T = TypeVar("T", bound=CParam)
|
28
|
+
|
18
29
|
|
19
30
|
@overload
|
20
|
-
def symbolic_function(
|
21
|
-
*args: SymbolicTypes, return_type: None = None
|
22
|
-
) -> QParamScalar: ...
|
31
|
+
def symbolic_function(*args: Any, return_type: None = None) -> CParamScalar: ...
|
23
32
|
|
24
33
|
|
25
34
|
@overload
|
26
|
-
def symbolic_function(*args:
|
35
|
+
def symbolic_function(*args: Any, return_type: Type[T]) -> T: ...
|
27
36
|
|
28
37
|
|
29
|
-
def symbolic_function(
|
30
|
-
*args: SymbolicTypes, return_type: Optional[Type[QParam]] = None
|
31
|
-
) -> QParam:
|
38
|
+
def symbolic_function(*args: Any, return_type: Optional[Type[T]] = None) -> CParam:
|
32
39
|
qmodule = (
|
33
40
|
model_state_container.QMODULE
|
34
41
|
) # FIXME: https://classiq.atlassian.net/browse/CAD-15126
|
@@ -36,14 +43,12 @@ def symbolic_function(
|
|
36
43
|
expr = f"{sys._getframe(1).f_code.co_name}({','.join(str_args)})"
|
37
44
|
|
38
45
|
if return_type is None:
|
39
|
-
return
|
46
|
+
return CParamScalar(expr)
|
40
47
|
|
41
|
-
if
|
42
|
-
|
43
|
-
f"Unsupported return type for symbolic function: {return_type}"
|
44
|
-
)
|
48
|
+
if TYPE_CHECKING:
|
49
|
+
assert return_type is not None
|
45
50
|
|
46
|
-
qmod_type = python_type_to_qmod(
|
51
|
+
qmod_type = python_type_to_qmod(return_type, qmodule=qmodule)
|
47
52
|
if qmod_type is None:
|
48
53
|
raise ClassiqValueError(
|
49
54
|
f"Unsupported return type for symbolic function: {return_type}"
|
@@ -56,211 +61,211 @@ def symbolic_function(
|
|
56
61
|
)
|
57
62
|
|
58
63
|
|
59
|
-
def sin(x: SymbolicTypes) ->
|
64
|
+
def sin(x: SymbolicTypes) -> CParamScalar:
|
60
65
|
return symbolic_function(x)
|
61
66
|
|
62
67
|
|
63
|
-
def cos(x: SymbolicTypes) ->
|
68
|
+
def cos(x: SymbolicTypes) -> CParamScalar:
|
64
69
|
return symbolic_function(x)
|
65
70
|
|
66
71
|
|
67
|
-
def tan(x: SymbolicTypes) ->
|
72
|
+
def tan(x: SymbolicTypes) -> CParamScalar:
|
68
73
|
return symbolic_function(x)
|
69
74
|
|
70
75
|
|
71
|
-
def cot(x: SymbolicTypes) ->
|
76
|
+
def cot(x: SymbolicTypes) -> CParamScalar:
|
72
77
|
return symbolic_function(x)
|
73
78
|
|
74
79
|
|
75
|
-
def sec(x: SymbolicTypes) ->
|
80
|
+
def sec(x: SymbolicTypes) -> CParamScalar:
|
76
81
|
return symbolic_function(x)
|
77
82
|
|
78
83
|
|
79
|
-
def csc(x: SymbolicTypes) ->
|
84
|
+
def csc(x: SymbolicTypes) -> CParamScalar:
|
80
85
|
return symbolic_function(x)
|
81
86
|
|
82
87
|
|
83
|
-
def asin(x: SymbolicTypes) ->
|
88
|
+
def asin(x: SymbolicTypes) -> CParamScalar:
|
84
89
|
return symbolic_function(x)
|
85
90
|
|
86
91
|
|
87
|
-
def acos(x: SymbolicTypes) ->
|
92
|
+
def acos(x: SymbolicTypes) -> CParamScalar:
|
88
93
|
return symbolic_function(x)
|
89
94
|
|
90
95
|
|
91
|
-
def atan(x: SymbolicTypes) ->
|
96
|
+
def atan(x: SymbolicTypes) -> CParamScalar:
|
92
97
|
return symbolic_function(x)
|
93
98
|
|
94
99
|
|
95
|
-
def acot(x: SymbolicTypes) ->
|
100
|
+
def acot(x: SymbolicTypes) -> CParamScalar:
|
96
101
|
return symbolic_function(x)
|
97
102
|
|
98
103
|
|
99
|
-
def asec(x: SymbolicTypes) ->
|
104
|
+
def asec(x: SymbolicTypes) -> CParamScalar:
|
100
105
|
return symbolic_function(x)
|
101
106
|
|
102
107
|
|
103
|
-
def acsc(x: SymbolicTypes) ->
|
108
|
+
def acsc(x: SymbolicTypes) -> CParamScalar:
|
104
109
|
return symbolic_function(x)
|
105
110
|
|
106
111
|
|
107
|
-
def sinh(x: SymbolicTypes) ->
|
112
|
+
def sinh(x: SymbolicTypes) -> CParamScalar:
|
108
113
|
return symbolic_function(x)
|
109
114
|
|
110
115
|
|
111
|
-
def cosh(x: SymbolicTypes) ->
|
116
|
+
def cosh(x: SymbolicTypes) -> CParamScalar:
|
112
117
|
return symbolic_function(x)
|
113
118
|
|
114
119
|
|
115
|
-
def tanh(x: SymbolicTypes) ->
|
120
|
+
def tanh(x: SymbolicTypes) -> CParamScalar:
|
116
121
|
return symbolic_function(x)
|
117
122
|
|
118
123
|
|
119
|
-
def coth(x: SymbolicTypes) ->
|
124
|
+
def coth(x: SymbolicTypes) -> CParamScalar:
|
120
125
|
return symbolic_function(x)
|
121
126
|
|
122
127
|
|
123
|
-
def sech(x: SymbolicTypes) ->
|
128
|
+
def sech(x: SymbolicTypes) -> CParamScalar:
|
124
129
|
return symbolic_function(x)
|
125
130
|
|
126
131
|
|
127
|
-
def csch(x: SymbolicTypes) ->
|
132
|
+
def csch(x: SymbolicTypes) -> CParamScalar:
|
128
133
|
return symbolic_function(x)
|
129
134
|
|
130
135
|
|
131
|
-
def asinh(x: SymbolicTypes) ->
|
136
|
+
def asinh(x: SymbolicTypes) -> CParamScalar:
|
132
137
|
return symbolic_function(x)
|
133
138
|
|
134
139
|
|
135
|
-
def acosh(x: SymbolicTypes) ->
|
140
|
+
def acosh(x: SymbolicTypes) -> CParamScalar:
|
136
141
|
return symbolic_function(x)
|
137
142
|
|
138
143
|
|
139
|
-
def atanh(x: SymbolicTypes) ->
|
144
|
+
def atanh(x: SymbolicTypes) -> CParamScalar:
|
140
145
|
return symbolic_function(x)
|
141
146
|
|
142
147
|
|
143
|
-
def acoth(x: SymbolicTypes) ->
|
148
|
+
def acoth(x: SymbolicTypes) -> CParamScalar:
|
144
149
|
return symbolic_function(x)
|
145
150
|
|
146
151
|
|
147
|
-
def asech(x: SymbolicTypes) ->
|
152
|
+
def asech(x: SymbolicTypes) -> CParamScalar:
|
148
153
|
return symbolic_function(x)
|
149
154
|
|
150
155
|
|
151
|
-
def exp(x: SymbolicTypes) ->
|
156
|
+
def exp(x: SymbolicTypes) -> CParamScalar:
|
152
157
|
return symbolic_function(x)
|
153
158
|
|
154
159
|
|
155
|
-
def log(x: SymbolicTypes, base: SymbolicTypes = E) ->
|
160
|
+
def log(x: SymbolicTypes, base: SymbolicTypes = E) -> CParamScalar:
|
156
161
|
return symbolic_function(x, base)
|
157
162
|
|
158
163
|
|
159
|
-
def ln(x: SymbolicTypes) ->
|
164
|
+
def ln(x: SymbolicTypes) -> CParamScalar:
|
160
165
|
return symbolic_function(x)
|
161
166
|
|
162
167
|
|
163
|
-
def sqrt(x: SymbolicTypes) ->
|
168
|
+
def sqrt(x: SymbolicTypes) -> CParamScalar:
|
164
169
|
return symbolic_function(x)
|
165
170
|
|
166
171
|
|
167
|
-
def abs(x: SymbolicTypes) ->
|
172
|
+
def abs(x: SymbolicTypes) -> CParamScalar:
|
168
173
|
return symbolic_function(x)
|
169
174
|
|
170
175
|
|
171
|
-
def floor(x: SymbolicTypes) ->
|
176
|
+
def floor(x: SymbolicTypes) -> CParamScalar:
|
172
177
|
return symbolic_function(x)
|
173
178
|
|
174
179
|
|
175
|
-
def ceiling(x: SymbolicTypes) ->
|
180
|
+
def ceiling(x: SymbolicTypes) -> CParamScalar:
|
176
181
|
return symbolic_function(x)
|
177
182
|
|
178
183
|
|
179
|
-
def erf(x: SymbolicTypes) ->
|
184
|
+
def erf(x: SymbolicTypes) -> CParamScalar:
|
180
185
|
return symbolic_function(x)
|
181
186
|
|
182
187
|
|
183
|
-
def erfc(x: SymbolicTypes) ->
|
188
|
+
def erfc(x: SymbolicTypes) -> CParamScalar:
|
184
189
|
return symbolic_function(x)
|
185
190
|
|
186
191
|
|
187
|
-
def gamma(x: SymbolicTypes) ->
|
192
|
+
def gamma(x: SymbolicTypes) -> CParamScalar:
|
188
193
|
return symbolic_function(x)
|
189
194
|
|
190
195
|
|
191
|
-
def beta(x: SymbolicTypes) ->
|
196
|
+
def beta(x: SymbolicTypes) -> CParamScalar:
|
192
197
|
return symbolic_function(x)
|
193
198
|
|
194
199
|
|
195
|
-
def besselj(x: SymbolicTypes) ->
|
200
|
+
def besselj(x: SymbolicTypes) -> CParamScalar:
|
196
201
|
return symbolic_function(x)
|
197
202
|
|
198
203
|
|
199
|
-
def bessely(x: SymbolicTypes) ->
|
204
|
+
def bessely(x: SymbolicTypes) -> CParamScalar:
|
200
205
|
return symbolic_function(x)
|
201
206
|
|
202
207
|
|
203
|
-
def besseli(x: SymbolicTypes) ->
|
208
|
+
def besseli(x: SymbolicTypes) -> CParamScalar:
|
204
209
|
return symbolic_function(x)
|
205
210
|
|
206
211
|
|
207
|
-
def besselk(x: SymbolicTypes) ->
|
212
|
+
def besselk(x: SymbolicTypes) -> CParamScalar:
|
208
213
|
return symbolic_function(x)
|
209
214
|
|
210
215
|
|
211
|
-
def dirichlet_eta(x: SymbolicTypes) ->
|
216
|
+
def dirichlet_eta(x: SymbolicTypes) -> CParamScalar:
|
212
217
|
return symbolic_function(x)
|
213
218
|
|
214
219
|
|
215
|
-
def polygamma(x: SymbolicTypes) ->
|
220
|
+
def polygamma(x: SymbolicTypes) -> CParamScalar:
|
216
221
|
return symbolic_function(x)
|
217
222
|
|
218
223
|
|
219
|
-
def loggamma(x: SymbolicTypes) ->
|
224
|
+
def loggamma(x: SymbolicTypes) -> CParamScalar:
|
220
225
|
return symbolic_function(x)
|
221
226
|
|
222
227
|
|
223
|
-
def factorial(x: SymbolicTypes) ->
|
228
|
+
def factorial(x: SymbolicTypes) -> CParamScalar:
|
224
229
|
return symbolic_function(x)
|
225
230
|
|
226
231
|
|
227
|
-
def binomial(x: SymbolicTypes) ->
|
232
|
+
def binomial(x: SymbolicTypes) -> CParamScalar:
|
228
233
|
return symbolic_function(x)
|
229
234
|
|
230
235
|
|
231
|
-
def subfactorial(x: SymbolicTypes) ->
|
236
|
+
def subfactorial(x: SymbolicTypes) -> CParamScalar:
|
232
237
|
return symbolic_function(x)
|
233
238
|
|
234
239
|
|
235
|
-
def primorial(x: SymbolicTypes) ->
|
240
|
+
def primorial(x: SymbolicTypes) -> CParamScalar:
|
236
241
|
return symbolic_function(x)
|
237
242
|
|
238
243
|
|
239
|
-
def bell(x: SymbolicTypes) ->
|
244
|
+
def bell(x: SymbolicTypes) -> CParamScalar:
|
240
245
|
return symbolic_function(x)
|
241
246
|
|
242
247
|
|
243
|
-
def bernoulli(x: SymbolicTypes) ->
|
248
|
+
def bernoulli(x: SymbolicTypes) -> CParamScalar:
|
244
249
|
return symbolic_function(x)
|
245
250
|
|
246
251
|
|
247
|
-
def euler(x: SymbolicTypes) ->
|
252
|
+
def euler(x: SymbolicTypes) -> CParamScalar:
|
248
253
|
return symbolic_function(x)
|
249
254
|
|
250
255
|
|
251
|
-
def catalan(x: SymbolicTypes) ->
|
256
|
+
def catalan(x: SymbolicTypes) -> CParamScalar:
|
252
257
|
return symbolic_function(x)
|
253
258
|
|
254
259
|
|
255
|
-
def Piecewise(*args: Tuple[SymbolicTypes, SymbolicTypes]) ->
|
260
|
+
def Piecewise(*args: Tuple[SymbolicTypes, SymbolicTypes]) -> CParamScalar: # noqa: N802
|
256
261
|
return symbolic_function(*args)
|
257
262
|
|
258
263
|
|
259
|
-
def max(x: SymbolicTypes, y: SymbolicTypes) ->
|
264
|
+
def max(x: SymbolicTypes, y: SymbolicTypes) -> CParamScalar:
|
260
265
|
return symbolic_function(x, y)
|
261
266
|
|
262
267
|
|
263
|
-
def min(x: SymbolicTypes, y: SymbolicTypes) ->
|
268
|
+
def min(x: SymbolicTypes, y: SymbolicTypes) -> CParamScalar:
|
264
269
|
return symbolic_function(x, y)
|
265
270
|
|
266
271
|
|
@@ -276,7 +281,7 @@ def logical_not(x: SymbolicTypes) -> SymbolicExpr:
|
|
276
281
|
return SymbolicExpr._unary_op(x, "not")
|
277
282
|
|
278
283
|
|
279
|
-
def mod_inverse(a: SymbolicTypes, m: SymbolicTypes) ->
|
284
|
+
def mod_inverse(a: SymbolicTypes, m: SymbolicTypes) -> CParamScalar:
|
280
285
|
return symbolic_function(a, m)
|
281
286
|
|
282
287
|
|
classiq/qmod/symbolic_expr.py
CHANGED
classiq/qmod/symbolic_type.py
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
from typing import Tuple, Union
|
2
2
|
|
3
|
-
from classiq.qmod.qmod_parameter import QParam
|
4
3
|
from classiq.qmod.symbolic_expr import SymbolicExpr
|
5
4
|
|
6
|
-
SymbolicTypes = Union[
|
7
|
-
QParam, SymbolicExpr, int, float, bool, Tuple["SymbolicTypes", ...]
|
8
|
-
]
|
5
|
+
SymbolicTypes = Union[SymbolicExpr, int, float, bool, Tuple["SymbolicTypes", ...]]
|
classiq/qmod/utilities.py
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
import inspect
|
2
|
+
import itertools
|
1
3
|
import keyword
|
2
4
|
import sys
|
5
|
+
from types import FrameType
|
3
6
|
from typing import get_args, get_origin
|
4
7
|
|
8
|
+
from classiq.interface.ast_node import SourceReference
|
9
|
+
|
5
10
|
DEFAULT_DECIMAL_PRECISION = 4
|
6
11
|
|
7
12
|
|
@@ -25,3 +30,27 @@ def version_portable_get_args(py_type: type) -> tuple:
|
|
25
30
|
return get_args(py_type) # The result of __class_getitem__
|
26
31
|
else:
|
27
32
|
return get_args(py_type)[0]
|
33
|
+
|
34
|
+
|
35
|
+
def get_source_ref(frame: FrameType) -> SourceReference:
|
36
|
+
filename = inspect.getfile(frame)
|
37
|
+
lineno = frame.f_lineno
|
38
|
+
if sys.version_info[0:2] < (3, 11) or frame.f_lasti < 0:
|
39
|
+
source_ref = SourceReference(
|
40
|
+
file_name=filename,
|
41
|
+
start_line=lineno,
|
42
|
+
start_column=-1,
|
43
|
+
end_line=-1,
|
44
|
+
end_column=-1,
|
45
|
+
)
|
46
|
+
else:
|
47
|
+
positions_gen = frame.f_code.co_positions()
|
48
|
+
positions = next(itertools.islice(positions_gen, frame.f_lasti // 2, None))
|
49
|
+
source_ref = SourceReference(
|
50
|
+
file_name=filename,
|
51
|
+
start_line=positions[0],
|
52
|
+
start_column=positions[2],
|
53
|
+
end_line=positions[1],
|
54
|
+
end_column=positions[3],
|
55
|
+
)
|
56
|
+
return source_ref
|
classiq/synthesis.py
CHANGED
@@ -5,8 +5,7 @@ import pydantic
|
|
5
5
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
6
6
|
from classiq.interface.generator.model.constraints import Constraints
|
7
7
|
from classiq.interface.generator.model.preferences.preferences import Preferences
|
8
|
-
from classiq.interface.model.
|
9
|
-
from classiq.interface.model.model import SerializedModel
|
8
|
+
from classiq.interface.model.model import Model, SerializedModel
|
10
9
|
|
11
10
|
from classiq._internals.api_wrapper import ApiWrapper
|
12
11
|
from classiq._internals.async_utils import syncify_function
|
@@ -15,9 +14,9 @@ SerializedQuantumProgram = NewType("SerializedQuantumProgram", str)
|
|
15
14
|
|
16
15
|
|
17
16
|
async def synthesize_async(
|
18
|
-
serialized_model:
|
17
|
+
serialized_model: SerializedModel,
|
19
18
|
) -> SerializedQuantumProgram:
|
20
|
-
model
|
19
|
+
model = pydantic.parse_raw_as(Model, serialized_model)
|
21
20
|
quantum_program = await ApiWrapper.call_generation_task(model)
|
22
21
|
return SerializedQuantumProgram(quantum_program.json(indent=2))
|
23
22
|
|
@@ -26,27 +25,27 @@ synthesize = syncify_function(synthesize_async)
|
|
26
25
|
|
27
26
|
|
28
27
|
def set_preferences(
|
29
|
-
serialized_model:
|
30
|
-
) ->
|
31
|
-
model
|
28
|
+
serialized_model: SerializedModel, preferences: Preferences
|
29
|
+
) -> SerializedModel:
|
30
|
+
model = pydantic.parse_raw_as(Model, serialized_model)
|
32
31
|
model.preferences = preferences
|
33
|
-
return model.get_model()
|
32
|
+
return model.get_model()
|
34
33
|
|
35
34
|
|
36
35
|
def set_constraints(
|
37
|
-
serialized_model:
|
38
|
-
) ->
|
39
|
-
model
|
36
|
+
serialized_model: SerializedModel, constraints: Constraints
|
37
|
+
) -> SerializedModel:
|
38
|
+
model = pydantic.parse_raw_as(Model, serialized_model)
|
40
39
|
model.constraints = constraints
|
41
|
-
return model.get_model()
|
40
|
+
return model.get_model()
|
42
41
|
|
43
42
|
|
44
43
|
def set_execution_preferences(
|
45
|
-
serialized_model:
|
46
|
-
) ->
|
47
|
-
model
|
44
|
+
serialized_model: SerializedModel, execution_preferences: ExecutionPreferences
|
45
|
+
) -> SerializedModel:
|
46
|
+
model = pydantic.parse_raw_as(Model, serialized_model)
|
48
47
|
model.execution_preferences = execution_preferences
|
49
|
-
return model.get_model()
|
48
|
+
return model.get_model()
|
50
49
|
|
51
50
|
|
52
51
|
__all__ = [
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: classiq
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.41.0
|
4
4
|
Summary: Classiq's Python SDK for quantum computing
|
5
5
|
Home-page: https://classiq.io
|
6
6
|
License: Proprietary
|
@@ -31,6 +31,7 @@ Provides-Extra: analyzer-sdk
|
|
31
31
|
Provides-Extra: qml
|
32
32
|
Requires-Dist: ConfigArgParse (>=1.5.3,<2.0.0)
|
33
33
|
Requires-Dist: Pyomo (>=6.5,<6.6)
|
34
|
+
Requires-Dist: black (>=24.0,<25.0)
|
34
35
|
Requires-Dist: httpx (>=0.23.0,<1)
|
35
36
|
Requires-Dist: ipywidgets (>=7.7.1,<8.0.0) ; extra == "analyzer-sdk"
|
36
37
|
Requires-Dist: keyring (>=23.5.0,<24.0.0)
|
@@ -38,11 +39,11 @@ Requires-Dist: matplotlib (>=3.4.3,<4.0.0)
|
|
38
39
|
Requires-Dist: networkx (>=2.5.1,<3.0.0)
|
39
40
|
Requires-Dist: numexpr (>=2.7.3,<3.0.0)
|
40
41
|
Requires-Dist: numpy (>=1.20.1,<2.0.0)
|
41
|
-
Requires-Dist: packaging (>=
|
42
|
-
Requires-Dist: pandas (>=1.4.0,<
|
42
|
+
Requires-Dist: packaging (>=22.0,<23.0)
|
43
|
+
Requires-Dist: pandas (>=1.4.0,<3.0.0)
|
43
44
|
Requires-Dist: plotly (>=5.7.0,<6.0.0)
|
44
45
|
Requires-Dist: pydantic (>=1.9.1,<2.0.0)
|
45
|
-
Requires-Dist: scipy (
|
46
|
+
Requires-Dist: scipy (>=1.10.1,<2.0.0)
|
46
47
|
Requires-Dist: sympy (>=1.9.0,<1.11.0)
|
47
48
|
Requires-Dist: tabulate (>=0.8.9,<1)
|
48
49
|
Requires-Dist: torch (>=2.0,<3.0) ; extra == "qml"
|