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
classiq/interface/ast_node.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any,
|
|
1
|
+
from typing import Any, TypeVar
|
|
2
2
|
from uuid import UUID
|
|
3
3
|
|
|
4
4
|
import pydantic
|
|
@@ -13,8 +13,8 @@ ASTNodeType = TypeVar("ASTNodeType", bound="ASTNode")
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class ASTNode(HashablePydanticBaseModel):
|
|
16
|
-
source_ref:
|
|
17
|
-
back_ref:
|
|
16
|
+
source_ref: SourceReference | None = pydantic.Field(default=None)
|
|
17
|
+
back_ref: UUID | None = pydantic.Field(default=None)
|
|
18
18
|
|
|
19
19
|
def _as_back_ref(self: Self) -> Self:
|
|
20
20
|
return self
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import warnings
|
|
4
4
|
from collections.abc import Iterable
|
|
5
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Union
|
|
6
6
|
|
|
7
7
|
import pydantic
|
|
8
8
|
from pydantic import BaseModel
|
|
@@ -103,19 +103,19 @@ class AliceBobBackendPreferences(BackendPreferences):
|
|
|
103
103
|
backend_service_provider: ProviderTypeVendor.ALICE_BOB = pydantic.Field(
|
|
104
104
|
default=ProviderVendor.ALICE_AND_BOB
|
|
105
105
|
)
|
|
106
|
-
distance:
|
|
106
|
+
distance: int | None = pydantic.Field(
|
|
107
107
|
default=None, description="Repetition code distance"
|
|
108
108
|
)
|
|
109
|
-
kappa_1:
|
|
109
|
+
kappa_1: float | None = pydantic.Field(
|
|
110
110
|
default=None, description="One-photon dissipation rate (Hz)"
|
|
111
111
|
)
|
|
112
|
-
kappa_2:
|
|
112
|
+
kappa_2: float | None = pydantic.Field(
|
|
113
113
|
default=None, description="Two-photon dissipation rate (Hz)"
|
|
114
114
|
)
|
|
115
|
-
average_nb_photons:
|
|
115
|
+
average_nb_photons: float | None = pydantic.Field(
|
|
116
116
|
default=None, description="Average number of photons"
|
|
117
117
|
)
|
|
118
|
-
api_key:
|
|
118
|
+
api_key: pydantic_backend.PydanticAliceBobApiKeyType | None = pydantic.Field(
|
|
119
119
|
default=None, description="AliceBob API key"
|
|
120
120
|
)
|
|
121
121
|
|
|
@@ -131,7 +131,7 @@ class AliceBobBackendPreferences(BackendPreferences):
|
|
|
131
131
|
|
|
132
132
|
@pydantic.field_validator("api_key", mode="after")
|
|
133
133
|
@classmethod
|
|
134
|
-
def _validate_api_key(cls, api_key:
|
|
134
|
+
def _validate_api_key(cls, api_key: str | None) -> str | None:
|
|
135
135
|
if api_key is not None:
|
|
136
136
|
warnings.warn(
|
|
137
137
|
"API key is no longer required for Alice&Bob backends.",
|
|
@@ -193,14 +193,14 @@ class AwsBackendPreferences(BackendPreferences):
|
|
|
193
193
|
backend_service_provider: ProviderTypeVendor.AMAZON_BRAKET = pydantic.Field(
|
|
194
194
|
default=ProviderVendor.AMAZON_BRAKET
|
|
195
195
|
)
|
|
196
|
-
aws_role_arn:
|
|
196
|
+
aws_role_arn: str | None = pydantic.Field(
|
|
197
197
|
default=None,
|
|
198
198
|
description="ARN of the role to be assumed for execution on your Braket account.",
|
|
199
199
|
)
|
|
200
|
-
s3_bucket_name:
|
|
200
|
+
s3_bucket_name: str | None = pydantic.Field(
|
|
201
201
|
default=None, description="S3 Bucket Name"
|
|
202
202
|
)
|
|
203
|
-
s3_folder:
|
|
203
|
+
s3_folder: str | None = pydantic.Field(
|
|
204
204
|
default=None, description="S3 Folder Path Within The S3 Bucket"
|
|
205
205
|
)
|
|
206
206
|
run_through_classiq: bool = pydantic.Field(
|
|
@@ -229,15 +229,15 @@ class IBMBackendPreferences(BackendPreferences):
|
|
|
229
229
|
backend_service_provider: ProviderTypeVendor.IBM_CLOUD = pydantic.Field(
|
|
230
230
|
default=ProviderVendor.IBM_QUANTUM
|
|
231
231
|
)
|
|
232
|
-
access_token:
|
|
232
|
+
access_token: str | None = pydantic.Field(
|
|
233
233
|
default=None,
|
|
234
234
|
description="IBM Cloud access token to be used"
|
|
235
235
|
" with IBM Quantum hosted backends",
|
|
236
236
|
)
|
|
237
|
-
channel:
|
|
237
|
+
channel: str | None = pydantic.Field(
|
|
238
238
|
default=None, description="Channel to use for IBM cloud backends."
|
|
239
239
|
)
|
|
240
|
-
instance_crn:
|
|
240
|
+
instance_crn: str | None = pydantic.Field(
|
|
241
241
|
default=None, description="IBM Cloud instance CRN."
|
|
242
242
|
)
|
|
243
243
|
run_through_classiq: bool = pydantic.Field(
|
|
@@ -303,12 +303,12 @@ class AzureBackendPreferences(BackendPreferences):
|
|
|
303
303
|
default="East US", description="Azure personal resource region"
|
|
304
304
|
)
|
|
305
305
|
|
|
306
|
-
credentials:
|
|
306
|
+
credentials: AzureCredential | None = pydantic.Field(
|
|
307
307
|
default=None,
|
|
308
308
|
description="The service principal credential to access personal quantum workspace",
|
|
309
309
|
)
|
|
310
310
|
|
|
311
|
-
ionq_error_mitigation_flag:
|
|
311
|
+
ionq_error_mitigation_flag: bool | None = pydantic.Field(
|
|
312
312
|
default=False,
|
|
313
313
|
description="Error mitigation configuration upon running on IonQ through Azure.",
|
|
314
314
|
)
|
|
@@ -343,7 +343,7 @@ class IonqBackendPreferences(BackendPreferences):
|
|
|
343
343
|
backend_service_provider: ProviderTypeVendor.IONQ = pydantic.Field(
|
|
344
344
|
default=ProviderVendor.IONQ
|
|
345
345
|
)
|
|
346
|
-
api_key:
|
|
346
|
+
api_key: pydantic_backend.PydanticIonQApiKeyType | None = pydantic.Field(
|
|
347
347
|
default=None, description="IonQ API key"
|
|
348
348
|
)
|
|
349
349
|
error_mitigation: bool = pydantic.Field(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING, Annotated
|
|
3
|
+
from typing import TYPE_CHECKING, Annotated
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, ConfigDict, Field
|
|
6
6
|
|
|
@@ -22,10 +22,10 @@ else:
|
|
|
22
22
|
|
|
23
23
|
class Gate(BaseModel):
|
|
24
24
|
gate: PydanticGateName
|
|
25
|
-
target:
|
|
26
|
-
control:
|
|
27
|
-
targets:
|
|
28
|
-
controls:
|
|
25
|
+
target: int | None = None
|
|
26
|
+
control: int | None = None
|
|
27
|
+
targets: list[int] | None = None
|
|
28
|
+
controls: list[int] | None = None
|
|
29
29
|
model_config = ConfigDict(extra="allow")
|
|
30
30
|
|
|
31
31
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
class HardwareEfficientConstraints(BaseModel):
|
|
7
5
|
num_qubits: int
|
|
8
|
-
num_two_qubit_gates:
|
|
9
|
-
num_one_qubit_gates:
|
|
10
|
-
max_depth:
|
|
6
|
+
num_two_qubit_gates: int | None = None
|
|
7
|
+
num_one_qubit_gates: int | None = None
|
|
8
|
+
max_depth: int | None = None
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class HardwareEfficient(BaseModel):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from collections.abc import Collection, Iterable
|
|
2
2
|
from functools import reduce
|
|
3
3
|
from itertools import combinations
|
|
4
|
-
from typing import Any,
|
|
4
|
+
from typing import Any, cast
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import pydantic
|
|
@@ -65,7 +65,7 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
|
65
65
|
|
|
66
66
|
@staticmethod
|
|
67
67
|
def _validate_monomial_coefficient(
|
|
68
|
-
coeff:
|
|
68
|
+
coeff: sympy.Expr | ParameterComplexType,
|
|
69
69
|
) -> ParameterComplexType:
|
|
70
70
|
if isinstance(coeff, str):
|
|
71
71
|
validate_expression_str(coeff)
|
|
@@ -219,7 +219,7 @@ class PauliOperator(HashablePydanticBaseModel, VersionedModel):
|
|
|
219
219
|
def from_unzipped_lists(
|
|
220
220
|
cls,
|
|
221
221
|
operators: list[list["Pauli"]],
|
|
222
|
-
coefficients:
|
|
222
|
+
coefficients: list[complex] | None = None,
|
|
223
223
|
) -> "PauliOperator":
|
|
224
224
|
if coefficients is None:
|
|
225
225
|
coefficients = [1] * len(operators)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
import numpy as np
|
|
4
2
|
import pyomo.core as pyo
|
|
5
3
|
|
|
@@ -7,8 +5,8 @@ import pyomo.core as pyo
|
|
|
7
5
|
def knapsack(
|
|
8
6
|
values: list[int],
|
|
9
7
|
upper_bound: int,
|
|
10
|
-
weights:
|
|
11
|
-
max_weight:
|
|
8
|
+
weights: list[int] | None = None,
|
|
9
|
+
max_weight: int | None = None,
|
|
12
10
|
) -> pyo.ConcreteModel:
|
|
13
11
|
model = pyo.ConcreteModel()
|
|
14
12
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import itertools
|
|
2
|
-
from typing import Union
|
|
3
2
|
|
|
4
3
|
import networkx as nx
|
|
5
4
|
import pyomo.core as pyo
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
def tsp_digraph(
|
|
9
|
-
graph: nx.DiGraph, source:
|
|
8
|
+
graph: nx.DiGraph, source: int | str, sink: int | str, nonedge: int
|
|
10
9
|
) -> pyo.ConcreteModel:
|
|
11
10
|
model = pyo.ConcreteModel()
|
|
12
11
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
from collections.abc import Sequence
|
|
3
|
-
from typing import Union
|
|
4
3
|
|
|
5
4
|
import zstandard as zstd
|
|
6
5
|
from pydantic import BaseModel
|
|
7
6
|
from pydantic_core import from_json, to_json
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
def compress_pydantic(obj:
|
|
9
|
+
def compress_pydantic(obj: BaseModel | Sequence[BaseModel]) -> bytes:
|
|
11
10
|
json_data = to_json(obj)
|
|
12
11
|
compressed_data = _compress(json_data, level=22) # max compression level
|
|
13
12
|
return compressed_data
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
def decompress(compressed_data: bytes) ->
|
|
15
|
+
def decompress(compressed_data: bytes) -> dict | list[dict]:
|
|
17
16
|
decompressed_data = _decompress(compressed_data)
|
|
18
17
|
return from_json(decompressed_data)
|
|
19
18
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from collections.abc import Mapping, Sequence
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Union, cast
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, Field
|
|
@@ -20,11 +20,11 @@ ParameterValue = Union[float, int, str, None]
|
|
|
20
20
|
|
|
21
21
|
class FunctionDebugInfo(BaseModel):
|
|
22
22
|
name: str
|
|
23
|
-
statement_type:
|
|
23
|
+
statement_type: StatementType | None = None
|
|
24
24
|
is_inverse: bool = Field(default=False)
|
|
25
|
-
control_variable:
|
|
25
|
+
control_variable: str | None = Field(default=None)
|
|
26
26
|
port_to_passed_variable_map: dict[str, str] = Field(default_factory=dict)
|
|
27
|
-
node:
|
|
27
|
+
node: ConcreteQuantumStatement | None = None
|
|
28
28
|
|
|
29
29
|
@property
|
|
30
30
|
def is_allocate_or_free(self) -> bool:
|
|
@@ -61,7 +61,7 @@ class DebugInfoCollection(BaseModel):
|
|
|
61
61
|
def __setitem__(self, key: UUID, value: FunctionDebugInfo) -> None:
|
|
62
62
|
self.data[str(key)] = value
|
|
63
63
|
|
|
64
|
-
def get(self, key: UUID) ->
|
|
64
|
+
def get(self, key: UUID) -> FunctionDebugInfo | None:
|
|
65
65
|
return self.data.get(str(key))
|
|
66
66
|
|
|
67
67
|
def __getitem__(self, key: UUID) -> FunctionDebugInfo:
|
|
@@ -70,7 +70,7 @@ class DebugInfoCollection(BaseModel):
|
|
|
70
70
|
def __contains__(self, key: UUID) -> bool:
|
|
71
71
|
return str(key) in self.data
|
|
72
72
|
|
|
73
|
-
def get_blackbox_data(self, key: UUID) ->
|
|
73
|
+
def get_blackbox_data(self, key: UUID) -> FunctionDebugInfoInterface | None:
|
|
74
74
|
if (debug_info := self.get(key)) is None:
|
|
75
75
|
return None
|
|
76
76
|
return self.blackbox_data.get(debug_info.name)
|
|
@@ -103,7 +103,7 @@ def new_function_debug_info_by_node(
|
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
def calculate_port_to_passed_variable_mapping(
|
|
106
|
-
arg_decls: Sequence[PositionalArg], args: Sequence[
|
|
106
|
+
arg_decls: Sequence[PositionalArg], args: Sequence[ArgValue | None]
|
|
107
107
|
) -> dict[str, str]:
|
|
108
108
|
return {
|
|
109
109
|
arg_decl.name: str(cast(ConcreteHandleBinding, arg))
|
classiq/interface/exceptions.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from collections.abc import Iterable
|
|
3
|
-
from typing import Optional
|
|
4
3
|
|
|
5
4
|
_logger = logging.getLogger(__name__)
|
|
6
5
|
|
|
@@ -53,7 +52,7 @@ class ClassiqAnalyzerVisualizationError(ClassiqError):
|
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
class ClassiqAPIError(ClassiqError):
|
|
56
|
-
def __init__(self, message: str, status_code:
|
|
55
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
57
56
|
self.status_code = status_code
|
|
58
57
|
super().__init__(message)
|
|
59
58
|
|
|
@@ -66,6 +65,10 @@ class ClassiqValueError(ClassiqError, ValueError):
|
|
|
66
65
|
pass
|
|
67
66
|
|
|
68
67
|
|
|
68
|
+
class ClassiqTypeError(ClassiqError, TypeError):
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
|
|
69
72
|
class ClassiqArithmeticError(ClassiqValueError):
|
|
70
73
|
pass
|
|
71
74
|
|
|
@@ -187,7 +190,7 @@ class ClassiqExpansionError(ClassiqError):
|
|
|
187
190
|
|
|
188
191
|
|
|
189
192
|
class ClassiqInternalError(ClassiqError):
|
|
190
|
-
def __init__(self, message:
|
|
193
|
+
def __init__(self, message: str | None = None) -> None:
|
|
191
194
|
final_message = "Internal error occurred. Please contact Classiq support."
|
|
192
195
|
if message is not None:
|
|
193
196
|
final_message += f"\nError: {message}"
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, Field
|
|
4
2
|
|
|
5
3
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
|
@@ -27,7 +25,7 @@ class IQCCAuthItemDetails(BaseModel):
|
|
|
27
25
|
id: str
|
|
28
26
|
name: str
|
|
29
27
|
description: str
|
|
30
|
-
scope_id:
|
|
28
|
+
scope_id: str | None = Field(default=None)
|
|
31
29
|
|
|
32
30
|
|
|
33
31
|
class IQCCAuthItemsDetails(VersionedModel):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Annotated, Literal,
|
|
1
|
+
from typing import Annotated, Literal, Union
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, Field
|
|
4
4
|
|
|
@@ -17,7 +17,7 @@ class MinimizeCostInput(BaseModel, json_encoders=CUSTOM_ENCODERS):
|
|
|
17
17
|
initial_params: Arguments
|
|
18
18
|
max_iteration: int
|
|
19
19
|
quantile: float
|
|
20
|
-
tolerance:
|
|
20
|
+
tolerance: float | None
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class MinimizeClassicalCostInput(MinimizeCostInput):
|
|
@@ -41,7 +41,7 @@ ConcreteMinimizeCostInput = Annotated[
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class PrimitivesInput(BaseModel, json_encoders=CUSTOM_ENCODERS):
|
|
44
|
-
sample:
|
|
45
|
-
estimate:
|
|
46
|
-
minimize:
|
|
47
|
-
random_seed:
|
|
44
|
+
sample: list[Arguments] | None = Field(default=None)
|
|
45
|
+
estimate: EstimateInput | None = Field(default=None)
|
|
46
|
+
minimize: ConcreteMinimizeCostInput | None = Field(default=None)
|
|
47
|
+
random_seed: int | None = Field(default=None)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
import pydantic
|
|
4
2
|
|
|
5
3
|
from classiq.interface.backend.backend_preferences import (
|
|
@@ -43,7 +41,7 @@ class ExecutionPreferences(pydantic.BaseModel):
|
|
|
43
41
|
job_name (Optional[str]): The name of the job, with a minimum length of 1 character.
|
|
44
42
|
"""
|
|
45
43
|
|
|
46
|
-
noise_properties:
|
|
44
|
+
noise_properties: NoiseProperties | None = pydantic.Field(
|
|
47
45
|
default=None, description="Properties of the noise in the circuit"
|
|
48
46
|
)
|
|
49
47
|
random_seed: int = pydantic.Field(
|
|
@@ -53,13 +51,13 @@ class ExecutionPreferences(pydantic.BaseModel):
|
|
|
53
51
|
backend_preferences: BackendPreferencesTypes = backend_preferences_field(
|
|
54
52
|
backend_name=ClassiqSimulatorBackendNames.SIMULATOR
|
|
55
53
|
)
|
|
56
|
-
num_shots:
|
|
54
|
+
num_shots: pydantic.PositiveInt | None = pydantic.Field(default=None)
|
|
57
55
|
transpile_to_hardware: TranspilationOption = pydantic.Field(
|
|
58
56
|
default=TranspilationOption.DECOMPOSE,
|
|
59
57
|
description="Transpile the circuit to the hardware basis gates before execution",
|
|
60
58
|
title="Transpilation Option",
|
|
61
59
|
)
|
|
62
|
-
job_name:
|
|
60
|
+
job_name: str | None = pydantic.Field(
|
|
63
61
|
min_length=1, description="The job name", default=None
|
|
64
62
|
)
|
|
65
63
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
-
from typing import Annotated, Literal,
|
|
2
|
+
from typing import Annotated, Literal, Union
|
|
3
3
|
|
|
4
4
|
import pydantic
|
|
5
5
|
from pydantic import BaseModel, Field
|
|
@@ -51,28 +51,28 @@ class ProviderJobs(BaseModel):
|
|
|
51
51
|
class JobCost(BaseModel):
|
|
52
52
|
total_cost: float = Field(default=0)
|
|
53
53
|
currency_code: str = Field(default="USD")
|
|
54
|
-
organization:
|
|
54
|
+
organization: str | None = Field(default=None)
|
|
55
55
|
jobs: list[ProviderJobs] = Field(default=[])
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
class ExecutionJobDetails(VersionedModel):
|
|
59
59
|
id: str
|
|
60
60
|
|
|
61
|
-
name:
|
|
61
|
+
name: str | None = Field(default=None)
|
|
62
62
|
start_time: datetime
|
|
63
|
-
end_time:
|
|
63
|
+
end_time: datetime | None = Field(default=None)
|
|
64
64
|
|
|
65
|
-
provider:
|
|
66
|
-
backend_name:
|
|
65
|
+
provider: str | None = Field(default=None)
|
|
66
|
+
backend_name: str | None = Field(default=None)
|
|
67
67
|
|
|
68
68
|
status: JobStatus
|
|
69
69
|
|
|
70
|
-
num_shots:
|
|
71
|
-
program_id:
|
|
70
|
+
num_shots: int | None = Field(default=None)
|
|
71
|
+
program_id: str | None = Field(default=None)
|
|
72
72
|
|
|
73
|
-
error:
|
|
73
|
+
error: str | None = Field(default=None)
|
|
74
74
|
|
|
75
|
-
cost:
|
|
75
|
+
cost: JobCost | None = Field(default=None)
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
class ExecutionJobsQueryResults(VersionedModel):
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
from typing import Annotated, Any, Literal, Union
|
|
1
|
+
from typing import Annotated, Any, Literal, TypeAlias, Union
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
-
from typing_extensions import TypeAlias
|
|
5
4
|
|
|
6
5
|
from classiq.interface.applications.iqae.iqae_result import IQAEResult
|
|
7
6
|
from classiq.interface.enum_utils import StrEnum
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
import pydantic
|
|
7
7
|
from pydantic import BaseModel, ConfigDict
|
|
@@ -35,7 +35,7 @@ class QuantumBaseCode(BaseModel):
|
|
|
35
35
|
@pydantic.field_validator("code")
|
|
36
36
|
@classmethod
|
|
37
37
|
def load_quantum_program(
|
|
38
|
-
cls, code:
|
|
38
|
+
cls, code: CodeType | IonqQuantumCircuit, values: ValidationInfo
|
|
39
39
|
) -> CodeType:
|
|
40
40
|
syntax = values.data.get("syntax")
|
|
41
41
|
if isinstance(code, IonqQuantumCircuit):
|
|
@@ -57,11 +57,11 @@ class QuantumCode(QuantumBaseCode):
|
|
|
57
57
|
default_factory=dict,
|
|
58
58
|
description="The map of outputs to their qubits in the circuit.",
|
|
59
59
|
)
|
|
60
|
-
registers_initialization:
|
|
60
|
+
registers_initialization: RegistersInitialization | None = pydantic.Field(
|
|
61
61
|
default=None,
|
|
62
62
|
description="Initial conditions for the different registers in the circuit.",
|
|
63
63
|
)
|
|
64
|
-
synthesis_execution_data:
|
|
64
|
+
synthesis_execution_data: ExecutionData | None = pydantic.Field(default=None)
|
|
65
65
|
synthesis_execution_arguments: Arguments = pydantic.Field(default_factory=dict)
|
|
66
66
|
model_config = ConfigDict(validate_assignment=True)
|
|
67
67
|
|
|
@@ -90,9 +90,9 @@ class QuantumCode(QuantumBaseCode):
|
|
|
90
90
|
@classmethod
|
|
91
91
|
def validate_synthesis_execution_data(
|
|
92
92
|
cls,
|
|
93
|
-
synthesis_execution_data:
|
|
93
|
+
synthesis_execution_data: ExecutionData | None,
|
|
94
94
|
values: ValidationInfo,
|
|
95
|
-
) ->
|
|
95
|
+
) -> ExecutionData | None:
|
|
96
96
|
if (
|
|
97
97
|
synthesis_execution_data is not None
|
|
98
98
|
and synthesis_execution_data.function_execution
|
|
@@ -103,8 +103,8 @@ class QuantumCode(QuantumBaseCode):
|
|
|
103
103
|
|
|
104
104
|
@staticmethod
|
|
105
105
|
def from_file(
|
|
106
|
-
file_path:
|
|
107
|
-
syntax:
|
|
106
|
+
file_path: str | Path,
|
|
107
|
+
syntax: str | QuantumInstructionSet | None = None,
|
|
108
108
|
arguments: MultipleArguments = (),
|
|
109
109
|
) -> QuantumCode:
|
|
110
110
|
path = Path(file_path)
|
|
@@ -9,13 +9,13 @@ from typing import (
|
|
|
9
9
|
Any,
|
|
10
10
|
DefaultDict,
|
|
11
11
|
Optional,
|
|
12
|
+
TypeAlias,
|
|
12
13
|
Union,
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
import pandas as pd
|
|
16
16
|
import pydantic
|
|
17
17
|
from pydantic import BaseModel
|
|
18
|
-
from typing_extensions import Self
|
|
18
|
+
from typing_extensions import Self
|
|
19
19
|
|
|
20
20
|
from classiq.interface.exceptions import (
|
|
21
21
|
ClassiqError,
|
|
@@ -52,6 +52,8 @@ MAGNITUDE = "magnitude"
|
|
|
52
52
|
PHASE = "phase"
|
|
53
53
|
|
|
54
54
|
if TYPE_CHECKING:
|
|
55
|
+
import pandas as pd
|
|
56
|
+
|
|
55
57
|
DotAccessParsedState = Mapping[Name, Any]
|
|
56
58
|
else:
|
|
57
59
|
DotAccessParsedState = ParsedState
|
|
@@ -90,8 +92,8 @@ ParsedStateVector: TypeAlias = list[SimulatedState]
|
|
|
90
92
|
|
|
91
93
|
|
|
92
94
|
class VaRResult(BaseModel):
|
|
93
|
-
var:
|
|
94
|
-
alpha:
|
|
95
|
+
var: float | None = None
|
|
96
|
+
alpha: float | None = None
|
|
95
97
|
|
|
96
98
|
|
|
97
99
|
class GroverSimulationResults(VersionedModel):
|
|
@@ -119,7 +121,7 @@ def flip_counts_qubit_order(counts: Counts) -> Counts:
|
|
|
119
121
|
|
|
120
122
|
def get_sampled_state(
|
|
121
123
|
parsed_counts: ParsedCounts, state: ParsedState
|
|
122
|
-
) ->
|
|
124
|
+
) -> SampledState | None:
|
|
123
125
|
for sampled_state in parsed_counts:
|
|
124
126
|
if sampled_state.state == state:
|
|
125
127
|
return sampled_state
|
|
@@ -150,7 +152,7 @@ def get_parsed_counts(counts: Counts, parsed_states: ParsedStates) -> ParsedCoun
|
|
|
150
152
|
|
|
151
153
|
def prepare_parsed_state_vector(
|
|
152
154
|
state_vector: StateVector, parsed_state_vector_states: ParsedStates
|
|
153
|
-
) ->
|
|
155
|
+
) -> ParsedStateVector | None:
|
|
154
156
|
if not state_vector:
|
|
155
157
|
return None
|
|
156
158
|
|
|
@@ -165,7 +167,11 @@ def prepare_parsed_state_vector(
|
|
|
165
167
|
return sorted(parsed_state_vector, key=lambda k: abs(k.amplitude), reverse=True)
|
|
166
168
|
|
|
167
169
|
|
|
168
|
-
def _flatten_columns(
|
|
170
|
+
def _flatten_columns(
|
|
171
|
+
df: "pd.DataFrame", columns_to_flatten: list[str]
|
|
172
|
+
) -> "pd.DataFrame":
|
|
173
|
+
import pandas as pd
|
|
174
|
+
|
|
169
175
|
if len(df.columns) == 0:
|
|
170
176
|
return df
|
|
171
177
|
|
|
@@ -221,7 +227,7 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
221
227
|
default_factory=dict,
|
|
222
228
|
description="A mapping between the raw states of counts (bitstrings) to their parsed states (registers' values)",
|
|
223
229
|
)
|
|
224
|
-
histogram:
|
|
230
|
+
histogram: dict[State, pydantic.NonNegativeFloat] | None = pydantic.Field(
|
|
225
231
|
None,
|
|
226
232
|
description="Histogram of probability per state (an alternative to counts)",
|
|
227
233
|
)
|
|
@@ -233,15 +239,15 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
233
239
|
default=None,
|
|
234
240
|
description="The state vector when executed on a simulator, with LSB right qubit order",
|
|
235
241
|
)
|
|
236
|
-
parsed_state_vector_states:
|
|
242
|
+
parsed_state_vector_states: ParsedStates | None = pydantic.Field(
|
|
237
243
|
default=None,
|
|
238
244
|
description="A mapping between the raw states of the state vector (bitstrings) to their parsed states (registers' values)",
|
|
239
245
|
)
|
|
240
|
-
physical_qubits_map:
|
|
246
|
+
physical_qubits_map: OutputQubitsMap | None = pydantic.Field(
|
|
241
247
|
default=None,
|
|
242
248
|
description="The map of all registers (also non measured) to their qubits in the circuit. Used for state_vector which represent also the non-measured qubits.",
|
|
243
249
|
)
|
|
244
|
-
num_shots:
|
|
250
|
+
num_shots: pydantic.NonNegativeInt | None = pydantic.Field(
|
|
245
251
|
default=None, description="The total number of shots the circuit was executed"
|
|
246
252
|
)
|
|
247
253
|
|
|
@@ -274,7 +280,7 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
274
280
|
return get_parsed_counts(self.counts, self.parsed_states)
|
|
275
281
|
|
|
276
282
|
@property
|
|
277
|
-
def parsed_state_vector(self) ->
|
|
283
|
+
def parsed_state_vector(self) -> ParsedStateVector | None:
|
|
278
284
|
if TYPE_CHECKING:
|
|
279
285
|
assert self.parsed_state_vector_states is not None
|
|
280
286
|
return prepare_parsed_state_vector(
|
|
@@ -327,7 +333,7 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
327
333
|
return dict(reduced_counts)
|
|
328
334
|
|
|
329
335
|
def parsed_counts_of_outputs(
|
|
330
|
-
self, output_names:
|
|
336
|
+
self, output_names: Name | tuple[Name, ...]
|
|
331
337
|
) -> ParsedCounts:
|
|
332
338
|
if isinstance(output_names, Name):
|
|
333
339
|
output_names = (output_names,)
|
|
@@ -361,7 +367,9 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
361
367
|
)[::-1]
|
|
362
368
|
return number_utils.binary_to_float_or_int(bin_rep=register_binary_string)
|
|
363
369
|
|
|
364
|
-
def _counts_df(self) -> pd.DataFrame:
|
|
370
|
+
def _counts_df(self) -> "pd.DataFrame":
|
|
371
|
+
import pandas as pd
|
|
372
|
+
|
|
365
373
|
data: dict[str, Any] = defaultdict(list)
|
|
366
374
|
|
|
367
375
|
for bitstring, count in self.counts.items():
|
|
@@ -382,7 +390,9 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
382
390
|
|
|
383
391
|
return pd.DataFrame(data, columns=columns)
|
|
384
392
|
|
|
385
|
-
def _state_vector_df(self) -> pd.DataFrame:
|
|
393
|
+
def _state_vector_df(self) -> "pd.DataFrame":
|
|
394
|
+
import pandas as pd
|
|
395
|
+
|
|
386
396
|
data: dict[str, Any] = defaultdict(list)
|
|
387
397
|
|
|
388
398
|
if not self.state_vector:
|
|
@@ -408,7 +418,7 @@ class ExecutionDetails(BaseModel, QmodPyObject):
|
|
|
408
418
|
return pd.DataFrame(data, columns=columns)
|
|
409
419
|
|
|
410
420
|
@functools.cached_property
|
|
411
|
-
def dataframe(self) -> pd.DataFrame:
|
|
421
|
+
def dataframe(self) -> "pd.DataFrame":
|
|
412
422
|
reserved_words = frozenset(
|
|
413
423
|
[BITSTRING, PROBABILITY, COUNT, AMPLITUDE, PHASE, MAGNITUDE]
|
|
414
424
|
)
|
|
@@ -449,9 +459,9 @@ class MultipleExecutionDetails(VersionedModel):
|
|
|
449
459
|
|
|
450
460
|
|
|
451
461
|
class EstimationMetadata(BaseModel, extra="allow"):
|
|
452
|
-
shots:
|
|
462
|
+
shots: pydantic.NonNegativeInt | None = None
|
|
453
463
|
remapped_qubits: bool = False
|
|
454
|
-
input_qubit_map:
|
|
464
|
+
input_qubit_map: list[PydanticNonNegIntTuple] | None = None
|
|
455
465
|
|
|
456
466
|
|
|
457
467
|
class EstimationResult(BaseModel, QmodPyObject):
|