classiq 0.92.0__py3-none-any.whl → 0.94.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.
Potentially problematic release.
This version of classiq might be problematic. Click here for more details.
- classiq/__init__.py +6 -19
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
- classiq/_analyzer_extras/interactive_hardware.py +19 -12
- classiq/_internals/api_wrapper.py +38 -52
- classiq/_internals/async_utils.py +4 -7
- classiq/_internals/authentication/auth0.py +3 -3
- classiq/_internals/authentication/device.py +4 -4
- classiq/_internals/authentication/password_manager.py +13 -13
- classiq/_internals/authentication/token_manager.py +4 -5
- classiq/_internals/client.py +17 -44
- classiq/_internals/config.py +1 -2
- classiq/_internals/help.py +1 -2
- classiq/_internals/host_checker.py +3 -3
- classiq/_internals/jobs.py +14 -14
- classiq/_internals/type_validation.py +3 -3
- classiq/analyzer/analyzer.py +18 -18
- classiq/analyzer/rb.py +17 -8
- classiq/applications/chemistry/__init__.py +0 -30
- classiq/applications/chemistry/op_utils.py +4 -4
- classiq/applications/chemistry/problems.py +3 -3
- classiq/applications/chemistry/ucc.py +1 -2
- classiq/applications/chemistry/z2_symmetries.py +4 -4
- classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
- classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
- classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
- classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
- classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
- classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
- classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
- classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
- classiq/applications/iqae/iqae.py +8 -8
- classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
- classiq/applications/qnn/datasets/dataset_parity.py +6 -6
- classiq/applications/qnn/qlayer.py +8 -7
- classiq/applications/qnn/torch_utils.py +3 -4
- classiq/applications/qnn/types.py +2 -1
- classiq/applications/qsp/qsp.py +6 -5
- classiq/applications/qsvm/qsvm_data_generation.py +1 -2
- classiq/evaluators/classical_expression.py +0 -4
- classiq/evaluators/parameter_types.py +17 -12
- classiq/evaluators/qmod_annotated_expression.py +24 -26
- classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
- classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
- classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
- classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +4 -4
- classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
- classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
- classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
- classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
- classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
- classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
- classiq/execution/execution_session.py +18 -19
- classiq/execution/jobs.py +26 -26
- classiq/execution/qnn.py +1 -2
- classiq/execution/user_budgets.py +52 -7
- classiq/executor.py +1 -3
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +4 -4
- classiq/interface/analyzer/cytoscape_graph.py +3 -3
- classiq/interface/analyzer/result.py +4 -4
- classiq/interface/applications/qsvm.py +5 -8
- classiq/interface/ast_node.py +3 -3
- classiq/interface/backend/backend_preferences.py +16 -16
- classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
- classiq/interface/chemistry/ansatz_library.py +3 -5
- classiq/interface/chemistry/operator.py +3 -3
- classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
- classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
- classiq/interface/compression_utils.py +2 -3
- classiq/interface/debug_info/debug_info.py +7 -7
- classiq/interface/exceptions.py +6 -3
- classiq/interface/execution/iqcc.py +1 -3
- classiq/interface/execution/primitives.py +6 -6
- classiq/interface/executor/estimate_cost.py +1 -1
- classiq/interface/executor/execution_preferences.py +3 -5
- classiq/interface/executor/execution_request.py +10 -10
- classiq/interface/executor/execution_result.py +1 -2
- classiq/interface/executor/quantum_code.py +8 -8
- classiq/interface/executor/result.py +28 -18
- classiq/interface/executor/user_budget.py +2 -3
- classiq/interface/executor/vqe_result.py +5 -6
- classiq/interface/generator/ansatz_library.py +6 -8
- classiq/interface/generator/application_apis/__init__.py +0 -2
- classiq/interface/generator/arith/arithmetic.py +2 -2
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
- classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
- classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
- classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
- classiq/interface/generator/arith/arithmetic_operations.py +4 -6
- classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
- classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
- classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
- classiq/interface/generator/arith/binary_ops.py +7 -36
- classiq/interface/generator/arith/logical_ops.py +2 -3
- classiq/interface/generator/arith/number_utils.py +2 -2
- classiq/interface/generator/arith/register_user_input.py +2 -2
- classiq/interface/generator/arith/unary_ops.py +2 -2
- classiq/interface/generator/circuit_code/circuit_code.py +8 -10
- classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
- classiq/interface/generator/complex_type.py +2 -2
- classiq/interface/generator/copy.py +1 -3
- classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
- classiq/interface/generator/expressions/evaluated_expression.py +2 -3
- classiq/interface/generator/expressions/expression.py +2 -2
- classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
- classiq/interface/generator/function_param_list.py +0 -20
- classiq/interface/generator/function_params.py +5 -6
- classiq/interface/generator/functions/classical_function_declaration.py +2 -2
- classiq/interface/generator/functions/classical_type.py +3 -3
- classiq/interface/generator/functions/type_modifier.py +0 -14
- classiq/interface/generator/functions/type_name.py +2 -2
- classiq/interface/generator/generated_circuit_data.py +12 -13
- classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
- classiq/interface/generator/hardware/hardware_data.py +8 -8
- classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
- classiq/interface/generator/mcu.py +3 -3
- classiq/interface/generator/mcx.py +3 -3
- classiq/interface/generator/model/constraints.py +34 -5
- classiq/interface/generator/model/preferences/preferences.py +15 -21
- classiq/interface/generator/model/quantum_register.py +7 -10
- classiq/interface/generator/noise_properties.py +3 -7
- classiq/interface/generator/parameters.py +1 -1
- classiq/interface/generator/partitioned_register.py +1 -2
- classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
- classiq/interface/generator/qsvm.py +2 -2
- classiq/interface/generator/quantum_function_call.py +8 -11
- classiq/interface/generator/quantum_program.py +12 -15
- classiq/interface/generator/range_types.py +3 -3
- classiq/interface/generator/slice_parsing_utils.py +4 -5
- classiq/interface/generator/standard_gates/standard_gates.py +2 -4
- classiq/interface/generator/state_preparation/state_preparation.py +6 -8
- classiq/interface/generator/synthesis_execution_parameter.py +1 -3
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
- classiq/interface/generator/transpiler_basis_gates.py +2 -4
- classiq/interface/generator/types/builtin_enum_declarations.py +0 -136
- classiq/interface/generator/types/compilation_metadata.py +12 -1
- classiq/interface/generator/types/enum_declaration.py +2 -1
- classiq/interface/generator/validations/flow_graph.py +3 -3
- classiq/interface/generator/visitor.py +10 -12
- classiq/interface/hardware.py +2 -2
- classiq/interface/helpers/classproperty.py +2 -2
- classiq/interface/helpers/custom_encoders.py +2 -1
- classiq/interface/helpers/custom_pydantic_types.py +1 -1
- classiq/interface/helpers/text_utils.py +1 -4
- classiq/interface/ide/visual_model.py +5 -5
- classiq/interface/jobs.py +3 -3
- classiq/interface/model/allocate.py +4 -4
- classiq/interface/model/block.py +2 -2
- classiq/interface/model/bounds.py +3 -3
- classiq/interface/model/control.py +1 -1
- classiq/interface/model/inplace_binary_operation.py +2 -2
- classiq/interface/model/model.py +4 -4
- classiq/interface/model/parameter.py +1 -3
- classiq/interface/model/port_declaration.py +1 -1
- classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
- classiq/interface/model/quantum_function_call.py +3 -6
- classiq/interface/model/quantum_function_declaration.py +1 -0
- classiq/interface/model/quantum_lambda_function.py +4 -4
- classiq/interface/model/quantum_statement.py +4 -4
- classiq/interface/model/quantum_type.py +14 -14
- classiq/interface/model/validation_handle.py +2 -3
- classiq/interface/model/variable_declaration_statement.py +2 -2
- classiq/interface/pretty_print/expression_to_qmod.py +3 -4
- classiq/interface/server/routes.py +0 -4
- classiq/interface/source_reference.py +3 -4
- classiq/model_expansions/arithmetic.py +6 -7
- classiq/model_expansions/arithmetic_compute_result_attrs.py +4 -5
- classiq/model_expansions/capturing/captured_vars.py +3 -3
- classiq/model_expansions/capturing/mangling_utils.py +1 -2
- classiq/model_expansions/closure.py +12 -11
- classiq/model_expansions/function_builder.py +14 -6
- classiq/model_expansions/generative_functions.py +1 -4
- classiq/model_expansions/interpreters/base_interpreter.py +2 -6
- classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
- classiq/model_expansions/quantum_operations/allocate.py +4 -4
- classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
- classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
- classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
- classiq/model_expansions/quantum_operations/emitter.py +3 -5
- classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
- classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
- classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
- classiq/model_expansions/scope.py +7 -7
- classiq/model_expansions/scope_initialization.py +4 -0
- classiq/model_expansions/visitors/symbolic_param_inference.py +3 -3
- classiq/model_expansions/visitors/uncomputation_signature_inference.py +317 -0
- classiq/model_expansions/visitors/variable_references.py +15 -14
- classiq/open_library/functions/__init__.py +6 -0
- classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
- classiq/open_library/functions/grover.py +8 -10
- classiq/open_library/functions/modular_exponentiation.py +96 -8
- classiq/qmod/__init__.py +5 -2
- classiq/qmod/builtins/classical_execution_primitives.py +4 -11
- classiq/qmod/builtins/classical_functions.py +1 -42
- classiq/qmod/builtins/enums.py +0 -136
- classiq/qmod/builtins/functions/__init__.py +0 -13
- classiq/qmod/builtins/functions/allocation.py +4 -4
- classiq/qmod/builtins/functions/arithmetic.py +22 -27
- classiq/qmod/builtins/functions/standard_gates.py +27 -27
- classiq/qmod/builtins/operations.py +43 -58
- classiq/qmod/builtins/structs.py +2 -58
- classiq/qmod/cfunc.py +3 -2
- classiq/qmod/classical_function.py +2 -1
- classiq/qmod/classical_variable.py +4 -2
- classiq/qmod/cparam.py +2 -8
- classiq/qmod/create_model_function.py +7 -7
- classiq/qmod/declaration_inferrer.py +33 -30
- classiq/qmod/model_state_container.py +2 -2
- classiq/qmod/native/pretty_printer.py +25 -14
- classiq/qmod/pretty_print/expression_to_python.py +5 -3
- classiq/qmod/pretty_print/pretty_printer.py +39 -17
- classiq/qmod/python_classical_type.py +40 -13
- classiq/qmod/qfunc.py +139 -16
- classiq/qmod/qmod_constant.py +2 -2
- classiq/qmod/qmod_parameter.py +5 -2
- classiq/qmod/qmod_variable.py +47 -43
- classiq/qmod/quantum_callable.py +18 -13
- classiq/qmod/quantum_expandable.py +33 -26
- classiq/qmod/quantum_function.py +51 -32
- classiq/qmod/semantics/annotation/call_annotation.py +2 -2
- classiq/qmod/semantics/error_manager.py +5 -6
- classiq/qmod/semantics/lambdas.py +1 -2
- classiq/qmod/semantics/validation/types_validation.py +1 -2
- classiq/qmod/symbolic.py +2 -4
- classiq/qmod/symbolic_expr.py +12 -4
- classiq/qmod/utilities.py +13 -10
- classiq/qmod/write_qmod.py +3 -4
- classiq/quantum_program.py +1 -3
- classiq/synthesis.py +11 -7
- {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/METADATA +38 -37
- {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/RECORD +240 -261
- classiq-0.94.0.dist-info/WHEEL +4 -0
- classiq-0.94.0.dist-info/licenses/LICENSE.txt +27 -0
- classiq/applications/chemistry/ansatz_parameters.py +0 -29
- classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
- classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
- classiq/applications/chemistry/ground_state_problem.py +0 -42
- classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
- classiq/interface/chemistry/elements.py +0 -120
- classiq/interface/chemistry/fermionic_operator.py +0 -208
- classiq/interface/chemistry/ground_state_problem.py +0 -132
- classiq/interface/chemistry/ground_state_result.py +0 -8
- classiq/interface/chemistry/molecule.py +0 -71
- classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
- classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
- classiq/interface/generator/chemistry_function_params.py +0 -50
- classiq/interface/generator/entangler_params.py +0 -72
- classiq/interface/generator/entanglers.py +0 -14
- classiq/interface/generator/hartree_fock.py +0 -26
- classiq/interface/generator/hva.py +0 -22
- classiq/interface/generator/linear_pauli_rotations.py +0 -92
- classiq/interface/generator/qft.py +0 -37
- classiq/interface/generator/ucc.py +0 -74
- classiq/interface/helpers/backward_compatibility.py +0 -9
- classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
- classiq/qmod/builtins/functions/chemistry.py +0 -123
- classiq-0.92.0.dist-info/WHEEL +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Callable
|
|
2
2
|
|
|
3
3
|
from classiq.interface.exceptions import ClassiqArithmeticError
|
|
4
4
|
from classiq.interface.generator.arith.argument_utils import (
|
|
@@ -16,7 +16,6 @@ from classiq.interface.generator.arith.binary_ops import (
|
|
|
16
16
|
BitwiseAnd,
|
|
17
17
|
BitwiseOr,
|
|
18
18
|
BitwiseXor,
|
|
19
|
-
CyclicShift,
|
|
20
19
|
Equal,
|
|
21
20
|
GreaterEqual,
|
|
22
21
|
GreaterThan,
|
|
@@ -57,9 +56,9 @@ def get_params(
|
|
|
57
56
|
node_id: str,
|
|
58
57
|
args: list[RegisterOrFloat],
|
|
59
58
|
machine_precision: int,
|
|
60
|
-
output_size:
|
|
61
|
-
inplace_arg:
|
|
62
|
-
target:
|
|
59
|
+
output_size: int | None = None,
|
|
60
|
+
inplace_arg: str | None = None,
|
|
61
|
+
target: RegisterArithmeticInfo | None = None,
|
|
63
62
|
) -> ArithmeticOperationParams:
|
|
64
63
|
operation = id2op(node_id)
|
|
65
64
|
if target and not operation_allows_target(operation):
|
|
@@ -78,9 +77,9 @@ def or_params_getter(
|
|
|
78
77
|
left_arg: RegisterOrInt,
|
|
79
78
|
right_arg: RegisterOrInt,
|
|
80
79
|
machine_precision: int,
|
|
81
|
-
output_size:
|
|
82
|
-
inplace_arg:
|
|
83
|
-
target:
|
|
80
|
+
output_size: int | None = None,
|
|
81
|
+
inplace_arg: str | None = None,
|
|
82
|
+
target: RegisterArithmeticInfo | None = None,
|
|
84
83
|
) -> ArithmeticOperationParams:
|
|
85
84
|
return BitwiseOr(
|
|
86
85
|
left_arg=left_arg,
|
|
@@ -94,9 +93,9 @@ def and_params_getter(
|
|
|
94
93
|
left_arg: RegisterOrInt,
|
|
95
94
|
right_arg: RegisterOrInt,
|
|
96
95
|
machine_precision: int,
|
|
97
|
-
output_size:
|
|
98
|
-
inplace_arg:
|
|
99
|
-
target:
|
|
96
|
+
output_size: int | None = None,
|
|
97
|
+
inplace_arg: str | None = None,
|
|
98
|
+
target: RegisterArithmeticInfo | None = None,
|
|
100
99
|
) -> ArithmeticOperationParams:
|
|
101
100
|
return BitwiseAnd(
|
|
102
101
|
left_arg=left_arg,
|
|
@@ -110,9 +109,9 @@ def xor_params_getter(
|
|
|
110
109
|
left_arg: RegisterOrInt,
|
|
111
110
|
right_arg: RegisterOrInt,
|
|
112
111
|
machine_precision: int,
|
|
113
|
-
output_size:
|
|
114
|
-
inplace_arg:
|
|
115
|
-
target:
|
|
112
|
+
output_size: int | None = None,
|
|
113
|
+
inplace_arg: str | None = None,
|
|
114
|
+
target: RegisterArithmeticInfo | None = None,
|
|
116
115
|
) -> ArithmeticOperationParams:
|
|
117
116
|
return BitwiseXor(
|
|
118
117
|
left_arg=left_arg,
|
|
@@ -126,9 +125,9 @@ def xor_params_getter(
|
|
|
126
125
|
def invert_params_getter(
|
|
127
126
|
arg: RegisterOrInt,
|
|
128
127
|
machine_precision: int,
|
|
129
|
-
output_size:
|
|
130
|
-
inplace_arg:
|
|
131
|
-
target:
|
|
128
|
+
output_size: int | None = None,
|
|
129
|
+
inplace_arg: str | None = None,
|
|
130
|
+
target: RegisterArithmeticInfo | None = None,
|
|
132
131
|
) -> ArithmeticOperationParams:
|
|
133
132
|
return BitwiseInvert(
|
|
134
133
|
arg=arg,
|
|
@@ -141,9 +140,9 @@ def invert_params_getter(
|
|
|
141
140
|
def usub_params_getter(
|
|
142
141
|
arg: RegisterOrInt,
|
|
143
142
|
machine_precision: int,
|
|
144
|
-
output_size:
|
|
145
|
-
inplace_arg:
|
|
146
|
-
target:
|
|
143
|
+
output_size: int | None = None,
|
|
144
|
+
inplace_arg: str | None = None,
|
|
145
|
+
target: RegisterArithmeticInfo | None = None,
|
|
147
146
|
) -> ArithmeticOperationParams:
|
|
148
147
|
return Negation(
|
|
149
148
|
arg=arg,
|
|
@@ -157,9 +156,9 @@ def adder_params_getter(
|
|
|
157
156
|
left_arg: RegisterOrFloat,
|
|
158
157
|
right_arg: RegisterOrFloat,
|
|
159
158
|
machine_precision: int,
|
|
160
|
-
output_size:
|
|
161
|
-
inplace_arg:
|
|
162
|
-
target:
|
|
159
|
+
output_size: int | None = None,
|
|
160
|
+
inplace_arg: str | None = None,
|
|
161
|
+
target: RegisterArithmeticInfo | None = None,
|
|
163
162
|
) -> ArithmeticOperationParams:
|
|
164
163
|
return Adder(
|
|
165
164
|
left_arg=left_arg,
|
|
@@ -174,9 +173,9 @@ def multiplier_params_getter(
|
|
|
174
173
|
left_arg: RegisterOrFloat,
|
|
175
174
|
right_arg: RegisterOrFloat,
|
|
176
175
|
machine_precision: int,
|
|
177
|
-
output_size:
|
|
178
|
-
inplace_arg:
|
|
179
|
-
target:
|
|
176
|
+
output_size: int | None = None,
|
|
177
|
+
inplace_arg: str | None = None,
|
|
178
|
+
target: RegisterArithmeticInfo | None = None,
|
|
180
179
|
) -> ArithmeticOperationParams:
|
|
181
180
|
return Multiplier(
|
|
182
181
|
left_arg=left_arg,
|
|
@@ -190,9 +189,9 @@ def power_params_getter(
|
|
|
190
189
|
left_arg: RegisterArithmeticInfo,
|
|
191
190
|
right_arg: int,
|
|
192
191
|
machine_precision: int,
|
|
193
|
-
output_size:
|
|
194
|
-
inplace_arg:
|
|
195
|
-
target:
|
|
192
|
+
output_size: int | None = None,
|
|
193
|
+
inplace_arg: str | None = None,
|
|
194
|
+
target: RegisterArithmeticInfo | None = None,
|
|
196
195
|
) -> ArithmeticOperationParams:
|
|
197
196
|
return Power(
|
|
198
197
|
left_arg=left_arg,
|
|
@@ -206,9 +205,9 @@ def min_params_getter(
|
|
|
206
205
|
left_arg: RegisterOrFloat,
|
|
207
206
|
right_arg: RegisterOrFloat,
|
|
208
207
|
machine_precision: int,
|
|
209
|
-
output_size:
|
|
210
|
-
inplace_arg:
|
|
211
|
-
target:
|
|
208
|
+
output_size: int | None = None,
|
|
209
|
+
inplace_arg: str | None = None,
|
|
210
|
+
target: RegisterArithmeticInfo | None = None,
|
|
212
211
|
) -> ArithmeticOperationParams:
|
|
213
212
|
return Min(
|
|
214
213
|
left_arg=left_arg,
|
|
@@ -222,9 +221,9 @@ def max_params_getter(
|
|
|
222
221
|
left_arg: RegisterOrFloat,
|
|
223
222
|
right_arg: RegisterOrFloat,
|
|
224
223
|
machine_precision: int,
|
|
225
|
-
output_size:
|
|
226
|
-
inplace_arg:
|
|
227
|
-
target:
|
|
224
|
+
output_size: int | None = None,
|
|
225
|
+
inplace_arg: str | None = None,
|
|
226
|
+
target: RegisterArithmeticInfo | None = None,
|
|
228
227
|
) -> ArithmeticOperationParams:
|
|
229
228
|
return Max(
|
|
230
229
|
left_arg=left_arg,
|
|
@@ -238,9 +237,9 @@ def sub_params_getter(
|
|
|
238
237
|
left_arg: RegisterOrFloat,
|
|
239
238
|
right_arg: RegisterOrFloat,
|
|
240
239
|
machine_precision: int,
|
|
241
|
-
output_size:
|
|
242
|
-
inplace_arg:
|
|
243
|
-
target:
|
|
240
|
+
output_size: int | None = None,
|
|
241
|
+
inplace_arg: str | None = None,
|
|
242
|
+
target: RegisterArithmeticInfo | None = None,
|
|
244
243
|
) -> ArithmeticOperationParams:
|
|
245
244
|
return Subtractor(
|
|
246
245
|
left_arg=left_arg,
|
|
@@ -255,9 +254,9 @@ def equal_params_getter(
|
|
|
255
254
|
left_arg: RegisterOrFloat,
|
|
256
255
|
right_arg: RegisterOrFloat,
|
|
257
256
|
machine_precision: int,
|
|
258
|
-
output_size:
|
|
259
|
-
inplace_arg:
|
|
260
|
-
target:
|
|
257
|
+
output_size: int | None = None,
|
|
258
|
+
inplace_arg: str | None = None,
|
|
259
|
+
target: RegisterArithmeticInfo | None = None,
|
|
261
260
|
) -> ArithmeticOperationParams:
|
|
262
261
|
return Equal(
|
|
263
262
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -268,9 +267,9 @@ def not_equal_params_getter(
|
|
|
268
267
|
left_arg: RegisterOrFloat,
|
|
269
268
|
right_arg: RegisterOrFloat,
|
|
270
269
|
machine_precision: int,
|
|
271
|
-
output_size:
|
|
272
|
-
inplace_arg:
|
|
273
|
-
target:
|
|
270
|
+
output_size: int | None = None,
|
|
271
|
+
inplace_arg: str | None = None,
|
|
272
|
+
target: RegisterArithmeticInfo | None = None,
|
|
274
273
|
) -> ArithmeticOperationParams:
|
|
275
274
|
return NotEqual(
|
|
276
275
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -281,9 +280,9 @@ def greater_than_params_getter(
|
|
|
281
280
|
left_arg: RegisterOrFloat,
|
|
282
281
|
right_arg: RegisterOrFloat,
|
|
283
282
|
machine_precision: int,
|
|
284
|
-
output_size:
|
|
285
|
-
inplace_arg:
|
|
286
|
-
target:
|
|
283
|
+
output_size: int | None = None,
|
|
284
|
+
inplace_arg: str | None = None,
|
|
285
|
+
target: RegisterArithmeticInfo | None = None,
|
|
287
286
|
) -> ArithmeticOperationParams:
|
|
288
287
|
return GreaterThan(
|
|
289
288
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -294,9 +293,9 @@ def greater_equal_params_getter(
|
|
|
294
293
|
left_arg: RegisterOrFloat,
|
|
295
294
|
right_arg: RegisterOrFloat,
|
|
296
295
|
machine_precision: int,
|
|
297
|
-
output_size:
|
|
298
|
-
inplace_arg:
|
|
299
|
-
target:
|
|
296
|
+
output_size: int | None = None,
|
|
297
|
+
inplace_arg: str | None = None,
|
|
298
|
+
target: RegisterArithmeticInfo | None = None,
|
|
300
299
|
) -> ArithmeticOperationParams:
|
|
301
300
|
return GreaterEqual(
|
|
302
301
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -307,9 +306,9 @@ def less_than_params_getter(
|
|
|
307
306
|
left_arg: RegisterOrFloat,
|
|
308
307
|
right_arg: RegisterOrFloat,
|
|
309
308
|
machine_precision: int,
|
|
310
|
-
output_size:
|
|
311
|
-
inplace_arg:
|
|
312
|
-
target:
|
|
309
|
+
output_size: int | None = None,
|
|
310
|
+
inplace_arg: str | None = None,
|
|
311
|
+
target: RegisterArithmeticInfo | None = None,
|
|
313
312
|
) -> ArithmeticOperationParams:
|
|
314
313
|
return LessThan(
|
|
315
314
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -320,9 +319,9 @@ def less_equal_params_getter(
|
|
|
320
319
|
left_arg: RegisterOrFloat,
|
|
321
320
|
right_arg: RegisterOrFloat,
|
|
322
321
|
machine_precision: int,
|
|
323
|
-
output_size:
|
|
324
|
-
inplace_arg:
|
|
325
|
-
target:
|
|
322
|
+
output_size: int | None = None,
|
|
323
|
+
inplace_arg: str | None = None,
|
|
324
|
+
target: RegisterArithmeticInfo | None = None,
|
|
326
325
|
) -> ArithmeticOperationParams:
|
|
327
326
|
return LessEqual(
|
|
328
327
|
left_arg=left_arg, right_arg=right_arg, machine_precision=machine_precision
|
|
@@ -332,9 +331,9 @@ def less_equal_params_getter(
|
|
|
332
331
|
def logical_and_params_getter(
|
|
333
332
|
*arg: list[RegisterOrFloat],
|
|
334
333
|
machine_precision: int,
|
|
335
|
-
output_size:
|
|
336
|
-
inplace_arg:
|
|
337
|
-
target:
|
|
334
|
+
output_size: int | None = None,
|
|
335
|
+
inplace_arg: str | None = None,
|
|
336
|
+
target: RegisterArithmeticInfo | None = None,
|
|
338
337
|
) -> ArithmeticOperationParams:
|
|
339
338
|
return LogicalAnd(args=arg, target=target, machine_precision=machine_precision)
|
|
340
339
|
|
|
@@ -342,9 +341,9 @@ def logical_and_params_getter(
|
|
|
342
341
|
def logical_or_params_getter(
|
|
343
342
|
*arg: list[RegisterOrFloat],
|
|
344
343
|
machine_precision: int,
|
|
345
|
-
output_size:
|
|
346
|
-
inplace_arg:
|
|
347
|
-
target:
|
|
344
|
+
output_size: int | None = None,
|
|
345
|
+
inplace_arg: str | None = None,
|
|
346
|
+
target: RegisterArithmeticInfo | None = None,
|
|
348
347
|
) -> ArithmeticOperationParams:
|
|
349
348
|
return LogicalOr(args=arg, target=target, machine_precision=machine_precision)
|
|
350
349
|
|
|
@@ -353,9 +352,9 @@ def lshift_params_getter(
|
|
|
353
352
|
left_arg: RegisterArithmeticInfo,
|
|
354
353
|
right_arg: int,
|
|
355
354
|
machine_precision: int,
|
|
356
|
-
output_size:
|
|
357
|
-
inplace_arg:
|
|
358
|
-
target:
|
|
355
|
+
output_size: int | None = None,
|
|
356
|
+
inplace_arg: str | None = None,
|
|
357
|
+
target: RegisterArithmeticInfo | None = None,
|
|
359
358
|
) -> ArithmeticOperationParams:
|
|
360
359
|
return LShift(
|
|
361
360
|
left_arg=left_arg,
|
|
@@ -370,9 +369,9 @@ def rshift_params_getter(
|
|
|
370
369
|
left_arg: RegisterArithmeticInfo,
|
|
371
370
|
right_arg: int,
|
|
372
371
|
machine_precision: int,
|
|
373
|
-
output_size:
|
|
374
|
-
inplace_arg:
|
|
375
|
-
target:
|
|
372
|
+
output_size: int | None = None,
|
|
373
|
+
inplace_arg: str | None = None,
|
|
374
|
+
target: RegisterArithmeticInfo | None = None,
|
|
376
375
|
) -> ArithmeticOperationParams:
|
|
377
376
|
return RShift(
|
|
378
377
|
left_arg=left_arg,
|
|
@@ -383,47 +382,13 @@ def rshift_params_getter(
|
|
|
383
382
|
)
|
|
384
383
|
|
|
385
384
|
|
|
386
|
-
def clshift_params_getter(
|
|
387
|
-
left_arg: RegisterArithmeticInfo,
|
|
388
|
-
right_arg: int,
|
|
389
|
-
machine_precision: int,
|
|
390
|
-
output_size: Optional[int] = None,
|
|
391
|
-
inplace_arg: Optional[str] = None,
|
|
392
|
-
target: Optional[RegisterArithmeticInfo] = None,
|
|
393
|
-
) -> ArithmeticOperationParams:
|
|
394
|
-
return CyclicShift(
|
|
395
|
-
left_arg=left_arg,
|
|
396
|
-
right_arg=-right_arg,
|
|
397
|
-
machine_precision=machine_precision,
|
|
398
|
-
inplace_arg=inplace_arg,
|
|
399
|
-
output_size=output_size,
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
def crshift_params_getter(
|
|
404
|
-
left_arg: RegisterArithmeticInfo,
|
|
405
|
-
right_arg: int,
|
|
406
|
-
machine_precision: int,
|
|
407
|
-
output_size: Optional[int] = None,
|
|
408
|
-
inplace_arg: Optional[str] = None,
|
|
409
|
-
target: Optional[RegisterArithmeticInfo] = None,
|
|
410
|
-
) -> ArithmeticOperationParams:
|
|
411
|
-
return CyclicShift(
|
|
412
|
-
left_arg=left_arg,
|
|
413
|
-
right_arg=right_arg,
|
|
414
|
-
machine_precision=machine_precision,
|
|
415
|
-
inplace_arg=inplace_arg,
|
|
416
|
-
output_size=output_size,
|
|
417
|
-
)
|
|
418
|
-
|
|
419
|
-
|
|
420
385
|
def modulo_params_getter(
|
|
421
386
|
left_arg: RegisterArithmeticInfo,
|
|
422
387
|
right_arg: int,
|
|
423
388
|
machine_precision: int,
|
|
424
|
-
output_size:
|
|
425
|
-
inplace_arg:
|
|
426
|
-
target:
|
|
389
|
+
output_size: int | None = None,
|
|
390
|
+
inplace_arg: str | None = None,
|
|
391
|
+
target: RegisterArithmeticInfo | None = None,
|
|
427
392
|
) -> ArithmeticOperationParams:
|
|
428
393
|
return Modulo(
|
|
429
394
|
left_arg=left_arg,
|
|
@@ -453,8 +418,6 @@ params_getter_map: dict[str, ParamsGetter] = dict(
|
|
|
453
418
|
NotEq=not_equal_params_getter,
|
|
454
419
|
RShift=rshift_params_getter,
|
|
455
420
|
LShift=lshift_params_getter,
|
|
456
|
-
CRShift=crshift_params_getter,
|
|
457
|
-
CLShift=clshift_params_getter,
|
|
458
421
|
Mod=modulo_params_getter,
|
|
459
422
|
min=min_params_getter,
|
|
460
423
|
max=max_params_getter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
import networkx as nx
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ class ArithmeticResultBuilder:
|
|
|
27
27
|
|
|
28
28
|
@staticmethod
|
|
29
29
|
def convert_result_definition(
|
|
30
|
-
node: Any, definition:
|
|
30
|
+
node: Any, definition: RegisterOrConst | None, machine_precision: int
|
|
31
31
|
) -> RegisterOrConst:
|
|
32
32
|
if definition:
|
|
33
33
|
return definition
|
|
@@ -61,7 +61,7 @@ class ArithmeticResultBuilder:
|
|
|
61
61
|
graph: nx.DiGraph,
|
|
62
62
|
result_definitions: ArithmeticDefinitions,
|
|
63
63
|
machine_precision: int,
|
|
64
|
-
) -> tuple[RegisterArithmeticInfo,
|
|
64
|
+
) -> tuple[RegisterArithmeticInfo, RegisterArithmeticInfo | None]:
|
|
65
65
|
inputs_node_set: set[str] = {
|
|
66
66
|
vertex for vertex, deg in graph.in_degree if deg == 0
|
|
67
67
|
}
|
|
@@ -95,7 +95,7 @@ class ArithmeticResultBuilder:
|
|
|
95
95
|
node: str,
|
|
96
96
|
*,
|
|
97
97
|
machine_precision: int,
|
|
98
|
-
) -> tuple[RegisterArithmeticInfo,
|
|
98
|
+
) -> tuple[RegisterArithmeticInfo, RegisterArithmeticInfo | None]:
|
|
99
99
|
node_params = arithmetic_param_getters.get_params(
|
|
100
100
|
node_id=node,
|
|
101
101
|
args=args,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ast
|
|
2
2
|
import itertools
|
|
3
3
|
from collections.abc import Iterator
|
|
4
|
-
from typing import Any,
|
|
4
|
+
from typing import Any, cast
|
|
5
5
|
|
|
6
6
|
from classiq.interface.exceptions import ClassiqArithmeticError
|
|
7
7
|
|
|
@@ -25,13 +25,17 @@ class AstNodeRewrite(ast.NodeTransformer):
|
|
|
25
25
|
new_node.id = self.extract_node_id(new_node)
|
|
26
26
|
return new_node
|
|
27
27
|
|
|
28
|
-
def extract_node_id(self, node: ast.AST) ->
|
|
28
|
+
def extract_node_id(self, node: ast.AST) -> str | float | None:
|
|
29
29
|
if hasattr(node, "id"):
|
|
30
30
|
return node.id
|
|
31
31
|
elif hasattr(node, "op"):
|
|
32
32
|
return type(node.op).__name__ + next(self.count_str_gen)
|
|
33
|
-
elif
|
|
34
|
-
|
|
33
|
+
elif (
|
|
34
|
+
hasattr(node, "func")
|
|
35
|
+
and hasattr(node.func, "id")
|
|
36
|
+
and isinstance(node.func.id, str)
|
|
37
|
+
):
|
|
38
|
+
return node.func.id + next(self.count_str_gen)
|
|
35
39
|
elif hasattr(node, "value"):
|
|
36
40
|
return node.value
|
|
37
41
|
elif hasattr(node, "ops"):
|
|
@@ -5,7 +5,6 @@ from typing import (
|
|
|
5
5
|
ClassVar,
|
|
6
6
|
Generic,
|
|
7
7
|
Literal,
|
|
8
|
-
Optional,
|
|
9
8
|
TypeVar,
|
|
10
9
|
Union,
|
|
11
10
|
)
|
|
@@ -120,7 +119,7 @@ class BinaryOpParams(
|
|
|
120
119
|
class InplacableBinaryOpParams(
|
|
121
120
|
BinaryOpParams[LeftDataT, RightDataT], Generic[LeftDataT, RightDataT]
|
|
122
121
|
):
|
|
123
|
-
inplace_arg:
|
|
122
|
+
inplace_arg: ArgToInplace | None = None
|
|
124
123
|
|
|
125
124
|
@pydantic.model_validator(mode="before")
|
|
126
125
|
@classmethod
|
|
@@ -128,7 +127,7 @@ class InplacableBinaryOpParams(
|
|
|
128
127
|
if isinstance(values, dict):
|
|
129
128
|
left_arg = values.get("left_arg")
|
|
130
129
|
right_arg = values.get("right_arg")
|
|
131
|
-
inplace_arg:
|
|
130
|
+
inplace_arg: ArgToInplace | None = values.get("inplace_arg")
|
|
132
131
|
if inplace_arg == ArgToInplace.RIGHT and isinstance(right_arg, Numeric):
|
|
133
132
|
raise ClassiqValueError(
|
|
134
133
|
_NumericArgumentInplaceErrorMessage.format(right_arg)
|
|
@@ -179,7 +178,7 @@ class InplacableBinaryOpParams(
|
|
|
179
178
|
0, arg.fraction_places - self.result_register.fraction_places # type: ignore[attr-defined]
|
|
180
179
|
)
|
|
181
180
|
|
|
182
|
-
def _carried_arguments(self) -> tuple[
|
|
181
|
+
def _carried_arguments(self) -> tuple[LeftDataT | None, RightDataT | None]:
|
|
183
182
|
if self.inplace_arg == ArgToInplace.RIGHT and isinstance(
|
|
184
183
|
self.left_arg, RegisterArithmeticInfo
|
|
185
184
|
):
|
|
@@ -611,7 +610,7 @@ class Power(BinaryOpParams[RegisterArithmeticInfo, pydantic.PositiveInt]):
|
|
|
611
610
|
|
|
612
611
|
def _get_inner_action_garbage_size(
|
|
613
612
|
self,
|
|
614
|
-
action_type:
|
|
613
|
+
action_type: type["Power"] | type[Multiplier],
|
|
615
614
|
*,
|
|
616
615
|
arg: RegisterArithmeticInfo,
|
|
617
616
|
action_right_arg: RegisterOrConst,
|
|
@@ -662,7 +661,7 @@ class EffectiveUnaryOpParams(
|
|
|
662
661
|
|
|
663
662
|
class LShift(EffectiveUnaryOpParams[pydantic.NonNegativeInt]):
|
|
664
663
|
output_name = "left_shifted"
|
|
665
|
-
inplace_arg:
|
|
664
|
+
inplace_arg: ArgToInplace | None = ArgToInplace.LEFT
|
|
666
665
|
|
|
667
666
|
@pydantic.model_validator(mode="after")
|
|
668
667
|
def _validate_legal_modulo(self) -> Self:
|
|
@@ -703,7 +702,7 @@ class LShift(EffectiveUnaryOpParams[pydantic.NonNegativeInt]):
|
|
|
703
702
|
|
|
704
703
|
class RShift(EffectiveUnaryOpParams[pydantic.NonNegativeInt]):
|
|
705
704
|
output_name = "right_shifted"
|
|
706
|
-
inplace_arg:
|
|
705
|
+
inplace_arg: ArgToInplace | None = ArgToInplace.LEFT
|
|
707
706
|
|
|
708
707
|
@staticmethod
|
|
709
708
|
def _shifted_fraction_places(*, arg: RegisterArithmeticInfo, shift: int) -> int:
|
|
@@ -751,37 +750,9 @@ class RShift(EffectiveUnaryOpParams[pydantic.NonNegativeInt]):
|
|
|
751
750
|
)
|
|
752
751
|
|
|
753
752
|
|
|
754
|
-
class CyclicShift(EffectiveUnaryOpParams[int]):
|
|
755
|
-
output_name = "cyclic_shifted"
|
|
756
|
-
inplace_arg: Optional[ArgToInplace] = ArgToInplace.LEFT
|
|
757
|
-
|
|
758
|
-
@pydantic.model_validator(mode="after")
|
|
759
|
-
def _validate_legal_modulo(self) -> Self:
|
|
760
|
-
output_size = self.output_size
|
|
761
|
-
if output_size is None:
|
|
762
|
-
return self
|
|
763
|
-
arg = self.left_arg
|
|
764
|
-
if not isinstance(arg, RegisterArithmeticInfo):
|
|
765
|
-
raise ClassiqValueError("left arg must be a RegisterArithmeticInfo")
|
|
766
|
-
assert arg.fraction_places == 0, _FLOATING_POINT_MODULO_ERROR_MESSAGE
|
|
767
|
-
return self
|
|
768
|
-
|
|
769
|
-
def garbage_output_size(self) -> pydantic.NonNegativeInt:
|
|
770
|
-
if self.inplace_arg is None:
|
|
771
|
-
return 0
|
|
772
|
-
return max(0, self.left_arg.size - self.result_register.size)
|
|
773
|
-
|
|
774
|
-
def _get_result_register(self) -> RegisterArithmeticInfo:
|
|
775
|
-
return RegisterArithmeticInfo(
|
|
776
|
-
size=self.output_size or self.left_arg.size,
|
|
777
|
-
is_signed=self._include_sign and self.left_arg.is_signed,
|
|
778
|
-
fraction_places=self.left_arg.fraction_places,
|
|
779
|
-
)
|
|
780
|
-
|
|
781
|
-
|
|
782
753
|
class Modulo(EffectiveUnaryOpParams[int]):
|
|
783
754
|
output_name = "modulus"
|
|
784
|
-
inplace_arg:
|
|
755
|
+
inplace_arg: ArgToInplace | None = ArgToInplace.LEFT
|
|
785
756
|
|
|
786
757
|
@pydantic.field_validator("left_arg", mode="before")
|
|
787
758
|
@classmethod
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from collections.abc import Iterable
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
import pydantic
|
|
5
4
|
from pydantic import ConfigDict
|
|
@@ -19,7 +18,7 @@ def get_arg_name(idx: int) -> str:
|
|
|
19
18
|
|
|
20
19
|
class LogicalOps(ArithmeticOperationParams):
|
|
21
20
|
args: list[RegisterOrConst]
|
|
22
|
-
target:
|
|
21
|
+
target: RegisterArithmeticInfo | None
|
|
23
22
|
_should_invert_node_list: list[str] = pydantic.PrivateAttr(default_factory=list)
|
|
24
23
|
|
|
25
24
|
def update_should_invert_node_list(self, invert_args: list[str]) -> None:
|
|
@@ -27,7 +26,7 @@ class LogicalOps(ArithmeticOperationParams):
|
|
|
27
26
|
|
|
28
27
|
@pydantic.field_validator("output_size")
|
|
29
28
|
@classmethod
|
|
30
|
-
def _validate_output_size(cls, output_size:
|
|
29
|
+
def _validate_output_size(cls, output_size: int | None) -> int:
|
|
31
30
|
if output_size is not None and output_size != 1:
|
|
32
31
|
raise ClassiqValueError("logical operation output size must be 1")
|
|
33
32
|
return 1
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Final
|
|
1
|
+
from typing import Final
|
|
2
2
|
|
|
3
3
|
MAXIMAL_MACHINE_PRECISION: Final[int] = 20
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ def binary_to_float(
|
|
|
25
25
|
|
|
26
26
|
def binary_to_float_or_int(
|
|
27
27
|
bin_rep: str, fraction_part_size: int = 0, is_signed: bool = False
|
|
28
|
-
) ->
|
|
28
|
+
) -> float | int:
|
|
29
29
|
if fraction_part_size == 0:
|
|
30
30
|
return binary_to_int(bin_rep, is_signed)
|
|
31
31
|
return binary_to_float(bin_rep, fraction_part_size, is_signed)
|
|
@@ -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 ConfigDict
|
|
@@ -51,7 +51,7 @@ class RegisterArithmeticInfo(HashablePydanticBaseModel):
|
|
|
51
51
|
@pydantic.field_validator("bounds", mode="before")
|
|
52
52
|
@classmethod
|
|
53
53
|
def _validate_bounds(
|
|
54
|
-
cls, bounds:
|
|
54
|
+
cls, bounds: PydanticFloatTuple | None, info: ValidationInfo
|
|
55
55
|
) -> PydanticFloatTuple:
|
|
56
56
|
size = info.data.get("size")
|
|
57
57
|
is_signed = info.data.get("is_signed", False)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from collections.abc import Iterable
|
|
2
|
-
from typing import Final
|
|
2
|
+
from typing import Final
|
|
3
3
|
|
|
4
4
|
import pydantic
|
|
5
5
|
from pydantic import ConfigDict
|
|
@@ -127,7 +127,7 @@ class Sign(UnaryOpParams):
|
|
|
127
127
|
@pydantic.field_validator("output_size")
|
|
128
128
|
@classmethod
|
|
129
129
|
def _validate_output_size(
|
|
130
|
-
cls, output_size:
|
|
130
|
+
cls, output_size: pydantic.PositiveInt | None
|
|
131
131
|
) -> pydantic.PositiveInt:
|
|
132
132
|
if output_size is not None and output_size != 1:
|
|
133
133
|
raise ClassiqValueError("Sign output size must be 1")
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
import pydantic
|
|
4
2
|
|
|
5
3
|
from classiq.interface.exceptions import ClassiqMissingOutputFormatError
|
|
@@ -26,31 +24,31 @@ class CircuitCodeInterface(pydantic.BaseModel):
|
|
|
26
24
|
return {key: LongStr(value) for key, value in outputs.items()}
|
|
27
25
|
|
|
28
26
|
@property
|
|
29
|
-
def qasm(self) ->
|
|
27
|
+
def qasm(self) -> Code | None:
|
|
30
28
|
return self.outputs.get(QuantumFormat.QASM)
|
|
31
29
|
|
|
32
30
|
@property
|
|
33
|
-
def qsharp(self) ->
|
|
31
|
+
def qsharp(self) -> Code | None:
|
|
34
32
|
return self.outputs.get(QuantumFormat.QSHARP)
|
|
35
33
|
|
|
36
34
|
@property
|
|
37
|
-
def qir(self) ->
|
|
35
|
+
def qir(self) -> Code | None:
|
|
38
36
|
return self.outputs.get(QuantumFormat.QIR)
|
|
39
37
|
|
|
40
38
|
@property
|
|
41
|
-
def ionq(self) ->
|
|
39
|
+
def ionq(self) -> Code | None:
|
|
42
40
|
return self.outputs.get(QuantumFormat.IONQ)
|
|
43
41
|
|
|
44
42
|
@property
|
|
45
|
-
def cirq_json(self) ->
|
|
43
|
+
def cirq_json(self) -> Code | None:
|
|
46
44
|
return self.outputs.get(QuantumFormat.CIRQ_JSON)
|
|
47
45
|
|
|
48
46
|
@property
|
|
49
|
-
def qasm_cirq_compatible(self) ->
|
|
47
|
+
def qasm_cirq_compatible(self) -> Code | None:
|
|
50
48
|
return self.outputs.get(QuantumFormat.QASM_CIRQ_COMPATIBLE)
|
|
51
49
|
|
|
52
50
|
@property
|
|
53
|
-
def _execution_serialization(self) ->
|
|
51
|
+
def _execution_serialization(self) -> Code | None:
|
|
54
52
|
return self.outputs.get(QuantumFormat.EXECUTION_SERIALIZATION)
|
|
55
53
|
|
|
56
54
|
def get_code(self, instruction_set: QuantumInstructionSet) -> Code:
|
|
@@ -60,7 +58,7 @@ class CircuitCodeInterface(pydantic.BaseModel):
|
|
|
60
58
|
raise ClassiqMissingOutputFormatError(missing_formats=[quantum_format])
|
|
61
59
|
return code
|
|
62
60
|
|
|
63
|
-
def get_code_by_priority(self) ->
|
|
61
|
+
def get_code_by_priority(self) -> CodeAndSyntax | None:
|
|
64
62
|
for instruction_set, quantum_format in INSTRUCTION_SET_TO_FORMAT.items():
|
|
65
63
|
code = self.outputs.get(quantum_format)
|
|
66
64
|
if code is not None:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from typing import Annotated
|
|
1
|
+
from typing import Annotated
|
|
2
2
|
|
|
3
3
|
from pydantic import PlainSerializer, PlainValidator
|
|
4
4
|
from pydantic.json_schema import WithJsonSchema
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
def validate_complex(v:
|
|
7
|
+
def validate_complex(v: complex | str) -> complex:
|
|
8
8
|
if isinstance(v, str):
|
|
9
9
|
v = "".join(v.split())
|
|
10
10
|
return complex(v)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
import pydantic
|
|
4
2
|
|
|
5
3
|
from classiq.interface.generator.arith import argument_utils
|
|
@@ -10,7 +8,7 @@ from classiq.interface.generator.function_params import FunctionParams
|
|
|
10
8
|
class Copy(FunctionParams):
|
|
11
9
|
source: argument_utils.RegisterOrConst
|
|
12
10
|
target: RegisterArithmeticInfo
|
|
13
|
-
output_size:
|
|
11
|
+
output_size: pydantic.PositiveInt | None = pydantic.Field(default=None)
|
|
14
12
|
|
|
15
13
|
@property
|
|
16
14
|
def source_size(self) -> int:
|