classiq 0.93.0__py3-none-any.whl → 0.94.1__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 (261) 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 +5 -4
  45. classiq/applications/qsvm/qsvm_data_generation.py +1 -2
  46. classiq/evaluators/classical_expression.py +0 -4
  47. classiq/evaluators/parameter_types.py +7 -8
  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 +2 -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 +5 -3
  182. classiq/model_expansions/quantum_operations/allocate.py +4 -4
  183. classiq/model_expansions/quantum_operations/assignment_result_processor.py +2 -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 +2 -2
  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 +5 -5
  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 +35 -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/cparam.py +2 -8
  212. classiq/qmod/create_model_function.py +7 -7
  213. classiq/qmod/declaration_inferrer.py +33 -30
  214. classiq/qmod/model_state_container.py +2 -2
  215. classiq/qmod/native/pretty_printer.py +25 -14
  216. classiq/qmod/pretty_print/expression_to_python.py +5 -3
  217. classiq/qmod/pretty_print/pretty_printer.py +39 -17
  218. classiq/qmod/python_classical_type.py +40 -13
  219. classiq/qmod/qfunc.py +139 -16
  220. classiq/qmod/qmod_constant.py +2 -2
  221. classiq/qmod/qmod_parameter.py +5 -2
  222. classiq/qmod/qmod_variable.py +47 -43
  223. classiq/qmod/quantum_callable.py +18 -13
  224. classiq/qmod/quantum_expandable.py +31 -26
  225. classiq/qmod/quantum_function.py +51 -32
  226. classiq/qmod/semantics/annotation/call_annotation.py +2 -2
  227. classiq/qmod/semantics/error_manager.py +5 -6
  228. classiq/qmod/semantics/lambdas.py +1 -2
  229. classiq/qmod/semantics/validation/types_validation.py +1 -2
  230. classiq/qmod/symbolic.py +2 -4
  231. classiq/qmod/utilities.py +13 -10
  232. classiq/qmod/write_qmod.py +3 -4
  233. classiq/quantum_program.py +1 -3
  234. classiq/synthesis.py +11 -7
  235. {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/METADATA +2 -3
  236. {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/RECORD +238 -260
  237. classiq/applications/chemistry/ansatz_parameters.py +0 -29
  238. classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
  239. classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
  240. classiq/applications/chemistry/ground_state_problem.py +0 -42
  241. classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
  242. classiq/interface/chemistry/elements.py +0 -120
  243. classiq/interface/chemistry/fermionic_operator.py +0 -208
  244. classiq/interface/chemistry/ground_state_problem.py +0 -132
  245. classiq/interface/chemistry/ground_state_result.py +0 -8
  246. classiq/interface/chemistry/molecule.py +0 -71
  247. classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
  248. classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
  249. classiq/interface/generator/chemistry_function_params.py +0 -50
  250. classiq/interface/generator/entangler_params.py +0 -72
  251. classiq/interface/generator/entanglers.py +0 -14
  252. classiq/interface/generator/hartree_fock.py +0 -26
  253. classiq/interface/generator/hva.py +0 -22
  254. classiq/interface/generator/linear_pauli_rotations.py +0 -92
  255. classiq/interface/generator/qft.py +0 -37
  256. classiq/interface/generator/ucc.py +0 -74
  257. classiq/interface/helpers/backward_compatibility.py +0 -9
  258. classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
  259. classiq/qmod/builtins/functions/chemistry.py +0 -123
  260. {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/WHEEL +0 -0
  261. {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/licenses/LICENSE.txt +0 -0
classiq/__init__.py CHANGED
@@ -1,19 +1,7 @@
1
1
  """Classiq SDK."""
2
2
 
3
- import sys
4
- import warnings
5
-
6
- from classiq.interface.exceptions import ClassiqDeprecationWarning
7
-
8
- if sys.version_info[0:2] <= (3, 9):
9
- warnings.warn(
10
- "Python version 3.9 will no longer be supported starting on 2025-10-01 "
11
- "at the earliest",
12
- ClassiqDeprecationWarning,
13
- stacklevel=2,
14
- )
15
-
16
3
  from classiq.interface._version import VERSION as _VERSION
4
+ from classiq.interface.exceptions import ClassiqDeprecationWarning
17
5
  from classiq.interface.generator.application_apis import * # noqa: F403
18
6
  from classiq.interface.generator.arith.register_user_input import (
19
7
  RegisterArithmeticInfo,
@@ -36,10 +24,6 @@ from classiq._internals.client import configure
36
24
  from classiq._internals.config import Configuration
37
25
  from classiq._internals.help import open_help
38
26
  from classiq.analyzer import Analyzer
39
- from classiq.applications.chemistry import (
40
- construct_chemistry_model,
41
- molecule_problem_to_qmod,
42
- )
43
27
  from classiq.applications.combinatorial_optimization import (
44
28
  CombinatorialProblem,
45
29
  compute_qaoa_initial_point,
@@ -51,6 +35,7 @@ from classiq.applications.hamiltonian.pauli_decomposition import (
51
35
  hamiltonian_to_matrix,
52
36
  matrix_to_hamiltonian,
53
37
  matrix_to_pauli_operator,
38
+ pauli_operator_to_matrix,
54
39
  )
55
40
  from classiq.execution import * # noqa: F403
56
41
  from classiq.execution import __all__ as _execution_all
@@ -65,6 +50,7 @@ from classiq.qmod import * # noqa: F403
65
50
  from classiq.qmod import __all__ as _qmod_all
66
51
  from classiq.quantum_program import ExecutionParams, assign_parameters, transpile
67
52
  from classiq.synthesis import (
53
+ QmodFormat,
68
54
  qasm_to_qmod,
69
55
  quantum_program_from_qasm,
70
56
  quantum_program_from_qasm_async,
@@ -81,8 +67,6 @@ from classiq.synthesis import (
81
67
 
82
68
  _application_constructors_all = [
83
69
  "construct_combinatorial_optimization_model",
84
- "construct_chemistry_model",
85
- "molecule_problem_to_qmod",
86
70
  ]
87
71
 
88
72
  __version__ = _VERSION
@@ -113,6 +97,7 @@ __all__ = (
113
97
  "synthesize_async",
114
98
  "execute",
115
99
  "execute_async",
100
+ "qasm_to_qmod",
116
101
  "set_preferences",
117
102
  "set_constraints",
118
103
  "set_execution_preferences",
@@ -125,8 +110,10 @@ __all__ = (
125
110
  "hamiltonian_to_matrix",
126
111
  "matrix_to_hamiltonian",
127
112
  "matrix_to_pauli_operator",
113
+ "pauli_operator_to_matrix",
128
114
  "quantum_program_from_qasm",
129
115
  "quantum_program_from_qasm_async",
116
+ "QmodFormat",
130
117
  ]
131
118
  + _md_all
132
119
  + _sub_modules
@@ -1,11 +1,11 @@
1
1
  import asyncio
2
- from collections.abc import Awaitable
2
+ from collections.abc import Awaitable, Callable
3
3
  from functools import wraps
4
- from typing import TYPE_CHECKING, Callable
5
-
6
- from ipywidgets import widgets # type: ignore[import]
4
+ from typing import TYPE_CHECKING
7
5
 
8
6
  if TYPE_CHECKING:
7
+ from ipywidgets import widgets # type: ignore[import]
8
+
9
9
  from classiq._analyzer_extras.interactive_hardware import InteractiveHardware
10
10
 
11
11
  WidgetName = str
@@ -30,7 +30,7 @@ def widget_callback(widget_name: WidgetName) -> Callable[[WidgetFunc], Callable]
30
30
  def decorator(function: WidgetFunc) -> Callable:
31
31
  @wraps(function)
32
32
  async def wrapper(self: "InteractiveHardware", **kwargs: WidgetValue) -> None:
33
- widget: widgets = getattr(self, widget_name)
33
+ widget: "widgets" = getattr(self, widget_name)
34
34
  interactive_loop = _create_interactive_loop_async(
35
35
  function=function, self=self, widget=widget
36
36
  )
@@ -43,7 +43,7 @@ def widget_callback(widget_name: WidgetName) -> Callable[[WidgetFunc], Callable]
43
43
 
44
44
 
45
45
  async def _create_interactive_loop_async(
46
- function: WidgetFunc, self: "InteractiveHardware", widget: widgets
46
+ function: WidgetFunc, self: "InteractiveHardware", widget: "widgets"
47
47
  ) -> None:
48
48
  while True:
49
49
  value: WidgetValue = await _wait_for_change(widget=widget)
@@ -51,7 +51,7 @@ async def _create_interactive_loop_async(
51
51
  await function(self, value)
52
52
 
53
53
 
54
- def _wait_for_change(widget: widgets) -> asyncio.Future:
54
+ def _wait_for_change(widget: "widgets") -> asyncio.Future:
55
55
  future: asyncio.Future = asyncio.Future()
56
56
 
57
57
  def _get_value(change) -> None: # type: ignore[no-untyped-def]
@@ -1,8 +1,5 @@
1
1
  import json
2
- from typing import Optional
3
-
4
- import plotly.graph_objects as go
5
- from ipywidgets import Combobox, HBox, VBox # type: ignore[import]
2
+ from typing import TYPE_CHECKING
6
3
 
7
4
  from classiq.interface.analyzer import analysis_params
8
5
  from classiq.interface.backend.quantum_backend_providers import AnalyzerProviderVendor
@@ -17,6 +14,10 @@ from classiq.analyzer.analyzer_utilities import (
17
14
  ProviderNameEnum,
18
15
  )
19
16
 
17
+ if TYPE_CHECKING:
18
+ import plotly.graph_objects as go
19
+ from ipywidgets import Combobox, VBox # type: ignore[import]
20
+
20
21
 
21
22
  class InteractiveHardware(AnalyzerUtilities):
22
23
  def __init__(
@@ -31,7 +32,9 @@ class InteractiveHardware(AnalyzerUtilities):
31
32
  self.devices_combobox = self._initialize_devices_combobox()
32
33
  self.hardware_graph = self._initialize_hardware_graph()
33
34
 
34
- def show_interactive_graph(self) -> VBox:
35
+ def show_interactive_graph(self) -> "VBox":
36
+ from ipywidgets import HBox, VBox
37
+
35
38
  combobox_layout = HBox([self.providers_combobox, self.devices_combobox])
36
39
  return VBox([combobox_layout, self.hardware_graph])
37
40
 
@@ -40,7 +43,9 @@ class InteractiveHardware(AnalyzerUtilities):
40
43
  await self._device_selection_response_async()
41
44
 
42
45
  @staticmethod
43
- def _initialize_providers_combobox() -> Combobox:
46
+ def _initialize_providers_combobox() -> "Combobox":
47
+ from ipywidgets import Combobox
48
+
44
49
  combobox = Combobox(
45
50
  placeholder="Choose provider",
46
51
  options=list(AnalyzerProviderVendor),
@@ -51,7 +56,9 @@ class InteractiveHardware(AnalyzerUtilities):
51
56
  return combobox
52
57
 
53
58
  @staticmethod
54
- def _initialize_devices_combobox() -> Combobox:
59
+ def _initialize_devices_combobox() -> "Combobox":
60
+ from ipywidgets import Combobox
61
+
55
62
  combobox = Combobox(
56
63
  placeholder="Choose first provider",
57
64
  description="devices:",
@@ -61,12 +68,14 @@ class InteractiveHardware(AnalyzerUtilities):
61
68
  return combobox
62
69
 
63
70
  @staticmethod
64
- def _initialize_hardware_graph() -> go.FigureWidget:
71
+ def _initialize_hardware_graph() -> "go.FigureWidget":
72
+ import plotly.graph_objects as go
73
+
65
74
  return go.FigureWidget()
66
75
 
67
76
  @widget_callback(widget_name="providers_combobox")
68
77
  async def _provider_selection_response_async(
69
- self, provider: Optional[ProviderNameEnum]
78
+ self, provider: ProviderNameEnum | None
70
79
  ) -> None:
71
80
  if not provider:
72
81
  return
@@ -76,9 +85,7 @@ class InteractiveHardware(AnalyzerUtilities):
76
85
  self.devices_combobox.placeholder = "Choose device"
77
86
 
78
87
  @widget_callback(widget_name="devices_combobox")
79
- async def _device_selection_response_async(
80
- self, device: Optional[DeviceName]
81
- ) -> None:
88
+ async def _device_selection_response_async(self, device: DeviceName | None) -> None:
82
89
  provider = self.providers_combobox.value
83
90
  if not device or not provider:
84
91
  return
@@ -1,5 +1,5 @@
1
1
  import json
2
- from typing import Any, Optional, Protocol, TypeVar
2
+ from typing import Any, Protocol, TypeVar
3
3
 
4
4
  import httpx
5
5
  import pydantic
@@ -10,7 +10,6 @@ import classiq.interface.pyomo_extension
10
10
  from classiq.interface.analyzer import analysis_params, result as analysis_result
11
11
  from classiq.interface.analyzer.analysis_params import AnalysisRBParams
12
12
  from classiq.interface.analyzer.result import GraphStatus, QmodCode
13
- from classiq.interface.chemistry import ground_state_problem, operator
14
13
  from classiq.interface.enum_utils import StrEnum
15
14
  from classiq.interface.exceptions import ClassiqAPIError, ClassiqValueError
16
15
  from classiq.interface.execution.iqcc import (
@@ -75,8 +74,8 @@ class ApiWrapper:
75
74
  url: str,
76
75
  model: pydantic.BaseModel,
77
76
  use_versioned_url: bool = True,
78
- http_client: Optional[httpx.AsyncClient] = None,
79
- exclude: Optional[IncEx] = None,
77
+ http_client: httpx.AsyncClient | None = None,
78
+ exclude: IncEx | None = None,
80
79
  ) -> dict:
81
80
  # TODO: we can't use model.dict() - it doesn't serialize complex class.
82
81
  # This was added because JSON serializer doesn't serialize complex type, and pydantic does.
@@ -95,12 +94,12 @@ class ApiWrapper:
95
94
  cls,
96
95
  http_method: str,
97
96
  url: str,
98
- body: Optional[dict] = None,
99
- params: Optional[dict] = None,
97
+ body: dict | None = None,
98
+ params: dict | None = None,
100
99
  use_versioned_url: bool = True,
101
- headers: Optional[dict[str, str]] = None,
100
+ headers: dict[str, str] | None = None,
102
101
  allow_none: bool = False,
103
- http_client: Optional[httpx.AsyncClient] = None,
102
+ http_client: httpx.AsyncClient | None = None,
104
103
  ) -> dict:
105
104
  res: Any = await client().call_api(
106
105
  http_method=http_method,
@@ -123,7 +122,7 @@ class ApiWrapper:
123
122
  url: str,
124
123
  job_input: pydantic.BaseModel,
125
124
  result_type: type[ResultType],
126
- http_client: Optional[httpx.AsyncClient],
125
+ http_client: httpx.AsyncClient | None,
127
126
  ) -> ResultType:
128
127
  poller = JobPoller(base_url=url)
129
128
  result = await poller.run_pydantic(
@@ -135,7 +134,7 @@ class ApiWrapper:
135
134
  async def call_generation_task(
136
135
  cls,
137
136
  model: Model,
138
- http_client: Optional[httpx.AsyncClient] = None,
137
+ http_client: httpx.AsyncClient | None = None,
139
138
  ) -> generator_result.QuantumProgram:
140
139
  return await cls._call_job_and_poll(
141
140
  routes.TASKS_GENERATE_FULL_PATH,
@@ -148,7 +147,7 @@ class ApiWrapper:
148
147
  async def call_transpilation_task(
149
148
  cls,
150
149
  params: TranspilationParams,
151
- http_client: Optional[httpx.AsyncClient] = None,
150
+ http_client: httpx.AsyncClient | None = None,
152
151
  ) -> generator_result.QuantumProgram:
153
152
  return await cls._call_job_and_poll(
154
153
  routes.TRANSPILATION_FULL_PATH,
@@ -161,7 +160,7 @@ class ApiWrapper:
161
160
  async def call_assign_parameters_task(
162
161
  cls,
163
162
  params: ParameterAssignmentsParams,
164
- http_client: Optional[httpx.AsyncClient] = None,
163
+ http_client: httpx.AsyncClient | None = None,
165
164
  ) -> generator_result.QuantumProgram:
166
165
  return await cls._call_job_and_poll(
167
166
  routes.ASSIGN_PARAMETERS_FULL_PATH,
@@ -174,7 +173,7 @@ class ApiWrapper:
174
173
  async def call_qasm_to_qmod_task(
175
174
  cls,
176
175
  params: QasmToQmodParams,
177
- http_client: Optional[httpx.AsyncClient] = None,
176
+ http_client: httpx.AsyncClient | None = None,
178
177
  ) -> QmodCode:
179
178
  return await cls._call_job_and_poll(
180
179
  routes.QASM_TO_QMOD_FULL_PATH,
@@ -187,7 +186,7 @@ class ApiWrapper:
187
186
  async def call_get_visual_model(
188
187
  cls,
189
188
  program_id: str,
190
- http_client: Optional[httpx.AsyncClient] = None,
189
+ http_client: httpx.AsyncClient | None = None,
191
190
  ) -> ProgramVisualModel:
192
191
  raw_result = await cls._call_task(
193
192
  http_method=HTTPMethod.GET,
@@ -200,7 +199,7 @@ class ApiWrapper:
200
199
  async def call_visualization_task(
201
200
  cls,
202
201
  circuit: generator_result.QuantumProgram,
203
- http_client: Optional[httpx.AsyncClient] = None,
202
+ http_client: httpx.AsyncClient | None = None,
204
203
  ) -> ProgramVisualModel:
205
204
  return await cls._call_job_and_poll(
206
205
  routes.TASKS_VISUAL_MODEL_FULL_PATH,
@@ -213,7 +212,7 @@ class ApiWrapper:
213
212
  async def call_create_execution_session(
214
213
  cls,
215
214
  circuit: generator_result.QuantumProgram,
216
- http_client: Optional[httpx.AsyncClient] = None,
215
+ http_client: httpx.AsyncClient | None = None,
217
216
  ) -> str:
218
217
  raw_result = await cls._call_task_pydantic(
219
218
  http_method=HTTPMethod.POST,
@@ -229,7 +228,7 @@ class ApiWrapper:
229
228
  cls,
230
229
  session_id: str,
231
230
  primitives_input: PrimitivesInput,
232
- http_client: Optional[httpx.AsyncClient] = None,
231
+ http_client: httpx.AsyncClient | None = None,
233
232
  ) -> execution_request.ExecutionJobDetails:
234
233
  data = await cls._call_task_pydantic(
235
234
  http_method=HTTPMethod.POST,
@@ -243,7 +242,7 @@ class ApiWrapper:
243
242
  async def call_convert_quantum_program(
244
243
  cls,
245
244
  circuit: generator_result.QuantumProgram,
246
- http_client: Optional[httpx.AsyncClient] = None,
245
+ http_client: httpx.AsyncClient | None = None,
247
246
  ) -> dict:
248
247
  return await cls._call_task_pydantic(
249
248
  http_method=HTTPMethod.POST,
@@ -257,7 +256,7 @@ class ApiWrapper:
257
256
  async def call_execute_execution_input(
258
257
  cls,
259
258
  execution_input: dict,
260
- http_client: Optional[httpx.AsyncClient] = None,
259
+ http_client: httpx.AsyncClient | None = None,
261
260
  ) -> execution_request.ExecutionJobDetails:
262
261
  data = await cls._call_task(
263
262
  http_method=HTTPMethod.POST,
@@ -271,7 +270,7 @@ class ApiWrapper:
271
270
  async def call_get_execution_job_details(
272
271
  cls,
273
272
  job_id: JobID,
274
- http_client: Optional[httpx.AsyncClient] = None,
273
+ http_client: httpx.AsyncClient | None = None,
275
274
  ) -> execution_request.ExecutionJobDetails:
276
275
  data = await cls._call_task(
277
276
  http_method=HTTPMethod.GET,
@@ -284,7 +283,7 @@ class ApiWrapper:
284
283
  async def call_get_execution_job_result(
285
284
  cls,
286
285
  job_id: JobID,
287
- http_client: Optional[httpx.AsyncClient] = None,
286
+ http_client: httpx.AsyncClient | None = None,
288
287
  ) -> classiq.interface.executor.execution_result.ExecuteGeneratedCircuitResults:
289
288
  data = await cls._call_task(
290
289
  http_method=HTTPMethod.GET,
@@ -300,7 +299,7 @@ class ApiWrapper:
300
299
  cls,
301
300
  job_id: JobID,
302
301
  name: str,
303
- http_client: Optional[httpx.AsyncClient] = None,
302
+ http_client: httpx.AsyncClient | None = None,
304
303
  ) -> execution_request.ExecutionJobDetails:
305
304
  data = await cls._call_task(
306
305
  http_method=HTTPMethod.PATCH,
@@ -316,7 +315,7 @@ class ApiWrapper:
316
315
  async def call_cancel_execution_job(
317
316
  cls,
318
317
  job_id: JobID,
319
- http_client: Optional[httpx.AsyncClient] = None,
318
+ http_client: httpx.AsyncClient | None = None,
320
319
  ) -> None:
321
320
  await cls._call_task(
322
321
  http_method=HTTPMethod.PUT,
@@ -330,7 +329,7 @@ class ApiWrapper:
330
329
  cls,
331
330
  offset: int,
332
331
  limit: int,
333
- http_client: Optional[httpx.AsyncClient] = None,
332
+ http_client: httpx.AsyncClient | None = None,
334
333
  ) -> execution_request.ExecutionJobsQueryResults:
335
334
  data = await cls._call_task(
336
335
  http_method=HTTPMethod.GET,
@@ -347,7 +346,7 @@ class ApiWrapper:
347
346
  async def call_analysis_task(
348
347
  cls,
349
348
  params: analysis_params.AnalysisParams,
350
- http_client: Optional[httpx.AsyncClient] = None,
349
+ http_client: httpx.AsyncClient | None = None,
351
350
  ) -> analysis_result.Analysis:
352
351
  data = await cls._call_task_pydantic(
353
352
  http_method=HTTPMethod.POST,
@@ -362,7 +361,7 @@ class ApiWrapper:
362
361
  async def call_analyzer_app(
363
362
  cls,
364
363
  params: generator_result.QuantumProgram,
365
- http_client: Optional[httpx.AsyncClient] = None,
364
+ http_client: httpx.AsyncClient | None = None,
366
365
  ) -> analysis_result.DataID:
367
366
  data = await cls._call_task_pydantic(
368
367
  http_method=HTTPMethod.POST,
@@ -376,7 +375,7 @@ class ApiWrapper:
376
375
  async def get_generated_circuit_from_qasm(
377
376
  cls,
378
377
  params: analysis_result.QasmCode,
379
- http_client: Optional[httpx.AsyncClient] = None,
378
+ http_client: httpx.AsyncClient | None = None,
380
379
  ) -> generator_result.QuantumProgram:
381
380
  data = await cls._call_task_pydantic(
382
381
  http_method=HTTPMethod.POST,
@@ -390,7 +389,7 @@ class ApiWrapper:
390
389
  async def get_analyzer_app_data(
391
390
  cls,
392
391
  params: analysis_result.DataID,
393
- http_client: Optional[httpx.AsyncClient] = None,
392
+ http_client: httpx.AsyncClient | None = None,
394
393
  ) -> generator_result.QuantumProgram:
395
394
  data = await cls._call_task(
396
395
  http_method=HTTPMethod.GET,
@@ -403,7 +402,7 @@ class ApiWrapper:
403
402
  async def call_rb_analysis_task(
404
403
  cls,
405
404
  params: AnalysisRBParams,
406
- http_client: Optional[httpx.AsyncClient] = None,
405
+ http_client: httpx.AsyncClient | None = None,
407
406
  ) -> analysis_result.RbResults:
408
407
  data = await cls._call_task(
409
408
  http_method=HTTPMethod.POST,
@@ -418,7 +417,7 @@ class ApiWrapper:
418
417
  async def call_hardware_connectivity_task(
419
418
  cls,
420
419
  params: analysis_params.AnalysisHardwareParams,
421
- http_client: Optional[httpx.AsyncClient] = None,
420
+ http_client: httpx.AsyncClient | None = None,
422
421
  ) -> analysis_result.GraphResult:
423
422
  data = await cls._call_task_pydantic(
424
423
  http_method=HTTPMethod.POST,
@@ -432,7 +431,7 @@ class ApiWrapper:
432
431
  async def call_table_graphs_task(
433
432
  cls,
434
433
  params: analysis_params.AnalysisHardwareListParams,
435
- http_client: Optional[httpx.AsyncClient] = None,
434
+ http_client: httpx.AsyncClient | None = None,
436
435
  ) -> analysis_result.GraphResult:
437
436
  return await cls._call_job_and_poll(
438
437
  routes.ANALYZER_HC_TABLE_GRAPH_FULL_PATH,
@@ -445,7 +444,7 @@ class ApiWrapper:
445
444
  async def call_available_devices_task(
446
445
  cls,
447
446
  params: analysis_params.AnalysisOptionalDevicesParams,
448
- http_client: Optional[httpx.AsyncClient] = None,
447
+ http_client: httpx.AsyncClient | None = None,
449
448
  ) -> analysis_result.DevicesResult:
450
449
  hardware_info = await cls.call_get_all_hardware_devices(http_client=http_client)
451
450
  return cls._get_devices_from_hardware_info(hardware_info, params)
@@ -477,7 +476,7 @@ class ApiWrapper:
477
476
  @classmethod
478
477
  async def call_get_all_hardware_devices(
479
478
  cls,
480
- http_client: Optional[httpx.AsyncClient] = None,
479
+ http_client: httpx.AsyncClient | None = None,
481
480
  ) -> list[HardwareInformation]:
482
481
  data = await client().call_api(
483
482
  http_method=HTTPMethod.GET,
@@ -489,24 +488,11 @@ class ApiWrapper:
489
488
  raise ClassiqAPIError(f"Unexpected value: {data}")
490
489
  return [HardwareInformation.model_validate(info) for info in data]
491
490
 
492
- @classmethod
493
- async def call_generate_hamiltonian_task(
494
- cls,
495
- problem: ground_state_problem.CHEMISTRY_PROBLEMS_TYPE,
496
- http_client: Optional[httpx.AsyncClient] = None,
497
- ) -> operator.PauliOperator:
498
- return await cls._call_job_and_poll(
499
- routes.GENERATE_HAMILTONIAN_FULL_PATH,
500
- problem,
501
- operator.PauliOperator,
502
- http_client,
503
- )
504
-
505
491
  @classmethod
506
492
  async def call_iqcc_init_auth(
507
493
  cls,
508
494
  data: IQCCInitAuthData,
509
- http_client: Optional[httpx.AsyncClient] = None,
495
+ http_client: httpx.AsyncClient | None = None,
510
496
  ) -> IQCCInitAuthResponse:
511
497
  response = await cls._call_task_pydantic(
512
498
  http_method=HTTPMethod.PUT,
@@ -520,8 +506,8 @@ class ApiWrapper:
520
506
  async def call_iqcc_probe_auth(
521
507
  cls,
522
508
  data: IQCCProbeAuthData,
523
- http_client: Optional[httpx.AsyncClient] = None,
524
- ) -> Optional[IQCCProbeAuthResponse]:
509
+ http_client: httpx.AsyncClient | None = None,
510
+ ) -> IQCCProbeAuthResponse | None:
525
511
  try:
526
512
  response = await cls._call_task_pydantic(
527
513
  http_method=HTTPMethod.PUT,
@@ -539,7 +525,7 @@ class ApiWrapper:
539
525
  @classmethod
540
526
  async def call_iqcc_list_auth_scopes(
541
527
  cls,
542
- http_client: Optional[httpx.AsyncClient] = None,
528
+ http_client: httpx.AsyncClient | None = None,
543
529
  ) -> IQCCAuthItemsDetails:
544
530
  response = await cls._call_task(
545
531
  http_method=HTTPMethod.GET,
@@ -552,7 +538,7 @@ class ApiWrapper:
552
538
  async def call_iqcc_list_auth_methods(
553
539
  cls,
554
540
  data: IQCCListAuthMethods,
555
- http_client: Optional[httpx.AsyncClient] = None,
541
+ http_client: httpx.AsyncClient | None = None,
556
542
  ) -> IQCCAuthItemsDetails:
557
543
  response = await cls._call_task_pydantic(
558
544
  http_method=HTTPMethod.PUT,
@@ -566,7 +552,7 @@ class ApiWrapper:
566
552
  async def call_iqcc_list_auth_targets(
567
553
  cls,
568
554
  data: IQCCListAuthTargets,
569
- http_client: Optional[httpx.AsyncClient] = None,
555
+ http_client: httpx.AsyncClient | None = None,
570
556
  ) -> IQCCAuthItemsDetails:
571
557
  response = await cls._call_task_pydantic(
572
558
  http_method=HTTPMethod.PUT,
@@ -3,14 +3,11 @@ import functools
3
3
  import itertools
4
4
  import logging
5
5
  import time
6
- from collections.abc import AsyncGenerator, Awaitable, Iterable
6
+ from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
7
7
  from typing import (
8
8
  Any,
9
- Callable,
10
- Optional,
11
9
  SupportsFloat,
12
10
  TypeVar,
13
- Union,
14
11
  )
15
12
 
16
13
  T = TypeVar("T")
@@ -58,7 +55,7 @@ def enable_jupyter_notebook() -> None:
58
55
 
59
56
 
60
57
  def _make_iterable_interval(
61
- interval_sec: Union[SupportsFloat, Iterable[SupportsFloat]],
58
+ interval_sec: SupportsFloat | Iterable[SupportsFloat],
62
59
  ) -> Iterable[float]:
63
60
  if isinstance(interval_sec, Iterable):
64
61
  return map(float, interval_sec)
@@ -67,8 +64,8 @@ def _make_iterable_interval(
67
64
 
68
65
  async def poll_for(
69
66
  poller: Callable[..., Awaitable[T]],
70
- timeout_sec: Optional[float],
71
- interval_sec: Union[float, Iterable[float]],
67
+ timeout_sec: float | None,
68
+ interval_sec: float | Iterable[float],
72
69
  ) -> AsyncGenerator[T, None]:
73
70
  if timeout_sec is not None:
74
71
  end_time = time.perf_counter() + timeout_sec
@@ -1,6 +1,6 @@
1
1
  import urllib.parse
2
2
  from dataclasses import dataclass
3
- from typing import Any, Optional, Union
3
+ from typing import Any
4
4
 
5
5
  from httpx import AsyncClient, Response, codes
6
6
  from pydantic import Field
@@ -35,7 +35,7 @@ class AuthSettings(BaseSettings):
35
35
  @dataclass
36
36
  class Tokens:
37
37
  access_token: str
38
- refresh_token: Optional[str]
38
+ refresh_token: str | None
39
39
 
40
40
 
41
41
  class Auth0:
@@ -57,7 +57,7 @@ class Auth0:
57
57
  self,
58
58
  url: str,
59
59
  payload: dict[str, str],
60
- allow_error: Union[bool, int] = False,
60
+ allow_error: bool | int = False,
61
61
  ) -> dict[str, Any]:
62
62
  encoded_payload = urllib.parse.urlencode(payload)
63
63
  client: AsyncClient
@@ -2,7 +2,7 @@ import asyncio
2
2
  import webbrowser
3
3
  from collections.abc import Iterable
4
4
  from datetime import timedelta
5
- from typing import Any, Optional, TypeVar
5
+ from typing import Any, TypeVar
6
6
 
7
7
  from classiq.interface.exceptions import (
8
8
  ClassiqAuthenticationError,
@@ -51,9 +51,9 @@ class DeviceRegistrar:
51
51
  def _handle_ready_data(
52
52
  cls, data: dict[str, Any], get_refresh_token: bool
53
53
  ) -> Tokens:
54
- access_token: Optional[str] = data.get("access_token")
54
+ access_token: str | None = data.get("access_token")
55
55
  # If refresh token was not requested, this would be None
56
- refresh_token: Optional[str] = data.get("refresh_token")
56
+ refresh_token: str | None = data.get("refresh_token")
57
57
 
58
58
  if access_token is None or (
59
59
  get_refresh_token is True and refresh_token is None
@@ -86,7 +86,7 @@ class DeviceRegistrar:
86
86
  async for data in poll_for(
87
87
  poller=poller, timeout_sec=timeout, interval_sec=interval_coro()
88
88
  ):
89
- error_code: Optional[str] = data.get("error")
89
+ error_code: str | None = data.get("error")
90
90
  if error_code is None:
91
91
  return cls._handle_ready_data(data, get_refresh_token)
92
92
  elif error_code == "authorization_pending":