classiq 0.92.0__py3-none-any.whl → 0.99.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 (318) hide show
  1. classiq/__init__.py +11 -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 +31 -142
  5. classiq/_internals/async_utils.py +4 -7
  6. classiq/_internals/authentication/auth0.py +41 -15
  7. classiq/_internals/authentication/authorization_code.py +9 -0
  8. classiq/_internals/authentication/authorization_flow.py +41 -0
  9. classiq/_internals/authentication/device.py +33 -52
  10. classiq/_internals/authentication/hybrid_flow.py +19 -0
  11. classiq/_internals/authentication/password_manager.py +13 -13
  12. classiq/_internals/authentication/token_manager.py +9 -9
  13. classiq/_internals/client.py +17 -44
  14. classiq/_internals/config.py +19 -5
  15. classiq/_internals/help.py +1 -2
  16. classiq/_internals/host_checker.py +3 -3
  17. classiq/_internals/jobs.py +14 -14
  18. classiq/_internals/type_validation.py +3 -3
  19. classiq/analyzer/analyzer.py +18 -18
  20. classiq/analyzer/rb.py +17 -8
  21. classiq/analyzer/show_interactive_hack.py +1 -1
  22. classiq/applications/__init__.py +2 -2
  23. classiq/applications/chemistry/__init__.py +0 -30
  24. classiq/applications/chemistry/op_utils.py +4 -4
  25. classiq/applications/chemistry/problems.py +3 -3
  26. classiq/applications/chemistry/ucc.py +1 -2
  27. classiq/applications/chemistry/z2_symmetries.py +4 -4
  28. classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
  29. classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
  30. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
  31. classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
  32. classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
  33. classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
  34. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
  35. classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
  36. classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
  37. classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
  38. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
  39. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
  40. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
  41. classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
  42. classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
  43. classiq/applications/iqae/iqae.py +14 -11
  44. classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
  45. classiq/applications/qnn/datasets/dataset_parity.py +6 -6
  46. classiq/applications/qnn/gradients/simple_quantum_gradient.py +1 -1
  47. classiq/applications/qnn/qlayer.py +9 -8
  48. classiq/applications/qnn/torch_utils.py +5 -6
  49. classiq/applications/qnn/types.py +2 -1
  50. classiq/applications/qsp/__init__.py +20 -2
  51. classiq/applications/qsp/qsp.py +239 -11
  52. classiq/applications/qsvm/qsvm_data_generation.py +1 -2
  53. classiq/evaluators/classical_expression.py +0 -4
  54. classiq/evaluators/parameter_types.py +20 -12
  55. classiq/evaluators/qmod_annotated_expression.py +31 -26
  56. classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
  57. classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
  58. classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
  59. classiq/evaluators/qmod_node_evaluators/binary_op_evaluation.py +4 -4
  60. classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +14 -4
  61. classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
  62. classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
  63. classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
  64. classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
  65. classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
  66. classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
  67. classiq/execution/__init__.py +0 -3
  68. classiq/execution/execution_session.py +28 -21
  69. classiq/execution/jobs.py +26 -26
  70. classiq/execution/qnn.py +1 -2
  71. classiq/execution/user_budgets.py +71 -37
  72. classiq/executor.py +1 -3
  73. classiq/interface/_version.py +1 -1
  74. classiq/interface/analyzer/analysis_params.py +4 -4
  75. classiq/interface/analyzer/cytoscape_graph.py +3 -3
  76. classiq/interface/analyzer/result.py +4 -4
  77. classiq/interface/ast_node.py +3 -3
  78. classiq/interface/backend/backend_preferences.py +26 -50
  79. classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
  80. classiq/interface/backend/provider_config/__init__.py +0 -0
  81. classiq/interface/backend/provider_config/provider_config.py +8 -0
  82. classiq/interface/backend/provider_config/providers/__init__.py +0 -0
  83. classiq/interface/backend/provider_config/providers/alice_bob.py +47 -0
  84. classiq/interface/backend/provider_config/providers/aqt.py +16 -0
  85. classiq/interface/backend/provider_config/providers/azure.py +37 -0
  86. classiq/interface/backend/provider_config/providers/braket.py +39 -0
  87. classiq/interface/backend/provider_config/providers/ibm.py +26 -0
  88. classiq/interface/backend/provider_config/providers/ionq.py +22 -0
  89. classiq/interface/backend/quantum_backend_providers.py +20 -2
  90. classiq/interface/chemistry/ansatz_library.py +3 -5
  91. classiq/interface/chemistry/operator.py +3 -3
  92. classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
  93. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
  94. classiq/interface/compression_utils.py +2 -3
  95. classiq/interface/debug_info/debug_info.py +8 -7
  96. classiq/interface/exceptions.py +10 -7
  97. classiq/interface/execution/primitives.py +6 -6
  98. classiq/interface/executor/estimate_cost.py +1 -1
  99. classiq/interface/executor/execution_preferences.py +3 -5
  100. classiq/interface/executor/execution_request.py +10 -10
  101. classiq/interface/executor/execution_result.py +1 -2
  102. classiq/interface/executor/quantum_code.py +8 -8
  103. classiq/interface/executor/result.py +28 -18
  104. classiq/interface/executor/user_budget.py +25 -17
  105. classiq/interface/executor/vqe_result.py +5 -6
  106. classiq/interface/generator/ansatz_library.py +6 -8
  107. classiq/interface/generator/application_apis/__init__.py +0 -3
  108. classiq/interface/generator/arith/arithmetic.py +2 -2
  109. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
  110. classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
  111. classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
  112. classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
  113. classiq/interface/generator/arith/arithmetic_operations.py +4 -6
  114. classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
  115. classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
  116. classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
  117. classiq/interface/generator/arith/binary_ops.py +15 -40
  118. classiq/interface/generator/arith/logical_ops.py +2 -3
  119. classiq/interface/generator/arith/number_utils.py +2 -2
  120. classiq/interface/generator/arith/register_user_input.py +3 -3
  121. classiq/interface/generator/arith/unary_ops.py +2 -2
  122. classiq/interface/generator/circuit_code/circuit_code.py +8 -10
  123. classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
  124. classiq/interface/generator/complex_type.py +2 -2
  125. classiq/interface/generator/copy.py +1 -3
  126. classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
  127. classiq/interface/generator/expressions/evaluated_expression.py +2 -3
  128. classiq/interface/generator/expressions/expression.py +2 -2
  129. classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
  130. classiq/interface/generator/function_param_list.py +0 -40
  131. classiq/interface/generator/function_params.py +5 -6
  132. classiq/interface/generator/functions/classical_function_declaration.py +2 -2
  133. classiq/interface/generator/functions/classical_type.py +3 -3
  134. classiq/interface/generator/functions/type_modifier.py +0 -15
  135. classiq/interface/generator/functions/type_name.py +2 -2
  136. classiq/interface/generator/generated_circuit_data.py +14 -18
  137. classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
  138. classiq/interface/generator/hardware/hardware_data.py +8 -8
  139. classiq/interface/generator/hardware_efficient_ansatz.py +9 -9
  140. classiq/interface/generator/mcu.py +3 -3
  141. classiq/interface/generator/mcx.py +3 -3
  142. classiq/interface/generator/model/constraints.py +34 -5
  143. classiq/interface/generator/model/preferences/preferences.py +15 -21
  144. classiq/interface/generator/model/quantum_register.py +7 -10
  145. classiq/interface/generator/noise_properties.py +3 -7
  146. classiq/interface/generator/parameters.py +1 -1
  147. classiq/interface/generator/partitioned_register.py +1 -2
  148. classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
  149. classiq/interface/generator/quantum_function_call.py +9 -12
  150. classiq/interface/generator/quantum_program.py +10 -23
  151. classiq/interface/generator/range_types.py +3 -3
  152. classiq/interface/generator/slice_parsing_utils.py +4 -5
  153. classiq/interface/generator/standard_gates/standard_gates.py +2 -4
  154. classiq/interface/generator/synthesis_execution_parameter.py +1 -3
  155. classiq/interface/generator/synthesis_metadata/synthesis_duration.py +9 -0
  156. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
  157. classiq/interface/generator/transpiler_basis_gates.py +12 -4
  158. classiq/interface/generator/types/builtin_enum_declarations.py +0 -145
  159. classiq/interface/generator/types/compilation_metadata.py +12 -1
  160. classiq/interface/generator/types/enum_declaration.py +2 -1
  161. classiq/interface/generator/validations/flow_graph.py +3 -3
  162. classiq/interface/generator/visitor.py +10 -12
  163. classiq/interface/hardware.py +2 -3
  164. classiq/interface/helpers/classproperty.py +2 -2
  165. classiq/interface/helpers/custom_encoders.py +2 -1
  166. classiq/interface/helpers/custom_pydantic_types.py +1 -1
  167. classiq/interface/helpers/text_utils.py +1 -4
  168. classiq/interface/ide/visual_model.py +6 -5
  169. classiq/interface/interface_version.py +1 -1
  170. classiq/interface/jobs.py +3 -3
  171. classiq/interface/model/allocate.py +4 -4
  172. classiq/interface/model/block.py +6 -2
  173. classiq/interface/model/bounds.py +3 -3
  174. classiq/interface/model/classical_if.py +4 -0
  175. classiq/interface/model/control.py +8 -1
  176. classiq/interface/model/inplace_binary_operation.py +2 -2
  177. classiq/interface/model/invert.py +4 -0
  178. classiq/interface/model/model.py +4 -4
  179. classiq/interface/model/model_visitor.py +40 -1
  180. classiq/interface/model/parameter.py +1 -3
  181. classiq/interface/model/port_declaration.py +1 -1
  182. classiq/interface/model/power.py +4 -0
  183. classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
  184. classiq/interface/model/quantum_function_call.py +3 -6
  185. classiq/interface/model/quantum_function_declaration.py +1 -0
  186. classiq/interface/model/quantum_lambda_function.py +4 -4
  187. classiq/interface/model/quantum_statement.py +11 -4
  188. classiq/interface/model/quantum_type.py +14 -14
  189. classiq/interface/model/repeat.py +4 -0
  190. classiq/interface/model/skip_control.py +4 -0
  191. classiq/interface/model/validation_handle.py +2 -3
  192. classiq/interface/model/variable_declaration_statement.py +2 -2
  193. classiq/interface/model/within_apply_operation.py +4 -0
  194. classiq/interface/pretty_print/expression_to_qmod.py +3 -4
  195. classiq/interface/server/routes.py +0 -16
  196. classiq/interface/source_reference.py +3 -4
  197. classiq/model_expansions/arithmetic.py +11 -7
  198. classiq/model_expansions/arithmetic_compute_result_attrs.py +30 -27
  199. classiq/model_expansions/capturing/captured_vars.py +3 -3
  200. classiq/model_expansions/capturing/mangling_utils.py +1 -2
  201. classiq/model_expansions/closure.py +12 -11
  202. classiq/model_expansions/function_builder.py +14 -6
  203. classiq/model_expansions/generative_functions.py +7 -12
  204. classiq/model_expansions/interpreters/base_interpreter.py +3 -7
  205. classiq/model_expansions/interpreters/frontend_generative_interpreter.py +2 -1
  206. classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
  207. classiq/model_expansions/quantum_operations/allocate.py +4 -4
  208. classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
  209. classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
  210. classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
  211. classiq/model_expansions/quantum_operations/emitter.py +3 -5
  212. classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
  213. classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
  214. classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
  215. classiq/model_expansions/scope.py +7 -7
  216. classiq/model_expansions/scope_initialization.py +4 -0
  217. classiq/model_expansions/visitors/symbolic_param_inference.py +6 -6
  218. classiq/model_expansions/visitors/uncomputation_signature_inference.py +328 -0
  219. classiq/model_expansions/visitors/variable_references.py +15 -14
  220. classiq/open_library/functions/__init__.py +28 -11
  221. classiq/open_library/functions/amplitude_loading.py +81 -0
  222. classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
  223. classiq/open_library/functions/grover.py +8 -10
  224. classiq/open_library/functions/lcu.py +47 -18
  225. classiq/open_library/functions/modular_exponentiation.py +93 -8
  226. classiq/open_library/functions/qsvt.py +66 -79
  227. classiq/open_library/functions/qsvt_temp.py +536 -0
  228. classiq/open_library/functions/state_preparation.py +130 -27
  229. classiq/qmod/__init__.py +6 -4
  230. classiq/qmod/builtins/classical_execution_primitives.py +4 -23
  231. classiq/qmod/builtins/classical_functions.py +1 -42
  232. classiq/qmod/builtins/enums.py +15 -153
  233. classiq/qmod/builtins/functions/__init__.py +9 -18
  234. classiq/qmod/builtins/functions/allocation.py +25 -4
  235. classiq/qmod/builtins/functions/arithmetic.py +22 -27
  236. classiq/qmod/builtins/functions/exponentiation.py +51 -2
  237. classiq/qmod/builtins/functions/mcx_func.py +7 -0
  238. classiq/qmod/builtins/functions/standard_gates.py +46 -27
  239. classiq/qmod/builtins/operations.py +173 -79
  240. classiq/qmod/builtins/structs.py +24 -91
  241. classiq/qmod/cfunc.py +3 -2
  242. classiq/qmod/classical_function.py +2 -1
  243. classiq/qmod/classical_variable.py +4 -2
  244. classiq/qmod/cparam.py +2 -8
  245. classiq/qmod/create_model_function.py +7 -7
  246. classiq/qmod/declaration_inferrer.py +33 -30
  247. classiq/qmod/expression_query.py +7 -4
  248. classiq/qmod/model_state_container.py +2 -2
  249. classiq/qmod/native/pretty_printer.py +25 -14
  250. classiq/qmod/pretty_print/expression_to_python.py +5 -3
  251. classiq/qmod/pretty_print/pretty_printer.py +39 -17
  252. classiq/qmod/python_classical_type.py +40 -13
  253. classiq/qmod/qfunc.py +124 -19
  254. classiq/qmod/qmod_constant.py +2 -2
  255. classiq/qmod/qmod_parameter.py +5 -2
  256. classiq/qmod/qmod_variable.py +47 -46
  257. classiq/qmod/quantum_callable.py +18 -13
  258. classiq/qmod/quantum_expandable.py +33 -26
  259. classiq/qmod/quantum_function.py +84 -36
  260. classiq/qmod/semantics/annotation/call_annotation.py +5 -5
  261. classiq/qmod/semantics/error_manager.py +12 -14
  262. classiq/qmod/semantics/lambdas.py +1 -2
  263. classiq/qmod/semantics/validation/types_validation.py +1 -2
  264. classiq/qmod/symbolic.py +2 -4
  265. classiq/qmod/symbolic_expr.py +12 -4
  266. classiq/qmod/utilities.py +13 -20
  267. classiq/qmod/write_qmod.py +3 -4
  268. classiq/quantum_program.py +1 -3
  269. classiq/synthesis.py +11 -7
  270. {classiq-0.92.0.dist-info → classiq-0.99.0.dist-info}/METADATA +38 -37
  271. {classiq-0.92.0.dist-info → classiq-0.99.0.dist-info}/RECORD +273 -300
  272. classiq-0.99.0.dist-info/WHEEL +4 -0
  273. classiq-0.99.0.dist-info/licenses/LICENSE.txt +27 -0
  274. classiq/applications/chemistry/ansatz_parameters.py +0 -29
  275. classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
  276. classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
  277. classiq/applications/chemistry/ground_state_problem.py +0 -42
  278. classiq/applications/qsvm/__init__.py +0 -8
  279. classiq/applications/qsvm/qsvm.py +0 -11
  280. classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
  281. classiq/execution/iqcc.py +0 -128
  282. classiq/interface/applications/qsvm.py +0 -117
  283. classiq/interface/chemistry/elements.py +0 -120
  284. classiq/interface/chemistry/fermionic_operator.py +0 -208
  285. classiq/interface/chemistry/ground_state_problem.py +0 -132
  286. classiq/interface/chemistry/ground_state_result.py +0 -8
  287. classiq/interface/chemistry/molecule.py +0 -71
  288. classiq/interface/execution/iqcc.py +0 -44
  289. classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
  290. classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
  291. classiq/interface/generator/application_apis/qsvm_declarations.py +0 -6
  292. classiq/interface/generator/chemistry_function_params.py +0 -50
  293. classiq/interface/generator/entangler_params.py +0 -72
  294. classiq/interface/generator/entanglers.py +0 -14
  295. classiq/interface/generator/hamiltonian_evolution/qdrift.py +0 -27
  296. classiq/interface/generator/hartree_fock.py +0 -26
  297. classiq/interface/generator/hva.py +0 -22
  298. classiq/interface/generator/linear_pauli_rotations.py +0 -92
  299. classiq/interface/generator/qft.py +0 -37
  300. classiq/interface/generator/qsvm.py +0 -96
  301. classiq/interface/generator/state_preparation/__init__.py +0 -14
  302. classiq/interface/generator/state_preparation/bell_state_preparation.py +0 -27
  303. classiq/interface/generator/state_preparation/computational_basis_state_preparation.py +0 -28
  304. classiq/interface/generator/state_preparation/distributions.py +0 -53
  305. classiq/interface/generator/state_preparation/exponential_state_preparation.py +0 -14
  306. classiq/interface/generator/state_preparation/ghz_state_preparation.py +0 -14
  307. classiq/interface/generator/state_preparation/metrics.py +0 -41
  308. classiq/interface/generator/state_preparation/state_preparation.py +0 -113
  309. classiq/interface/generator/state_preparation/state_preparation_abc.py +0 -24
  310. classiq/interface/generator/state_preparation/uniform_distibution_state_preparation.py +0 -13
  311. classiq/interface/generator/state_preparation/w_state_preparation.py +0 -13
  312. classiq/interface/generator/ucc.py +0 -74
  313. classiq/interface/helpers/backward_compatibility.py +0 -9
  314. classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
  315. classiq/open_library/functions/lookup_table.py +0 -58
  316. classiq/qmod/builtins/functions/chemistry.py +0 -123
  317. classiq/qmod/builtins/functions/qsvm.py +0 -24
  318. classiq-0.92.0.dist-info/WHEEL +0 -4
classiq/__init__.py CHANGED
@@ -1,19 +1,11 @@
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.backend.quantum_backend_providers import (
5
+ ProviderVendor,
6
+ __all__ as _be_all,
7
+ )
8
+ from classiq.interface.exceptions import ClassiqDeprecationWarning
17
9
  from classiq.interface.generator.application_apis import * # noqa: F403
18
10
  from classiq.interface.generator.arith.register_user_input import (
19
11
  RegisterArithmeticInfo,
@@ -36,10 +28,6 @@ from classiq._internals.client import configure
36
28
  from classiq._internals.config import Configuration
37
29
  from classiq._internals.help import open_help
38
30
  from classiq.analyzer import Analyzer
39
- from classiq.applications.chemistry import (
40
- construct_chemistry_model,
41
- molecule_problem_to_qmod,
42
- )
43
31
  from classiq.applications.combinatorial_optimization import (
44
32
  CombinatorialProblem,
45
33
  compute_qaoa_initial_point,
@@ -51,6 +39,7 @@ from classiq.applications.hamiltonian.pauli_decomposition import (
51
39
  hamiltonian_to_matrix,
52
40
  matrix_to_hamiltonian,
53
41
  matrix_to_pauli_operator,
42
+ pauli_operator_to_matrix,
54
43
  )
55
44
  from classiq.execution import * # noqa: F403
56
45
  from classiq.execution import __all__ as _execution_all
@@ -65,6 +54,7 @@ from classiq.qmod import * # noqa: F403
65
54
  from classiq.qmod import __all__ as _qmod_all
66
55
  from classiq.quantum_program import ExecutionParams, assign_parameters, transpile
67
56
  from classiq.synthesis import (
57
+ QmodFormat,
68
58
  qasm_to_qmod,
69
59
  quantum_program_from_qasm,
70
60
  quantum_program_from_qasm_async,
@@ -81,8 +71,6 @@ from classiq.synthesis import (
81
71
 
82
72
  _application_constructors_all = [
83
73
  "construct_combinatorial_optimization_model",
84
- "construct_chemistry_model",
85
- "molecule_problem_to_qmod",
86
74
  ]
87
75
 
88
76
  __version__ = _VERSION
@@ -113,6 +101,7 @@ __all__ = (
113
101
  "synthesize_async",
114
102
  "execute",
115
103
  "execute_async",
104
+ "qasm_to_qmod",
116
105
  "set_preferences",
117
106
  "set_constraints",
118
107
  "set_execution_preferences",
@@ -125,8 +114,10 @@ __all__ = (
125
114
  "hamiltonian_to_matrix",
126
115
  "matrix_to_hamiltonian",
127
116
  "matrix_to_pauli_operator",
117
+ "pauli_operator_to_matrix",
128
118
  "quantum_program_from_qasm",
129
119
  "quantum_program_from_qasm_async",
120
+ "QmodFormat",
130
121
  ]
131
122
  + _md_all
132
123
  + _sub_modules
@@ -134,6 +125,7 @@ __all__ = (
134
125
  + _qmod_all
135
126
  + _execution_all
136
127
  + _open_library_all
128
+ + _be_all
137
129
  )
138
130
 
139
131
 
@@ -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,18 +10,8 @@ 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
- from classiq.interface.execution.iqcc import (
17
- IQCCAuthItemsDetails,
18
- IQCCInitAuthData,
19
- IQCCInitAuthResponse,
20
- IQCCListAuthMethods,
21
- IQCCListAuthTargets,
22
- IQCCProbeAuthData,
23
- IQCCProbeAuthResponse,
24
- )
25
15
  from classiq.interface.execution.primitives import PrimitivesInput
26
16
  from classiq.interface.executor import execution_request
27
17
  from classiq.interface.executor.quantum_program_params import (
@@ -75,8 +65,8 @@ class ApiWrapper:
75
65
  url: str,
76
66
  model: pydantic.BaseModel,
77
67
  use_versioned_url: bool = True,
78
- http_client: Optional[httpx.AsyncClient] = None,
79
- exclude: Optional[IncEx] = None,
68
+ http_client: httpx.AsyncClient | None = None,
69
+ exclude: IncEx | None = None,
80
70
  ) -> dict:
81
71
  # TODO: we can't use model.dict() - it doesn't serialize complex class.
82
72
  # This was added because JSON serializer doesn't serialize complex type, and pydantic does.
@@ -95,12 +85,12 @@ class ApiWrapper:
95
85
  cls,
96
86
  http_method: str,
97
87
  url: str,
98
- body: Optional[dict] = None,
99
- params: Optional[dict] = None,
88
+ body: dict | None = None,
89
+ params: dict | None = None,
100
90
  use_versioned_url: bool = True,
101
- headers: Optional[dict[str, str]] = None,
91
+ headers: dict[str, str] | None = None,
102
92
  allow_none: bool = False,
103
- http_client: Optional[httpx.AsyncClient] = None,
93
+ http_client: httpx.AsyncClient | None = None,
104
94
  ) -> dict:
105
95
  res: Any = await client().call_api(
106
96
  http_method=http_method,
@@ -123,7 +113,7 @@ class ApiWrapper:
123
113
  url: str,
124
114
  job_input: pydantic.BaseModel,
125
115
  result_type: type[ResultType],
126
- http_client: Optional[httpx.AsyncClient],
116
+ http_client: httpx.AsyncClient | None,
127
117
  ) -> ResultType:
128
118
  poller = JobPoller(base_url=url)
129
119
  result = await poller.run_pydantic(
@@ -135,7 +125,7 @@ class ApiWrapper:
135
125
  async def call_generation_task(
136
126
  cls,
137
127
  model: Model,
138
- http_client: Optional[httpx.AsyncClient] = None,
128
+ http_client: httpx.AsyncClient | None = None,
139
129
  ) -> generator_result.QuantumProgram:
140
130
  return await cls._call_job_and_poll(
141
131
  routes.TASKS_GENERATE_FULL_PATH,
@@ -148,7 +138,7 @@ class ApiWrapper:
148
138
  async def call_transpilation_task(
149
139
  cls,
150
140
  params: TranspilationParams,
151
- http_client: Optional[httpx.AsyncClient] = None,
141
+ http_client: httpx.AsyncClient | None = None,
152
142
  ) -> generator_result.QuantumProgram:
153
143
  return await cls._call_job_and_poll(
154
144
  routes.TRANSPILATION_FULL_PATH,
@@ -161,7 +151,7 @@ class ApiWrapper:
161
151
  async def call_assign_parameters_task(
162
152
  cls,
163
153
  params: ParameterAssignmentsParams,
164
- http_client: Optional[httpx.AsyncClient] = None,
154
+ http_client: httpx.AsyncClient | None = None,
165
155
  ) -> generator_result.QuantumProgram:
166
156
  return await cls._call_job_and_poll(
167
157
  routes.ASSIGN_PARAMETERS_FULL_PATH,
@@ -174,7 +164,7 @@ class ApiWrapper:
174
164
  async def call_qasm_to_qmod_task(
175
165
  cls,
176
166
  params: QasmToQmodParams,
177
- http_client: Optional[httpx.AsyncClient] = None,
167
+ http_client: httpx.AsyncClient | None = None,
178
168
  ) -> QmodCode:
179
169
  return await cls._call_job_and_poll(
180
170
  routes.QASM_TO_QMOD_FULL_PATH,
@@ -187,7 +177,7 @@ class ApiWrapper:
187
177
  async def call_get_visual_model(
188
178
  cls,
189
179
  program_id: str,
190
- http_client: Optional[httpx.AsyncClient] = None,
180
+ http_client: httpx.AsyncClient | None = None,
191
181
  ) -> ProgramVisualModel:
192
182
  raw_result = await cls._call_task(
193
183
  http_method=HTTPMethod.GET,
@@ -200,7 +190,7 @@ class ApiWrapper:
200
190
  async def call_visualization_task(
201
191
  cls,
202
192
  circuit: generator_result.QuantumProgram,
203
- http_client: Optional[httpx.AsyncClient] = None,
193
+ http_client: httpx.AsyncClient | None = None,
204
194
  ) -> ProgramVisualModel:
205
195
  return await cls._call_job_and_poll(
206
196
  routes.TASKS_VISUAL_MODEL_FULL_PATH,
@@ -213,7 +203,7 @@ class ApiWrapper:
213
203
  async def call_create_execution_session(
214
204
  cls,
215
205
  circuit: generator_result.QuantumProgram,
216
- http_client: Optional[httpx.AsyncClient] = None,
206
+ http_client: httpx.AsyncClient | None = None,
217
207
  ) -> str:
218
208
  raw_result = await cls._call_task_pydantic(
219
209
  http_method=HTTPMethod.POST,
@@ -229,7 +219,7 @@ class ApiWrapper:
229
219
  cls,
230
220
  session_id: str,
231
221
  primitives_input: PrimitivesInput,
232
- http_client: Optional[httpx.AsyncClient] = None,
222
+ http_client: httpx.AsyncClient | None = None,
233
223
  ) -> execution_request.ExecutionJobDetails:
234
224
  data = await cls._call_task_pydantic(
235
225
  http_method=HTTPMethod.POST,
@@ -243,7 +233,7 @@ class ApiWrapper:
243
233
  async def call_convert_quantum_program(
244
234
  cls,
245
235
  circuit: generator_result.QuantumProgram,
246
- http_client: Optional[httpx.AsyncClient] = None,
236
+ http_client: httpx.AsyncClient | None = None,
247
237
  ) -> dict:
248
238
  return await cls._call_task_pydantic(
249
239
  http_method=HTTPMethod.POST,
@@ -257,7 +247,7 @@ class ApiWrapper:
257
247
  async def call_execute_execution_input(
258
248
  cls,
259
249
  execution_input: dict,
260
- http_client: Optional[httpx.AsyncClient] = None,
250
+ http_client: httpx.AsyncClient | None = None,
261
251
  ) -> execution_request.ExecutionJobDetails:
262
252
  data = await cls._call_task(
263
253
  http_method=HTTPMethod.POST,
@@ -271,7 +261,7 @@ class ApiWrapper:
271
261
  async def call_get_execution_job_details(
272
262
  cls,
273
263
  job_id: JobID,
274
- http_client: Optional[httpx.AsyncClient] = None,
264
+ http_client: httpx.AsyncClient | None = None,
275
265
  ) -> execution_request.ExecutionJobDetails:
276
266
  data = await cls._call_task(
277
267
  http_method=HTTPMethod.GET,
@@ -284,7 +274,7 @@ class ApiWrapper:
284
274
  async def call_get_execution_job_result(
285
275
  cls,
286
276
  job_id: JobID,
287
- http_client: Optional[httpx.AsyncClient] = None,
277
+ http_client: httpx.AsyncClient | None = None,
288
278
  ) -> classiq.interface.executor.execution_result.ExecuteGeneratedCircuitResults:
289
279
  data = await cls._call_task(
290
280
  http_method=HTTPMethod.GET,
@@ -300,7 +290,7 @@ class ApiWrapper:
300
290
  cls,
301
291
  job_id: JobID,
302
292
  name: str,
303
- http_client: Optional[httpx.AsyncClient] = None,
293
+ http_client: httpx.AsyncClient | None = None,
304
294
  ) -> execution_request.ExecutionJobDetails:
305
295
  data = await cls._call_task(
306
296
  http_method=HTTPMethod.PATCH,
@@ -316,7 +306,7 @@ class ApiWrapper:
316
306
  async def call_cancel_execution_job(
317
307
  cls,
318
308
  job_id: JobID,
319
- http_client: Optional[httpx.AsyncClient] = None,
309
+ http_client: httpx.AsyncClient | None = None,
320
310
  ) -> None:
321
311
  await cls._call_task(
322
312
  http_method=HTTPMethod.PUT,
@@ -330,7 +320,7 @@ class ApiWrapper:
330
320
  cls,
331
321
  offset: int,
332
322
  limit: int,
333
- http_client: Optional[httpx.AsyncClient] = None,
323
+ http_client: httpx.AsyncClient | None = None,
334
324
  ) -> execution_request.ExecutionJobsQueryResults:
335
325
  data = await cls._call_task(
336
326
  http_method=HTTPMethod.GET,
@@ -347,7 +337,7 @@ class ApiWrapper:
347
337
  async def call_analysis_task(
348
338
  cls,
349
339
  params: analysis_params.AnalysisParams,
350
- http_client: Optional[httpx.AsyncClient] = None,
340
+ http_client: httpx.AsyncClient | None = None,
351
341
  ) -> analysis_result.Analysis:
352
342
  data = await cls._call_task_pydantic(
353
343
  http_method=HTTPMethod.POST,
@@ -358,25 +348,11 @@ class ApiWrapper:
358
348
 
359
349
  return analysis_result.Analysis.model_validate(data)
360
350
 
361
- @classmethod
362
- async def call_analyzer_app(
363
- cls,
364
- params: generator_result.QuantumProgram,
365
- http_client: Optional[httpx.AsyncClient] = None,
366
- ) -> analysis_result.DataID:
367
- data = await cls._call_task_pydantic(
368
- http_method=HTTPMethod.POST,
369
- url=routes.ANALYZER_DATA_FULL_PATH,
370
- model=params,
371
- http_client=http_client,
372
- )
373
- return analysis_result.DataID.model_validate(data)
374
-
375
351
  @classmethod
376
352
  async def get_generated_circuit_from_qasm(
377
353
  cls,
378
354
  params: analysis_result.QasmCode,
379
- http_client: Optional[httpx.AsyncClient] = None,
355
+ http_client: httpx.AsyncClient | None = None,
380
356
  ) -> generator_result.QuantumProgram:
381
357
  data = await cls._call_task_pydantic(
382
358
  http_method=HTTPMethod.POST,
@@ -390,7 +366,7 @@ class ApiWrapper:
390
366
  async def get_analyzer_app_data(
391
367
  cls,
392
368
  params: analysis_result.DataID,
393
- http_client: Optional[httpx.AsyncClient] = None,
369
+ http_client: httpx.AsyncClient | None = None,
394
370
  ) -> generator_result.QuantumProgram:
395
371
  data = await cls._call_task(
396
372
  http_method=HTTPMethod.GET,
@@ -403,7 +379,7 @@ class ApiWrapper:
403
379
  async def call_rb_analysis_task(
404
380
  cls,
405
381
  params: AnalysisRBParams,
406
- http_client: Optional[httpx.AsyncClient] = None,
382
+ http_client: httpx.AsyncClient | None = None,
407
383
  ) -> analysis_result.RbResults:
408
384
  data = await cls._call_task(
409
385
  http_method=HTTPMethod.POST,
@@ -418,7 +394,7 @@ class ApiWrapper:
418
394
  async def call_hardware_connectivity_task(
419
395
  cls,
420
396
  params: analysis_params.AnalysisHardwareParams,
421
- http_client: Optional[httpx.AsyncClient] = None,
397
+ http_client: httpx.AsyncClient | None = None,
422
398
  ) -> analysis_result.GraphResult:
423
399
  data = await cls._call_task_pydantic(
424
400
  http_method=HTTPMethod.POST,
@@ -432,7 +408,7 @@ class ApiWrapper:
432
408
  async def call_table_graphs_task(
433
409
  cls,
434
410
  params: analysis_params.AnalysisHardwareListParams,
435
- http_client: Optional[httpx.AsyncClient] = None,
411
+ http_client: httpx.AsyncClient | None = None,
436
412
  ) -> analysis_result.GraphResult:
437
413
  return await cls._call_job_and_poll(
438
414
  routes.ANALYZER_HC_TABLE_GRAPH_FULL_PATH,
@@ -445,7 +421,7 @@ class ApiWrapper:
445
421
  async def call_available_devices_task(
446
422
  cls,
447
423
  params: analysis_params.AnalysisOptionalDevicesParams,
448
- http_client: Optional[httpx.AsyncClient] = None,
424
+ http_client: httpx.AsyncClient | None = None,
449
425
  ) -> analysis_result.DevicesResult:
450
426
  hardware_info = await cls.call_get_all_hardware_devices(http_client=http_client)
451
427
  return cls._get_devices_from_hardware_info(hardware_info, params)
@@ -477,7 +453,7 @@ class ApiWrapper:
477
453
  @classmethod
478
454
  async def call_get_all_hardware_devices(
479
455
  cls,
480
- http_client: Optional[httpx.AsyncClient] = None,
456
+ http_client: httpx.AsyncClient | None = None,
481
457
  ) -> list[HardwareInformation]:
482
458
  data = await client().call_api(
483
459
  http_method=HTTPMethod.GET,
@@ -489,93 +465,6 @@ class ApiWrapper:
489
465
  raise ClassiqAPIError(f"Unexpected value: {data}")
490
466
  return [HardwareInformation.model_validate(info) for info in data]
491
467
 
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
- @classmethod
506
- async def call_iqcc_init_auth(
507
- cls,
508
- data: IQCCInitAuthData,
509
- http_client: Optional[httpx.AsyncClient] = None,
510
- ) -> IQCCInitAuthResponse:
511
- response = await cls._call_task_pydantic(
512
- http_method=HTTPMethod.PUT,
513
- url=f"{routes.IQCC_INIT_AUTH_FULL_PATH}",
514
- model=data,
515
- http_client=http_client,
516
- )
517
- return IQCCInitAuthResponse.model_validate(response)
518
-
519
- @classmethod
520
- async def call_iqcc_probe_auth(
521
- cls,
522
- data: IQCCProbeAuthData,
523
- http_client: Optional[httpx.AsyncClient] = None,
524
- ) -> Optional[IQCCProbeAuthResponse]:
525
- try:
526
- response = await cls._call_task_pydantic(
527
- http_method=HTTPMethod.PUT,
528
- url=f"{routes.IQCC_PROBE_AUTH_FULL_PATH}",
529
- model=data,
530
- http_client=http_client,
531
- )
532
- except ClassiqAPIError as ex:
533
- if ex.status_code == 418:
534
- return None
535
- raise
536
-
537
- return IQCCProbeAuthResponse.model_validate(response)
538
-
539
- @classmethod
540
- async def call_iqcc_list_auth_scopes(
541
- cls,
542
- http_client: Optional[httpx.AsyncClient] = None,
543
- ) -> IQCCAuthItemsDetails:
544
- response = await cls._call_task(
545
- http_method=HTTPMethod.GET,
546
- url=routes.IQCC_LIST_AUTH_SCOPES_FULL_PATH,
547
- http_client=http_client,
548
- )
549
- return IQCCAuthItemsDetails.model_validate(response)
550
-
551
- @classmethod
552
- async def call_iqcc_list_auth_methods(
553
- cls,
554
- data: IQCCListAuthMethods,
555
- http_client: Optional[httpx.AsyncClient] = None,
556
- ) -> IQCCAuthItemsDetails:
557
- response = await cls._call_task_pydantic(
558
- http_method=HTTPMethod.PUT,
559
- url=routes.IQCC_LIST_AUTH_METHODS_FULL_PATH,
560
- model=data,
561
- http_client=http_client,
562
- )
563
- return IQCCAuthItemsDetails.model_validate(response)
564
-
565
- @classmethod
566
- async def call_iqcc_list_auth_targets(
567
- cls,
568
- data: IQCCListAuthTargets,
569
- http_client: Optional[httpx.AsyncClient] = None,
570
- ) -> IQCCAuthItemsDetails:
571
- response = await cls._call_task_pydantic(
572
- http_method=HTTPMethod.PUT,
573
- url=routes.IQCC_LIST_AUTH_TARGETS_FULL_PATH,
574
- model=data,
575
- http_client=http_client,
576
- )
577
- return IQCCAuthItemsDetails.model_validate(response)
578
-
579
468
  @classmethod
580
469
  async def call_get_all_budgets(cls) -> list[UserBudget]:
581
470
  data = await client().call_api(
@@ -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