classiq 0.92.0__py3-none-any.whl → 0.94.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.

Potentially problematic release.


This version of classiq might be problematic. Click here for more details.

Files changed (264) hide show
  1. classiq/__init__.py +6 -19
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
  3. classiq/_analyzer_extras/interactive_hardware.py +19 -12
  4. classiq/_internals/api_wrapper.py +38 -52
  5. classiq/_internals/async_utils.py +4 -7
  6. classiq/_internals/authentication/auth0.py +3 -3
  7. classiq/_internals/authentication/device.py +4 -4
  8. classiq/_internals/authentication/password_manager.py +13 -13
  9. classiq/_internals/authentication/token_manager.py +4 -5
  10. classiq/_internals/client.py +17 -44
  11. classiq/_internals/config.py +1 -2
  12. classiq/_internals/help.py +1 -2
  13. classiq/_internals/host_checker.py +3 -3
  14. classiq/_internals/jobs.py +14 -14
  15. classiq/_internals/type_validation.py +3 -3
  16. classiq/analyzer/analyzer.py +18 -18
  17. classiq/analyzer/rb.py +17 -8
  18. classiq/applications/chemistry/__init__.py +0 -30
  19. classiq/applications/chemistry/op_utils.py +4 -4
  20. classiq/applications/chemistry/problems.py +3 -3
  21. classiq/applications/chemistry/ucc.py +1 -2
  22. classiq/applications/chemistry/z2_symmetries.py +4 -4
  23. classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
  24. classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
  25. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
  26. classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
  27. classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
  28. classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
  29. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
  30. classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
  31. classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
  32. classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
  33. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
  34. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
  35. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
  36. classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
  37. classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
  38. classiq/applications/iqae/iqae.py +8 -8
  39. classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
  40. classiq/applications/qnn/datasets/dataset_parity.py +6 -6
  41. classiq/applications/qnn/qlayer.py +8 -7
  42. classiq/applications/qnn/torch_utils.py +3 -4
  43. classiq/applications/qnn/types.py +2 -1
  44. classiq/applications/qsp/qsp.py +6 -5
  45. classiq/applications/qsvm/qsvm_data_generation.py +1 -2
  46. classiq/evaluators/classical_expression.py +0 -4
  47. classiq/evaluators/parameter_types.py +17 -12
  48. classiq/evaluators/qmod_annotated_expression.py +24 -26
  49. classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
  50. classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
  51. classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
  52. classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +4 -4
  53. classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
  54. classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
  55. classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
  56. classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
  57. classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
  58. classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
  59. classiq/execution/execution_session.py +18 -19
  60. classiq/execution/jobs.py +26 -26
  61. classiq/execution/qnn.py +1 -2
  62. classiq/execution/user_budgets.py +52 -7
  63. classiq/executor.py +1 -3
  64. classiq/interface/_version.py +1 -1
  65. classiq/interface/analyzer/analysis_params.py +4 -4
  66. classiq/interface/analyzer/cytoscape_graph.py +3 -3
  67. classiq/interface/analyzer/result.py +4 -4
  68. classiq/interface/applications/qsvm.py +5 -8
  69. classiq/interface/ast_node.py +3 -3
  70. classiq/interface/backend/backend_preferences.py +16 -16
  71. classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
  72. classiq/interface/chemistry/ansatz_library.py +3 -5
  73. classiq/interface/chemistry/operator.py +3 -3
  74. classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
  75. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
  76. classiq/interface/compression_utils.py +2 -3
  77. classiq/interface/debug_info/debug_info.py +7 -7
  78. classiq/interface/exceptions.py +6 -3
  79. classiq/interface/execution/iqcc.py +1 -3
  80. classiq/interface/execution/primitives.py +6 -6
  81. classiq/interface/executor/estimate_cost.py +1 -1
  82. classiq/interface/executor/execution_preferences.py +3 -5
  83. classiq/interface/executor/execution_request.py +10 -10
  84. classiq/interface/executor/execution_result.py +1 -2
  85. classiq/interface/executor/quantum_code.py +8 -8
  86. classiq/interface/executor/result.py +28 -18
  87. classiq/interface/executor/user_budget.py +2 -3
  88. classiq/interface/executor/vqe_result.py +5 -6
  89. classiq/interface/generator/ansatz_library.py +6 -8
  90. classiq/interface/generator/application_apis/__init__.py +0 -2
  91. classiq/interface/generator/arith/arithmetic.py +2 -2
  92. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
  93. classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
  94. classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
  95. classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
  96. classiq/interface/generator/arith/arithmetic_operations.py +4 -6
  97. classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
  98. classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
  99. classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
  100. classiq/interface/generator/arith/binary_ops.py +7 -36
  101. classiq/interface/generator/arith/logical_ops.py +2 -3
  102. classiq/interface/generator/arith/number_utils.py +2 -2
  103. classiq/interface/generator/arith/register_user_input.py +2 -2
  104. classiq/interface/generator/arith/unary_ops.py +2 -2
  105. classiq/interface/generator/circuit_code/circuit_code.py +8 -10
  106. classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
  107. classiq/interface/generator/complex_type.py +2 -2
  108. classiq/interface/generator/copy.py +1 -3
  109. classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
  110. classiq/interface/generator/expressions/evaluated_expression.py +2 -3
  111. classiq/interface/generator/expressions/expression.py +2 -2
  112. classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
  113. classiq/interface/generator/function_param_list.py +0 -20
  114. classiq/interface/generator/function_params.py +5 -6
  115. classiq/interface/generator/functions/classical_function_declaration.py +2 -2
  116. classiq/interface/generator/functions/classical_type.py +3 -3
  117. classiq/interface/generator/functions/type_modifier.py +0 -14
  118. classiq/interface/generator/functions/type_name.py +2 -2
  119. classiq/interface/generator/generated_circuit_data.py +12 -13
  120. classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
  121. classiq/interface/generator/hardware/hardware_data.py +8 -8
  122. classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
  123. classiq/interface/generator/mcu.py +3 -3
  124. classiq/interface/generator/mcx.py +3 -3
  125. classiq/interface/generator/model/constraints.py +34 -5
  126. classiq/interface/generator/model/preferences/preferences.py +15 -21
  127. classiq/interface/generator/model/quantum_register.py +7 -10
  128. classiq/interface/generator/noise_properties.py +3 -7
  129. classiq/interface/generator/parameters.py +1 -1
  130. classiq/interface/generator/partitioned_register.py +1 -2
  131. classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
  132. classiq/interface/generator/qsvm.py +2 -2
  133. classiq/interface/generator/quantum_function_call.py +8 -11
  134. classiq/interface/generator/quantum_program.py +12 -15
  135. classiq/interface/generator/range_types.py +3 -3
  136. classiq/interface/generator/slice_parsing_utils.py +4 -5
  137. classiq/interface/generator/standard_gates/standard_gates.py +2 -4
  138. classiq/interface/generator/state_preparation/state_preparation.py +6 -8
  139. classiq/interface/generator/synthesis_execution_parameter.py +1 -3
  140. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
  141. classiq/interface/generator/transpiler_basis_gates.py +2 -4
  142. classiq/interface/generator/types/builtin_enum_declarations.py +0 -136
  143. classiq/interface/generator/types/compilation_metadata.py +12 -1
  144. classiq/interface/generator/types/enum_declaration.py +2 -1
  145. classiq/interface/generator/validations/flow_graph.py +3 -3
  146. classiq/interface/generator/visitor.py +10 -12
  147. classiq/interface/hardware.py +2 -2
  148. classiq/interface/helpers/classproperty.py +2 -2
  149. classiq/interface/helpers/custom_encoders.py +2 -1
  150. classiq/interface/helpers/custom_pydantic_types.py +1 -1
  151. classiq/interface/helpers/text_utils.py +1 -4
  152. classiq/interface/ide/visual_model.py +5 -5
  153. classiq/interface/jobs.py +3 -3
  154. classiq/interface/model/allocate.py +4 -4
  155. classiq/interface/model/block.py +2 -2
  156. classiq/interface/model/bounds.py +3 -3
  157. classiq/interface/model/control.py +1 -1
  158. classiq/interface/model/inplace_binary_operation.py +2 -2
  159. classiq/interface/model/model.py +4 -4
  160. classiq/interface/model/parameter.py +1 -3
  161. classiq/interface/model/port_declaration.py +1 -1
  162. classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
  163. classiq/interface/model/quantum_function_call.py +3 -6
  164. classiq/interface/model/quantum_function_declaration.py +1 -0
  165. classiq/interface/model/quantum_lambda_function.py +4 -4
  166. classiq/interface/model/quantum_statement.py +4 -4
  167. classiq/interface/model/quantum_type.py +14 -14
  168. classiq/interface/model/validation_handle.py +2 -3
  169. classiq/interface/model/variable_declaration_statement.py +2 -2
  170. classiq/interface/pretty_print/expression_to_qmod.py +3 -4
  171. classiq/interface/server/routes.py +0 -4
  172. classiq/interface/source_reference.py +3 -4
  173. classiq/model_expansions/arithmetic.py +6 -7
  174. classiq/model_expansions/arithmetic_compute_result_attrs.py +4 -5
  175. classiq/model_expansions/capturing/captured_vars.py +3 -3
  176. classiq/model_expansions/capturing/mangling_utils.py +1 -2
  177. classiq/model_expansions/closure.py +12 -11
  178. classiq/model_expansions/function_builder.py +14 -6
  179. classiq/model_expansions/generative_functions.py +1 -4
  180. classiq/model_expansions/interpreters/base_interpreter.py +2 -6
  181. classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
  182. classiq/model_expansions/quantum_operations/allocate.py +4 -4
  183. classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
  184. classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
  185. classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
  186. classiq/model_expansions/quantum_operations/emitter.py +3 -5
  187. classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
  188. classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
  189. classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
  190. classiq/model_expansions/scope.py +7 -7
  191. classiq/model_expansions/scope_initialization.py +4 -0
  192. classiq/model_expansions/visitors/symbolic_param_inference.py +3 -3
  193. classiq/model_expansions/visitors/uncomputation_signature_inference.py +317 -0
  194. classiq/model_expansions/visitors/variable_references.py +15 -14
  195. classiq/open_library/functions/__init__.py +6 -0
  196. classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
  197. classiq/open_library/functions/grover.py +8 -10
  198. classiq/open_library/functions/modular_exponentiation.py +96 -8
  199. classiq/qmod/__init__.py +5 -2
  200. classiq/qmod/builtins/classical_execution_primitives.py +4 -11
  201. classiq/qmod/builtins/classical_functions.py +1 -42
  202. classiq/qmod/builtins/enums.py +0 -136
  203. classiq/qmod/builtins/functions/__init__.py +0 -13
  204. classiq/qmod/builtins/functions/allocation.py +4 -4
  205. classiq/qmod/builtins/functions/arithmetic.py +22 -27
  206. classiq/qmod/builtins/functions/standard_gates.py +27 -27
  207. classiq/qmod/builtins/operations.py +43 -58
  208. classiq/qmod/builtins/structs.py +2 -58
  209. classiq/qmod/cfunc.py +3 -2
  210. classiq/qmod/classical_function.py +2 -1
  211. classiq/qmod/classical_variable.py +4 -2
  212. classiq/qmod/cparam.py +2 -8
  213. classiq/qmod/create_model_function.py +7 -7
  214. classiq/qmod/declaration_inferrer.py +33 -30
  215. classiq/qmod/model_state_container.py +2 -2
  216. classiq/qmod/native/pretty_printer.py +25 -14
  217. classiq/qmod/pretty_print/expression_to_python.py +5 -3
  218. classiq/qmod/pretty_print/pretty_printer.py +39 -17
  219. classiq/qmod/python_classical_type.py +40 -13
  220. classiq/qmod/qfunc.py +139 -16
  221. classiq/qmod/qmod_constant.py +2 -2
  222. classiq/qmod/qmod_parameter.py +5 -2
  223. classiq/qmod/qmod_variable.py +47 -43
  224. classiq/qmod/quantum_callable.py +18 -13
  225. classiq/qmod/quantum_expandable.py +33 -26
  226. classiq/qmod/quantum_function.py +51 -32
  227. classiq/qmod/semantics/annotation/call_annotation.py +2 -2
  228. classiq/qmod/semantics/error_manager.py +5 -6
  229. classiq/qmod/semantics/lambdas.py +1 -2
  230. classiq/qmod/semantics/validation/types_validation.py +1 -2
  231. classiq/qmod/symbolic.py +2 -4
  232. classiq/qmod/symbolic_expr.py +12 -4
  233. classiq/qmod/utilities.py +13 -10
  234. classiq/qmod/write_qmod.py +3 -4
  235. classiq/quantum_program.py +1 -3
  236. classiq/synthesis.py +11 -7
  237. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/METADATA +38 -37
  238. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/RECORD +240 -261
  239. classiq-0.94.0.dist-info/WHEEL +4 -0
  240. classiq-0.94.0.dist-info/licenses/LICENSE.txt +27 -0
  241. classiq/applications/chemistry/ansatz_parameters.py +0 -29
  242. classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
  243. classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
  244. classiq/applications/chemistry/ground_state_problem.py +0 -42
  245. classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
  246. classiq/interface/chemistry/elements.py +0 -120
  247. classiq/interface/chemistry/fermionic_operator.py +0 -208
  248. classiq/interface/chemistry/ground_state_problem.py +0 -132
  249. classiq/interface/chemistry/ground_state_result.py +0 -8
  250. classiq/interface/chemistry/molecule.py +0 -71
  251. classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
  252. classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
  253. classiq/interface/generator/chemistry_function_params.py +0 -50
  254. classiq/interface/generator/entangler_params.py +0 -72
  255. classiq/interface/generator/entanglers.py +0 -14
  256. classiq/interface/generator/hartree_fock.py +0 -26
  257. classiq/interface/generator/hva.py +0 -22
  258. classiq/interface/generator/linear_pauli_rotations.py +0 -92
  259. classiq/interface/generator/qft.py +0 -37
  260. classiq/interface/generator/ucc.py +0 -74
  261. classiq/interface/helpers/backward_compatibility.py +0 -9
  262. classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
  263. classiq/qmod/builtins/functions/chemistry.py +0 -123
  264. classiq-0.92.0.dist-info/WHEEL +0 -4
@@ -1,8 +1,8 @@
1
1
  from typing import Literal
2
2
 
3
- from classiq.qmod.qfunc import qfunc
3
+ from classiq.qmod.qfunc import qfunc, qperm
4
4
  from classiq.qmod.qmod_parameter import CReal
5
- from classiq.qmod.qmod_variable import Const, Permutable, QArray, QBit
5
+ from classiq.qmod.qmod_variable import Const, QArray, QBit
6
6
 
7
7
 
8
8
  @qfunc(external=True)
@@ -24,8 +24,8 @@ def H(target: QBit) -> None:
24
24
  pass
25
25
 
26
26
 
27
- @qfunc(external=True)
28
- def X(target: Permutable[QBit]) -> None:
27
+ @qperm(external=True)
28
+ def X(target: QBit) -> None:
29
29
  """
30
30
  [Qmod core-library function]
31
31
 
@@ -43,8 +43,8 @@ def X(target: Permutable[QBit]) -> None:
43
43
  pass
44
44
 
45
45
 
46
- @qfunc(external=True)
47
- def Y(target: Permutable[QBit]) -> None:
46
+ @qperm(external=True)
47
+ def Y(target: QBit) -> None:
48
48
  """
49
49
  [Qmod core-library function]
50
50
 
@@ -62,7 +62,7 @@ def Y(target: Permutable[QBit]) -> None:
62
62
  pass
63
63
 
64
64
 
65
- @qfunc(external=True)
65
+ @qperm(external=True)
66
66
  def Z(target: Const[QBit]) -> None:
67
67
  """
68
68
  [Qmod core-library function]
@@ -81,7 +81,7 @@ def Z(target: Const[QBit]) -> None:
81
81
  pass
82
82
 
83
83
 
84
- @qfunc(external=True)
84
+ @qperm(external=True)
85
85
  def I(target: Const[QBit]) -> None:
86
86
  """
87
87
  [Qmod core-library function]
@@ -100,7 +100,7 @@ def I(target: Const[QBit]) -> None:
100
100
  pass
101
101
 
102
102
 
103
- @qfunc(external=True)
103
+ @qperm(external=True)
104
104
  def S(target: Const[QBit]) -> None:
105
105
  """
106
106
  [Qmod core-library function]
@@ -119,7 +119,7 @@ def S(target: Const[QBit]) -> None:
119
119
  pass
120
120
 
121
121
 
122
- @qfunc(external=True)
122
+ @qperm(external=True)
123
123
  def T(target: Const[QBit]) -> None:
124
124
  """
125
125
  [Qmod core-library function]
@@ -138,7 +138,7 @@ def T(target: Const[QBit]) -> None:
138
138
  pass
139
139
 
140
140
 
141
- @qfunc(external=True)
141
+ @qperm(external=True)
142
142
  def SDG(target: Const[QBit]) -> None:
143
143
  """
144
144
  [Qmod core-library function]
@@ -157,7 +157,7 @@ def SDG(target: Const[QBit]) -> None:
157
157
  pass
158
158
 
159
159
 
160
- @qfunc(external=True)
160
+ @qperm(external=True)
161
161
  def TDG(target: Const[QBit]) -> None:
162
162
  """
163
163
  [Qmod core-library function]
@@ -176,7 +176,7 @@ def TDG(target: Const[QBit]) -> None:
176
176
  pass
177
177
 
178
178
 
179
- @qfunc(external=True)
179
+ @qperm(external=True)
180
180
  def PHASE(theta: CReal, target: Const[QBit]) -> None:
181
181
  """
182
182
  [Qmod core-library function]
@@ -238,7 +238,7 @@ def RY(theta: CReal, target: QBit) -> None:
238
238
  pass
239
239
 
240
240
 
241
- @qfunc(external=True)
241
+ @qperm(external=True)
242
242
  def RZ(theta: CReal, target: Const[QBit]) -> None:
243
243
  """
244
244
  [Qmod core-library function]
@@ -323,7 +323,7 @@ def RYY(theta: CReal, target: QArray[QBit, Literal[2]]) -> None:
323
323
  pass
324
324
 
325
325
 
326
- @qfunc(external=True)
326
+ @qperm(external=True)
327
327
  def RZZ(theta: CReal, target: Const[QArray[QBit, Literal[2]]]) -> None:
328
328
  """
329
329
  [Qmod core-library function]
@@ -369,8 +369,8 @@ def CH(ctrl: Const[QBit], target: QBit) -> None:
369
369
  pass
370
370
 
371
371
 
372
- @qfunc(external=True)
373
- def CX(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
372
+ @qperm(external=True)
373
+ def CX(ctrl: Const[QBit], target: QBit) -> None:
374
374
  """
375
375
  [Qmod core-library function]
376
376
 
@@ -394,8 +394,8 @@ def CX(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
394
394
  pass
395
395
 
396
396
 
397
- @qfunc(external=True)
398
- def CY(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
397
+ @qperm(external=True)
398
+ def CY(ctrl: Const[QBit], target: QBit) -> None:
399
399
  """
400
400
  [Qmod core-library function]
401
401
 
@@ -419,7 +419,7 @@ def CY(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
419
419
  pass
420
420
 
421
421
 
422
- @qfunc(external=True)
422
+ @qperm(external=True)
423
423
  def CZ(ctrl: Const[QBit], target: Const[QBit]) -> None:
424
424
  """
425
425
  [Qmod core-library function]
@@ -496,7 +496,7 @@ def CRY(theta: CReal, ctrl: Const[QBit], target: QBit) -> None:
496
496
  pass
497
497
 
498
498
 
499
- @qfunc(external=True)
499
+ @qperm(external=True)
500
500
  def CRZ(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
501
501
  """
502
502
  [Qmod core-library function]
@@ -522,7 +522,7 @@ def CRZ(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
522
522
  pass
523
523
 
524
524
 
525
- @qfunc(external=True)
525
+ @qperm(external=True)
526
526
  def CPHASE(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
527
527
  """
528
528
  [Qmod core-library function]
@@ -548,8 +548,8 @@ def CPHASE(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
548
548
  pass
549
549
 
550
550
 
551
- @qfunc(external=True)
552
- def SWAP(qbit0: Permutable[QBit], qbit1: Permutable[QBit]) -> None:
551
+ @qperm(external=True)
552
+ def SWAP(qbit0: QBit, qbit1: QBit) -> None:
553
553
  """
554
554
  [Qmod core-library function]
555
555
 
@@ -573,7 +573,7 @@ def SWAP(qbit0: Permutable[QBit], qbit1: Permutable[QBit]) -> None:
573
573
  pass
574
574
 
575
575
 
576
- @qfunc(external=True)
576
+ @qperm(external=True)
577
577
  def IDENTITY(target: Const[QArray[QBit]]) -> None:
578
578
  """
579
579
  [Qmod core-library function]
@@ -622,8 +622,8 @@ def U(theta: CReal, phi: CReal, lam: CReal, gam: CReal, target: QBit) -> None:
622
622
  pass
623
623
 
624
624
 
625
- @qfunc(external=True)
626
- def CCX(ctrl: Const[QArray[QBit, Literal[2]]], target: Permutable[QBit]) -> None:
625
+ @qperm(external=True)
626
+ def CCX(ctrl: Const[QArray[QBit, Literal[2]]], target: QBit) -> None:
627
627
  """
628
628
  [Qmod core-library function]
629
629
 
@@ -1,19 +1,15 @@
1
1
  import inspect
2
2
  import sys
3
- import warnings
4
- from collections.abc import Mapping
3
+ from collections.abc import Callable, Mapping
5
4
  from types import FrameType
6
5
  from typing import (
7
6
  Any,
8
- Callable,
9
7
  Final,
10
8
  NoReturn,
11
- Optional,
12
- Union,
13
9
  overload,
14
10
  )
15
11
 
16
- from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqValueError
12
+ from classiq.interface.exceptions import ClassiqValueError
17
13
  from classiq.interface.generator.expressions.expression import Expression
18
14
  from classiq.interface.generator.functions.builtins.internal_operators import (
19
15
  REPEAT_OPERATOR_NAME,
@@ -61,7 +57,7 @@ _MISSING_VALUE: Final[int] = -1
61
57
 
62
58
 
63
59
  @overload
64
- def allocate(num_qubits: Union[int, SymbolicExpr], out: Output[QVar]) -> None:
60
+ def allocate(num_qubits: int | SymbolicExpr, out: Output[QVar]) -> None:
65
61
  pass
66
62
 
67
63
 
@@ -72,9 +68,9 @@ def allocate(out: Output[QVar]) -> None:
72
68
 
73
69
  @overload
74
70
  def allocate(
75
- num_qubits: Union[int, SymbolicExpr],
76
- is_signed: Union[bool, SymbolicExpr],
77
- fraction_digits: Union[int, SymbolicExpr],
71
+ num_qubits: int | SymbolicExpr,
72
+ is_signed: bool | SymbolicExpr,
73
+ fraction_digits: int | SymbolicExpr,
78
74
  out: Output[QVar],
79
75
  ) -> None:
80
76
  pass
@@ -146,8 +142,8 @@ def allocate(*args: Any, **kwargs: Any) -> None:
146
142
 
147
143
  @suppress_return_value
148
144
  def bind(
149
- source: Union[Input[QVar], list[Input[QVar]]],
150
- destination: Union[Output[QVar], list[Output[QVar]]],
145
+ source: Input[QVar] | list[Input[QVar]],
146
+ destination: Output[QVar] | list[Output[QVar]],
151
147
  ) -> None:
152
148
  """
153
149
  Reassign qubit or arrays of qubits by redirecting their logical identifiers.
@@ -182,9 +178,9 @@ def bind(
182
178
 
183
179
  @suppress_return_value
184
180
  def if_(
185
- condition: Union[SymbolicExpr, bool],
186
- then: Union[QCallable, Callable[[], Statements]],
187
- else_: Union[QCallable, Callable[[], Statements], int] = _MISSING_VALUE,
181
+ condition: SymbolicExpr | bool,
182
+ then: QCallable | Callable[[], Statements],
183
+ else_: QCallable | Callable[[], Statements] | int = _MISSING_VALUE,
188
184
  ) -> None:
189
185
  """
190
186
  Conditionally executes quantum operations based on a symbolic or boolean expression.
@@ -219,9 +215,9 @@ def if_(
219
215
 
220
216
  @suppress_return_value
221
217
  def control(
222
- ctrl: Union[SymbolicExpr, QBit, QArray[QBit], list[QVar]],
223
- stmt_block: Union[QCallable, Callable[[], Statements]],
224
- else_block: Union[QCallable, Callable[[], Statements], None] = None,
218
+ ctrl: SymbolicExpr | QBit | QArray[QBit] | list[QVar],
219
+ stmt_block: QCallable | Callable[[], Statements],
220
+ else_block: QCallable | Callable[[], Statements] | None = None,
225
221
  ) -> None:
226
222
  """
227
223
  Conditionally executes quantum operations based on the value of quantum variables or expressions.
@@ -256,7 +252,15 @@ def control(
256
252
 
257
253
 
258
254
  @suppress_return_value
259
- def skip_control(stmt_block: Union[QCallable, Callable[[], Statements]]) -> None:
255
+ def skip_control(stmt_block: QCallable | Callable[[], Statements]) -> None:
256
+ """
257
+ Applies quantum statements unconditionally.
258
+
259
+ Args:
260
+ stmt_block: A callable that produces a quantum operation.
261
+
262
+ For more details, see [Qmod Reference](https://docs.classiq.io/latest/qmod-reference/language-reference/statements/skip-control).
263
+ """
260
264
  _validate_operand(stmt_block)
261
265
  assert QCallable.CURRENT_EXPANDABLE is not None
262
266
  source_ref = get_source_ref(sys._getframe(1))
@@ -396,9 +400,7 @@ def within_apply(
396
400
 
397
401
 
398
402
  @suppress_return_value
399
- def repeat(
400
- count: Union[SymbolicExpr, int], iteration: Callable[[int], Statements]
401
- ) -> None:
403
+ def repeat(count: SymbolicExpr | int, iteration: Callable[[int], Statements]) -> None:
402
404
  """
403
405
  Executes a quantum loop a specified number of times, applying a quantum operation on each iteration.
404
406
 
@@ -454,8 +456,8 @@ def repeat(
454
456
 
455
457
  @suppress_return_value
456
458
  def power(
457
- exponent: Union[SymbolicExpr, int],
458
- stmt_block: Union[QCallable, Callable[[], Statements]],
459
+ exponent: SymbolicExpr | int,
460
+ stmt_block: QCallable | Callable[[], Statements],
459
461
  ) -> None:
460
462
  """
461
463
  Apply a quantum operation raised to a symbolic or integer power.
@@ -499,7 +501,7 @@ def power(
499
501
 
500
502
 
501
503
  @suppress_return_value
502
- def invert(stmt_block: Union[QCallable, Callable[[], Statements]]) -> None:
504
+ def invert(stmt_block: QCallable | Callable[[], Statements]) -> None:
503
505
  """
504
506
  Apply the inverse of a quantum gate.
505
507
 
@@ -532,25 +534,10 @@ def invert(stmt_block: Union[QCallable, Callable[[], Statements]]) -> None:
532
534
  QCallable.CURRENT_EXPANDABLE.append_statement_to_body(invert_stmt)
533
535
 
534
536
 
535
- @overload
536
- def phase(
537
- phase_expr: Union[SymbolicExpr, float], theta: Union[SymbolicExpr, float] = 1.0
538
- ) -> None:
539
- pass
540
-
541
-
542
- @overload
543
- def phase(
544
- *, expr: Union[SymbolicExpr, float], theta: Union[SymbolicExpr, float] = 1.0
545
- ) -> None:
546
- pass
547
-
548
-
549
537
  @suppress_return_value
550
538
  def phase(
551
- phase_expr: Union[SymbolicExpr, float, None] = None,
552
- theta: Union[SymbolicExpr, float] = 1.0,
553
- expr: Any = None,
539
+ phase_expr: SymbolicExpr | float | None = None,
540
+ theta: SymbolicExpr | float = 1.0,
554
541
  ) -> None:
555
542
  """
556
543
  Applies a state-dependent or fixed phase shift (Z rotation) to the quantum state.
@@ -570,16 +557,6 @@ def phase(
570
557
  they are equivalent when the phase_expr is a single-qubit variable.
571
558
  """
572
559
  assert QCallable.CURRENT_EXPANDABLE is not None
573
- if expr is not None:
574
- warnings.warn(
575
- "Parameter 'expr' of function 'phase' has been renamed to "
576
- "'phase_expr'. Parameter 'expr' will no longer be supported starting on "
577
- "2025-09-19 at the earliest.\nHint: Change `phase(expr=..., theta=...)` to "
578
- "`phase(phase_expr=..., theta=...)` or `phase(..., ...)`.",
579
- category=ClassiqDeprecationWarning,
580
- stacklevel=2,
581
- )
582
- phase_expr = expr
583
560
  source_ref = get_source_ref(sys._getframe(1))
584
561
  QCallable.CURRENT_EXPANDABLE.append_statement_to_body(
585
562
  PhaseOperation(
@@ -592,7 +569,7 @@ def phase(
592
569
 
593
570
  @suppress_return_value
594
571
  def block(
595
- statements: Union[QCallable, Callable[[], Statements]],
572
+ statements: QCallable | Callable[[], Statements],
596
573
  ) -> None:
597
574
  _validate_operand(statements)
598
575
  assert QCallable.CURRENT_EXPANDABLE is not None
@@ -617,8 +594,8 @@ def reset_bounds(
617
594
  @overload
618
595
  def reset_bounds(
619
596
  target_var: QNum,
620
- lower_bound: Union[float, SymbolicExpr],
621
- upper_bound: Union[float, SymbolicExpr],
597
+ lower_bound: float | SymbolicExpr,
598
+ upper_bound: float | SymbolicExpr,
622
599
  ) -> None:
623
600
  pass
624
601
 
@@ -626,8 +603,8 @@ def reset_bounds(
626
603
  @suppress_return_value
627
604
  def reset_bounds(
628
605
  target_var: QNum,
629
- lower_bound: Optional[Union[float, SymbolicExpr]] = None,
630
- upper_bound: Optional[Union[float, SymbolicExpr]] = None,
606
+ lower_bound: float | SymbolicExpr | None = None,
607
+ upper_bound: float | SymbolicExpr | None = None,
631
608
  ) -> None:
632
609
  assert QCallable.CURRENT_EXPANDABLE is not None
633
610
  source_ref = get_source_ref(sys._getframe(1))
@@ -660,6 +637,14 @@ def _validate_operand(stmt_block: Any, num_params: int = 0) -> None:
660
637
  )
661
638
  if isinstance(stmt_block, QCallable):
662
639
  return
640
+ if not callable(stmt_block):
641
+ _raise_operand_error(
642
+ lambda operation_name, operand_arg_name: (
643
+ f"Argument {operand_arg_name!r} to {operation_name!r} must be a "
644
+ f"callable object"
645
+ ),
646
+ num_params,
647
+ )
663
648
  op_spec = inspect.getfullargspec(stmt_block)
664
649
  params = op_spec.args[: len(op_spec.args) - len(op_spec.defaults or ())]
665
650
  if len(params) > num_params or (
@@ -726,7 +711,7 @@ def _get_operand_hint(
726
711
 
727
712
 
728
713
  def _operand_to_body(
729
- callable_: Union[QCallable, Callable[[], Statements]], param_name: str
714
+ callable_: QCallable | Callable[[], Statements], param_name: str
730
715
  ) -> StatementBlock:
731
716
  op_name = sys._getframe(1).f_code.co_name
732
717
  if (
@@ -5,8 +5,8 @@ from classiq.interface.exceptions import ClassiqValueError
5
5
  from classiq.interface.generator.types.struct_declaration import StructDeclaration
6
6
  from classiq.interface.helpers.text_utils import are, readable_list, s
7
7
 
8
- from classiq.qmod.builtins.enums import LadderOperator, Pauli
9
- from classiq.qmod.cparam import CArray, CBool, CInt, CReal
8
+ from classiq.qmod.builtins.enums import Pauli
9
+ from classiq.qmod.cparam import CArray, CInt, CReal
10
10
  from classiq.qmod.python_classical_type import PythonClassicalType
11
11
 
12
12
 
@@ -131,55 +131,6 @@ class SparsePauliOp:
131
131
  )
132
132
 
133
133
 
134
- @dataclass
135
- class Position:
136
- x: CReal
137
- y: CReal
138
- z: CReal
139
-
140
-
141
- @dataclass
142
- class ChemistryAtom:
143
- element: CInt
144
- position: Position
145
-
146
-
147
- @dataclass
148
- class Molecule:
149
- atoms: CArray[ChemistryAtom]
150
- spin: CInt
151
- charge: CInt
152
-
153
-
154
- @dataclass
155
- class MoleculeProblem:
156
- mapping: CInt
157
- z2_symmetries: CBool
158
- molecule: Molecule
159
- freeze_core: CBool
160
- remove_orbitals: CArray[CInt]
161
-
162
-
163
- @dataclass
164
- class LadderOp:
165
- op: LadderOperator
166
- index: CInt
167
-
168
-
169
- @dataclass
170
- class LadderTerm:
171
- coefficient: CReal
172
- ops: CArray[LadderOp]
173
-
174
-
175
- @dataclass
176
- class FockHamiltonianProblem:
177
- mapping: CInt
178
- z2_symmetries: CBool
179
- terms: CArray[LadderTerm]
180
- num_particles: CArray[CInt]
181
-
182
-
183
134
  @dataclass
184
135
  class CombinatorialOptimizationSolution:
185
136
  probability: CReal
@@ -234,18 +185,11 @@ BUILTIN_STRUCT_DECLARATIONS = {
234
185
 
235
186
 
236
187
  __all__ = [
237
- "ChemistryAtom",
238
188
  "CombinatorialOptimizationSolution",
239
- "FockHamiltonianProblem",
240
189
  "GaussianModel",
241
190
  "IndexedPauli",
242
- "LadderOp",
243
- "LadderTerm",
244
191
  "LogNormalModel",
245
- "Molecule",
246
- "MoleculeProblem",
247
192
  "PauliTerm",
248
- "Position",
249
193
  "QSVMFeatureMapPauli",
250
194
  "QsvmResult",
251
195
  "SparsePauliOp",
classiq/qmod/cfunc.py CHANGED
@@ -1,4 +1,5 @@
1
- from typing import Any, Callable, Optional, Union, overload
1
+ from collections.abc import Callable
2
+ from typing import Any, overload
2
3
 
3
4
  from classiq.qmod.classical_function import CFunc
4
5
 
@@ -30,7 +31,7 @@ def cfunc(func: Callable) -> CFunc: ...
30
31
  def cfunc(func: None = None) -> Callable[[Callable], CFunc]: ...
31
32
 
32
33
 
33
- def cfunc(func: Optional[Callable] = None) -> Union[Callable[[Callable], CFunc], CFunc]:
34
+ def cfunc(func: Callable | None = None) -> Callable[[Callable], CFunc] | CFunc:
34
35
  caller_locals = get_caller_locals()
35
36
 
36
37
  def wrapper(func: Callable) -> CFunc:
@@ -1,7 +1,8 @@
1
1
  import ast
2
2
  import inspect
3
+ from collections.abc import Callable
3
4
  from textwrap import dedent
4
- from typing import Any, Callable
5
+ from typing import Any
5
6
 
6
7
  from classiq.interface.exceptions import ClassiqValueError
7
8
 
@@ -1,7 +1,7 @@
1
1
  import sys
2
2
  from typing import TYPE_CHECKING, Any
3
3
 
4
- from classiq.interface.exceptions import ClassiqInternalError
4
+ from classiq.interface.exceptions import ClassiqInternalError, ClassiqTypeError
5
5
  from classiq.interface.generator.expressions.expression import Expression
6
6
  from classiq.interface.generator.functions.classical_type import Bool, ClassicalType
7
7
  from classiq.interface.model.handle_binding import HandleBinding
@@ -37,7 +37,9 @@ def declare_classical_variable(
37
37
 
38
38
  def assign_classical_variable(target: CParam, value: Any, frame_depth: int) -> None:
39
39
  if not isinstance(value, SYMBOLIC_TYPES):
40
- raise TypeError(f"Invalid argument {value!r} for classical variable assignment")
40
+ raise ClassiqTypeError(
41
+ f"Invalid argument {value!r} for classical variable assignment"
42
+ )
41
43
 
42
44
  if TYPE_CHECKING:
43
45
  assert QCallable.CURRENT_EXPANDABLE is not None
classiq/qmod/cparam.py CHANGED
@@ -1,11 +1,9 @@
1
- import sys
2
1
  from abc import ABC, abstractmethod
3
- from typing import ( # type: ignore[attr-defined]
2
+ from typing import (
4
3
  TYPE_CHECKING,
5
4
  Any,
6
5
  Generic,
7
6
  Union,
8
- _GenericAlias,
9
7
  )
10
8
 
11
9
  from typing_extensions import ParamSpec
@@ -59,11 +57,7 @@ _P = ParamSpec("_P")
59
57
 
60
58
 
61
59
  class ArrayBase(Generic[_P]):
62
- # Support comma-separated generic args in older Python versions
63
- if sys.version_info[0:2] < (3, 10):
64
-
65
- def __class_getitem__(cls, args) -> _GenericAlias:
66
- return _GenericAlias(cls, args)
60
+ pass
67
61
 
68
62
 
69
63
  class CArray(CParamAbstract, ArrayBase[_P]):
@@ -1,4 +1,4 @@
1
- from typing import Optional, Union, cast
1
+ from typing import cast
2
2
 
3
3
  from classiq.interface.exceptions import ClassiqError
4
4
  from classiq.interface.executor.execution_preferences import ExecutionPreferences
@@ -28,12 +28,12 @@ def add_entry_point(
28
28
 
29
29
 
30
30
  def create_model(
31
- entry_point: Union[QFunc, GenerativeQFunc],
32
- constraints: Optional[Constraints] = None,
33
- execution_preferences: Optional[ExecutionPreferences] = None,
34
- preferences: Optional[Preferences] = None,
35
- classical_execution_function: Optional[CFunc] = None,
36
- out_file: Optional[str] = None,
31
+ entry_point: QFunc | GenerativeQFunc,
32
+ constraints: Constraints | None = None,
33
+ execution_preferences: ExecutionPreferences | None = None,
34
+ preferences: Preferences | None = None,
35
+ classical_execution_function: CFunc | None = None,
36
+ out_file: str | None = None,
37
37
  ) -> SerializedModel:
38
38
  """
39
39
  Create a serialized model from a given Qmod entry function and additional parameters.