classiq 0.84.0__py3-none-any.whl → 0.85.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/applications/combinatorial_optimization/combinatorial_problem.py +20 -42
- classiq/evaluators/classical_expression.py +32 -15
- classiq/execution/execution_session.py +49 -6
- classiq/interface/_version.py +1 -1
- classiq/interface/debug_info/debug_info.py +0 -4
- classiq/interface/generator/expressions/atomic_expression_functions.py +5 -0
- classiq/interface/generator/functions/builtins/internal_operators.py +2 -0
- classiq/interface/generator/functions/concrete_types.py +20 -0
- classiq/interface/generator/generated_circuit_data.py +5 -10
- classiq/interface/ide/operation_registry.py +45 -0
- classiq/interface/ide/visual_model.py +62 -1
- classiq/interface/model/bounds.py +12 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +7 -4
- classiq/interface/model/variable_declaration_statement.py +33 -6
- classiq/model_expansions/atomic_expression_functions_defs.py +5 -1
- classiq/model_expansions/function_builder.py +4 -1
- classiq/model_expansions/interpreters/generative_interpreter.py +16 -1
- classiq/model_expansions/quantum_operations/assignment_result_processor.py +63 -21
- classiq/model_expansions/quantum_operations/bounds.py +7 -1
- classiq/model_expansions/quantum_operations/classical_var_emitter.py +16 -0
- classiq/model_expansions/quantum_operations/variable_decleration.py +30 -10
- classiq/model_expansions/scope.py +7 -0
- classiq/model_expansions/transformers/var_splitter.py +1 -1
- classiq/open_library/functions/__init__.py +0 -2
- classiq/open_library/functions/qaoa_penalty.py +8 -1
- classiq/open_library/functions/state_preparation.py +1 -32
- classiq/qmod/__init__.py +2 -0
- classiq/qmod/builtins/operations.py +65 -1
- classiq/qmod/classical_variable.py +74 -0
- classiq/qmod/native/pretty_printer.py +18 -14
- classiq/qmod/pretty_print/pretty_printer.py +34 -15
- classiq/qmod/qfunc.py +2 -19
- classiq/qmod/qmod_variable.py +5 -8
- classiq/qmod/quantum_expandable.py +1 -1
- classiq/qmod/quantum_function.py +42 -2
- classiq/qmod/symbolic_type.py +2 -1
- {classiq-0.84.0.dist-info → classiq-0.85.0.dist-info}/METADATA +1 -1
- {classiq-0.84.0.dist-info → classiq-0.85.0.dist-info}/RECORD +39 -37
- classiq/interface/model/quantum_variable_declaration.py +0 -7
- {classiq-0.84.0.dist-info → classiq-0.85.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
import sys
|
2
|
+
from typing import TYPE_CHECKING, Any
|
3
|
+
|
4
|
+
from classiq.interface.exceptions import ClassiqInternalError
|
5
|
+
from classiq.interface.generator.expressions.expression import Expression
|
6
|
+
from classiq.interface.generator.functions.classical_type import Bool, ClassicalType
|
7
|
+
from classiq.interface.model.handle_binding import HandleBinding
|
8
|
+
from classiq.interface.model.quantum_expressions.arithmetic_operation import (
|
9
|
+
ArithmeticOperation,
|
10
|
+
ArithmeticOperationKind,
|
11
|
+
)
|
12
|
+
from classiq.interface.model.variable_declaration_statement import (
|
13
|
+
VariableDeclarationStatement,
|
14
|
+
)
|
15
|
+
|
16
|
+
from classiq.qmod.cparam import CBool, CParam, CParamScalar
|
17
|
+
from classiq.qmod.qmod_variable import QBit, _infer_variable_name
|
18
|
+
from classiq.qmod.quantum_callable import QCallable
|
19
|
+
from classiq.qmod.symbolic import symbolic_function
|
20
|
+
from classiq.qmod.symbolic_type import SYMBOLIC_TYPES
|
21
|
+
from classiq.qmod.utilities import get_source_ref
|
22
|
+
|
23
|
+
|
24
|
+
def declare_classical_variable(
|
25
|
+
name: str, classical_type: ClassicalType, frame_depth: int
|
26
|
+
) -> None:
|
27
|
+
if TYPE_CHECKING:
|
28
|
+
assert QCallable.CURRENT_EXPANDABLE is not None
|
29
|
+
QCallable.CURRENT_EXPANDABLE.append_statement_to_body(
|
30
|
+
VariableDeclarationStatement(
|
31
|
+
name=name,
|
32
|
+
qmod_type=classical_type,
|
33
|
+
source_ref=get_source_ref(sys._getframe(frame_depth)),
|
34
|
+
)
|
35
|
+
)
|
36
|
+
|
37
|
+
|
38
|
+
def assign_classical_variable(target: CParam, value: Any, frame_depth: int) -> None:
|
39
|
+
if not isinstance(value, SYMBOLIC_TYPES):
|
40
|
+
raise TypeError(f"Invalid argument {value!r} for classical variable assignment")
|
41
|
+
|
42
|
+
if TYPE_CHECKING:
|
43
|
+
assert QCallable.CURRENT_EXPANDABLE is not None
|
44
|
+
QCallable.CURRENT_EXPANDABLE.append_statement_to_body(
|
45
|
+
ArithmeticOperation(
|
46
|
+
expression=Expression(expr=str(value)),
|
47
|
+
result_var=HandleBinding(name=str(target)),
|
48
|
+
operation_kind=ArithmeticOperationKind.Assignment,
|
49
|
+
source_ref=get_source_ref(sys._getframe(frame_depth)),
|
50
|
+
)
|
51
|
+
)
|
52
|
+
|
53
|
+
|
54
|
+
def measure(var: QBit) -> CParamScalar:
|
55
|
+
"""
|
56
|
+
Measures the given qubit. `measure` is a non-unitary operation.
|
57
|
+
|
58
|
+
Args:
|
59
|
+
var: a qubit variable
|
60
|
+
|
61
|
+
Returns:
|
62
|
+
the measurement result (a symbolic boolean variable)
|
63
|
+
"""
|
64
|
+
name = _infer_variable_name(None, 2)
|
65
|
+
if name is None:
|
66
|
+
raise ClassiqInternalError("Could not infer measure var name")
|
67
|
+
declare_classical_variable(name, Bool(), 2)
|
68
|
+
res_var = CParamScalar(name)
|
69
|
+
res_val = symbolic_function(
|
70
|
+
var,
|
71
|
+
return_type=CBool, # type:ignore[type-abstract]
|
72
|
+
)
|
73
|
+
assign_classical_variable(res_var, res_val, 2)
|
74
|
+
return res_var
|
@@ -29,6 +29,7 @@ from classiq.interface.generator.visitor import NodeType
|
|
29
29
|
from classiq.interface.model.allocate import Allocate
|
30
30
|
from classiq.interface.model.bind_operation import BindOperation
|
31
31
|
from classiq.interface.model.block import Block
|
32
|
+
from classiq.interface.model.bounds import SetBoundsStatement
|
32
33
|
from classiq.interface.model.classical_if import ClassicalIf
|
33
34
|
from classiq.interface.model.classical_parameter_declaration import (
|
34
35
|
AnonClassicalParameterDeclaration,
|
@@ -76,9 +77,6 @@ from classiq.interface.model.quantum_type import (
|
|
76
77
|
QuantumBitvector,
|
77
78
|
QuantumNumeric,
|
78
79
|
)
|
79
|
-
from classiq.interface.model.quantum_variable_declaration import (
|
80
|
-
QuantumVariableDeclaration,
|
81
|
-
)
|
82
80
|
from classiq.interface.model.repeat import Repeat
|
83
81
|
from classiq.interface.model.statement_block import StatementBlock
|
84
82
|
from classiq.interface.model.variable_declaration_statement import (
|
@@ -189,11 +187,6 @@ class DSLPrettyPrinter(ModelVisitor):
|
|
189
187
|
self._level -= 1
|
190
188
|
return variables_str
|
191
189
|
|
192
|
-
def visit_QuantumVariableDeclaration(
|
193
|
-
self, var_decl: QuantumVariableDeclaration
|
194
|
-
) -> str:
|
195
|
-
return f"{var_decl.name}: {self.visit(var_decl.quantum_type)}"
|
196
|
-
|
197
190
|
def visit_AnonPortDeclaration(self, port_decl: AnonPortDeclaration) -> str:
|
198
191
|
modifier_str = (
|
199
192
|
f"{port_decl.type_modifier} "
|
@@ -263,9 +256,9 @@ class DSLPrettyPrinter(ModelVisitor):
|
|
263
256
|
return type_.name
|
264
257
|
|
265
258
|
def visit_VariableDeclarationStatement(
|
266
|
-
self,
|
259
|
+
self, var_decl: VariableDeclarationStatement
|
267
260
|
) -> str:
|
268
|
-
return f"{self._indent}{self.
|
261
|
+
return f"{self._indent}{var_decl.name}: {self.visit(var_decl.qmod_type)};\n"
|
269
262
|
|
270
263
|
def visit_AnonQuantumOperandDeclaration(
|
271
264
|
self, op_decl: AnonQuantumOperandDeclaration
|
@@ -361,10 +354,10 @@ class DSLPrettyPrinter(ModelVisitor):
|
|
361
354
|
return invert_code
|
362
355
|
|
363
356
|
def visit_Block(self, block: Block) -> str:
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
return
|
357
|
+
block_code = f"{self._indent}{{\n"
|
358
|
+
block_code += self._visit_body(block.statements)
|
359
|
+
block_code += f"{self._indent}}}\n"
|
360
|
+
return block_code
|
368
361
|
|
369
362
|
def _visit_body(self, body: StatementBlock) -> str:
|
370
363
|
code = ""
|
@@ -443,6 +436,17 @@ class DSLPrettyPrinter(ModelVisitor):
|
|
443
436
|
def visit_OperandIdentifier(self, op: OperandIdentifier) -> str:
|
444
437
|
return str(op)
|
445
438
|
|
439
|
+
def visit_SetBoundsStatement(self, op: SetBoundsStatement) -> str:
|
440
|
+
target = self.visit(op.target)
|
441
|
+
if op.lower_bound is None or op.upper_bound is None:
|
442
|
+
return f"{self._indent}reset_bounds({target});\n"
|
443
|
+
else:
|
444
|
+
lower_bound = self.visit(op.lower_bound)
|
445
|
+
upper_bound = self.visit(op.upper_bound)
|
446
|
+
return (
|
447
|
+
f"{self._indent}reset_bounds({target}, {lower_bound}, {upper_bound});\n"
|
448
|
+
)
|
449
|
+
|
446
450
|
@property
|
447
451
|
def _indent(self) -> str:
|
448
452
|
return " " * self._level
|
@@ -30,6 +30,8 @@ from classiq.interface.generator.types.struct_declaration import StructDeclarati
|
|
30
30
|
from classiq.interface.generator.visitor import NodeType, Visitor
|
31
31
|
from classiq.interface.model.allocate import Allocate
|
32
32
|
from classiq.interface.model.bind_operation import BindOperation
|
33
|
+
from classiq.interface.model.block import Block
|
34
|
+
from classiq.interface.model.bounds import SetBoundsStatement
|
33
35
|
from classiq.interface.model.classical_if import ClassicalIf
|
34
36
|
from classiq.interface.model.classical_parameter_declaration import (
|
35
37
|
AnonClassicalParameterDeclaration,
|
@@ -75,9 +77,6 @@ from classiq.interface.model.quantum_type import (
|
|
75
77
|
QuantumBitvector,
|
76
78
|
QuantumNumeric,
|
77
79
|
)
|
78
|
-
from classiq.interface.model.quantum_variable_declaration import (
|
79
|
-
QuantumVariableDeclaration,
|
80
|
-
)
|
81
80
|
from classiq.interface.model.repeat import Repeat
|
82
81
|
from classiq.interface.model.statement_block import StatementBlock
|
83
82
|
from classiq.interface.model.variable_declaration_statement import (
|
@@ -91,6 +90,8 @@ from classiq.qmod.pretty_print.expression_to_python import transform_expression
|
|
91
90
|
|
92
91
|
|
93
92
|
class VariableDeclarationAssignment(Visitor):
|
93
|
+
# FIXME: Support classical variable types
|
94
|
+
|
94
95
|
def __init__(self, pretty_printer: "PythonPrettyPrinter") -> None:
|
95
96
|
self.pretty_printer = pretty_printer
|
96
97
|
|
@@ -251,11 +252,6 @@ class PythonPrettyPrinter(ModelVisitor):
|
|
251
252
|
self._level -= 1
|
252
253
|
return variables_str
|
253
254
|
|
254
|
-
def visit_QuantumVariableDeclaration(
|
255
|
-
self, var_decl: QuantumVariableDeclaration
|
256
|
-
) -> str:
|
257
|
-
return f"{var_decl.name}: {self.visit(var_decl.quantum_type)}"
|
258
|
-
|
259
255
|
def visit_AnonPortDeclaration(self, port_decl: AnonPortDeclaration) -> str:
|
260
256
|
var_type = self._extract_port_type(port_decl)
|
261
257
|
return f"{port_decl.name}: {var_type}"
|
@@ -361,14 +357,23 @@ class PythonPrettyPrinter(ModelVisitor):
|
|
361
357
|
self._imports[type_.name] = 1
|
362
358
|
|
363
359
|
def visit_VariableDeclarationStatement(
|
364
|
-
self,
|
360
|
+
self,
|
361
|
+
local_decl: VariableDeclarationStatement,
|
362
|
+
walrus: bool = False,
|
365
363
|
) -> str:
|
366
364
|
type_name, params = VariableDeclarationAssignment(self).visit(
|
367
|
-
local_decl.
|
365
|
+
local_decl.qmod_type
|
368
366
|
)
|
369
367
|
params = [f'"{local_decl.name}"'] + params
|
370
368
|
param_args = ", ".join(params)
|
371
|
-
|
369
|
+
|
370
|
+
res = f"{self._indent}{local_decl.name}"
|
371
|
+
if walrus:
|
372
|
+
res += " := "
|
373
|
+
else:
|
374
|
+
res += f": {self.visit(local_decl.qmod_type)} = "
|
375
|
+
res += f"{type_name}({param_args})\n"
|
376
|
+
return res
|
372
377
|
|
373
378
|
def _visit_operand_arg_decl(self, arg_decl: AnonPositionalArg) -> str:
|
374
379
|
if isinstance(arg_decl, AnonPortDeclaration):
|
@@ -476,6 +481,10 @@ class PythonPrettyPrinter(ModelVisitor):
|
|
476
481
|
self._imports["invert"] = 1
|
477
482
|
return f"{self._indent}invert({self._visit_body(invert.body)})\n"
|
478
483
|
|
484
|
+
def visit_Block(self, block: Block) -> str:
|
485
|
+
self._imports["block"] = 1
|
486
|
+
return f"{self._indent}block({self._visit_body(block.statements)})\n"
|
487
|
+
|
479
488
|
def _visit_body(
|
480
489
|
self, body: StatementBlock, operand_arguments: Optional[list[str]] = None
|
481
490
|
) -> str:
|
@@ -488,10 +497,8 @@ class PythonPrettyPrinter(ModelVisitor):
|
|
488
497
|
self._level += 1
|
489
498
|
for i, statement in enumerate(body):
|
490
499
|
if isinstance(statement, VariableDeclarationStatement):
|
491
|
-
|
492
|
-
|
493
|
-
)
|
494
|
-
if isinstance(statement, AmplitudeLoadingOperation):
|
500
|
+
code += self.visit_VariableDeclarationStatement(statement, walrus=True)
|
501
|
+
elif isinstance(statement, AmplitudeLoadingOperation):
|
495
502
|
code += self.visit_AmplitudeLoadingOperation(statement, in_lambda=True)
|
496
503
|
elif isinstance(statement, ArithmeticOperation):
|
497
504
|
code += self.visit_ArithmeticOperation(statement, in_lambda=True)
|
@@ -574,6 +581,18 @@ class PythonPrettyPrinter(ModelVisitor):
|
|
574
581
|
def visit_OperandIdentifier(self, op: OperandIdentifier) -> str:
|
575
582
|
return str(op)
|
576
583
|
|
584
|
+
def visit_SetBoundsStatement(self, op: SetBoundsStatement) -> str:
|
585
|
+
self._imports["reset_bounds"] = 1
|
586
|
+
target = self.visit(op.target)
|
587
|
+
if op.lower_bound is None or op.upper_bound is None:
|
588
|
+
return f"{self._indent}reset_bounds({target})\n"
|
589
|
+
else:
|
590
|
+
lower_bound = self.visit(op.lower_bound)
|
591
|
+
upper_bound = self.visit(op.upper_bound)
|
592
|
+
return (
|
593
|
+
f"{self._indent}reset_bounds({target}, {lower_bound}, {upper_bound})\n"
|
594
|
+
)
|
595
|
+
|
577
596
|
@property
|
578
597
|
def _indent(self) -> str:
|
579
598
|
return " " * self._level
|
classiq/qmod/qfunc.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import warnings
|
2
1
|
from typing import Callable, Literal, Optional, Union, overload
|
3
2
|
|
4
|
-
from classiq.interface.exceptions import
|
3
|
+
from classiq.interface.exceptions import ClassiqInternalError
|
5
4
|
|
6
5
|
from classiq.qmod.global_declarative_switch import get_global_declarative_switch
|
7
6
|
from classiq.qmod.quantum_callable import QCallable
|
@@ -57,23 +56,7 @@ def qfunc(
|
|
57
56
|
synthesize_separately: bool = False,
|
58
57
|
unchecked: Optional[list[str]] = None,
|
59
58
|
) -> Union[Callable[[Callable], QCallable], QCallable]:
|
60
|
-
if generative is
|
61
|
-
warnings.warn(
|
62
|
-
"The use of `generative=True` is no longer required. Note that the "
|
63
|
-
"treatment of parameters of Qmod types will change from Python value to "
|
64
|
-
"symbolic in a near release. Change Qmod types to the corresponding Python "
|
65
|
-
"built-in types in order to use the parameters in Python expression "
|
66
|
-
"contexts.\n"
|
67
|
-
"Recommended changes:\n"
|
68
|
-
"@qfunc(generative=True) -> @qfunc\n"
|
69
|
-
"CInt->int\n"
|
70
|
-
"CReal->float\n"
|
71
|
-
"CArray->list\n\n"
|
72
|
-
"For more information see https://docs.classiq.io/latest/qmod-reference/language-reference/generative-descriptions/",
|
73
|
-
ClassiqDeprecationWarning,
|
74
|
-
stacklevel=2,
|
75
|
-
)
|
76
|
-
elif generative is None:
|
59
|
+
if generative is None:
|
77
60
|
generative = True
|
78
61
|
if get_global_declarative_switch():
|
79
62
|
generative = False
|
classiq/qmod/qmod_variable.py
CHANGED
@@ -74,7 +74,7 @@ from classiq.qmod.quantum_callable import QCallable
|
|
74
74
|
from classiq.qmod.semantics.annotation.qstruct_annotator import QStructAnnotator
|
75
75
|
from classiq.qmod.semantics.validation.types_validation import validate_qstruct
|
76
76
|
from classiq.qmod.symbolic_expr import Symbolic, SymbolicExpr
|
77
|
-
from classiq.qmod.symbolic_type import SymbolicTypes
|
77
|
+
from classiq.qmod.symbolic_type import SYMBOLIC_TYPES, SymbolicTypes
|
78
78
|
from classiq.qmod.utilities import (
|
79
79
|
get_source_ref,
|
80
80
|
unwrap_forward_ref,
|
@@ -104,9 +104,6 @@ def _infer_variable_name(name: Any, depth: int) -> Any:
|
|
104
104
|
return name
|
105
105
|
|
106
106
|
|
107
|
-
_SYMBOLIC_TYPES = tuple(get_origin(t) or t for t in get_args(SymbolicTypes))
|
108
|
-
|
109
|
-
|
110
107
|
class QVar(Symbolic):
|
111
108
|
CONSTRUCTOR_DEPTH: int = 1
|
112
109
|
|
@@ -230,7 +227,7 @@ class QScalar(QVar, SymbolicExpr):
|
|
230
227
|
)
|
231
228
|
|
232
229
|
def __ior__(self, other: Any) -> Self:
|
233
|
-
if not isinstance(other,
|
230
|
+
if not isinstance(other, SYMBOLIC_TYPES):
|
234
231
|
raise TypeError(
|
235
232
|
f"Invalid argument {other!r} for out-of-place arithmetic operation"
|
236
233
|
)
|
@@ -241,7 +238,7 @@ class QScalar(QVar, SymbolicExpr):
|
|
241
238
|
return self
|
242
239
|
|
243
240
|
def __ixor__(self, other: Any) -> Self:
|
244
|
-
if not isinstance(other,
|
241
|
+
if not isinstance(other, SYMBOLIC_TYPES):
|
245
242
|
raise TypeError(
|
246
243
|
f"Invalid argument {other!r} for in-place arithmetic operation"
|
247
244
|
)
|
@@ -252,7 +249,7 @@ class QScalar(QVar, SymbolicExpr):
|
|
252
249
|
return self
|
253
250
|
|
254
251
|
def __iadd__(self, other: Any) -> Self:
|
255
|
-
if not isinstance(other,
|
252
|
+
if not isinstance(other, SYMBOLIC_TYPES):
|
256
253
|
raise TypeError(
|
257
254
|
f"Invalid argument {other!r} for in-place arithmetic operation"
|
258
255
|
)
|
@@ -263,7 +260,7 @@ class QScalar(QVar, SymbolicExpr):
|
|
263
260
|
return self
|
264
261
|
|
265
262
|
def __imul__(self, other: Any) -> Self:
|
266
|
-
if not isinstance(other,
|
263
|
+
if not isinstance(other, SYMBOLIC_TYPES):
|
267
264
|
raise TypeError(
|
268
265
|
f"Invalid argument {other!r} for out of ampltiude encoding operation"
|
269
266
|
)
|
@@ -135,7 +135,7 @@ class QExpandable(QCallable, QExpandableInterface, ABC):
|
|
135
135
|
) -> None:
|
136
136
|
self.append_statement_to_body(
|
137
137
|
VariableDeclarationStatement(
|
138
|
-
name=name,
|
138
|
+
name=name, qmod_type=qtype, source_ref=source_ref
|
139
139
|
)
|
140
140
|
)
|
141
141
|
|
classiq/qmod/quantum_function.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import ast
|
2
2
|
import functools
|
3
|
+
import warnings
|
3
4
|
from abc import abstractmethod
|
4
5
|
from dataclasses import is_dataclass
|
5
6
|
from enum import EnumMeta
|
6
7
|
from inspect import isclass
|
7
8
|
from typing import Any, Callable, Optional, get_origin
|
8
9
|
|
9
|
-
from classiq.interface.exceptions import ClassiqError
|
10
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqError
|
10
11
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
11
12
|
from classiq.interface.generator.functions.port_declaration import (
|
12
13
|
PortDeclarationDirection,
|
@@ -28,7 +29,7 @@ from classiq.qmod.declaration_inferrer import infer_func_decl, is_qvar
|
|
28
29
|
from classiq.qmod.generative import set_frontend_interpreter
|
29
30
|
from classiq.qmod.global_declarative_switch import get_global_declarative_switch
|
30
31
|
from classiq.qmod.qmod_constant import QConstant
|
31
|
-
from classiq.qmod.qmod_parameter import CArray
|
32
|
+
from classiq.qmod.qmod_parameter import CArray, CParamList
|
32
33
|
from classiq.qmod.quantum_callable import QCallable, QCallableList
|
33
34
|
from classiq.qmod.quantum_expandable import QExpandable, QTerminalCallable
|
34
35
|
from classiq.qmod.semantics.annotation.qstruct_annotator import QStructAnnotator
|
@@ -218,6 +219,7 @@ class QFunc(BaseQFunc):
|
|
218
219
|
|
219
220
|
|
220
221
|
class ExternalQFunc(QTerminalCallable):
|
222
|
+
FRAME_DEPTH = 2 # FIXME: Remove (CLS-2912)
|
221
223
|
_decl: NamedParamsQuantumFunctionDeclaration
|
222
224
|
|
223
225
|
def __init__(self, py_callable: Callable) -> None:
|
@@ -242,6 +244,44 @@ class ExternalQFunc(QTerminalCallable):
|
|
242
244
|
def pure_decl(self) -> NamedParamsQuantumFunctionDeclaration:
|
243
245
|
return self.func_decl
|
244
246
|
|
247
|
+
def __call__(self, *args: Any, **kwargs: Any) -> None:
|
248
|
+
if self._py_callable.__name__ == "parametric_suzuki_trotter":
|
249
|
+
warnings.warn(
|
250
|
+
(
|
251
|
+
"Function 'parametric_suzuki_trotter' is deprecated and will no "
|
252
|
+
"longer be supported starting on 21/7/2025 at the earliest. "
|
253
|
+
"Instead, use 'multi_suzuki_trotter'."
|
254
|
+
),
|
255
|
+
ClassiqDeprecationWarning,
|
256
|
+
stacklevel=2,
|
257
|
+
)
|
258
|
+
if self._py_callable.__name__ == "sparse_suzuki_trotter":
|
259
|
+
warnings.warn(
|
260
|
+
(
|
261
|
+
"Function 'sparse_suzuki_trotter' is deprecated and will no "
|
262
|
+
"longer be supported starting on 21/7/2025 at the earliest. "
|
263
|
+
"Instead, use 'suzuki_trotter'."
|
264
|
+
),
|
265
|
+
ClassiqDeprecationWarning,
|
266
|
+
stacklevel=2,
|
267
|
+
)
|
268
|
+
if (
|
269
|
+
self._py_callable.__name__ == "suzuki_trotter"
|
270
|
+
and len(args) > 0
|
271
|
+
and isinstance(args[0], (list, CParamList))
|
272
|
+
):
|
273
|
+
warnings.warn(
|
274
|
+
(
|
275
|
+
"Parameter type CArray[PauliTerm] to function 'suzuki_trotter' is "
|
276
|
+
"deprecated and will no longer be supported starting on 21/7/2025 "
|
277
|
+
"at the earliest. Instead, send a 'SparsePauliOp' (see "
|
278
|
+
"https://docs.classiq.io/latest/qmod-reference/language-reference/classical-types/#hamiltonians)."
|
279
|
+
),
|
280
|
+
ClassiqDeprecationWarning,
|
281
|
+
stacklevel=2,
|
282
|
+
)
|
283
|
+
super().__call__(*args, **kwargs)
|
284
|
+
|
245
285
|
|
246
286
|
class GenerativeQFunc(BaseQFunc):
|
247
287
|
FRAME_DEPTH = 3
|
classiq/qmod/symbolic_type.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
from typing import Union
|
1
|
+
from typing import Union, get_args, get_origin
|
2
2
|
|
3
3
|
from classiq.qmod.symbolic_expr import SymbolicExpr
|
4
4
|
|
5
5
|
SymbolicTypes = Union[SymbolicExpr, int, float, bool, tuple["SymbolicTypes", ...]]
|
6
|
+
SYMBOLIC_TYPES = tuple(get_origin(t) or t for t in get_args(SymbolicTypes))
|