classiq 0.52.0__py3-none-any.whl → 0.54.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.
Files changed (303) hide show
  1. classiq/__init__.py +1 -3
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
  3. classiq/_internals/__init__.py +0 -20
  4. classiq/_internals/api_wrapper.py +23 -17
  5. classiq/_internals/async_utils.py +1 -3
  6. classiq/_internals/authentication/auth0.py +5 -5
  7. classiq/_internals/authentication/device.py +5 -4
  8. classiq/_internals/authentication/password_manager.py +3 -3
  9. classiq/_internals/authentication/token_manager.py +3 -2
  10. classiq/_internals/client.py +11 -13
  11. classiq/_internals/config.py +2 -2
  12. classiq/_internals/jobs.py +7 -6
  13. classiq/_internals/type_validation.py +9 -9
  14. classiq/analyzer/__init__.py +1 -3
  15. classiq/analyzer/analyzer.py +8 -7
  16. classiq/analyzer/analyzer_utilities.py +8 -8
  17. classiq/analyzer/rb.py +11 -11
  18. classiq/applications/__init__.py +1 -3
  19. classiq/applications/chemistry/__init__.py +1 -3
  20. classiq/applications/chemistry/ansatz_parameters.py +4 -4
  21. classiq/applications/chemistry/chemistry_model_constructor.py +10 -9
  22. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +26 -9
  23. classiq/applications/combinatorial_helpers/encoding_mapping.py +10 -10
  24. classiq/applications/combinatorial_helpers/encoding_utils.py +4 -4
  25. classiq/applications/combinatorial_helpers/memory.py +5 -7
  26. classiq/applications/combinatorial_helpers/optimization_model.py +43 -24
  27. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +4 -6
  28. classiq/applications/combinatorial_helpers/pyomo_utils.py +95 -24
  29. classiq/applications/combinatorial_helpers/sympy_utils.py +2 -2
  30. classiq/applications/combinatorial_helpers/transformations/encoding.py +8 -8
  31. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -5
  32. classiq/applications/combinatorial_helpers/transformations/ising_converter.py +7 -9
  33. classiq/applications/combinatorial_helpers/transformations/penalty.py +1 -2
  34. classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -2
  35. classiq/applications/combinatorial_helpers/transformations/slack_variables.py +1 -2
  36. classiq/applications/combinatorial_optimization/__init__.py +1 -3
  37. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
  38. classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
  39. classiq/applications/finance/__init__.py +1 -3
  40. classiq/applications/grover/__init__.py +1 -3
  41. classiq/applications/grover/grover_model_constructor.py +7 -9
  42. classiq/applications/hamiltonian/pauli_decomposition.py +6 -6
  43. classiq/applications/qnn/__init__.py +1 -3
  44. classiq/applications/qnn/circuit_utils.py +5 -5
  45. classiq/applications/qnn/datasets/__init__.py +1 -3
  46. classiq/applications/qnn/datasets/dataset_base_classes.py +5 -4
  47. classiq/applications/qnn/datasets/dataset_parity.py +2 -2
  48. classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
  49. classiq/applications/qnn/qlayer.py +25 -6
  50. classiq/applications/qnn/torch_utils.py +2 -2
  51. classiq/applications/qnn/types.py +5 -5
  52. classiq/applications/qsvm/qsvm.py +1 -3
  53. classiq/applications/qsvm/qsvm_data_generation.py +3 -3
  54. classiq/applications/qsvm/qsvm_model_constructor.py +5 -5
  55. classiq/execution/__init__.py +3 -3
  56. classiq/execution/all_hardware_devices.py +1 -3
  57. classiq/execution/execution_session.py +57 -16
  58. classiq/execution/iqcc.py +1 -1
  59. classiq/execution/jobs.py +4 -4
  60. classiq/execution/qaoa.py +84 -0
  61. classiq/execution/qnn.py +3 -3
  62. classiq/executor.py +4 -4
  63. classiq/interface/_version.py +1 -1
  64. classiq/interface/analyzer/analysis_params.py +9 -10
  65. classiq/interface/analyzer/cytoscape_graph.py +5 -5
  66. classiq/interface/analyzer/result.py +17 -17
  67. classiq/interface/applications/qsvm.py +6 -10
  68. classiq/interface/backend/backend_preferences.py +4 -3
  69. classiq/interface/backend/ionq/ionq_quantum_program.py +4 -5
  70. classiq/interface/backend/pydantic_backend.py +1 -2
  71. classiq/interface/chemistry/fermionic_operator.py +5 -5
  72. classiq/interface/chemistry/ground_state_problem.py +7 -8
  73. classiq/interface/chemistry/molecule.py +4 -4
  74. classiq/interface/chemistry/operator.py +11 -13
  75. classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -3
  76. classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
  77. classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
  78. classiq/interface/combinatorial_optimization/examples/mht.py +2 -3
  79. classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
  80. classiq/interface/combinatorial_optimization/examples/set_cover.py +1 -2
  81. classiq/interface/combinatorial_optimization/mht_qaoa_input.py +5 -7
  82. classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
  83. classiq/interface/combinatorial_optimization/result.py +1 -3
  84. classiq/interface/debug_info/debug_info.py +8 -7
  85. classiq/interface/exceptions.py +11 -7
  86. classiq/interface/execution/iqcc.py +1 -3
  87. classiq/interface/execution/jobs.py +2 -2
  88. classiq/interface/execution/primitives.py +3 -3
  89. classiq/interface/executor/aws_execution_cost.py +4 -4
  90. classiq/interface/executor/execution_request.py +2 -3
  91. classiq/interface/executor/execution_result.py +3 -3
  92. classiq/interface/executor/iqae_result.py +3 -5
  93. classiq/interface/executor/optimizer_preferences.py +2 -2
  94. classiq/interface/executor/quantum_code.py +6 -6
  95. classiq/interface/executor/register_initialization.py +2 -4
  96. classiq/interface/executor/result.py +35 -28
  97. classiq/interface/executor/vqe_result.py +8 -8
  98. classiq/interface/finance/function_input.py +2 -2
  99. classiq/interface/finance/gaussian_model_input.py +5 -5
  100. classiq/interface/finance/log_normal_model_input.py +2 -2
  101. classiq/interface/finance/model_input.py +1 -2
  102. classiq/interface/generator/adjacency.py +1 -3
  103. classiq/interface/generator/ansatz_library.py +4 -4
  104. classiq/interface/generator/application_apis/finance_declarations.py +1 -1
  105. classiq/interface/generator/arith/argument_utils.py +3 -3
  106. classiq/interface/generator/arith/arithmetic.py +7 -7
  107. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +5 -5
  108. classiq/interface/generator/arith/arithmetic_expression_abc.py +11 -11
  109. classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
  110. classiq/interface/generator/arith/arithmetic_expression_validator.py +8 -8
  111. classiq/interface/generator/arith/arithmetic_operations.py +4 -3
  112. classiq/interface/generator/arith/arithmetic_param_getters.py +6 -6
  113. classiq/interface/generator/arith/arithmetic_result_builder.py +9 -9
  114. classiq/interface/generator/arith/ast_node_rewrite.py +2 -1
  115. classiq/interface/generator/arith/binary_ops.py +10 -13
  116. classiq/interface/generator/arith/extremum_operations.py +3 -2
  117. classiq/interface/generator/arith/logical_ops.py +7 -6
  118. classiq/interface/generator/arith/number_utils.py +4 -4
  119. classiq/interface/generator/arith/register_user_input.py +4 -4
  120. classiq/interface/generator/arith/unary_ops.py +2 -1
  121. classiq/interface/generator/builtin_api_builder.py +2 -1
  122. classiq/interface/generator/circuit_code/circuit_code.py +4 -4
  123. classiq/interface/generator/circuit_code/types_and_constants.py +3 -5
  124. classiq/interface/generator/complex_type.py +1 -2
  125. classiq/interface/generator/control_state.py +2 -2
  126. classiq/interface/generator/custom_ansatz.py +1 -3
  127. classiq/interface/generator/distance.py +3 -5
  128. classiq/interface/generator/excitations.py +3 -2
  129. classiq/interface/generator/expressions/enums/finance_functions.py +1 -3
  130. classiq/interface/generator/expressions/evaluated_expression.py +4 -3
  131. classiq/interface/generator/expressions/expression.py +4 -5
  132. classiq/interface/generator/expressions/expression_constants.py +4 -4
  133. classiq/interface/generator/expressions/qmod_qarray_proxy.py +2 -1
  134. classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -1
  135. classiq/interface/generator/expressions/qmod_qstruct_proxy.py +2 -1
  136. classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -1
  137. classiq/interface/generator/expressions/qmod_struct_instance.py +2 -1
  138. classiq/interface/generator/expressions/sympy_supported_expressions.py +11 -13
  139. classiq/interface/generator/finance.py +2 -2
  140. classiq/interface/generator/function_param_library.py +6 -6
  141. classiq/interface/generator/function_params.py +13 -19
  142. classiq/interface/generator/functions/classical_function_declaration.py +4 -3
  143. classiq/interface/generator/functions/classical_type.py +13 -13
  144. classiq/interface/generator/functions/concrete_types.py +1 -2
  145. classiq/interface/generator/functions/function_declaration.py +1 -1
  146. classiq/interface/generator/functions/qmod_python_interface.py +2 -1
  147. classiq/interface/generator/functions/type_name.py +3 -2
  148. classiq/interface/generator/generated_circuit_data.py +34 -22
  149. classiq/interface/generator/grover_diffuser.py +7 -7
  150. classiq/interface/generator/grover_operator.py +2 -2
  151. classiq/interface/generator/hardware/hardware_data.py +7 -6
  152. classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
  153. classiq/interface/generator/identity.py +5 -6
  154. classiq/interface/generator/linear_pauli_rotations.py +6 -6
  155. classiq/interface/generator/mcu.py +2 -2
  156. classiq/interface/generator/mcx.py +6 -6
  157. classiq/interface/generator/model/__init__.py +1 -3
  158. classiq/interface/generator/model/constraints.py +2 -2
  159. classiq/interface/generator/model/model.py +5 -6
  160. classiq/interface/generator/model/preferences/preferences.py +7 -6
  161. classiq/interface/generator/model/quantum_register.py +6 -11
  162. classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
  163. classiq/interface/generator/oracles/custom_oracle.py +2 -2
  164. classiq/interface/generator/oracles/oracle_abc.py +6 -5
  165. classiq/interface/generator/partitioned_register.py +6 -5
  166. classiq/interface/generator/piecewise_linear_amplitude_loading.py +8 -7
  167. classiq/interface/generator/qpe.py +4 -4
  168. classiq/interface/generator/qsvm.py +3 -3
  169. classiq/interface/generator/quantum_function_call.py +24 -29
  170. classiq/interface/generator/quantum_program.py +9 -9
  171. classiq/interface/generator/register_role.py +2 -4
  172. classiq/interface/generator/slice_parsing_utils.py +4 -3
  173. classiq/interface/generator/standard_gates/standard_gates.py +3 -3
  174. classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
  175. classiq/interface/generator/state_preparation/distributions.py +6 -5
  176. classiq/interface/generator/state_preparation/metrics.py +2 -4
  177. classiq/interface/generator/state_preparation/state_preparation.py +4 -4
  178. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +3 -3
  179. classiq/interface/generator/transpiler_basis_gates.py +2 -2
  180. classiq/interface/generator/types/enum_declaration.py +2 -3
  181. classiq/interface/generator/types/qstruct_declaration.py +2 -1
  182. classiq/interface/generator/types/struct_declaration.py +3 -2
  183. classiq/interface/generator/ucc.py +2 -1
  184. classiq/interface/generator/unitary_gate.py +2 -2
  185. classiq/interface/generator/user_defined_function_params.py +1 -1
  186. classiq/interface/generator/validations/flow_graph.py +6 -5
  187. classiq/interface/generator/validations/validator_functions.py +3 -2
  188. classiq/interface/generator/visitor.py +9 -14
  189. classiq/interface/hardware.py +5 -6
  190. classiq/interface/helpers/custom_encoders.py +2 -2
  191. classiq/interface/helpers/custom_pydantic_types.py +8 -9
  192. classiq/interface/helpers/dotdict.py +18 -0
  193. classiq/interface/helpers/hashable_mixin.py +3 -2
  194. classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
  195. classiq/interface/helpers/pydantic_model_helpers.py +4 -3
  196. classiq/interface/helpers/validation_helpers.py +2 -2
  197. classiq/interface/ide/ide_data.py +11 -15
  198. classiq/interface/ide/visual_model.py +33 -22
  199. classiq/interface/jobs.py +2 -2
  200. classiq/interface/model/bind_operation.py +5 -4
  201. classiq/interface/model/classical_parameter_declaration.py +2 -2
  202. classiq/interface/model/handle_binding.py +3 -2
  203. classiq/interface/model/inplace_binary_operation.py +2 -1
  204. classiq/interface/model/model.py +12 -11
  205. classiq/interface/model/native_function_definition.py +10 -0
  206. classiq/interface/model/port_declaration.py +2 -2
  207. classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +3 -2
  208. classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -2
  209. classiq/interface/model/quantum_expressions/quantum_expression.py +8 -7
  210. classiq/interface/model/quantum_function_call.py +9 -14
  211. classiq/interface/model/quantum_function_declaration.py +10 -12
  212. classiq/interface/model/quantum_lambda_function.py +3 -16
  213. classiq/interface/model/quantum_statement.py +4 -3
  214. classiq/interface/model/quantum_type.py +5 -5
  215. classiq/interface/model/statement_block.py +2 -3
  216. classiq/interface/model/validation_handle.py +5 -4
  217. classiq/interface/server/global_versions.py +3 -3
  218. classiq/model_expansions/atomic_expression_functions_defs.py +3 -2
  219. classiq/model_expansions/call_to_model_converter.py +190 -0
  220. classiq/model_expansions/capturing/captured_var_manager.py +4 -6
  221. classiq/model_expansions/capturing/propagated_var_stack.py +7 -7
  222. classiq/model_expansions/closure.py +17 -9
  223. classiq/model_expansions/evaluators/arg_type_match.py +3 -2
  224. classiq/model_expansions/evaluators/argument_types.py +3 -3
  225. classiq/model_expansions/evaluators/control.py +3 -3
  226. classiq/model_expansions/evaluators/parameter_types.py +7 -7
  227. classiq/model_expansions/evaluators/quantum_type_utils.py +2 -1
  228. classiq/model_expansions/evaluators/type_type_match.py +1 -1
  229. classiq/model_expansions/expression_evaluator.py +10 -9
  230. classiq/model_expansions/expression_renamer.py +6 -6
  231. classiq/model_expansions/function_builder.py +19 -12
  232. classiq/model_expansions/generative_functions.py +3 -2
  233. classiq/model_expansions/interpreter.py +31 -19
  234. classiq/model_expansions/model_tables.py +14 -14
  235. classiq/model_expansions/quantum_operations/bind.py +2 -4
  236. classiq/model_expansions/quantum_operations/classicalif.py +1 -1
  237. classiq/model_expansions/quantum_operations/control.py +2 -4
  238. classiq/model_expansions/quantum_operations/emitter.py +10 -13
  239. classiq/model_expansions/quantum_operations/expression_operation.py +23 -16
  240. classiq/model_expansions/quantum_operations/inplace_binary_operation.py +164 -38
  241. classiq/model_expansions/quantum_operations/phase.py +6 -6
  242. classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +25 -5
  243. classiq/model_expansions/quantum_operations/quantum_function_call.py +41 -2
  244. classiq/model_expansions/quantum_operations/repeat.py +1 -3
  245. classiq/model_expansions/scope.py +11 -10
  246. classiq/model_expansions/scope_initialization.py +6 -5
  247. classiq/model_expansions/sympy_conversion/expression_to_sympy.py +6 -6
  248. classiq/model_expansions/sympy_conversion/sympy_to_python.py +2 -2
  249. classiq/model_expansions/visitors/variable_references.py +5 -4
  250. classiq/qmod/__init__.py +2 -0
  251. classiq/qmod/builtins/classical_execution_primitives.py +9 -9
  252. classiq/qmod/builtins/functions/__init__.py +75 -53
  253. classiq/qmod/builtins/functions/amplitude_estimation.py +4 -1
  254. classiq/qmod/builtins/functions/arithmetic.py +14 -1
  255. classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +86 -6
  256. classiq/qmod/builtins/functions/grover.py +41 -45
  257. classiq/qmod/builtins/functions/hea.py +60 -4
  258. classiq/qmod/builtins/functions/linear_pauli_rotation.py +26 -4
  259. classiq/qmod/builtins/functions/modular_exponentiation.py +90 -29
  260. classiq/qmod/builtins/functions/operators.py +1 -1
  261. classiq/qmod/builtins/functions/qaoa_penalty.py +14 -5
  262. classiq/qmod/builtins/functions/qft_functions.py +57 -0
  263. classiq/qmod/builtins/functions/qpe.py +20 -4
  264. classiq/qmod/builtins/functions/qsvt.py +49 -4
  265. classiq/qmod/builtins/functions/standard_gates.py +18 -18
  266. classiq/qmod/builtins/functions/state_preparation.py +92 -10
  267. classiq/qmod/builtins/functions/swap_test.py +7 -1
  268. classiq/qmod/builtins/functions/utility_functions.py +43 -0
  269. classiq/qmod/builtins/functions/variational.py +53 -0
  270. classiq/qmod/builtins/operations.py +4 -5
  271. classiq/qmod/cfunc.py +2 -2
  272. classiq/qmod/classical_function.py +3 -7
  273. classiq/qmod/create_model_function.py +19 -8
  274. classiq/qmod/declaration_inferrer.py +7 -10
  275. classiq/qmod/expression_query.py +3 -3
  276. classiq/qmod/generative.py +2 -1
  277. classiq/qmod/model_state_container.py +5 -7
  278. classiq/qmod/native/__init__.py +1 -3
  279. classiq/qmod/native/expression_to_qmod.py +9 -8
  280. classiq/qmod/native/pretty_printer.py +6 -5
  281. classiq/qmod/pretty_print/__init__.py +1 -3
  282. classiq/qmod/pretty_print/expression_to_python.py +13 -12
  283. classiq/qmod/pretty_print/pretty_printer.py +13 -12
  284. classiq/qmod/python_classical_type.py +8 -4
  285. classiq/qmod/qfunc.py +4 -4
  286. classiq/qmod/qmod_parameter.py +3 -1
  287. classiq/qmod/qmod_variable.py +11 -10
  288. classiq/qmod/quantum_expandable.py +32 -15
  289. classiq/qmod/quantum_function.py +34 -5
  290. classiq/qmod/semantics/annotation.py +1 -1
  291. classiq/qmod/semantics/error_manager.py +8 -7
  292. classiq/qmod/semantics/static_semantics_visitor.py +19 -24
  293. classiq/qmod/semantics/validation/constants_validation.py +1 -1
  294. classiq/qmod/semantics/validation/func_call_validation.py +2 -2
  295. classiq/qmod/semantics/validation/main_validation.py +33 -0
  296. classiq/qmod/semantics/validation/types_validation.py +2 -1
  297. classiq/qmod/symbolic.py +5 -8
  298. classiq/qmod/symbolic_type.py +2 -2
  299. classiq/qmod/synthesize_separately.py +16 -0
  300. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/METADATA +1 -1
  301. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/RECORD +302 -295
  302. classiq/qmod/builtins/functions/qft.py +0 -23
  303. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/WHEEL +0 -0
@@ -1,5 +1,3 @@
1
- from typing import Dict
2
-
3
1
  from classiq.interface.generator.constant import Constant
4
2
  from classiq.interface.generator.types.enum_declaration import EnumDeclaration
5
3
  from classiq.interface.generator.types.qstruct_declaration import QStructDeclaration
@@ -8,11 +6,11 @@ from classiq.interface.model.native_function_definition import NativeFunctionDef
8
6
 
9
7
 
10
8
  class ModelStateContainer:
11
- enum_decls: Dict[str, EnumDeclaration]
12
- type_decls: Dict[str, StructDeclaration]
13
- qstruct_decls: Dict[str, QStructDeclaration]
14
- native_defs: Dict[str, NativeFunctionDefinition]
15
- constants: Dict[str, Constant]
9
+ enum_decls: dict[str, EnumDeclaration]
10
+ type_decls: dict[str, StructDeclaration]
11
+ qstruct_decls: dict[str, QStructDeclaration]
12
+ native_defs: dict[str, NativeFunctionDefinition]
13
+ constants: dict[str, Constant]
16
14
 
17
15
 
18
16
  QMODULE = ModelStateContainer()
@@ -1,9 +1,7 @@
1
- from typing import List
2
-
3
1
  from .pretty_printer import DSLPrettyPrinter
4
2
 
5
3
  __all__ = ["DSLPrettyPrinter"]
6
4
 
7
5
 
8
- def __dir__() -> List[str]:
6
+ def __dir__() -> list[str]:
9
7
  return __all__
@@ -1,14 +1,15 @@
1
1
  import ast
2
2
  import re
3
+ from collections.abc import Mapping
3
4
  from dataclasses import dataclass
4
- from typing import Callable, Dict, List, Mapping, Optional, Type
5
+ from typing import Callable, Optional
5
6
 
6
7
  import numpy as np
7
8
 
8
9
  from classiq.qmod.utilities import DEFAULT_DECIMAL_PRECISION
9
10
 
10
11
  IDENTIFIER = re.compile(r"[a-zA-Z_]\w*")
11
- BINARY_OPS: Mapping[Type[ast.operator], str] = {
12
+ BINARY_OPS: Mapping[type[ast.operator], str] = {
12
13
  ast.Add: "+",
13
14
  ast.Sub: "-",
14
15
  ast.Mult: "*",
@@ -21,14 +22,14 @@ BINARY_OPS: Mapping[Type[ast.operator], str] = {
21
22
  ast.LShift: "<<",
22
23
  ast.RShift: ">>",
23
24
  }
24
- BOOL_OPS: Mapping[Type[ast.boolop], str] = {ast.And: "and", ast.Or: "or"}
25
- UNARY_OPS: Mapping[Type[ast.unaryop], str] = {
25
+ BOOL_OPS: Mapping[type[ast.boolop], str] = {ast.And: "and", ast.Or: "or"}
26
+ UNARY_OPS: Mapping[type[ast.unaryop], str] = {
26
27
  ast.UAdd: "+",
27
28
  ast.USub: "-",
28
29
  ast.Invert: "~",
29
30
  ast.Not: "not",
30
31
  }
31
- COMPARE_OPS: Mapping[Type[ast.cmpop], str] = {
32
+ COMPARE_OPS: Mapping[type[ast.cmpop], str] = {
32
33
  ast.Eq: "==",
33
34
  ast.NotEq: "!=",
34
35
  ast.Lt: "<",
@@ -139,7 +140,7 @@ class ASTToQMODCode:
139
140
  else:
140
141
  raise AssertionError("Error parsing expression: unsupported AST node.")
141
142
 
142
- def indent_items(self, items: Callable[[], List[str]]) -> str:
143
+ def indent_items(self, items: Callable[[], list[str]]) -> str:
143
144
  should_indent = (
144
145
  len("".join([i.strip() for i in items()])) >= LIST_FORMAT_CHAR_LIMIT
145
146
  )
@@ -165,8 +166,8 @@ class ASTToQMODCode:
165
166
  def _remove_redundant_parentheses(expr: str) -> str:
166
167
  if not (expr.startswith("(") and expr.endswith(")")):
167
168
  return expr
168
- parentheses_map: Dict[int, int] = dict()
169
- stack: List[int] = []
169
+ parentheses_map: dict[int, int] = dict()
170
+ stack: list[int] = []
170
171
  for index, char in enumerate(expr):
171
172
  if char == "(":
172
173
  stack.append(index)
@@ -1,4 +1,5 @@
1
- from typing import Dict, List, Mapping, Optional, Union
1
+ from collections.abc import Mapping
2
+ from typing import Optional, Union
2
3
 
3
4
  from classiq.interface.generator.constant import Constant
4
5
  from classiq.interface.generator.expressions.expression import Expression
@@ -135,7 +136,7 @@ class DSLPrettyPrinter(Visitor):
135
136
  def visit_EnumDeclaration(self, enum_decl: EnumDeclaration) -> str:
136
137
  return f"enum {enum_decl.name} {{\n{self._visit_members(enum_decl.members)}}}\n"
137
138
 
138
- def _visit_members(self, members: Dict[str, int]) -> str:
139
+ def _visit_members(self, members: dict[str, int]) -> str:
139
140
  self._level += 1
140
141
  members_str = "".join(
141
142
  f"{self._indent}{self.visit(member_name)} = {member_value};\n"
@@ -310,7 +311,7 @@ class DSLPrettyPrinter(Visitor):
310
311
  def visit_InplaceBinaryOperation(self, op: InplaceBinaryOperation) -> str:
311
312
  return f"{self._indent}{op.operation.value}({self.visit(op.value)}, {self.visit(op.target)});\n"
312
313
 
313
- def _visit_pack_expr(self, vars: List[HandleBinding]) -> str:
314
+ def _visit_pack_expr(self, vars: list[HandleBinding]) -> str:
314
315
  if len(vars) == 1:
315
316
  return self.visit(vars[0])
316
317
 
@@ -324,7 +325,7 @@ class DSLPrettyPrinter(Visitor):
324
325
 
325
326
  def visit_QuantumLambdaFunction(self, qlambda: QuantumLambdaFunction) -> str:
326
327
  positional_args = ", ".join(
327
- qlambda.get_rename_params()[idx]
328
+ qlambda.pos_rename_params[idx]
328
329
  for idx, arg_decl in enumerate(
329
330
  qlambda.func_decl.positional_arg_declarations
330
331
  )
@@ -358,7 +359,7 @@ class DSLPrettyPrinter(Visitor):
358
359
  ) -> str:
359
360
  return f"{self._indent}{self.visit(amplitude_loading_op.result_var)} *= {self.visit(amplitude_loading_op.expression)};\n"
360
361
 
361
- def _print_bind_handles(self, handles: List[HandleBinding]) -> str:
362
+ def _print_bind_handles(self, handles: list[HandleBinding]) -> str:
362
363
  if len(handles) == 1:
363
364
  return self.visit(handles[0])
364
365
 
@@ -1,9 +1,7 @@
1
- from typing import List
2
-
3
1
  from .pretty_printer import PythonPrettyPrinter
4
2
 
5
3
  __all__ = ["PythonPrettyPrinter"]
6
4
 
7
5
 
8
- def __dir__() -> List[str]:
6
+ def __dir__() -> list[str]:
9
7
  return __all__
@@ -1,7 +1,8 @@
1
1
  import ast
2
2
  import re
3
+ from collections.abc import Mapping
3
4
  from dataclasses import dataclass
4
- from typing import Callable, Dict, List, Mapping, Type
5
+ from typing import Callable
5
6
 
6
7
  import numpy as np
7
8
 
@@ -9,7 +10,7 @@ import classiq
9
10
  from classiq.qmod.utilities import DEFAULT_DECIMAL_PRECISION
10
11
 
11
12
  IDENTIFIER = re.compile(r"[a-zA-Z_]\w*")
12
- BINARY_OPS: Mapping[Type[ast.operator], str] = {
13
+ BINARY_OPS: Mapping[type[ast.operator], str] = {
13
14
  ast.Add: "+",
14
15
  ast.Sub: "-",
15
16
  ast.Mult: "*",
@@ -22,14 +23,14 @@ BINARY_OPS: Mapping[Type[ast.operator], str] = {
22
23
  ast.LShift: "<<",
23
24
  ast.RShift: ">>",
24
25
  }
25
- BOOL_OPS: Mapping[Type[ast.boolop], str] = {ast.And: "and", ast.Or: "or"}
26
- UNARY_OPS: Mapping[Type[ast.unaryop], str] = {
26
+ BOOL_OPS: Mapping[type[ast.boolop], str] = {ast.And: "and", ast.Or: "or"}
27
+ UNARY_OPS: Mapping[type[ast.unaryop], str] = {
27
28
  ast.UAdd: "+",
28
29
  ast.USub: "-",
29
30
  ast.Invert: "~",
30
31
  ast.Not: "not",
31
32
  }
32
- COMPARE_OPS: Mapping[Type[ast.cmpop], str] = {
33
+ COMPARE_OPS: Mapping[type[ast.cmpop], str] = {
33
34
  ast.Eq: "==",
34
35
  ast.NotEq: "!=",
35
36
  ast.Lt: "<",
@@ -43,8 +44,8 @@ LIST_FORMAT_CHAR_LIMIT = 20
43
44
  @dataclass
44
45
  class ASTToQMODCode(ast.NodeVisitor):
45
46
  level: int
46
- imports: Dict[str, int]
47
- symbolic_imports: Dict[str, int]
47
+ imports: dict[str, int]
48
+ symbolic_imports: dict[str, int]
48
49
  decimal_precision: int
49
50
  indent_seq: str = " "
50
51
 
@@ -162,7 +163,7 @@ class ASTToQMODCode(ast.NodeVisitor):
162
163
  def generic_visit(self, node: ast.AST) -> None:
163
164
  raise AssertionError("Cannot parse node of type: " + type(node).__name__)
164
165
 
165
- def indent_items(self, items: Callable[[], List[str]]) -> str:
166
+ def indent_items(self, items: Callable[[], list[str]]) -> str:
166
167
  should_indent = (
167
168
  len("".join([i.strip() for i in items()])) >= LIST_FORMAT_CHAR_LIMIT
168
169
  )
@@ -188,8 +189,8 @@ class ASTToQMODCode(ast.NodeVisitor):
188
189
  def _remove_redundant_parentheses(expr: str) -> str:
189
190
  if not (expr.startswith("(") and expr.endswith(")")):
190
191
  return expr
191
- parentheses_map: Dict[int, int] = dict()
192
- stack: List[int] = []
192
+ parentheses_map: dict[int, int] = dict()
193
+ stack: list[int] = []
193
194
  for index, char in enumerate(expr):
194
195
  if char == "(":
195
196
  stack.append(index)
@@ -208,8 +209,8 @@ def _remove_redundant_parentheses(expr: str) -> str:
208
209
 
209
210
  def transform_expression(
210
211
  expr: str,
211
- imports: Dict[str, int],
212
- symbolic_imports: Dict[str, int],
212
+ imports: dict[str, int],
213
+ symbolic_imports: dict[str, int],
213
214
  level: int = 0,
214
215
  decimal_precision: int = DEFAULT_DECIMAL_PRECISION,
215
216
  ) -> str:
@@ -1,4 +1,5 @@
1
- from typing import Dict, List, Mapping, Optional, Tuple, Union, cast
1
+ from collections.abc import Mapping
2
+ from typing import Optional, Union, cast
2
3
 
3
4
  import black
4
5
 
@@ -88,20 +89,20 @@ class VariableDeclarationAssignment(Visitor):
88
89
  def __init__(self, pretty_printer: "PythonPrettyPrinter") -> None:
89
90
  self.pretty_printer = pretty_printer
90
91
 
91
- def visit(self, node: NodeType) -> Tuple[str, Optional[List[str]]]:
92
+ def visit(self, node: NodeType) -> tuple[str, Optional[list[str]]]:
92
93
  res = super().visit(node)
93
94
  if not isinstance(res, tuple):
94
95
  raise AssertionError(f"Pretty printing for {type(node)} is not supported ")
95
96
  return res # type: ignore[return-value]
96
97
 
97
- def visit_QuantumBit(self, qtype: QuantumBit) -> Tuple[str, Optional[List[str]]]:
98
+ def visit_QuantumBit(self, qtype: QuantumBit) -> tuple[str, Optional[list[str]]]:
98
99
  self.pretty_printer._imports["QBit"] = 1
99
100
 
100
101
  return "QBit", None
101
102
 
102
103
  def visit_QuantumBitvector(
103
104
  self, qtype: QuantumBitvector
104
- ) -> Tuple[str, Optional[List[str]]]:
105
+ ) -> tuple[str, Optional[list[str]]]:
105
106
  self.pretty_printer._imports["QArray"] = 1
106
107
 
107
108
  element_type = self.pretty_printer.visit(qtype.element_type)
@@ -111,7 +112,7 @@ class VariableDeclarationAssignment(Visitor):
111
112
 
112
113
  def visit_QuantumNumeric(
113
114
  self, qtype: QuantumNumeric
114
- ) -> Tuple[str, Optional[List[str]]]:
115
+ ) -> tuple[str, Optional[list[str]]]:
115
116
  self.pretty_printer._imports["QNum"] = 1
116
117
 
117
118
  params = []
@@ -124,7 +125,7 @@ class VariableDeclarationAssignment(Visitor):
124
125
 
125
126
  return "QNum", params
126
127
 
127
- def visit_TypeName(self, qtype: TypeName) -> Tuple[str, None]:
128
+ def visit_TypeName(self, qtype: TypeName) -> tuple[str, None]:
128
129
  return qtype.name, None
129
130
 
130
131
 
@@ -136,7 +137,7 @@ class PythonPrettyPrinter(Visitor):
136
137
  self._import_enum = False
137
138
  self._import_dataclass = False
138
139
  self._import_annotated = False
139
- self._symbolic_imports: Dict[str, int] = dict()
140
+ self._symbolic_imports: dict[str, int] = dict()
140
141
  self._functions: Optional[Mapping[str, QuantumFunctionDeclaration]] = None
141
142
 
142
143
  def visit(self, node: NodeType) -> str:
@@ -183,7 +184,7 @@ class PythonPrettyPrinter(Visitor):
183
184
  def special_imports(self) -> str:
184
185
  imports = ""
185
186
  if self._import_annotated:
186
- imports += "from typing_extensions import Annotated\n"
187
+ imports += "from typing import Annotated\n"
187
188
  if self._import_dataclass:
188
189
  imports += "from dataclasses import dataclass\n"
189
190
  if self._import_enum:
@@ -214,7 +215,7 @@ class PythonPrettyPrinter(Visitor):
214
215
  self._import_enum = True
215
216
  return f"class {enum_decl.name}(IntEnum):\n{self._visit_members(enum_decl.members)}\n"
216
217
 
217
- def _visit_members(self, members: Dict[str, int]) -> str:
218
+ def _visit_members(self, members: dict[str, int]) -> str:
218
219
  self._level += 1
219
220
  members_str = "".join(
220
221
  f"{self._indent}{self.visit(member_name)} = {member_value}\n"
@@ -418,7 +419,7 @@ class PythonPrettyPrinter(Visitor):
418
419
  return f"{self._indent}invert({self._visit_body(invert.body)})\n"
419
420
 
420
421
  def _visit_body(
421
- self, body: StatementBlock, operand_arguments: Optional[List[str]] = None
422
+ self, body: StatementBlock, operand_arguments: Optional[list[str]] = None
422
423
  ) -> str:
423
424
  if len(body) == 0:
424
425
  return "lambda: []"
@@ -454,7 +455,7 @@ class PythonPrettyPrinter(Visitor):
454
455
  )
455
456
 
456
457
  def visit_QuantumLambdaFunction(self, qlambda: QuantumLambdaFunction) -> str:
457
- return self._visit_body(qlambda.body, qlambda.get_rename_params())
458
+ return self._visit_body(qlambda.body, qlambda.pos_rename_params)
458
459
 
459
460
  def visit_HandleBinding(self, var_ref: HandleBinding) -> str:
460
461
  return var_ref.name
@@ -482,7 +483,7 @@ class PythonPrettyPrinter(Visitor):
482
483
  ) -> str:
483
484
  return f"{self._indent}{self.visit(amplitude_loading_op.result_var)} *= {self.visit(amplitude_loading_op.expression)}\n"
484
485
 
485
- def _print_bind_handles(self, handles: List[HandleBinding]) -> str:
486
+ def _print_bind_handles(self, handles: list[HandleBinding]) -> str:
486
487
  if len(handles) == 1:
487
488
  return self.visit(handles[0])
488
489
 
@@ -26,6 +26,11 @@ if sys.version_info[0:2] >= (3, 9):
26
26
  pass
27
27
  from classiq.interface.generator.functions.concrete_types import ConcreteClassicalType
28
28
 
29
+ CARRAY_ERROR_MESSAGE = (
30
+ "CArray accepts one or two generic parameters in the form "
31
+ "`CArray[<element-type>]` or `CArray[<element-type>, <size>]`"
32
+ )
33
+
29
34
 
30
35
  class PythonClassicalType:
31
36
  def convert(self, py_type: type) -> Optional[ConcreteClassicalType]:
@@ -48,16 +53,15 @@ class PythonClassicalType:
48
53
  element_type=self.convert(array_args[0]),
49
54
  size=get_type_hint_expr(array_args[1]),
50
55
  )
51
- raise ClassiqValueError(
52
- "CArray accepts one or two generic parameters in the form "
53
- "`CArray[<element-type>]` or `CArray[<element-type>, <size>]`"
54
- )
56
+ raise ClassiqValueError(CARRAY_ERROR_MESSAGE)
55
57
  elif inspect.isclass(py_type) and dataclasses.is_dataclass(py_type):
56
58
  self.register_struct(py_type)
57
59
  return Struct(name=py_type.__name__)
58
60
  elif inspect.isclass(py_type) and isinstance(py_type, EnumMeta):
59
61
  self.register_enum(py_type)
60
62
  return Enum(name=py_type.__name__)
63
+ elif py_type in (CArray, list):
64
+ raise ClassiqValueError(CARRAY_ERROR_MESSAGE)
61
65
  return None
62
66
 
63
67
  def register_struct(self, py_type: type) -> None:
classiq/qmod/qfunc.py CHANGED
@@ -1,14 +1,14 @@
1
- from typing import Callable, List, Literal, Optional, Union, overload
1
+ from typing import Callable, Literal, Optional, Union, overload
2
2
 
3
3
  from classiq.qmod.quantum_callable import QCallable
4
4
  from classiq.qmod.quantum_function import ExternalQFunc, GenerativeQFunc, QFunc
5
5
 
6
- GEN_QFUNCS: List[GenerativeQFunc] = []
7
- DEC_QFUNCS: List[QFunc] = []
6
+ GEN_QFUNCS: list[GenerativeQFunc] = []
7
+ DEC_QFUNCS: list[QFunc] = []
8
8
 
9
9
 
10
10
  def set_discovered_functions(
11
- dec_funcs: List[QFunc], gen_funcs: List[GenerativeQFunc]
11
+ dec_funcs: list[QFunc], gen_funcs: list[GenerativeQFunc]
12
12
  ) -> None:
13
13
  DEC_QFUNCS.clear()
14
14
  DEC_QFUNCS.extend(dec_funcs)
@@ -44,7 +44,9 @@ class CParamList(CParam):
44
44
  self._list_type = list_type
45
45
 
46
46
  def __getitem__(self, key: Any) -> CParam:
47
+ param_type = self._list_type.element_type
47
48
  if isinstance(key, slice):
49
+ param_type = self._list_type
48
50
  start = key.start if key.start is not None else ""
49
51
  stop = key.stop if key.stop is not None else ""
50
52
  if key.step is not None:
@@ -53,7 +55,7 @@ class CParamList(CParam):
53
55
  key = f"{start}:{stop}"
54
56
  return create_param(
55
57
  f"({self})[{key}]",
56
- self._list_type.element_type,
58
+ param_type,
57
59
  qmodule=self._qmodule,
58
60
  )
59
61
 
@@ -1,17 +1,15 @@
1
1
  import abc
2
2
  import sys
3
+ from collections.abc import Iterator, Mapping
3
4
  from contextlib import contextmanager
4
5
  from typing import ( # type: ignore[attr-defined]
5
6
  TYPE_CHECKING,
7
+ Annotated,
6
8
  Any,
7
9
  ForwardRef,
8
10
  Generic,
9
- Iterator,
10
11
  Literal,
11
- Mapping,
12
12
  Optional,
13
- Tuple,
14
- Type,
15
13
  TypeVar,
16
14
  Union,
17
15
  _GenericAlias,
@@ -20,7 +18,7 @@ from typing import ( # type: ignore[attr-defined]
20
18
  get_origin,
21
19
  )
22
20
 
23
- from typing_extensions import Annotated, ParamSpec, Self, _AnnotatedAlias
21
+ from typing_extensions import ParamSpec, Self, _AnnotatedAlias
24
22
 
25
23
  from classiq.interface.exceptions import ClassiqValueError
26
24
  from classiq.interface.generator.expressions.expression import Expression
@@ -127,7 +125,7 @@ class QVar(Symbolic):
127
125
  raise NotImplementedError()
128
126
 
129
127
  @staticmethod
130
- def from_type_hint(type_hint: Any) -> Optional[Type["QVar"]]:
128
+ def from_type_hint(type_hint: Any) -> Optional[type["QVar"]]:
131
129
  if _is_input_output_typehint(type_hint):
132
130
  return QVar.from_type_hint(type_hint.__args__[0])
133
131
  type_ = get_origin(type_hint) or type_hint
@@ -322,7 +320,7 @@ class QNum(Generic[_P], QScalar):
322
320
  super().__init__(name, _expr_str=_expr_str, depth=3)
323
321
 
324
322
  @classmethod
325
- def _get_attributes(cls, type_hint: Any) -> Tuple[Any, Any, Any]:
323
+ def _get_attributes(cls, type_hint: Any) -> tuple[Any, Any, Any]:
326
324
  type_args = version_portable_get_args(type_hint)
327
325
  if len(type_args) == 0:
328
326
  return None, None, None
@@ -413,6 +411,9 @@ class QArray(ArrayBase[_P], QVar):
413
411
  self._get_slice(key) if isinstance(key, slice) else self._get_subscript(key)
414
412
  )
415
413
 
414
+ def __setitem__(self, *args: Any) -> None:
415
+ pass
416
+
416
417
  def _get_subscript(self, index: Union[slice, int, SymbolicExpr]) -> Any:
417
418
  if isinstance(index, SymbolicExpr) and index.is_quantum:
418
419
  raise ClassiqValueError("Non-classical parameter for slicing")
@@ -492,7 +493,7 @@ class QArray(ArrayBase[_P], QVar):
492
493
  return CParamScalar(f"get_field({self}, 'len')")
493
494
 
494
495
  @classmethod
495
- def _get_attributes(cls, type_hint: Any) -> Tuple[Type[QVar], Any]:
496
+ def _get_attributes(cls, type_hint: Any) -> tuple[type[QVar], Any]:
496
497
  type_args = version_portable_get_args(type_hint)
497
498
  if len(type_args) == 0:
498
499
  return QBit, None
@@ -505,7 +506,7 @@ class QArray(ArrayBase[_P], QVar):
505
506
  "QArray receives two type arguments: QArray[element_type: QVar, "
506
507
  "length: int | CInt]"
507
508
  )
508
- return cast(Tuple[Type[QVar], Any], type_args)
509
+ return cast(tuple[type[QVar], Any], type_args)
509
510
 
510
511
  @classmethod
511
512
  def to_qmod_quantum_type(cls, type_hint: Any) -> QuantumType:
@@ -597,7 +598,7 @@ class QStruct(QVar):
597
598
  base_handle = HandleBinding(name=origin) if isinstance(origin, str) else origin
598
599
  with _no_current_expandable():
599
600
  field_vars = {
600
- field_name: cast(Type[QVar], field_class).to_qvar(
601
+ field_name: cast(type[QVar], field_class).to_qvar(
601
602
  FieldHandleBinding(base_handle=base_handle, field=field_name),
602
603
  field_type,
603
604
  f"get_field({expr_str if expr_str is not None else str(origin)}, '{field_name}')",
@@ -1,4 +1,5 @@
1
1
  import inspect
2
+ import warnings
2
3
  from abc import ABC
3
4
  from dataclasses import is_dataclass
4
5
  from enum import Enum as PythonEnum
@@ -8,10 +9,7 @@ from typing import (
8
9
  Any,
9
10
  Callable,
10
11
  ClassVar,
11
- Dict,
12
- List,
13
12
  Optional,
14
- Type,
15
13
  Union,
16
14
  cast,
17
15
  overload,
@@ -21,7 +19,7 @@ import pydantic
21
19
  from sympy import Basic
22
20
  from typing_extensions import Self
23
21
 
24
- from classiq.interface.exceptions import ClassiqValueError
22
+ from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqValueError
25
23
  from classiq.interface.generator.expressions.expression import Expression
26
24
  from classiq.interface.generator.functions.concrete_types import (
27
25
  NativePythonClassicalTypes,
@@ -73,15 +71,15 @@ ArgType = Union[CParam, QVar, QCallable]
73
71
 
74
72
 
75
73
  class QExpandable(QCallable, QExpandableInterface, ABC):
76
- STACK: ClassVar[List["QExpandable"]] = list()
74
+ STACK: ClassVar[list["QExpandable"]] = list()
77
75
 
78
76
  def __init__(self, py_callable: Callable) -> None:
79
77
  self._qmodule: ModelStateContainer = QMODULE
80
78
  self._py_callable: Callable = py_callable
81
- self._body: List[QuantumStatement] = list()
79
+ self._body: list[QuantumStatement] = list()
82
80
 
83
81
  @property
84
- def body(self) -> List[QuantumStatement]:
82
+ def body(self) -> list[QuantumStatement]:
85
83
  return self._body
86
84
 
87
85
  def __enter__(self) -> Self:
@@ -92,7 +90,7 @@ class QExpandable(QCallable, QExpandableInterface, ABC):
92
90
 
93
91
  def __exit__(
94
92
  self,
95
- exc_type: Optional[Type[BaseException]],
93
+ exc_type: Optional[type[BaseException]],
96
94
  exc_val: Optional[BaseException],
97
95
  exc_tb: Optional[TracebackType],
98
96
  ) -> None:
@@ -106,7 +104,7 @@ class QExpandable(QCallable, QExpandableInterface, ABC):
106
104
  with self, generative_mode_context(False):
107
105
  self._py_callable(*self._get_positional_args())
108
106
 
109
- def infer_rename_params(self) -> Optional[List[str]]:
107
+ def infer_rename_params(self) -> Optional[list[str]]:
110
108
  return None
111
109
 
112
110
  def add_local_handle(
@@ -124,8 +122,8 @@ class QExpandable(QCallable, QExpandableInterface, ABC):
124
122
  def append_statement_to_body(self, stmt: QuantumStatement) -> None:
125
123
  self._body.append(stmt)
126
124
 
127
- def _get_positional_args(self) -> List[ArgType]:
128
- result: List[ArgType] = []
125
+ def _get_positional_args(self) -> list[ArgType]:
126
+ result: list[ArgType] = []
129
127
  rename_params = self.infer_rename_params()
130
128
  if rename_params is not None and len(rename_params) != len(
131
129
  self.func_decl.positional_arg_declarations
@@ -178,7 +176,7 @@ class QLambdaFunction(QExpandable):
178
176
  if not is_generative_mode():
179
177
  super().expand()
180
178
 
181
- def infer_rename_params(self) -> List[str]:
179
+ def infer_rename_params(self) -> list[str]:
182
180
  return inspect.getfullargspec(self._py_callable).args
183
181
 
184
182
 
@@ -312,7 +310,7 @@ def prepare_arg(
312
310
  f"Quantum operand {param_name!r} cannot be initialized with a "
313
311
  f"list of non-callables"
314
312
  )
315
- val = cast(List[Union[QCallable, Callable[[Any], None]]], val)
313
+ val = cast(list[Union[QCallable, Callable[[Any], None]]], val)
316
314
  return [prepare_arg(arg_decl, v, func_name, param_name) for v in val]
317
315
 
318
316
  if not isinstance(val, QCallable):
@@ -390,8 +388,9 @@ def _get_operand_hint(
390
388
 
391
389
 
392
390
  def _prepare_args(
393
- decl: AnonQuantumFunctionDeclaration, arg_list: List[Any], kwargs: Dict[str, Any]
394
- ) -> List[ArgValue]:
391
+ decl: AnonQuantumFunctionDeclaration, arg_list: list[Any], kwargs: dict[str, Any]
392
+ ) -> list[ArgValue]:
393
+ _apply_control_backward_compatibility(decl, kwargs)
395
394
  result = []
396
395
  for idx, arg_decl in enumerate(decl.positional_arg_declarations):
397
396
  arg = None
@@ -414,6 +413,24 @@ def _prepare_args(
414
413
  return result
415
414
 
416
415
 
416
+ def _apply_control_backward_compatibility(
417
+ decl: AnonQuantumFunctionDeclaration, kwargs: dict[str, Any]
418
+ ) -> None:
419
+ from classiq.qmod.builtins.functions import __all__ as builtin_functions
420
+
421
+ if decl.name in builtin_functions and "control" in kwargs:
422
+ warnings.warn(
423
+ f"Parameter 'control' of function {decl.name!r} has been renamed to "
424
+ f"'ctrl'. Parameter 'control' will no longer be supported starting on "
425
+ f"4/11/24 at the earliest.\nHint: Change {decl.name}(control=...) to "
426
+ f"{decl.name}(ctrl=...).",
427
+ ClassiqDeprecationWarning,
428
+ stacklevel=6,
429
+ )
430
+ kwargs["ctrl"] = kwargs["control"]
431
+ kwargs.pop("control")
432
+
433
+
417
434
  def _create_quantum_function_call(
418
435
  decl_: QuantumFunctionDeclaration,
419
436
  index_: Optional[Union[CParamScalar, int]] = None,