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,9 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
1
|
from classiq.interface.generator.types.builtin_enum_declarations import (
|
4
2
|
FinanceFunctionType,
|
5
3
|
)
|
6
4
|
|
7
5
|
|
8
|
-
def get_finance_function_dict() ->
|
6
|
+
def get_finance_function_dict() -> dict[str, "FinanceFunctionType"]:
|
9
7
|
return {
|
10
8
|
"var": FinanceFunctionType.VAR,
|
11
9
|
"expected shortfall": FinanceFunctionType.SHORTFALL,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import re
|
2
|
+
from collections.abc import Mapping
|
2
3
|
from dataclasses import dataclass
|
3
|
-
from typing import Any,
|
4
|
+
from typing import Any, Optional
|
4
5
|
|
5
6
|
from sympy import Expr
|
6
7
|
from typing_extensions import get_args
|
@@ -19,7 +20,7 @@ from classiq.interface.generator.expressions.handle_identifier import HandleIden
|
|
19
20
|
class EvaluatedExpression:
|
20
21
|
value: ExpressionValue
|
21
22
|
|
22
|
-
def is_constant(self, constant_type: Optional[
|
23
|
+
def is_constant(self, constant_type: Optional[type] = None) -> bool:
|
23
24
|
if self.value is None:
|
24
25
|
return False
|
25
26
|
|
@@ -28,7 +29,7 @@ class EvaluatedExpression:
|
|
28
29
|
get_args(RuntimeConstant) if constant_type is None else constant_type,
|
29
30
|
)
|
30
31
|
|
31
|
-
def as_constant_type(self, constant_type:
|
32
|
+
def as_constant_type(self, constant_type: type) -> Any:
|
32
33
|
if not self.is_constant():
|
33
34
|
raise ClassiqValueError(
|
34
35
|
f"Invalid access to expression {self.value!r} as {constant_type}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import ast
|
2
|
-
import
|
3
|
-
from typing import Any,
|
2
|
+
from collections.abc import Mapping
|
3
|
+
from typing import Any, Optional
|
4
4
|
|
5
5
|
import pydantic
|
6
6
|
from pydantic import ConfigDict, PrivateAttr
|
@@ -45,14 +45,13 @@ class Expression(HashableASTNode):
|
|
45
45
|
@pydantic.field_validator("expr")
|
46
46
|
@classmethod
|
47
47
|
def format_expression(cls, expr: str) -> str:
|
48
|
-
|
49
|
-
expr = ast.unparse(ast.parse(expr))
|
48
|
+
expr = ast.unparse(ast.parse(expr))
|
50
49
|
return expr
|
51
50
|
|
52
51
|
def is_evaluated(self) -> bool:
|
53
52
|
return self._evaluated_expr is not None
|
54
53
|
|
55
|
-
def as_constant(self, constant_type:
|
54
|
+
def as_constant(self, constant_type: type) -> Any:
|
56
55
|
return self.value.as_constant_type(constant_type)
|
57
56
|
|
58
57
|
def to_int_value(self) -> int:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import keyword
|
2
|
-
from typing import Final
|
2
|
+
from typing import Final
|
3
3
|
|
4
4
|
from classiq.interface.generator.arith.arithmetic_expression_parser import (
|
5
5
|
DEFAULT_SUPPORTED_FUNC_NAMES,
|
@@ -11,12 +11,12 @@ from classiq.interface.generator.function_params import NAME_REGEX
|
|
11
11
|
|
12
12
|
SUPPORTED_VAR_NAMES_REG = NAME_REGEX
|
13
13
|
|
14
|
-
SUPPORTED_FUNC_NAMES:
|
14
|
+
SUPPORTED_FUNC_NAMES: set[str] = (
|
15
15
|
{"or", "and"}
|
16
16
|
.union(DEFAULT_SUPPORTED_FUNC_NAMES)
|
17
17
|
.union(set(SYMPY_SUPPORTED_EXPRESSIONS))
|
18
18
|
)
|
19
19
|
BOOLEAN_LITERALS = {"True", "False"}
|
20
|
-
FORBIDDEN_LITERALS:
|
20
|
+
FORBIDDEN_LITERALS: set[str] = set(keyword.kwlist) - SUPPORTED_FUNC_NAMES
|
21
21
|
CPARAM_EXECUTION_SUFFIX: Final[str] = "_param"
|
22
|
-
RESERVED_EXPRESSIONS:
|
22
|
+
RESERVED_EXPRESSIONS: frozenset[str] = frozenset({"i"})
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import TYPE_CHECKING
|
2
3
|
|
3
4
|
from classiq.interface.generator.expressions.non_symbolic_expr import NonSymbolicExpr
|
4
5
|
from classiq.interface.generator.expressions.qmod_sized_proxy import QmodSizedProxy
|
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
BASIC_ARITHMETIC_OPERATORS: List[str] = ["+", "-", "*", "/", "%"]
|
4
|
-
MATHEMATICAL_FUNCTIONS: List[str] = [
|
1
|
+
BASIC_ARITHMETIC_OPERATORS: list[str] = ["+", "-", "*", "/", "%"]
|
2
|
+
MATHEMATICAL_FUNCTIONS: list[str] = [
|
5
3
|
"sin",
|
6
4
|
"cos",
|
7
5
|
"tan",
|
@@ -36,7 +34,7 @@ MATHEMATICAL_FUNCTIONS: List[str] = [
|
|
36
34
|
"Min",
|
37
35
|
"mod_inverse",
|
38
36
|
]
|
39
|
-
SPECIAL_FUNCTIONS:
|
37
|
+
SPECIAL_FUNCTIONS: list[str] = [
|
40
38
|
"erf",
|
41
39
|
"erfc",
|
42
40
|
"gamma",
|
@@ -57,8 +55,8 @@ SPECIAL_FUNCTIONS: List[str] = [
|
|
57
55
|
"euler",
|
58
56
|
"catalan",
|
59
57
|
]
|
60
|
-
PIECEWISE_FUNCTIONS:
|
61
|
-
NUMERIC_CONSTANTS:
|
58
|
+
PIECEWISE_FUNCTIONS: list[str] = ["Piecewise", "Heaviside"]
|
59
|
+
NUMERIC_CONSTANTS: list[str] = [
|
62
60
|
"pi",
|
63
61
|
"E",
|
64
62
|
"I",
|
@@ -66,11 +64,11 @@ NUMERIC_CONSTANTS: List[str] = [
|
|
66
64
|
"EulerGamma",
|
67
65
|
"Catalan",
|
68
66
|
]
|
69
|
-
BOOLEAN_CONSTANTS:
|
70
|
-
CONSTANTS:
|
67
|
+
BOOLEAN_CONSTANTS: list[str] = ["true", "false"]
|
68
|
+
CONSTANTS: list[str] = NUMERIC_CONSTANTS + BOOLEAN_CONSTANTS
|
71
69
|
|
72
|
-
DATA_TYPES:
|
73
|
-
LOGIC_OPERATORS:
|
70
|
+
DATA_TYPES: list[str] = ["Matrix"]
|
71
|
+
LOGIC_OPERATORS: list[str] = [
|
74
72
|
"And",
|
75
73
|
"Or",
|
76
74
|
"Not",
|
@@ -80,9 +78,9 @@ LOGIC_OPERATORS: List[str] = [
|
|
80
78
|
"Nand",
|
81
79
|
"Nor",
|
82
80
|
]
|
83
|
-
RELATIONAL_OPERATORS:
|
81
|
+
RELATIONAL_OPERATORS: list[str] = ["<", "<=", ">", ">=", "!=", "<>", "Eq", "Ne"]
|
84
82
|
|
85
|
-
SYMPY_SUPPORTED_EXPRESSIONS:
|
83
|
+
SYMPY_SUPPORTED_EXPRESSIONS: list[str] = (
|
86
84
|
BASIC_ARITHMETIC_OPERATORS
|
87
85
|
+ MATHEMATICAL_FUNCTIONS
|
88
86
|
+ SPECIAL_FUNCTIONS
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import
|
3
|
+
from typing import Union
|
4
4
|
|
5
5
|
import pydantic
|
6
6
|
|
@@ -90,7 +90,7 @@ class FinancePayoff(function_params.FunctionParams):
|
|
90
90
|
description="The finance function to solve the model"
|
91
91
|
)
|
92
92
|
num_qubits: pydantic.PositiveInt
|
93
|
-
distribution_range:
|
93
|
+
distribution_range: tuple[float, float]
|
94
94
|
|
95
95
|
def _create_ios(self) -> None:
|
96
96
|
self._inputs = {
|
@@ -1,19 +1,19 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Iterable
|
2
2
|
|
3
3
|
from classiq.interface.generator.function_params import FunctionParams
|
4
4
|
|
5
5
|
|
6
6
|
class FunctionParamLibrary:
|
7
|
-
def __init__(self, param_list: Iterable[
|
8
|
-
self._param_list:
|
7
|
+
def __init__(self, param_list: Iterable[type[FunctionParams]]) -> None:
|
8
|
+
self._param_list: set[type[FunctionParams]] = set(param_list)
|
9
9
|
|
10
10
|
@property
|
11
|
-
def param_list(self) ->
|
11
|
+
def param_list(self) -> set[type[FunctionParams]]:
|
12
12
|
return self._param_list.copy()
|
13
13
|
|
14
14
|
# Private methods are for tests only
|
15
|
-
def _add(self, param:
|
15
|
+
def _add(self, param: type[FunctionParams]) -> None:
|
16
16
|
self._param_list.add(param)
|
17
17
|
|
18
|
-
def _remove(self, param:
|
18
|
+
def _remove(self, param: type[FunctionParams]) -> None:
|
19
19
|
self._param_list.discard(param)
|
@@ -1,16 +1,11 @@
|
|
1
1
|
import ast
|
2
2
|
import itertools
|
3
3
|
import re
|
4
|
+
from collections.abc import Collection, Iterable, Mapping
|
4
5
|
from typing import (
|
6
|
+
Annotated,
|
5
7
|
Any,
|
6
|
-
Collection,
|
7
|
-
Dict,
|
8
|
-
Iterable,
|
9
|
-
List,
|
10
|
-
Mapping,
|
11
8
|
Optional,
|
12
|
-
Set,
|
13
|
-
Type,
|
14
9
|
Union,
|
15
10
|
get_args,
|
16
11
|
)
|
@@ -18,7 +13,6 @@ from typing import (
|
|
18
13
|
import pydantic
|
19
14
|
import sympy
|
20
15
|
from pydantic import BeforeValidator, ConfigDict
|
21
|
-
from typing_extensions import Annotated
|
22
16
|
|
23
17
|
from classiq.interface.enum_utils import StrEnum
|
24
18
|
from classiq.interface.exceptions import ClassiqValueError
|
@@ -35,7 +29,7 @@ from classiq.interface.helpers.hashable_pydantic_base_model import (
|
|
35
29
|
FunctionParamsDiscriminator = str
|
36
30
|
|
37
31
|
IOName = PydanticNonEmptyString
|
38
|
-
ArithmeticIODict =
|
32
|
+
ArithmeticIODict = dict[IOName, RegisterArithmeticInfo]
|
39
33
|
|
40
34
|
DEFAULT_ZERO_NAME = "zero"
|
41
35
|
DEFAULT_OUTPUT_NAME = "OUT"
|
@@ -114,7 +108,7 @@ GenerationExpressionSupportedNodeTypes = Union[
|
|
114
108
|
|
115
109
|
|
116
110
|
def validate_expression_str(
|
117
|
-
expr_str: str, supported_functions: Optional[
|
111
|
+
expr_str: str, supported_functions: Optional[set[str]] = None
|
118
112
|
) -> None:
|
119
113
|
# By default, no functions are allowed.
|
120
114
|
supported_functions = supported_functions or set()
|
@@ -189,11 +183,11 @@ class FunctionParams(HashablePydanticBaseModel):
|
|
189
183
|
return sum(reg.size for reg in self.outputs.values())
|
190
184
|
|
191
185
|
@property
|
192
|
-
def _input_names(self) ->
|
186
|
+
def _input_names(self) -> list[IOName]:
|
193
187
|
return list(self._inputs.keys())
|
194
188
|
|
195
189
|
@property
|
196
|
-
def _output_names(self) ->
|
190
|
+
def _output_names(self) -> list[IOName]:
|
197
191
|
return list(self._outputs.keys())
|
198
192
|
|
199
193
|
def _create_zero_input_registers(self, names_and_sizes: Mapping[str, int]) -> None:
|
@@ -238,7 +232,7 @@ class FunctionParams(HashablePydanticBaseModel):
|
|
238
232
|
return sum(reg.size if reg is not None else 0 for reg in registers)
|
239
233
|
|
240
234
|
def _validate_io_names(self) -> None:
|
241
|
-
error_msg:
|
235
|
+
error_msg: list[str] = []
|
242
236
|
error_msg += self._get_error_msg(self._inputs, BAD_INPUT_REGISTER_ERROR_MSG)
|
243
237
|
error_msg += self._get_error_msg(self._outputs, BAD_OUTPUT_REGISTER_ERROR_MSG)
|
244
238
|
if error_msg:
|
@@ -257,7 +251,7 @@ class FunctionParams(HashablePydanticBaseModel):
|
|
257
251
|
if total_inputs_size != total_outputs_size:
|
258
252
|
raise ClassiqValueError(REGISTER_SIZES_MISMATCH_ERROR_MSG)
|
259
253
|
|
260
|
-
def _get_error_msg(self, names: Iterable[IOName], msg: str) ->
|
254
|
+
def _get_error_msg(self, names: Iterable[IOName], msg: str) -> list[str]:
|
261
255
|
bad_names = [name for name in names if re.fullmatch(NAME_REGEX, name) is None]
|
262
256
|
return [f"{msg}: {bad_names}"] if bad_names else []
|
263
257
|
|
@@ -272,10 +266,10 @@ def parse_function_params(
|
|
272
266
|
*,
|
273
267
|
params: Any,
|
274
268
|
discriminator: Optional[Any],
|
275
|
-
param_classes: Collection[
|
269
|
+
param_classes: Collection[type[FunctionParams]],
|
276
270
|
no_discriminator_error: Exception,
|
277
271
|
bad_function_error: Exception,
|
278
|
-
default_parser_class: Optional[
|
272
|
+
default_parser_class: Optional[type[FunctionParams]] = None,
|
279
273
|
) -> FunctionParams: # Any is for use in pydantic validators.
|
280
274
|
if not discriminator:
|
281
275
|
raise no_discriminator_error
|
@@ -299,11 +293,11 @@ def parse_function_params(
|
|
299
293
|
|
300
294
|
def parse_function_params_values(
|
301
295
|
*,
|
302
|
-
values:
|
296
|
+
values: dict[str, Any],
|
303
297
|
params_key: str,
|
304
298
|
discriminator_key: str,
|
305
|
-
param_classes: Collection[
|
306
|
-
default_parser_class:
|
299
|
+
param_classes: Collection[type[FunctionParams]],
|
300
|
+
default_parser_class: type[FunctionParams],
|
307
301
|
) -> None:
|
308
302
|
params = values.get(params_key, dict())
|
309
303
|
if isinstance(params, FunctionParams):
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Sequence
|
2
|
+
from typing import ClassVar, Optional
|
2
3
|
|
3
4
|
import pydantic
|
4
5
|
|
@@ -28,11 +29,11 @@ class ClassicalFunctionDeclaration(FunctionDeclaration):
|
|
28
29
|
)
|
29
30
|
|
30
31
|
BUILTIN_FUNCTION_DECLARATIONS: ClassVar[
|
31
|
-
|
32
|
+
dict[str, "ClassicalFunctionDeclaration"]
|
32
33
|
] = {}
|
33
34
|
|
34
35
|
FOREIGN_FUNCTION_DECLARATIONS: ClassVar[
|
35
|
-
|
36
|
+
dict[str, "ClassicalFunctionDeclaration"]
|
36
37
|
] = {}
|
37
38
|
|
38
39
|
@property
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import TYPE_CHECKING, Any,
|
1
|
+
from typing import TYPE_CHECKING, Any, Literal, Union
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
from pydantic import ConfigDict
|
@@ -19,7 +19,7 @@ NamedSymbol = Union[IndexedBase, Symbol]
|
|
19
19
|
|
20
20
|
|
21
21
|
class ClassicalType(HashableASTNode):
|
22
|
-
def as_symbolic(self, name: str) -> Union[NamedSymbol,
|
22
|
+
def as_symbolic(self, name: str) -> Union[NamedSymbol, list[NamedSymbol]]:
|
23
23
|
return Symbol(name)
|
24
24
|
|
25
25
|
model_config = ConfigDict(extra="forbid")
|
@@ -36,7 +36,7 @@ class Integer(ClassicalType):
|
|
36
36
|
|
37
37
|
@pydantic.model_validator(mode="before")
|
38
38
|
@classmethod
|
39
|
-
def _set_kind(cls, values: Any) ->
|
39
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
40
40
|
return values_with_discriminator(values, "kind", "int")
|
41
41
|
|
42
42
|
|
@@ -48,7 +48,7 @@ class Real(ClassicalType):
|
|
48
48
|
|
49
49
|
@pydantic.model_validator(mode="before")
|
50
50
|
@classmethod
|
51
|
-
def _set_kind(cls, values: Any) ->
|
51
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
52
52
|
return values_with_discriminator(values, "kind", "real")
|
53
53
|
|
54
54
|
|
@@ -57,7 +57,7 @@ class Bool(ClassicalType):
|
|
57
57
|
|
58
58
|
@pydantic.model_validator(mode="before")
|
59
59
|
@classmethod
|
60
|
-
def _set_kind(cls, values: Any) ->
|
60
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
61
61
|
return values_with_discriminator(values, "kind", "bool")
|
62
62
|
|
63
63
|
|
@@ -70,7 +70,7 @@ class ClassicalList(ClassicalType):
|
|
70
70
|
|
71
71
|
@pydantic.model_validator(mode="before")
|
72
72
|
@classmethod
|
73
|
-
def _set_kind(cls, values: Any) ->
|
73
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
74
74
|
return values_with_discriminator(values, "kind", "list")
|
75
75
|
|
76
76
|
|
@@ -79,7 +79,7 @@ class StructMetaType(ClassicalType):
|
|
79
79
|
|
80
80
|
@pydantic.model_validator(mode="before")
|
81
81
|
@classmethod
|
82
|
-
def _set_kind(cls, values: Any) ->
|
82
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
83
83
|
return values_with_discriminator(values, "kind", "type_proxy")
|
84
84
|
|
85
85
|
|
@@ -93,7 +93,7 @@ class ClassicalArray(ClassicalType):
|
|
93
93
|
|
94
94
|
@pydantic.model_validator(mode="before")
|
95
95
|
@classmethod
|
96
|
-
def _set_kind(cls, values: Any) ->
|
96
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
97
97
|
return values_with_discriminator(values, "kind", "array")
|
98
98
|
|
99
99
|
|
@@ -106,7 +106,7 @@ class VQEResult(OpaqueHandle):
|
|
106
106
|
|
107
107
|
@pydantic.model_validator(mode="before")
|
108
108
|
@classmethod
|
109
|
-
def _set_kind(cls, values: Any) ->
|
109
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
110
110
|
return values_with_discriminator(values, "kind", "vqe_result")
|
111
111
|
|
112
112
|
|
@@ -115,7 +115,7 @@ class Histogram(OpaqueHandle):
|
|
115
115
|
|
116
116
|
@pydantic.model_validator(mode="before")
|
117
117
|
@classmethod
|
118
|
-
def _set_kind(cls, values: Any) ->
|
118
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
119
119
|
return values_with_discriminator(values, "kind", "histogram")
|
120
120
|
|
121
121
|
|
@@ -124,7 +124,7 @@ class Estimation(OpaqueHandle):
|
|
124
124
|
|
125
125
|
@pydantic.model_validator(mode="before")
|
126
126
|
@classmethod
|
127
|
-
def _set_kind(cls, values: Any) ->
|
127
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
128
128
|
return values_with_discriminator(values, "kind", "estimation_result")
|
129
129
|
|
130
130
|
|
@@ -133,11 +133,11 @@ class IQAERes(OpaqueHandle):
|
|
133
133
|
|
134
134
|
@pydantic.model_validator(mode="before")
|
135
135
|
@classmethod
|
136
|
-
def _set_kind(cls, values: Any) ->
|
136
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
137
137
|
return values_with_discriminator(values, "kind", "iqae_result")
|
138
138
|
|
139
139
|
|
140
|
-
def as_symbolic(symbols:
|
140
|
+
def as_symbolic(symbols: dict[str, ClassicalType]) -> dict[str, RuntimeExpression]:
|
141
141
|
return {
|
142
142
|
param_name: param_type.as_symbolic(param_name)
|
143
143
|
for param_name, param_type in symbols.items()
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import TYPE_CHECKING, Any, Literal, Optional
|
2
3
|
|
3
4
|
import pydantic
|
4
5
|
|
@@ -25,7 +26,7 @@ class TypeName(ClassicalType, QuantumType):
|
|
25
26
|
|
26
27
|
@pydantic.model_validator(mode="before")
|
27
28
|
@classmethod
|
28
|
-
def _set_kind(cls, values: Any) ->
|
29
|
+
def _set_kind(cls, values: Any) -> dict[str, Any]:
|
29
30
|
return values_with_discriminator(values, "kind", "struct_instance")
|
30
31
|
|
31
32
|
def _update_size_in_bits_from_declaration(self) -> None:
|
@@ -1,20 +1,20 @@
|
|
1
1
|
import logging
|
2
|
-
from typing import Any,
|
2
|
+
from typing import Any, Literal, Optional, Union
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
from pydantic import ConfigDict
|
6
6
|
from typing_extensions import TypeAlias
|
7
7
|
|
8
|
+
from classiq.interface.enum_utils import StrEnum
|
8
9
|
from classiq.interface.generator.control_state import ControlState
|
9
10
|
from classiq.interface.generator.register_role import RegisterRole
|
10
11
|
from classiq.interface.generator.synthesis_metadata.synthesis_execution_data import (
|
11
12
|
ExecutionData,
|
12
13
|
)
|
13
|
-
from classiq.interface.ide.visual_model import OperationLevel, OperationParameter
|
14
14
|
|
15
15
|
_logger = logging.getLogger(__name__)
|
16
16
|
ParameterName = str
|
17
|
-
IOQubitMapping: TypeAlias =
|
17
|
+
IOQubitMapping: TypeAlias = dict[str, tuple[int, ...]]
|
18
18
|
|
19
19
|
CLASSIQ_HIERARCHY_SEPARATOR: Literal["."] = "."
|
20
20
|
|
@@ -42,8 +42,8 @@ class QubitMapping(pydantic.BaseModel):
|
|
42
42
|
class GeneratedRegister(pydantic.BaseModel):
|
43
43
|
name: str
|
44
44
|
role: RegisterRole
|
45
|
-
qubit_indexes_relative:
|
46
|
-
qubit_indexes_absolute:
|
45
|
+
qubit_indexes_relative: list[int]
|
46
|
+
qubit_indexes_absolute: list[int]
|
47
47
|
|
48
48
|
def __len__(self) -> int:
|
49
49
|
return self.qubit_indexes_relative.__len__()
|
@@ -55,13 +55,13 @@ class GeneratedRegister(pydantic.BaseModel):
|
|
55
55
|
|
56
56
|
class GeneratedFunction(pydantic.BaseModel):
|
57
57
|
name: str
|
58
|
-
control_states:
|
59
|
-
registers:
|
58
|
+
control_states: list[ControlState]
|
59
|
+
registers: list[GeneratedRegister] = list()
|
60
60
|
depth: Optional[int] = pydantic.Field(default=None)
|
61
61
|
width: Optional[int] = pydantic.Field(default=None)
|
62
|
-
released_auxiliary_qubits:
|
63
|
-
dangling_inputs:
|
64
|
-
dangling_outputs:
|
62
|
+
released_auxiliary_qubits: list[int] = list()
|
63
|
+
dangling_inputs: dict[str, GeneratedRegister] = dict()
|
64
|
+
dangling_outputs: dict[str, GeneratedRegister] = dict()
|
65
65
|
|
66
66
|
def __getitem__(self, key: Union[int, str]) -> GeneratedRegister:
|
67
67
|
if isinstance(key, int):
|
@@ -88,7 +88,7 @@ class GeneratedFunction(pydantic.BaseModel):
|
|
88
88
|
|
89
89
|
class GeneratedCircuitData(pydantic.BaseModel):
|
90
90
|
width: int
|
91
|
-
circuit_parameters:
|
91
|
+
circuit_parameters: list[ParameterName] = pydantic.Field(default_factory=list)
|
92
92
|
qubit_mapping: QubitMapping = pydantic.Field(default_factory=QubitMapping)
|
93
93
|
execution_data: Optional[ExecutionData] = pydantic.Field(default=None)
|
94
94
|
|
@@ -97,17 +97,29 @@ class GeneratedCircuitData(pydantic.BaseModel):
|
|
97
97
|
return cls(width=0)
|
98
98
|
|
99
99
|
|
100
|
+
class OperationLevel(StrEnum):
|
101
|
+
QMOD_FUNCTION_CALL = "QMOD_CALL"
|
102
|
+
QMOD_STATEMENT = "QMOD_STATEMENT"
|
103
|
+
ENGINE_FUNCTION_CALL = "ENGINE_CALL"
|
104
|
+
UNKNOWN = "UNKNOWN"
|
105
|
+
|
106
|
+
|
107
|
+
class OperationParameter(pydantic.BaseModel):
|
108
|
+
label: str
|
109
|
+
value: Optional[str] = None
|
110
|
+
|
111
|
+
|
100
112
|
class FunctionDebugInfoInterface(pydantic.BaseModel):
|
101
113
|
generated_function: Optional[GeneratedFunction] = pydantic.Field(default=None)
|
102
|
-
children:
|
103
|
-
relative_qubits:
|
104
|
-
absolute_qubits: Optional[
|
114
|
+
children: list["FunctionDebugInfoInterface"]
|
115
|
+
relative_qubits: tuple[int, ...]
|
116
|
+
absolute_qubits: Optional[tuple[int, ...]] = pydantic.Field(default=None)
|
105
117
|
is_basis_gate: Optional[bool] = pydantic.Field(default=None)
|
106
118
|
is_inverse: bool = pydantic.Field(default=False)
|
107
119
|
is_allocate_or_free: bool = pydantic.Field(default=False)
|
108
120
|
level: OperationLevel = pydantic.Field(default=OperationLevel.UNKNOWN)
|
109
|
-
parameters:
|
110
|
-
port_to_passed_variable_map:
|
121
|
+
parameters: list[OperationParameter] = list()
|
122
|
+
port_to_passed_variable_map: dict[str, str] = pydantic.Field(default={})
|
111
123
|
|
112
124
|
model_config = ConfigDict(extra="allow")
|
113
125
|
# Temporary field to store the override debug info for parallel old/new visualization
|
@@ -120,7 +132,7 @@ class FunctionDebugInfoInterface(pydantic.BaseModel):
|
|
120
132
|
return self.generated_function.name
|
121
133
|
|
122
134
|
@property
|
123
|
-
def registers(self) ->
|
135
|
+
def registers(self) -> list[GeneratedRegister]:
|
124
136
|
if self.generated_function is None:
|
125
137
|
return list()
|
126
138
|
return self.generated_function.registers
|
@@ -132,15 +144,15 @@ class FunctionDebugInfoInterface(pydantic.BaseModel):
|
|
132
144
|
return len(self.generated_function.control_states) > 0
|
133
145
|
|
134
146
|
@property
|
135
|
-
def control_states(self) ->
|
147
|
+
def control_states(self) -> list[ControlState]:
|
136
148
|
if self.generated_function is None:
|
137
149
|
return list()
|
138
150
|
return self.generated_function.control_states
|
139
151
|
|
140
152
|
@staticmethod
|
141
153
|
def create_parameters_from_dict(
|
142
|
-
parameters:
|
143
|
-
) ->
|
154
|
+
parameters: dict[str, str]
|
155
|
+
) -> list[OperationParameter]:
|
144
156
|
return [
|
145
157
|
OperationParameter(label=key, value=value)
|
146
158
|
for key, value in parameters.items()
|
@@ -175,8 +187,8 @@ class FunctionDebugInfoInterface(pydantic.BaseModel):
|
|
175
187
|
|
176
188
|
|
177
189
|
def _get_absolute_from_relative(
|
178
|
-
absolute_qubits:
|
179
|
-
) ->
|
190
|
+
absolute_qubits: tuple[int, ...], relative_qubits: tuple[int, ...]
|
191
|
+
) -> tuple[int, ...]:
|
180
192
|
if max(relative_qubits) >= len(absolute_qubits):
|
181
193
|
_logger.warning(
|
182
194
|
"Invalid qubit computation (relative qubits: %s, absolute qubits: %s)",
|