classiq 0.52.0__py3-none-any.whl → 0.54.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- classiq/__init__.py +1 -3
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
- classiq/_internals/__init__.py +0 -20
- classiq/_internals/api_wrapper.py +23 -17
- classiq/_internals/async_utils.py +1 -3
- classiq/_internals/authentication/auth0.py +5 -5
- classiq/_internals/authentication/device.py +5 -4
- classiq/_internals/authentication/password_manager.py +3 -3
- classiq/_internals/authentication/token_manager.py +3 -2
- classiq/_internals/client.py +11 -13
- classiq/_internals/config.py +2 -2
- classiq/_internals/jobs.py +7 -6
- classiq/_internals/type_validation.py +9 -9
- classiq/analyzer/__init__.py +1 -3
- classiq/analyzer/analyzer.py +8 -7
- classiq/analyzer/analyzer_utilities.py +8 -8
- classiq/analyzer/rb.py +11 -11
- classiq/applications/__init__.py +1 -3
- classiq/applications/chemistry/__init__.py +1 -3
- classiq/applications/chemistry/ansatz_parameters.py +4 -4
- classiq/applications/chemistry/chemistry_model_constructor.py +10 -9
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +26 -9
- classiq/applications/combinatorial_helpers/encoding_mapping.py +10 -10
- classiq/applications/combinatorial_helpers/encoding_utils.py +4 -4
- classiq/applications/combinatorial_helpers/memory.py +5 -7
- classiq/applications/combinatorial_helpers/optimization_model.py +43 -24
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +4 -6
- classiq/applications/combinatorial_helpers/pyomo_utils.py +95 -24
- classiq/applications/combinatorial_helpers/sympy_utils.py +2 -2
- classiq/applications/combinatorial_helpers/transformations/encoding.py +8 -8
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -5
- classiq/applications/combinatorial_helpers/transformations/ising_converter.py +7 -9
- classiq/applications/combinatorial_helpers/transformations/penalty.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/slack_variables.py +1 -2
- classiq/applications/combinatorial_optimization/__init__.py +1 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
- classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
- classiq/applications/finance/__init__.py +1 -3
- classiq/applications/grover/__init__.py +1 -3
- classiq/applications/grover/grover_model_constructor.py +7 -9
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -6
- classiq/applications/qnn/__init__.py +1 -3
- classiq/applications/qnn/circuit_utils.py +5 -5
- classiq/applications/qnn/datasets/__init__.py +1 -3
- classiq/applications/qnn/datasets/dataset_base_classes.py +5 -4
- classiq/applications/qnn/datasets/dataset_parity.py +2 -2
- classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
- classiq/applications/qnn/qlayer.py +25 -6
- classiq/applications/qnn/torch_utils.py +2 -2
- classiq/applications/qnn/types.py +5 -5
- classiq/applications/qsvm/qsvm.py +1 -3
- classiq/applications/qsvm/qsvm_data_generation.py +3 -3
- classiq/applications/qsvm/qsvm_model_constructor.py +5 -5
- classiq/execution/__init__.py +3 -3
- classiq/execution/all_hardware_devices.py +1 -3
- classiq/execution/execution_session.py +57 -16
- classiq/execution/iqcc.py +1 -1
- classiq/execution/jobs.py +4 -4
- classiq/execution/qaoa.py +84 -0
- classiq/execution/qnn.py +3 -3
- classiq/executor.py +4 -4
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +9 -10
- classiq/interface/analyzer/cytoscape_graph.py +5 -5
- classiq/interface/analyzer/result.py +17 -17
- classiq/interface/applications/qsvm.py +6 -10
- classiq/interface/backend/backend_preferences.py +4 -3
- classiq/interface/backend/ionq/ionq_quantum_program.py +4 -5
- classiq/interface/backend/pydantic_backend.py +1 -2
- classiq/interface/chemistry/fermionic_operator.py +5 -5
- classiq/interface/chemistry/ground_state_problem.py +7 -8
- classiq/interface/chemistry/molecule.py +4 -4
- classiq/interface/chemistry/operator.py +11 -13
- classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -3
- classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
- classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
- classiq/interface/combinatorial_optimization/examples/mht.py +2 -3
- classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
- classiq/interface/combinatorial_optimization/examples/set_cover.py +1 -2
- classiq/interface/combinatorial_optimization/mht_qaoa_input.py +5 -7
- classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
- classiq/interface/combinatorial_optimization/result.py +1 -3
- classiq/interface/debug_info/debug_info.py +8 -7
- classiq/interface/exceptions.py +11 -7
- classiq/interface/execution/iqcc.py +1 -3
- classiq/interface/execution/jobs.py +2 -2
- classiq/interface/execution/primitives.py +3 -3
- classiq/interface/executor/aws_execution_cost.py +4 -4
- classiq/interface/executor/execution_request.py +2 -3
- classiq/interface/executor/execution_result.py +3 -3
- classiq/interface/executor/iqae_result.py +3 -5
- classiq/interface/executor/optimizer_preferences.py +2 -2
- classiq/interface/executor/quantum_code.py +6 -6
- classiq/interface/executor/register_initialization.py +2 -4
- classiq/interface/executor/result.py +35 -28
- classiq/interface/executor/vqe_result.py +8 -8
- classiq/interface/finance/function_input.py +2 -2
- classiq/interface/finance/gaussian_model_input.py +5 -5
- classiq/interface/finance/log_normal_model_input.py +2 -2
- classiq/interface/finance/model_input.py +1 -2
- classiq/interface/generator/adjacency.py +1 -3
- classiq/interface/generator/ansatz_library.py +4 -4
- classiq/interface/generator/application_apis/finance_declarations.py +1 -1
- classiq/interface/generator/arith/argument_utils.py +3 -3
- classiq/interface/generator/arith/arithmetic.py +7 -7
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +5 -5
- classiq/interface/generator/arith/arithmetic_expression_abc.py +11 -11
- classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
- classiq/interface/generator/arith/arithmetic_expression_validator.py +8 -8
- classiq/interface/generator/arith/arithmetic_operations.py +4 -3
- classiq/interface/generator/arith/arithmetic_param_getters.py +6 -6
- classiq/interface/generator/arith/arithmetic_result_builder.py +9 -9
- classiq/interface/generator/arith/ast_node_rewrite.py +2 -1
- classiq/interface/generator/arith/binary_ops.py +10 -13
- classiq/interface/generator/arith/extremum_operations.py +3 -2
- classiq/interface/generator/arith/logical_ops.py +7 -6
- classiq/interface/generator/arith/number_utils.py +4 -4
- classiq/interface/generator/arith/register_user_input.py +4 -4
- classiq/interface/generator/arith/unary_ops.py +2 -1
- classiq/interface/generator/builtin_api_builder.py +2 -1
- classiq/interface/generator/circuit_code/circuit_code.py +4 -4
- classiq/interface/generator/circuit_code/types_and_constants.py +3 -5
- classiq/interface/generator/complex_type.py +1 -2
- classiq/interface/generator/control_state.py +2 -2
- classiq/interface/generator/custom_ansatz.py +1 -3
- classiq/interface/generator/distance.py +3 -5
- classiq/interface/generator/excitations.py +3 -2
- classiq/interface/generator/expressions/enums/finance_functions.py +1 -3
- classiq/interface/generator/expressions/evaluated_expression.py +4 -3
- classiq/interface/generator/expressions/expression.py +4 -5
- classiq/interface/generator/expressions/expression_constants.py +4 -4
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qstruct_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_struct_instance.py +2 -1
- classiq/interface/generator/expressions/sympy_supported_expressions.py +11 -13
- classiq/interface/generator/finance.py +2 -2
- classiq/interface/generator/function_param_library.py +6 -6
- classiq/interface/generator/function_params.py +13 -19
- classiq/interface/generator/functions/classical_function_declaration.py +4 -3
- classiq/interface/generator/functions/classical_type.py +13 -13
- classiq/interface/generator/functions/concrete_types.py +1 -2
- classiq/interface/generator/functions/function_declaration.py +1 -1
- classiq/interface/generator/functions/qmod_python_interface.py +2 -1
- classiq/interface/generator/functions/type_name.py +3 -2
- classiq/interface/generator/generated_circuit_data.py +34 -22
- classiq/interface/generator/grover_diffuser.py +7 -7
- classiq/interface/generator/grover_operator.py +2 -2
- classiq/interface/generator/hardware/hardware_data.py +7 -6
- classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
- classiq/interface/generator/identity.py +5 -6
- classiq/interface/generator/linear_pauli_rotations.py +6 -6
- classiq/interface/generator/mcu.py +2 -2
- classiq/interface/generator/mcx.py +6 -6
- classiq/interface/generator/model/__init__.py +1 -3
- classiq/interface/generator/model/constraints.py +2 -2
- classiq/interface/generator/model/model.py +5 -6
- classiq/interface/generator/model/preferences/preferences.py +7 -6
- classiq/interface/generator/model/quantum_register.py +6 -11
- classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
- classiq/interface/generator/oracles/custom_oracle.py +2 -2
- classiq/interface/generator/oracles/oracle_abc.py +6 -5
- classiq/interface/generator/partitioned_register.py +6 -5
- classiq/interface/generator/piecewise_linear_amplitude_loading.py +8 -7
- classiq/interface/generator/qpe.py +4 -4
- classiq/interface/generator/qsvm.py +3 -3
- classiq/interface/generator/quantum_function_call.py +24 -29
- classiq/interface/generator/quantum_program.py +9 -9
- classiq/interface/generator/register_role.py +2 -4
- classiq/interface/generator/slice_parsing_utils.py +4 -3
- classiq/interface/generator/standard_gates/standard_gates.py +3 -3
- classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
- classiq/interface/generator/state_preparation/distributions.py +6 -5
- classiq/interface/generator/state_preparation/metrics.py +2 -4
- classiq/interface/generator/state_preparation/state_preparation.py +4 -4
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +3 -3
- classiq/interface/generator/transpiler_basis_gates.py +2 -2
- classiq/interface/generator/types/enum_declaration.py +2 -3
- classiq/interface/generator/types/qstruct_declaration.py +2 -1
- classiq/interface/generator/types/struct_declaration.py +3 -2
- classiq/interface/generator/ucc.py +2 -1
- classiq/interface/generator/unitary_gate.py +2 -2
- classiq/interface/generator/user_defined_function_params.py +1 -1
- classiq/interface/generator/validations/flow_graph.py +6 -5
- classiq/interface/generator/validations/validator_functions.py +3 -2
- classiq/interface/generator/visitor.py +9 -14
- classiq/interface/hardware.py +5 -6
- classiq/interface/helpers/custom_encoders.py +2 -2
- classiq/interface/helpers/custom_pydantic_types.py +8 -9
- classiq/interface/helpers/dotdict.py +18 -0
- classiq/interface/helpers/hashable_mixin.py +3 -2
- classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
- classiq/interface/helpers/pydantic_model_helpers.py +4 -3
- classiq/interface/helpers/validation_helpers.py +2 -2
- classiq/interface/ide/ide_data.py +11 -15
- classiq/interface/ide/visual_model.py +33 -22
- classiq/interface/jobs.py +2 -2
- classiq/interface/model/bind_operation.py +5 -4
- classiq/interface/model/classical_parameter_declaration.py +2 -2
- classiq/interface/model/handle_binding.py +3 -2
- classiq/interface/model/inplace_binary_operation.py +2 -1
- classiq/interface/model/model.py +12 -11
- classiq/interface/model/native_function_definition.py +10 -0
- classiq/interface/model/port_declaration.py +2 -2
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +3 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -2
- classiq/interface/model/quantum_expressions/quantum_expression.py +8 -7
- classiq/interface/model/quantum_function_call.py +9 -14
- classiq/interface/model/quantum_function_declaration.py +10 -12
- classiq/interface/model/quantum_lambda_function.py +3 -16
- classiq/interface/model/quantum_statement.py +4 -3
- classiq/interface/model/quantum_type.py +5 -5
- classiq/interface/model/statement_block.py +2 -3
- classiq/interface/model/validation_handle.py +5 -4
- classiq/interface/server/global_versions.py +3 -3
- classiq/model_expansions/atomic_expression_functions_defs.py +3 -2
- classiq/model_expansions/call_to_model_converter.py +190 -0
- classiq/model_expansions/capturing/captured_var_manager.py +4 -6
- classiq/model_expansions/capturing/propagated_var_stack.py +7 -7
- classiq/model_expansions/closure.py +17 -9
- classiq/model_expansions/evaluators/arg_type_match.py +3 -2
- classiq/model_expansions/evaluators/argument_types.py +3 -3
- classiq/model_expansions/evaluators/control.py +3 -3
- classiq/model_expansions/evaluators/parameter_types.py +7 -7
- classiq/model_expansions/evaluators/quantum_type_utils.py +2 -1
- classiq/model_expansions/evaluators/type_type_match.py +1 -1
- classiq/model_expansions/expression_evaluator.py +10 -9
- classiq/model_expansions/expression_renamer.py +6 -6
- classiq/model_expansions/function_builder.py +19 -12
- classiq/model_expansions/generative_functions.py +3 -2
- classiq/model_expansions/interpreter.py +31 -19
- classiq/model_expansions/model_tables.py +14 -14
- classiq/model_expansions/quantum_operations/bind.py +2 -4
- classiq/model_expansions/quantum_operations/classicalif.py +1 -1
- classiq/model_expansions/quantum_operations/control.py +2 -4
- classiq/model_expansions/quantum_operations/emitter.py +10 -13
- classiq/model_expansions/quantum_operations/expression_operation.py +23 -16
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py +164 -38
- classiq/model_expansions/quantum_operations/phase.py +6 -6
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +25 -5
- classiq/model_expansions/quantum_operations/quantum_function_call.py +41 -2
- classiq/model_expansions/quantum_operations/repeat.py +1 -3
- classiq/model_expansions/scope.py +11 -10
- classiq/model_expansions/scope_initialization.py +6 -5
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +6 -6
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +2 -2
- classiq/model_expansions/visitors/variable_references.py +5 -4
- classiq/qmod/__init__.py +2 -0
- classiq/qmod/builtins/classical_execution_primitives.py +9 -9
- classiq/qmod/builtins/functions/__init__.py +75 -53
- classiq/qmod/builtins/functions/amplitude_estimation.py +4 -1
- classiq/qmod/builtins/functions/arithmetic.py +14 -1
- classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +86 -6
- classiq/qmod/builtins/functions/grover.py +41 -45
- classiq/qmod/builtins/functions/hea.py +60 -4
- classiq/qmod/builtins/functions/linear_pauli_rotation.py +26 -4
- classiq/qmod/builtins/functions/modular_exponentiation.py +90 -29
- classiq/qmod/builtins/functions/operators.py +1 -1
- classiq/qmod/builtins/functions/qaoa_penalty.py +14 -5
- classiq/qmod/builtins/functions/qft_functions.py +57 -0
- classiq/qmod/builtins/functions/qpe.py +20 -4
- classiq/qmod/builtins/functions/qsvt.py +49 -4
- classiq/qmod/builtins/functions/standard_gates.py +18 -18
- classiq/qmod/builtins/functions/state_preparation.py +92 -10
- classiq/qmod/builtins/functions/swap_test.py +7 -1
- classiq/qmod/builtins/functions/utility_functions.py +43 -0
- classiq/qmod/builtins/functions/variational.py +53 -0
- classiq/qmod/builtins/operations.py +4 -5
- classiq/qmod/cfunc.py +2 -2
- classiq/qmod/classical_function.py +3 -7
- classiq/qmod/create_model_function.py +19 -8
- classiq/qmod/declaration_inferrer.py +7 -10
- classiq/qmod/expression_query.py +3 -3
- classiq/qmod/generative.py +2 -1
- classiq/qmod/model_state_container.py +5 -7
- classiq/qmod/native/__init__.py +1 -3
- classiq/qmod/native/expression_to_qmod.py +9 -8
- classiq/qmod/native/pretty_printer.py +6 -5
- classiq/qmod/pretty_print/__init__.py +1 -3
- classiq/qmod/pretty_print/expression_to_python.py +13 -12
- classiq/qmod/pretty_print/pretty_printer.py +13 -12
- classiq/qmod/python_classical_type.py +8 -4
- classiq/qmod/qfunc.py +4 -4
- classiq/qmod/qmod_parameter.py +3 -1
- classiq/qmod/qmod_variable.py +11 -10
- classiq/qmod/quantum_expandable.py +32 -15
- classiq/qmod/quantum_function.py +34 -5
- classiq/qmod/semantics/annotation.py +1 -1
- classiq/qmod/semantics/error_manager.py +8 -7
- classiq/qmod/semantics/static_semantics_visitor.py +19 -24
- classiq/qmod/semantics/validation/constants_validation.py +1 -1
- classiq/qmod/semantics/validation/func_call_validation.py +2 -2
- classiq/qmod/semantics/validation/main_validation.py +33 -0
- classiq/qmod/semantics/validation/types_validation.py +2 -1
- classiq/qmod/symbolic.py +5 -8
- classiq/qmod/symbolic_type.py +2 -2
- classiq/qmod/synthesize_separately.py +16 -0
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/METADATA +1 -1
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/RECORD +302 -295
- classiq/qmod/builtins/functions/qft.py +0 -23
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/WHEEL +0 -0
@@ -1,11 +1,7 @@
|
|
1
|
-
from collections.abc import Sequence
|
1
|
+
from collections.abc import Iterable as IterableType, Sequence
|
2
2
|
from typing import (
|
3
3
|
Any,
|
4
|
-
Iterable as IterableType,
|
5
|
-
List,
|
6
4
|
Optional,
|
7
|
-
Tuple,
|
8
|
-
Type,
|
9
5
|
Union,
|
10
6
|
)
|
11
7
|
|
@@ -16,8 +12,8 @@ from pydantic import ConfigDict, field_validator
|
|
16
12
|
|
17
13
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
18
14
|
|
19
|
-
DataList =
|
20
|
-
LabelsInt =
|
15
|
+
DataList = list[list[float]]
|
16
|
+
LabelsInt = list[int]
|
21
17
|
|
22
18
|
|
23
19
|
def listify(obj: Union[IterableType, ArrayLike]) -> list:
|
@@ -33,13 +29,13 @@ def listify(obj: Union[IterableType, ArrayLike]) -> list:
|
|
33
29
|
|
34
30
|
def validate_array_to_list(name: str) -> Any:
|
35
31
|
@field_validator(name, mode="before")
|
36
|
-
def _listify(cls:
|
32
|
+
def _listify(cls: type[pydantic.BaseModel], value: Any) -> Any:
|
37
33
|
return listify(value)
|
38
34
|
|
39
35
|
return _listify
|
40
36
|
|
41
37
|
|
42
|
-
Shape =
|
38
|
+
Shape = tuple[int, ...]
|
43
39
|
|
44
40
|
|
45
41
|
class QSVMInternalState(VersionedModel):
|
@@ -118,4 +114,4 @@ class QSVMPredictResult(VersionedModel):
|
|
118
114
|
|
119
115
|
|
120
116
|
Data = Union[DataList, np.ndarray]
|
121
|
-
Labels = Union[
|
117
|
+
Labels = Union[list[Any], np.ndarray]
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from
|
3
|
+
from collections.abc import Iterable
|
4
|
+
from typing import Any, Optional, Union
|
4
5
|
|
5
6
|
import pydantic
|
6
7
|
from pydantic import BaseModel
|
@@ -50,7 +51,7 @@ class BackendPreferences(BaseModel):
|
|
50
51
|
@classmethod
|
51
52
|
def batch_preferences(
|
52
53
|
cls, *, backend_names: Iterable[str], **kwargs: Any
|
53
|
-
) ->
|
54
|
+
) -> list[BackendPreferences]:
|
54
55
|
return [cls(backend_name=name, **kwargs) for name in backend_names]
|
55
56
|
|
56
57
|
def is_nvidia_backend(self) -> bool:
|
@@ -121,7 +122,7 @@ class AliceBobBackendPreferences(BackendPreferences):
|
|
121
122
|
)
|
122
123
|
|
123
124
|
@property
|
124
|
-
def parameters(self) ->
|
125
|
+
def parameters(self) -> dict[str, Any]:
|
125
126
|
parameters = {
|
126
127
|
"distance": self.distance,
|
127
128
|
"kappa1": self.kappa_1,
|
@@ -1,9 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import TYPE_CHECKING,
|
3
|
+
from typing import TYPE_CHECKING, Annotated, Optional
|
4
4
|
|
5
5
|
from pydantic import BaseModel, ConfigDict, Field
|
6
|
-
from typing_extensions import Annotated
|
7
6
|
|
8
7
|
# This file is based on autogenerated code from: https://static.ionq.co/schemas/circuit-v0.json using
|
9
8
|
# https://pydantic-docs.helpmanual.io/datamodel_code_generator/
|
@@ -25,14 +24,14 @@ class Gate(BaseModel):
|
|
25
24
|
gate: PydanticGateName
|
26
25
|
target: Optional[int] = None
|
27
26
|
control: Optional[int] = None
|
28
|
-
targets: Optional[
|
29
|
-
controls: Optional[
|
27
|
+
targets: Optional[list[int]] = None
|
28
|
+
controls: Optional[list[int]] = None
|
30
29
|
model_config = ConfigDict(extra="allow")
|
31
30
|
|
32
31
|
|
33
32
|
class IonqQuantumCircuit(BaseModel):
|
34
33
|
qubits: int
|
35
|
-
circuit:
|
34
|
+
circuit: list[Gate]
|
36
35
|
model_config = ConfigDict(extra="allow")
|
37
36
|
|
38
37
|
@classmethod
|
@@ -1,7 +1,6 @@
|
|
1
|
-
from typing import TYPE_CHECKING
|
1
|
+
from typing import TYPE_CHECKING, Annotated
|
2
2
|
|
3
3
|
from pydantic import Field, StrictStr, constr
|
4
|
-
from typing_extensions import Annotated
|
5
4
|
|
6
5
|
AZURE_QUANTUM_RESOURCE_ID_REGEX = r"^/subscriptions/([a-fA-F0-9-]*)/resourceGroups/([^\s/]*)/providers/Microsoft\.Quantum/Workspaces/([^\s/]*)$"
|
7
6
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import itertools
|
4
|
-
from typing import
|
4
|
+
from typing import Union
|
5
5
|
|
6
6
|
import numpy as np
|
7
7
|
import pydantic
|
@@ -12,8 +12,8 @@ from classiq.interface.helpers.hashable_pydantic_base_model import (
|
|
12
12
|
HashablePydanticBaseModel,
|
13
13
|
)
|
14
14
|
|
15
|
-
LadderOperator =
|
16
|
-
FermionicOperatorTuple =
|
15
|
+
LadderOperator = tuple[str, int]
|
16
|
+
FermionicOperatorTuple = tuple["FermionicOperator", float]
|
17
17
|
|
18
18
|
_SUBSCRIPT_UNICODE_CHARS = {
|
19
19
|
"0": "\u2080",
|
@@ -118,7 +118,7 @@ class FermionicOperator(HashablePydanticBaseModel):
|
|
118
118
|
)
|
119
119
|
|
120
120
|
@property
|
121
|
-
def all_indices(self) ->
|
121
|
+
def all_indices(self) -> set[int]:
|
122
122
|
return {op[1] for op in self.op_list}
|
123
123
|
|
124
124
|
|
@@ -195,7 +195,7 @@ class SummedFermionicOperator(HashablePydanticBaseModel):
|
|
195
195
|
return True
|
196
196
|
|
197
197
|
@property
|
198
|
-
def _all_indices(self) ->
|
198
|
+
def _all_indices(self) -> set[int]:
|
199
199
|
return set(
|
200
200
|
itertools.chain.from_iterable(op.all_indices for op, _ in self.op_list)
|
201
201
|
)
|
@@ -1,9 +1,8 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Annotated, Literal, Optional, Union, cast
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
from pydantic import ConfigDict, Field
|
5
5
|
from pydantic_core.core_schema import ValidationInfo
|
6
|
-
from typing_extensions import Annotated
|
7
6
|
|
8
7
|
from classiq.interface.chemistry.fermionic_operator import SummedFermionicOperator
|
9
8
|
from classiq.interface.chemistry.molecule import Molecule
|
@@ -29,7 +28,7 @@ And use a list, and manually check its length
|
|
29
28
|
"""
|
30
29
|
NumSpinUpParticles = pydantic.NonNegativeInt
|
31
30
|
NumSpinDownParticles = pydantic.NonNegativeInt
|
32
|
-
NumParticles =
|
31
|
+
NumParticles = tuple[NumSpinUpParticles, NumSpinDownParticles]
|
33
32
|
|
34
33
|
|
35
34
|
class FermionMapping(StrEnum):
|
@@ -74,7 +73,7 @@ class MoleculeProblem(GroundStateProblem):
|
|
74
73
|
molecule: Molecule
|
75
74
|
basis: str = pydantic.Field(default="sto3g", description="Molecular basis set")
|
76
75
|
freeze_core: bool = pydantic.Field(default=False)
|
77
|
-
remove_orbitals:
|
76
|
+
remove_orbitals: list[int] = pydantic.Field(
|
78
77
|
default_factory=list, description="list of orbitals to remove"
|
79
78
|
)
|
80
79
|
|
@@ -85,7 +84,7 @@ class HamiltonianProblem(GroundStateProblem):
|
|
85
84
|
hamiltonian: SummedFermionicOperator = pydantic.Field(
|
86
85
|
description="Hamiltonian as a fermionic operator"
|
87
86
|
)
|
88
|
-
num_particles:
|
87
|
+
num_particles: list[pydantic.PositiveInt] = pydantic.Field(
|
89
88
|
description="Tuple containing the numbers of alpha particles and beta particles"
|
90
89
|
)
|
91
90
|
|
@@ -94,9 +93,9 @@ class HamiltonianProblem(GroundStateProblem):
|
|
94
93
|
def _validate_num_particles(
|
95
94
|
cls,
|
96
95
|
num_particles: Union[
|
97
|
-
|
96
|
+
list[Union[int, float]], tuple[Union[int, float], Union[int, float]]
|
98
97
|
],
|
99
|
-
) ->
|
98
|
+
) -> list[int]:
|
100
99
|
assert isinstance(num_particles, (list, tuple))
|
101
100
|
assert len(num_particles) == 2
|
102
101
|
|
@@ -105,7 +104,7 @@ class HamiltonianProblem(GroundStateProblem):
|
|
105
104
|
assert num_particles[0] >= 1
|
106
105
|
assert num_particles[1] >= 1
|
107
106
|
|
108
|
-
return cast(
|
107
|
+
return cast(list[int], num_particles)
|
109
108
|
|
110
109
|
|
111
110
|
CHEMISTRY_PROBLEMS = (MoleculeProblem, HamiltonianProblem)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Literal, Union
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
from pydantic import ConfigDict
|
@@ -19,7 +19,7 @@ class Atom(HashablePydanticBaseModel):
|
|
19
19
|
|
20
20
|
|
21
21
|
class Molecule(HashablePydanticBaseModel):
|
22
|
-
atoms:
|
22
|
+
atoms: list[Atom] = pydantic.Field(
|
23
23
|
description="A list of atoms each containing the atoms symbol and its (x,y,z) location",
|
24
24
|
min_length=1,
|
25
25
|
)
|
@@ -31,7 +31,7 @@ class Molecule(HashablePydanticBaseModel):
|
|
31
31
|
)
|
32
32
|
|
33
33
|
@property
|
34
|
-
def atoms_type(self) ->
|
34
|
+
def atoms_type(self) -> list[AtomType]:
|
35
35
|
return [(atom.symbol, [atom.x, atom.y, atom.z]) for atom in self.atoms]
|
36
36
|
|
37
37
|
@classmethod
|
@@ -42,7 +42,7 @@ class Molecule(HashablePydanticBaseModel):
|
|
42
42
|
|
43
43
|
@pydantic.field_validator("atoms", mode="before")
|
44
44
|
@classmethod
|
45
|
-
def _validate_atoms(cls, atoms:
|
45
|
+
def _validate_atoms(cls, atoms: list[Union[AtomType, Atom]]) -> list[Atom]:
|
46
46
|
return [cls._validate_atom(atom) for atom in atoms]
|
47
47
|
|
48
48
|
@staticmethod
|
@@ -1,9 +1,7 @@
|
|
1
|
+
from collections.abc import Collection
|
1
2
|
from functools import reduce
|
2
3
|
from typing import (
|
3
4
|
Any,
|
4
|
-
Collection,
|
5
|
-
Dict,
|
6
|
-
List,
|
7
5
|
Optional,
|
8
6
|
Union,
|
9
7
|
cast,
|
@@ -108,7 +106,7 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
108
106
|
|
109
107
|
@pydantic.model_validator(mode="before")
|
110
108
|
@classmethod
|
111
|
-
def _validate_hermitianity(cls, values:
|
109
|
+
def _validate_hermitianity(cls, values: dict[str, Any]) -> dict[str, Any]:
|
112
110
|
pauli_list = values.get("pauli_list", [])
|
113
111
|
if PauliOperator.check_if_hermitian(pauli_list):
|
114
112
|
values["is_hermitian"] = all(
|
@@ -153,7 +151,7 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
153
151
|
)
|
154
152
|
|
155
153
|
@staticmethod
|
156
|
-
def _is_sub_pauli_commutative(qubit_pauli_string: Union[
|
154
|
+
def _is_sub_pauli_commutative(qubit_pauli_string: Union[list[str], str]) -> bool:
|
157
155
|
unique_paulis = set(qubit_pauli_string) - {"I"}
|
158
156
|
return len(unique_paulis) <= 1
|
159
157
|
|
@@ -241,8 +239,8 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
241
239
|
@classmethod
|
242
240
|
def from_unzipped_lists(
|
243
241
|
cls,
|
244
|
-
operators:
|
245
|
-
coefficients: Optional[
|
242
|
+
operators: list[list["Pauli"]],
|
243
|
+
coefficients: Optional[list[complex]] = None,
|
246
244
|
) -> "PauliOperator":
|
247
245
|
if coefficients is None:
|
248
246
|
coefficients = [1] * len(operators)
|
@@ -316,7 +314,7 @@ class PauliOperatorV1(HashablePydanticBaseModel):
|
|
316
314
|
|
317
315
|
@pydantic.model_validator(mode="before")
|
318
316
|
@classmethod
|
319
|
-
def _validate_hermitianity(cls, v:
|
317
|
+
def _validate_hermitianity(cls, v: dict[str, Any]) -> dict[str, Any]:
|
320
318
|
pauli_list = cast(PydanticPauliList, v.get("pauli_list"))
|
321
319
|
if all(isinstance(summand[1], complex) for summand in pauli_list):
|
322
320
|
v["is_hermitian"] = all(
|
@@ -361,7 +359,7 @@ class PauliOperatorV1(HashablePydanticBaseModel):
|
|
361
359
|
)
|
362
360
|
|
363
361
|
@staticmethod
|
364
|
-
def _is_sub_pauli_commutative(qubit_pauli_string: Union[
|
362
|
+
def _is_sub_pauli_commutative(qubit_pauli_string: Union[list[str], str]) -> bool:
|
365
363
|
unique_paulis = set(qubit_pauli_string) - {"I"}
|
366
364
|
return len(unique_paulis) <= 1
|
367
365
|
|
@@ -445,8 +443,8 @@ class PauliOperatorV1(HashablePydanticBaseModel):
|
|
445
443
|
@classmethod
|
446
444
|
def from_unzipped_lists(
|
447
445
|
cls,
|
448
|
-
operators:
|
449
|
-
coefficients: Optional[
|
446
|
+
operators: list[list["Pauli"]],
|
447
|
+
coefficients: Optional[list[complex]] = None,
|
450
448
|
) -> "PauliOperatorV1":
|
451
449
|
if coefficients is None:
|
452
450
|
coefficients = [1] * len(operators)
|
@@ -505,9 +503,9 @@ def validate_operator_has_no_complex_coefficients(
|
|
505
503
|
return pauli_operator
|
506
504
|
|
507
505
|
|
508
|
-
def pauli_integers_to_str(paulis:
|
506
|
+
def pauli_integers_to_str(paulis: list[Pauli]) -> str:
|
509
507
|
return "".join([Pauli(pauli).name for pauli in paulis])
|
510
508
|
|
511
509
|
|
512
510
|
class PauliOperators(VersionedModel):
|
513
|
-
operators:
|
511
|
+
operators: list[PauliOperator]
|
@@ -1,10 +1,8 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
1
|
import numpy as np
|
4
2
|
import pyomo.core as pyo
|
5
3
|
|
6
4
|
|
7
|
-
def ascending_sequence(coeffs:
|
5
|
+
def ascending_sequence(coeffs: list[int], bound: int) -> pyo.ConcreteModel:
|
8
6
|
model = pyo.ConcreteModel()
|
9
7
|
model.x = pyo.Var(
|
10
8
|
range(len(coeffs)), domain=pyo.NonNegativeIntegers, bounds=(0, bound)
|
@@ -1,16 +1,14 @@
|
|
1
|
-
from typing import List, Tuple
|
2
|
-
|
3
1
|
import numpy as np
|
4
2
|
import pyomo.core as pyo
|
5
3
|
|
6
4
|
|
7
5
|
def integer_portfolio_optimization(
|
8
|
-
covariances: np.ndarray, returns: np.ndarray, upper_bounds:
|
6
|
+
covariances: np.ndarray, returns: np.ndarray, upper_bounds: list[int]
|
9
7
|
) -> pyo.ConcreteModel:
|
10
8
|
model = pyo.ConcreteModel()
|
11
9
|
num_assets = len(returns)
|
12
10
|
|
13
|
-
def bounds(model: pyo.ConcreteModel, i: int) ->
|
11
|
+
def bounds(model: pyo.ConcreteModel, i: int) -> tuple[int, int]:
|
14
12
|
return 0, upper_bounds[i]
|
15
13
|
|
16
14
|
model.x = pyo.Var(range(num_assets), domain=pyo.NonNegativeIntegers, bounds=bounds)
|
@@ -1,13 +1,13 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Optional
|
2
2
|
|
3
3
|
import numpy as np
|
4
4
|
import pyomo.core as pyo
|
5
5
|
|
6
6
|
|
7
7
|
def knapsack(
|
8
|
-
values:
|
8
|
+
values: list[int],
|
9
9
|
upper_bound: int,
|
10
|
-
weights: Optional[
|
10
|
+
weights: Optional[list[int]] = None,
|
11
11
|
max_weight: Optional[int] = None,
|
12
12
|
) -> pyo.ConcreteModel:
|
13
13
|
model = pyo.ConcreteModel()
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import math
|
2
|
-
from typing import Dict, Tuple
|
3
2
|
|
4
3
|
import networkx as nx
|
5
4
|
import pyomo.core as pyo
|
6
5
|
import pyomo.core.expr.numeric_expr as pyo_expr
|
7
6
|
|
8
7
|
Node = int
|
9
|
-
Edge =
|
10
|
-
Pubo =
|
8
|
+
Edge = tuple[Node, Node]
|
9
|
+
Pubo = dict[tuple[Edge, ...], float]
|
11
10
|
|
12
11
|
|
13
12
|
def build_mht_pyomo_model(
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import itertools
|
2
|
-
from typing import List
|
3
2
|
|
4
3
|
import pyomo.core as pyo
|
5
4
|
import pyomo.core.expr.numeric_expr as pyo_expr
|
6
5
|
|
7
6
|
|
8
|
-
def set_cover(sub_sets:
|
7
|
+
def set_cover(sub_sets: list[list[int]]) -> pyo.ConcreteModel:
|
9
8
|
entire_set = set(itertools.chain(*sub_sets))
|
10
9
|
n = max(entire_set)
|
11
10
|
num_sets = len(sub_sets)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
1
|
import more_itertools
|
4
2
|
import numpy as np
|
5
3
|
import pydantic
|
@@ -24,7 +22,7 @@ class MhtQaoaInput(BaseModel):
|
|
24
22
|
reps: pydantic.PositiveInt = pydantic.Field(
|
25
23
|
default=3, description="Number of QAOA layers."
|
26
24
|
)
|
27
|
-
plot_list:
|
25
|
+
plot_list: list[PlotData] = pydantic.Field(
|
28
26
|
description="The list of (x,y,t) plots of the MHT problem."
|
29
27
|
)
|
30
28
|
misdetection_maximum_time_steps: pydantic.NonNegativeInt = pydantic.Field(
|
@@ -56,8 +54,8 @@ class MhtQaoaInput(BaseModel):
|
|
56
54
|
@pydantic.field_validator("plot_list")
|
57
55
|
@classmethod
|
58
56
|
def round_plot_list_times_and_validate(
|
59
|
-
cls, plot_list:
|
60
|
-
) ->
|
57
|
+
cls, plot_list: list[PlotData]
|
58
|
+
) -> list[PlotData]:
|
61
59
|
MhtQaoaInput._check_all_ids_are_distinct(plot_list)
|
62
60
|
MhtQaoaInput._round_to_tolerance_decimals(plot_list)
|
63
61
|
|
@@ -75,11 +73,11 @@ class MhtQaoaInput(BaseModel):
|
|
75
73
|
return plot_list
|
76
74
|
|
77
75
|
@staticmethod
|
78
|
-
def _round_to_tolerance_decimals(plot_list:
|
76
|
+
def _round_to_tolerance_decimals(plot_list: list[PlotData]) -> None:
|
79
77
|
for plot in plot_list:
|
80
78
|
plot.t = np.round(plot.t, decimals=_TOLERANCE_DECIMALS)
|
81
79
|
|
82
80
|
@staticmethod
|
83
|
-
def _check_all_ids_are_distinct(plot_list:
|
81
|
+
def _check_all_ids_are_distinct(plot_list: list[PlotData]) -> None:
|
84
82
|
if not more_itertools.all_unique(plot.plot_id for plot in plot_list):
|
85
83
|
raise ClassiqValueError("Plot IDs should be unique.")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any
|
1
|
+
from typing import Any
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
from pydantic import BaseModel
|
@@ -14,4 +14,4 @@ class MaxCutProblem(BaseModel):
|
|
14
14
|
default_factory=CombinatorialOptimizer,
|
15
15
|
description="preferences for the VQE execution",
|
16
16
|
)
|
17
|
-
serialized_graph:
|
17
|
+
serialized_graph: dict[str, Any]
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import json
|
2
|
-
from
|
2
|
+
from collections.abc import Mapping
|
3
|
+
from typing import Any, Optional, Union
|
3
4
|
from uuid import UUID
|
4
5
|
|
5
6
|
from pydantic import BaseModel, Field
|
6
7
|
|
7
8
|
from classiq.interface.generator.generated_circuit_data import (
|
8
9
|
FunctionDebugInfoInterface,
|
10
|
+
OperationLevel,
|
9
11
|
)
|
10
|
-
from classiq.interface.ide.visual_model import OperationLevel
|
11
12
|
|
12
13
|
ParameterValue = Union[float, int, str, None]
|
13
14
|
|
@@ -15,11 +16,11 @@ ParameterValue = Union[float, int, str, None]
|
|
15
16
|
class FunctionDebugInfo(BaseModel):
|
16
17
|
name: str
|
17
18
|
# Parameters describe classical parameters passed to function
|
18
|
-
parameters:
|
19
|
+
parameters: dict[str, str]
|
19
20
|
level: OperationLevel
|
20
21
|
is_allocate_or_free: bool = Field(default=False)
|
21
22
|
is_inverse: bool = Field(default=False)
|
22
|
-
port_to_passed_variable_map:
|
23
|
+
port_to_passed_variable_map: dict[str, str] = Field(default_factory=dict)
|
23
24
|
|
24
25
|
@staticmethod
|
25
26
|
def param_controller(value: Any) -> str:
|
@@ -38,7 +39,7 @@ class FunctionDebugInfo(BaseModel):
|
|
38
39
|
self.port_to_passed_variable_map = new_port_to_passed_variable_map
|
39
40
|
|
40
41
|
def update_map_from_inout_port_mapping(
|
41
|
-
self, port_mapping: Mapping[str,
|
42
|
+
self, port_mapping: Mapping[str, tuple[str, str]]
|
42
43
|
) -> None:
|
43
44
|
new_port_to_passed_variable_map = self.port_to_passed_variable_map.copy()
|
44
45
|
for old_key, (new_key1, new_key2) in port_mapping.items():
|
@@ -53,8 +54,8 @@ class DebugInfoCollection(BaseModel):
|
|
53
54
|
# Pydantic only started supporting UUID as keys in Pydantic V2
|
54
55
|
# See https://github.com/pydantic/pydantic/issues/2096#issuecomment-814860206
|
55
56
|
# For now, we use strings as keys in the raw data and use UUID in the wrapper logic
|
56
|
-
data:
|
57
|
-
blackbox_data:
|
57
|
+
data: dict[str, FunctionDebugInfo] = Field(default={})
|
58
|
+
blackbox_data: dict[str, FunctionDebugInfoInterface] = Field(default={})
|
58
59
|
|
59
60
|
def __setitem__(self, key: UUID, value: FunctionDebugInfo) -> None:
|
60
61
|
self.data[str(key)] = value
|
classiq/interface/exceptions.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import logging
|
2
|
-
from
|
2
|
+
from collections.abc import Iterable
|
3
|
+
from typing import Optional
|
3
4
|
|
4
5
|
_logger = logging.getLogger(__name__)
|
5
6
|
|
@@ -26,7 +27,7 @@ class ClassiqExecutionError(ClassiqError):
|
|
26
27
|
|
27
28
|
|
28
29
|
class ClassiqMissingOutputFormatError(ClassiqError):
|
29
|
-
def __init__(self, missing_formats:
|
30
|
+
def __init__(self, missing_formats: list[str]) -> None:
|
30
31
|
msg = (
|
31
32
|
f"Cannot create program because output format is missing. "
|
32
33
|
f"Expected one of the following formats: {missing_formats}"
|
@@ -51,7 +52,9 @@ class ClassiqAnalyzerVisualizationError(ClassiqError):
|
|
51
52
|
|
52
53
|
|
53
54
|
class ClassiqAPIError(ClassiqError):
|
54
|
-
|
55
|
+
def __init__(self, message: str, status_code: Optional[int] = None) -> None:
|
56
|
+
self.status_code = status_code
|
57
|
+
super().__init__(message)
|
55
58
|
|
56
59
|
|
57
60
|
class ClassiqVersionError(ClassiqError):
|
@@ -144,7 +147,7 @@ class ClassiqCombOptNoSolutionError(ClassiqError):
|
|
144
147
|
|
145
148
|
class ClassiqCombOptTrivialProblemError(ClassiqError):
|
146
149
|
|
147
|
-
def __init__(self, solution:
|
150
|
+
def __init__(self, solution: list[int]) -> None:
|
148
151
|
super().__init__(
|
149
152
|
message=f"The problem doesn't have free decision variables. "
|
150
153
|
f"The trivial solution is {solution}."
|
@@ -188,9 +191,10 @@ class ClassiqExpansionError(ClassiqError):
|
|
188
191
|
|
189
192
|
class ClassiqInternalError(ClassiqError):
|
190
193
|
def __init__(self, message: Optional[str] = None) -> None:
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
+
final_message = "Internal error occurred. Please contact Classiq support."
|
195
|
+
if message is not None:
|
196
|
+
final_message += f"\nError: {message}"
|
197
|
+
super().__init__(final_message)
|
194
198
|
|
195
199
|
|
196
200
|
class ClassiqInternalExpansionError(ClassiqInternalError):
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
1
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
4
2
|
|
5
3
|
|
@@ -18,4 +16,4 @@ class IQCCProbeAuthData(IQCCInitAuthData):
|
|
18
16
|
|
19
17
|
|
20
18
|
class IQCCProbeAuthResponse(VersionedModel):
|
21
|
-
auth_token:
|
19
|
+
auth_token: str
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from datetime import datetime
|
2
|
-
from typing import
|
2
|
+
from typing import Optional
|
3
3
|
|
4
4
|
from pydantic import BaseModel
|
5
5
|
|
@@ -25,4 +25,4 @@ class ExecutionJobDetailsV1(BaseModel, extra="ignore"):
|
|
25
25
|
|
26
26
|
|
27
27
|
class ExecutionJobsQueryResultsV1(BaseModel, extra="ignore"):
|
28
|
-
results:
|
28
|
+
results: list[ExecutionJobDetailsV1]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Optional
|
2
2
|
|
3
3
|
from pydantic import BaseModel, Field
|
4
4
|
|
@@ -9,9 +9,9 @@ from classiq.interface.helpers.custom_encoders import CUSTOM_ENCODERS
|
|
9
9
|
|
10
10
|
class EstimateInput(BaseModel, json_encoders=CUSTOM_ENCODERS):
|
11
11
|
hamiltonian: PauliOperator
|
12
|
-
parameters:
|
12
|
+
parameters: list[Arguments]
|
13
13
|
|
14
14
|
|
15
15
|
class PrimitivesInput(BaseModel, json_encoders=CUSTOM_ENCODERS):
|
16
|
-
sample: Optional[
|
16
|
+
sample: Optional[list[Arguments]] = Field(default=None)
|
17
17
|
estimate: Optional[EstimateInput] = Field(default=None)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import datetime
|
2
2
|
from datetime import date
|
3
|
-
from typing import Any,
|
3
|
+
from typing import Any, Optional, Union
|
4
4
|
|
5
5
|
import pydantic
|
6
6
|
from pydantic import BaseModel, ConfigDict, Field
|
@@ -52,7 +52,7 @@ class ExecutionCostForTimePeriod(BaseModel):
|
|
52
52
|
raise ValueError('"end" date should be after "start" date')
|
53
53
|
return v
|
54
54
|
|
55
|
-
def dict(self, **kwargs: Any) ->
|
55
|
+
def dict(self, **kwargs: Any) -> dict[str, Any]:
|
56
56
|
data = super().model_dump(**kwargs)
|
57
57
|
data["start"] = self.start.strftime("%Y-%m-%d")
|
58
58
|
data["end"] = self.end.strftime("%Y-%m-%d")
|
@@ -80,11 +80,11 @@ class Total(pydantic.BaseModel):
|
|
80
80
|
class ExecutedTaskForPeriodItem(pydantic.BaseModel):
|
81
81
|
TimePeriod: TimePeriod
|
82
82
|
Total: Total
|
83
|
-
Groups: Optional[
|
83
|
+
Groups: Optional[list] = None
|
84
84
|
Estimated: Optional[bool] = None
|
85
85
|
|
86
86
|
model_config = ConfigDict(extra="forbid")
|
87
87
|
|
88
88
|
|
89
89
|
class ExecutionCostForTimePeriodResponse(pydantic.BaseModel):
|
90
|
-
executed_task_for_period:
|
90
|
+
executed_task_for_period: list[ExecutedTaskForPeriodItem]
|