Coverage for src/braket/task_result/gate_model_task_result.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# http://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License
14from typing import Dict, List, Optional, Union
16from pydantic import BaseModel, confloat, conint, conlist, constr
18from braket.ir.jaqcd.results import Expectation, Probability, Sample, StateVector, Variance
19from braket.schema_common.schema_base import BraketSchemaBase
20from braket.task_result.additional_metadata import AdditionalMetadata
21from braket.task_result.task_metadata import TaskMetadata
24class ResultType(BaseModel):
25 """
26 Result type of gate model task result.
28 Attributes:
29 type (Union[Expectation, Sample, StateVector, Variance, Probability]): the requested result
30 value (Union[List, float, Dict]): the value of the requested result
31 """
33 type: Union[Expectation, Sample, StateVector, Variance, Probability]
34 value: Union[List, float, Dict]
37class GateModelTaskResult(BraketSchemaBase):
38 """
39 The gate model task result schema
41 Attributes:
42 measurements (List[List[int]]: List of lists, where each list represents a shot
43 and each index of the list represents a qubit. Default is None.
44 - measurementProbabilities (Dict[str, float]): A dictionary of probabilistic results.
45 Key is the measurements in a big endian binary string.
46 Value is the probability the measurement occurred.
47 Default is None.
48 - measuredQubits (List[int]): The indices of the measured qubits.
49 Indicates which qubits are in `measurements`. Default is None.
50 - resultTypes (List[ResultType]): Requested result types and values of these results.
52 taskMetadata (TaskMetadata): the task metadata
53 additionalMetadata (AdditionalMetadata): additional metadata of the task
54 """
56 measurements: Optional[conlist(conlist(conint(ge=0, le=1), min_items=1), min_items=1)]
57 measurementProbabilities: Optional[
58 Dict[constr(regex="^[01]+$", min_length=1), confloat(ge=0, le=1)]
59 ]
60 resultTypes: Optional[List[ResultType]]
61 measuredQubits: Optional[conlist(conint(ge=0), min_items=1)]
62 taskMetadata: TaskMetadata
63 additionalMetadata: AdditionalMetadata