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,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Literal, Optional, Union
|
2
2
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
@@ -37,13 +37,13 @@ class QSVMFeatureMapPauli(QSVMFeatureMapDimensional):
|
|
37
37
|
reps: int = 2
|
38
38
|
entanglement: QSVMFeatureMapEntanglement = QSVMFeatureMapEntanglement.LINEAR
|
39
39
|
alpha: float = 2.0
|
40
|
-
paulis:
|
40
|
+
paulis: list[str] = ["Z", "ZZ"]
|
41
41
|
parameter_prefix: str = "x"
|
42
42
|
name: str = "PauliFeatureMap"
|
43
43
|
|
44
44
|
@pydantic.field_validator("paulis", mode="before")
|
45
45
|
@classmethod
|
46
|
-
def set_paulis(cls, paulis:
|
46
|
+
def set_paulis(cls, paulis: list[str]) -> list[str]:
|
47
47
|
# iterate every letter in every string in the list of paulis
|
48
48
|
for s in paulis:
|
49
49
|
if not all(map(VALID_PAULI_LETTERS.__contains__, s.upper())):
|
@@ -6,16 +6,11 @@ import random
|
|
6
6
|
import re
|
7
7
|
import string
|
8
8
|
from collections import defaultdict
|
9
|
+
from collections.abc import Iterable, Mapping, Sequence
|
10
|
+
from re import Match
|
9
11
|
from typing import (
|
10
12
|
Any,
|
11
|
-
Dict,
|
12
|
-
Iterable,
|
13
|
-
List,
|
14
|
-
Mapping,
|
15
|
-
Match,
|
16
13
|
Optional,
|
17
|
-
Sequence,
|
18
|
-
Tuple,
|
19
14
|
Union,
|
20
15
|
)
|
21
16
|
from uuid import UUID, uuid4
|
@@ -64,7 +59,7 @@ LEGAL_SLICING = rf"(\-?\d+)?({SEPARATOR}(\-?\d+)?)?({SEPARATOR}(\-?\d+)?)?"
|
|
64
59
|
|
65
60
|
_ALPHANUM_CHARACTERS = string.ascii_letters + string.digits
|
66
61
|
|
67
|
-
RegNameAndSlice =
|
62
|
+
RegNameAndSlice = tuple[str, slice]
|
68
63
|
|
69
64
|
ZERO_INDICATOR = "0"
|
70
65
|
INVERSE_SUFFIX = "_qinverse"
|
@@ -86,7 +81,7 @@ SUFFIX_RANDOMIZER = random.Random() # noqa: S311
|
|
86
81
|
|
87
82
|
def split_wire_pair_to_wires(
|
88
83
|
inout: WirePair,
|
89
|
-
) ->
|
84
|
+
) -> tuple[WireName, WireName]:
|
90
85
|
return inout.in_wire, inout.out_wire
|
91
86
|
|
92
87
|
|
@@ -98,7 +93,7 @@ def randomize_suffix(suffix_len: int = DEFAULT_SUFFIX_LEN) -> str:
|
|
98
93
|
|
99
94
|
def get_non_zero_wires(
|
100
95
|
wires: Iterable[WireName],
|
101
|
-
) ->
|
96
|
+
) -> list[WireName]:
|
102
97
|
return [wire for wire in wires if wire != ZERO_INDICATOR]
|
103
98
|
|
104
99
|
|
@@ -122,7 +117,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
122
117
|
release_by_inverse: bool = pydantic.Field(
|
123
118
|
default=False, description="Release zero inputs in inverse call."
|
124
119
|
)
|
125
|
-
control_states:
|
120
|
+
control_states: list[ControlState] = pydantic.Field(
|
126
121
|
default_factory=list,
|
127
122
|
description="Call the controlled function with the given controlled states.",
|
128
123
|
)
|
@@ -166,14 +161,14 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
166
161
|
return hash(self.name)
|
167
162
|
|
168
163
|
@property
|
169
|
-
def non_zero_input_wires(self) ->
|
164
|
+
def non_zero_input_wires(self) -> list[WireName]:
|
170
165
|
in_out_input_wires = [
|
171
166
|
split_wire_pair_to_wires(inout)[0] for inout in self.inouts.values()
|
172
167
|
]
|
173
168
|
return get_non_zero_wires(self.inputs_dict.values()) + in_out_input_wires
|
174
169
|
|
175
170
|
@property
|
176
|
-
def non_zero_output_wires(self) ->
|
171
|
+
def non_zero_output_wires(self) -> list[WireName]:
|
177
172
|
in_out_output_wires = [
|
178
173
|
split_wire_pair_to_wires(inout)[1] for inout in self.inouts.values()
|
179
174
|
]
|
@@ -246,7 +241,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
246
241
|
|
247
242
|
@pydantic.model_validator(mode="before")
|
248
243
|
@classmethod
|
249
|
-
def validate_composite_name(cls, values: Any) ->
|
244
|
+
def validate_composite_name(cls, values: Any) -> dict[str, Any]:
|
250
245
|
if (
|
251
246
|
isinstance(values, dict)
|
252
247
|
and isinstance(values.get("unitary_params"), CustomFunction)
|
@@ -259,7 +254,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
259
254
|
|
260
255
|
@pydantic.model_validator(mode="before")
|
261
256
|
@classmethod
|
262
|
-
def _parse_function_params(cls, values: Any) ->
|
257
|
+
def _parse_function_params(cls, values: Any) -> dict[str, Any]:
|
263
258
|
if isinstance(values, dict):
|
264
259
|
f_params.parse_function_params_values(
|
265
260
|
values=values,
|
@@ -279,7 +274,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
279
274
|
params: f_params.FunctionParams,
|
280
275
|
inputs: WireDict,
|
281
276
|
is_inverse: bool,
|
282
|
-
control_states:
|
277
|
+
control_states: list[ControlState],
|
283
278
|
strict_zero_ios: bool,
|
284
279
|
) -> None:
|
285
280
|
(
|
@@ -317,8 +312,8 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
317
312
|
@pydantic.field_validator("control_states")
|
318
313
|
@classmethod
|
319
314
|
def _validate_control_states(
|
320
|
-
cls, control_states:
|
321
|
-
) ->
|
315
|
+
cls, control_states: list[ControlState], info: ValidationInfo
|
316
|
+
) -> list[ControlState]:
|
322
317
|
control_names = [ctrl_state.name for ctrl_state in control_states]
|
323
318
|
function_params = info.data.get("function_params")
|
324
319
|
strict_zero_ios = info.data.get("strict_zero_ios")
|
@@ -349,10 +344,10 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
349
344
|
inputs: IOType,
|
350
345
|
fp: FunctionParams,
|
351
346
|
strict_zero_ios: bool,
|
352
|
-
control_states:
|
347
|
+
control_states: list[ControlState],
|
353
348
|
) -> None:
|
354
349
|
name_slice_pairs = [parse_io_slicing(input) for input in inputs]
|
355
|
-
slices_dict:
|
350
|
+
slices_dict: dict[str, list[slice]] = defaultdict(list)
|
356
351
|
for name, slice in name_slice_pairs:
|
357
352
|
slices_dict[name].append(slice)
|
358
353
|
|
@@ -374,7 +369,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
374
369
|
raise ClassiqValueError(BAD_INPUT_SLICING_MSG)
|
375
370
|
|
376
371
|
@staticmethod
|
377
|
-
def _register_validate_slices(slices:
|
372
|
+
def _register_validate_slices(slices: list[slice], reg_width: int) -> bool:
|
378
373
|
widths_separated = [len(range(reg_width)[reg_slice]) for reg_slice in slices]
|
379
374
|
# examples: slice(0), slice(5,None) when width <= 5, slice(5,3)
|
380
375
|
empty_slices = 0 in widths_separated
|
@@ -399,7 +394,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
399
394
|
params: Optional[FunctionParams] = info.data.get("function_params")
|
400
395
|
is_inverse: bool = info.data.get("is_inverse", False)
|
401
396
|
strict_zero_ios: bool = info.data.get("strict_zero_ios", True)
|
402
|
-
control_states:
|
397
|
+
control_states: list[ControlState] = info.data.get("control_states", list())
|
403
398
|
if params is None:
|
404
399
|
return dict()
|
405
400
|
if isinstance(params, CustomFunction):
|
@@ -440,7 +435,7 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
440
435
|
params: f_params.FunctionParams,
|
441
436
|
outputs: WireDict,
|
442
437
|
is_inverse: bool,
|
443
|
-
control_states:
|
438
|
+
control_states: list[ControlState],
|
444
439
|
strict_zero_ios: bool,
|
445
440
|
) -> None:
|
446
441
|
(
|
@@ -549,15 +544,15 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
549
544
|
expressions: Iterable[str],
|
550
545
|
params: f_params.FunctionParams,
|
551
546
|
io: f_params.PortDirection,
|
552
|
-
control_states:
|
547
|
+
control_states: list[ControlState],
|
553
548
|
strict_zero_ios: bool,
|
554
|
-
) ->
|
549
|
+
) -> tuple[list[str], list[str], list[str]]:
|
555
550
|
expression_matches: Iterable[Optional[Match]] = map(
|
556
551
|
functools.partial(re.fullmatch, IO_REGEX), expressions
|
557
552
|
)
|
558
553
|
|
559
|
-
valid_matches:
|
560
|
-
invalid_expressions:
|
554
|
+
valid_matches: list[Match] = []
|
555
|
+
invalid_expressions: list[str] = []
|
561
556
|
for expression, expression_match in zip(expressions, expression_matches):
|
562
557
|
(
|
563
558
|
invalid_expressions.append(expression)
|
@@ -565,8 +560,8 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
565
560
|
else valid_matches.append(expression_match)
|
566
561
|
)
|
567
562
|
|
568
|
-
invalid_slicings:
|
569
|
-
invalid_names:
|
563
|
+
invalid_slicings: list[str] = []
|
564
|
+
invalid_names: list[str] = []
|
570
565
|
valid_names = frozenset(
|
571
566
|
params.inputs_full(strict_zero_ios)
|
572
567
|
if io == PortDirection.Input
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import uuid
|
2
2
|
from datetime import datetime, timezone
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import
|
4
|
+
from typing import Optional, Union
|
5
5
|
|
6
6
|
import pydantic
|
7
7
|
from typing_extensions import TypeAlias
|
@@ -31,17 +31,17 @@ from classiq.interface.generator.synthesis_metadata.synthesis_duration import (
|
|
31
31
|
SynthesisStepDurations,
|
32
32
|
)
|
33
33
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
34
|
-
from classiq.interface.ide.
|
34
|
+
from classiq.interface.ide.visual_model import CircuitMetrics
|
35
35
|
|
36
36
|
RegisterName: TypeAlias = str
|
37
|
-
InitialConditions: TypeAlias =
|
37
|
+
InitialConditions: TypeAlias = dict[RegisterName, int]
|
38
38
|
|
39
39
|
|
40
40
|
class TranspiledCircuitData(CircuitCodeInterface):
|
41
41
|
depth: int
|
42
|
-
count_ops:
|
43
|
-
logical_to_physical_input_qubit_map:
|
44
|
-
logical_to_physical_output_qubit_map:
|
42
|
+
count_ops: dict[str, int]
|
43
|
+
logical_to_physical_input_qubit_map: list[int]
|
44
|
+
logical_to_physical_output_qubit_map: list[int]
|
45
45
|
|
46
46
|
def get_circuit_metrics(self) -> CircuitMetrics:
|
47
47
|
return CircuitMetrics(depth=self.depth, count_ops=self.count_ops)
|
@@ -65,7 +65,7 @@ class QuantumProgram(VersionedModel, CircuitCodeInterface):
|
|
65
65
|
transpiled_circuit: Optional[TranspiledCircuitData] = pydantic.Field(default=None)
|
66
66
|
creation_time: str = pydantic.Field(default_factory=_get_formatted_utc_current_time)
|
67
67
|
synthesis_duration: Optional[SynthesisStepDurations] = pydantic.Field(default=None)
|
68
|
-
debug_info: Optional[
|
68
|
+
debug_info: Optional[list[FunctionDebugInfoInterface]] = pydantic.Field(
|
69
69
|
default=None
|
70
70
|
)
|
71
71
|
program_id: str = pydantic.Field(default_factory=get_uuid_as_str)
|
@@ -123,7 +123,7 @@ class QuantumProgram(VersionedModel, CircuitCodeInterface):
|
|
123
123
|
synthesis_execution_data=self.data.execution_data,
|
124
124
|
)
|
125
125
|
|
126
|
-
def _get_initialization_qubits(self, name: str) ->
|
126
|
+
def _get_initialization_qubits(self, name: str) -> tuple[int, ...]:
|
127
127
|
qubits = self.data.qubit_mapping.logical_inputs.get(name)
|
128
128
|
if qubits is None:
|
129
129
|
raise ClassiqStateInitializationError(
|
@@ -133,7 +133,7 @@ class QuantumProgram(VersionedModel, CircuitCodeInterface):
|
|
133
133
|
|
134
134
|
def get_registers_initialization(
|
135
135
|
self, initial_values: InitialConditions
|
136
|
-
) ->
|
136
|
+
) -> dict[RegisterName, RegisterInitialization]:
|
137
137
|
return {
|
138
138
|
name: RegisterInitialization(
|
139
139
|
name=name,
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from typing import Set
|
2
|
-
|
3
1
|
from classiq.interface.enum_utils import StrEnum
|
4
2
|
|
5
3
|
|
@@ -13,7 +11,7 @@ class RegisterRole(StrEnum):
|
|
13
11
|
EXPLICIT_ZERO_INPUT = "explicit_zero_input"
|
14
12
|
|
15
13
|
@staticmethod
|
16
|
-
def output_roles(include_garbage: bool = False) ->
|
14
|
+
def output_roles(include_garbage: bool = False) -> set["RegisterRole"]:
|
17
15
|
roles = {
|
18
16
|
RegisterRole.OUTPUT,
|
19
17
|
RegisterRole.ZERO_OUTPUT,
|
@@ -24,7 +22,7 @@ class RegisterRole(StrEnum):
|
|
24
22
|
return roles
|
25
23
|
|
26
24
|
@staticmethod
|
27
|
-
def input_roles() ->
|
25
|
+
def input_roles() -> set["RegisterRole"]:
|
28
26
|
return {
|
29
27
|
RegisterRole.INPUT,
|
30
28
|
RegisterRole.ZERO_INPUT,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import re
|
2
|
-
from
|
2
|
+
from re import Match
|
3
|
+
from typing import Optional
|
3
4
|
|
4
5
|
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.function_params import NAME_REGEX
|
@@ -11,12 +12,12 @@ SLICING_CHARS = rf"[0-9\-{SEPARATOR}]+"
|
|
11
12
|
IO_REGEX = rf"(?P<{NAME}>{NAME_REGEX})(\[(?P<{SLICING}>{SLICING_CHARS})\])?"
|
12
13
|
|
13
14
|
|
14
|
-
def parse_io_slicing(io_str: str) ->
|
15
|
+
def parse_io_slicing(io_str: str) -> tuple[str, slice]:
|
15
16
|
name, slicing = separate_name_and_slice(io_str)
|
16
17
|
return name, get_slice(slicing)
|
17
18
|
|
18
19
|
|
19
|
-
def separate_name_and_slice(io_str: str) ->
|
20
|
+
def separate_name_and_slice(io_str: str) -> tuple[str, Optional[str]]:
|
20
21
|
match: Optional[Match] = re.fullmatch(IO_REGEX, io_str)
|
21
22
|
if match is None:
|
22
23
|
raise AssertionError("Input/output name validation error")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, Literal, Optional
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
@@ -13,7 +13,7 @@ To add new standard gates, refer to the following guide
|
|
13
13
|
https://docs.google.com/document/d/1Nt9frxnPkSn8swNpOQ983E95eaEiDWaiuWAKglGtUAA/edit#heading=h.e9g9309bzkxt
|
14
14
|
"""
|
15
15
|
|
16
|
-
_POSSIBLE_PARAMETERS:
|
16
|
+
_POSSIBLE_PARAMETERS: list[str] = ["theta", "phi", "lam"]
|
17
17
|
DEFAULT_STANDARD_GATE_ARG_NAME: str = "TARGET"
|
18
18
|
|
19
19
|
|
@@ -39,7 +39,7 @@ class _StandardGate(FunctionParams, metaclass=MyMetaAngledClassModel): # type:
|
|
39
39
|
return self._num_target_qubits
|
40
40
|
|
41
41
|
def __init_subclass__(
|
42
|
-
cls, angles: Optional[
|
42
|
+
cls, angles: Optional[list[str]] = None, **kwargs: Any
|
43
43
|
) -> None:
|
44
44
|
super().__init_subclass__(**kwargs)
|
45
45
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Literal
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
@@ -7,8 +7,8 @@ from classiq.interface.generator.state_preparation.state_preparation_abc import
|
|
7
7
|
)
|
8
8
|
|
9
9
|
BellStateName = Literal["psi+", "psi-", "phi+", "phi-"]
|
10
|
-
_ALIGNED_STATES:
|
11
|
-
_SIGNED_STATES:
|
10
|
+
_ALIGNED_STATES: frozenset[BellStateName] = frozenset({"phi+", "phi-"})
|
11
|
+
_SIGNED_STATES: frozenset[BellStateName] = frozenset({"psi-", "phi-"})
|
12
12
|
|
13
13
|
|
14
14
|
class BellStatePreparation(StatePreparationABC):
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Collection, Sequence
|
2
|
+
from typing import Union
|
2
3
|
|
3
4
|
import pydantic
|
4
5
|
from numpy.typing import ArrayLike
|
@@ -11,12 +12,12 @@ from classiq.interface.helpers.custom_pydantic_types import PydanticProbabilityF
|
|
11
12
|
|
12
13
|
|
13
14
|
class PMF(pydantic.BaseModel):
|
14
|
-
pmf:
|
15
|
+
pmf: tuple[PydanticProbabilityFloat, ...]
|
15
16
|
|
16
17
|
@pydantic.field_validator("pmf")
|
17
18
|
@classmethod
|
18
19
|
def _validate_pmf(
|
19
|
-
cls, pmf:
|
20
|
+
cls, pmf: tuple[PydanticProbabilityFloat, ...]
|
20
21
|
) -> Sequence[PydanticProbabilityFloat]:
|
21
22
|
return validate_probabilities(cls, pmf)
|
22
23
|
|
@@ -30,7 +31,7 @@ class GaussianMoments(pydantic.BaseModel):
|
|
30
31
|
|
31
32
|
|
32
33
|
class GaussianMixture(pydantic.BaseModel):
|
33
|
-
gaussian_moment_list:
|
34
|
+
gaussian_moment_list: tuple[GaussianMoments, ...]
|
34
35
|
num_qubits: pydantic.PositiveInt = pydantic.Field(
|
35
36
|
description="Number of qubits for the provided state."
|
36
37
|
)
|
@@ -39,7 +40,7 @@ class GaussianMixture(pydantic.BaseModel):
|
|
39
40
|
|
40
41
|
Probabilities = Union[PMF, GaussianMixture]
|
41
42
|
FlexibleProbabilities = Union[Probabilities, ArrayLike, dict, Collection[float]]
|
42
|
-
Amplitudes =
|
43
|
+
Amplitudes = tuple[float, ...]
|
43
44
|
FlexibleAmplitudes = Union[ArrayLike, Collection[float]]
|
44
45
|
Distribution = Union[Amplitudes, Probabilities]
|
45
46
|
|
@@ -1,16 +1,14 @@
|
|
1
|
-
from typing import FrozenSet
|
2
|
-
|
3
1
|
from classiq.interface.enum_utils import StrEnum
|
4
2
|
from classiq.interface.exceptions import ClassiqValueError
|
5
3
|
from classiq.interface.generator.preferences.optimization import (
|
6
4
|
StatePrepOptimizationMethod,
|
7
5
|
)
|
8
6
|
|
9
|
-
_AMPLITUDE_SUPPORTING_METRICS:
|
7
|
+
_AMPLITUDE_SUPPORTING_METRICS: frozenset = frozenset(
|
10
8
|
{"L2", "L1", "MAX_PROBABILITY", "TOTAL_VARIATION"}
|
11
9
|
)
|
12
10
|
|
13
|
-
_ZERO_DIVERGENT_METRICS:
|
11
|
+
_ZERO_DIVERGENT_METRICS: frozenset = frozenset({"KL", "BHATTACHARYYA"})
|
14
12
|
|
15
13
|
|
16
14
|
class Metrics(StrEnum):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Optional, Union
|
2
2
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
@@ -36,7 +36,7 @@ class StatePreparation(StatePreparationABC):
|
|
36
36
|
default=None,
|
37
37
|
validate_default=True,
|
38
38
|
)
|
39
|
-
error_metric:
|
39
|
+
error_metric: dict[Metrics, NonNegativeFloatRange] = pydantic.Field(
|
40
40
|
default_factory=lambda: {
|
41
41
|
Metrics.L2: NonNegativeFloatRange(lower_bound=0, upper_bound=1e-4)
|
42
42
|
}
|
@@ -80,8 +80,8 @@ class StatePreparation(StatePreparationABC):
|
|
80
80
|
@pydantic.field_validator("error_metric", mode="before")
|
81
81
|
@classmethod
|
82
82
|
def _validate_error_metric(
|
83
|
-
cls, error_metric:
|
84
|
-
) ->
|
83
|
+
cls, error_metric: dict[Metrics, NonNegativeFloatRange], info: ValidationInfo
|
84
|
+
) -> dict[Metrics, NonNegativeFloatRange]:
|
85
85
|
if not info.data.get("amplitudes"):
|
86
86
|
return error_metric
|
87
87
|
unsupported_metrics = {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Optional
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
import sympy
|
@@ -24,14 +24,14 @@ class FunctionExecutionData(pydantic.BaseModel):
|
|
24
24
|
|
25
25
|
|
26
26
|
class ExecutionData(pydantic.BaseModel):
|
27
|
-
function_execution:
|
27
|
+
function_execution: dict[str, FunctionExecutionData] = pydantic.Field(
|
28
28
|
default_factory=dict
|
29
29
|
)
|
30
30
|
|
31
31
|
@property
|
32
32
|
def execution_parameters(
|
33
33
|
self,
|
34
|
-
) ->
|
34
|
+
) -> set[PydanticExecutionParameter]:
|
35
35
|
return {
|
36
36
|
function_execution_data.power_var
|
37
37
|
for function_execution_data in self.function_execution.values()
|
@@ -1,10 +1,10 @@
|
|
1
|
-
from typing import TYPE_CHECKING,
|
1
|
+
from typing import TYPE_CHECKING, Optional
|
2
2
|
|
3
3
|
from typing_extensions import TypeAlias
|
4
4
|
|
5
5
|
from classiq.interface.enum_utils import StrEnum
|
6
6
|
|
7
|
-
BasisGates: TypeAlias =
|
7
|
+
BasisGates: TypeAlias = frozenset[str]
|
8
8
|
|
9
9
|
SINGLE_QUBIT_GATES: BasisGates = frozenset(
|
10
10
|
(
|
@@ -1,6 +1,5 @@
|
|
1
1
|
from collections import Counter
|
2
2
|
from enum import Enum, EnumMeta, IntEnum
|
3
|
-
from typing import Dict
|
4
3
|
|
5
4
|
import pydantic
|
6
5
|
|
@@ -11,14 +10,14 @@ from classiq.interface.exceptions import ClassiqValueError
|
|
11
10
|
class EnumDeclaration(HashableASTNode):
|
12
11
|
name: str
|
13
12
|
|
14
|
-
members:
|
13
|
+
members: dict[str, int] = pydantic.Field(
|
15
14
|
default_factory=dict,
|
16
15
|
description="Dictionary of member names and their values",
|
17
16
|
)
|
18
17
|
|
19
18
|
@pydantic.field_validator("members")
|
20
19
|
@classmethod
|
21
|
-
def _validate_members(cls, members:
|
20
|
+
def _validate_members(cls, members: dict[str, int]) -> dict[str, int]:
|
22
21
|
underscore_members = [
|
23
22
|
member for member in members.keys() if member.startswith("_")
|
24
23
|
]
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any
|
2
3
|
|
3
4
|
import pydantic
|
4
5
|
|
@@ -10,7 +11,7 @@ from classiq.interface.generator.functions.concrete_types import ConcreteClassic
|
|
10
11
|
class StructDeclaration(HashableASTNode):
|
11
12
|
name: str
|
12
13
|
|
13
|
-
variables:
|
14
|
+
variables: dict[str, ConcreteClassicalType] = pydantic.Field(
|
14
15
|
default_factory=dict,
|
15
16
|
description="Dictionary of variable names and their classical types",
|
16
17
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Union
|
2
2
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
@@ -8,7 +8,7 @@ from classiq.interface.generator import complex_type, function_params
|
|
8
8
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
9
9
|
|
10
10
|
DataNumber = Union[complex_type.Complex, float, int]
|
11
|
-
DataArray =
|
11
|
+
DataArray = list[list[DataNumber]]
|
12
12
|
|
13
13
|
UNITARY_GATE_INPUT: str = "TARGET"
|
14
14
|
UNITARY_GATE_OUTPUT: str = "TARGET"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from collections import Counter, defaultdict
|
2
|
+
from collections.abc import Collection, Iterable, Mapping
|
2
3
|
from dataclasses import dataclass
|
3
4
|
from itertools import chain
|
4
|
-
from typing import
|
5
|
+
from typing import Optional, TypeVar
|
5
6
|
|
6
7
|
import networkx as nx
|
7
8
|
|
@@ -152,7 +153,7 @@ def validate_legal_wiring(
|
|
152
153
|
raise ClassiqValueError(_join_errors(error_messages))
|
153
154
|
|
154
155
|
|
155
|
-
def _join_errors(error_messages:
|
156
|
+
def _join_errors(error_messages: list[str]) -> str:
|
156
157
|
if not error_messages:
|
157
158
|
error_messages.append(f"{UNKNOWN_ERROR_MSG}")
|
158
159
|
|
@@ -162,7 +163,7 @@ def _join_errors(error_messages: List[str]) -> str:
|
|
162
163
|
T = TypeVar("T")
|
163
164
|
|
164
165
|
|
165
|
-
def _recurring_names(name_list:
|
166
|
+
def _recurring_names(name_list: list[T]) -> Iterable[T]:
|
166
167
|
name_counter = Counter(name_list)
|
167
168
|
return (name for name, appearances in name_counter.items() if appearances > 1)
|
168
169
|
|
@@ -187,11 +188,11 @@ def validate_acyclic_logic_flow(
|
|
187
188
|
|
188
189
|
|
189
190
|
def validate_acyclicity_and_topologically_sort_logic_flow(
|
190
|
-
body:
|
191
|
+
body: list[SynthesisQuantumFunctionCall],
|
191
192
|
*,
|
192
193
|
flow_input_names: Collection[str],
|
193
194
|
flow_output_names: Collection[str],
|
194
|
-
) ->
|
195
|
+
) -> list[SynthesisQuantumFunctionCall]:
|
195
196
|
graph = validate_acyclic_logic_flow(
|
196
197
|
body=body,
|
197
198
|
flow_input_names=flow_input_names,
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Iterable, Sequence, Sized
|
2
|
+
from typing import TypeVar
|
2
3
|
|
3
4
|
import numpy as np
|
4
5
|
|
@@ -9,7 +10,7 @@ NOT_SUM_TO_ONE_ERROR = "Probabilities do not sum to 1"
|
|
9
10
|
|
10
11
|
SUM_TO_ONE_SENSITIVITY = 8
|
11
12
|
|
12
|
-
Amplitude = TypeVar("Amplitude",
|
13
|
+
Amplitude = TypeVar("Amplitude", tuple[float, ...], list[complex])
|
13
14
|
|
14
15
|
|
15
16
|
def _is_power_of_two(vector: Sized) -> bool:
|