braket.task_result.gate_model_task_result_v1 module

class braket.task_result.gate_model_task_result_v1.ResultTypeValue(*, type: Amplitude | Expectation | Probability | Sample | StateVector | DensityMatrix | Variance | AdjointGradient, value: list | float | dict)[source]

Bases: BaseModel

Requested result type and value of gate model task result.

type (Union[Expectation, Sample, StateVector, Variance, Probability, Amplitude,

AdjointGradient]): The requested result type

value

The value of the requested result

Type:

Union[List, float, Dict]

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

type: Amplitude | Expectation | Probability | Sample | StateVector | DensityMatrix | Variance | AdjointGradient
value: list | float | dict
class braket.task_result.gate_model_task_result_v1.GateModelTaskResult(*, braketSchemaHeader: BraketSchemaHeader = BraketSchemaHeader(name='braket.task_result.gate_model_task_result', version='1'), measurements: ConstrainedListValue[ConstrainedListValue[ConstrainedIntValue]] | None = None, measurementProbabilities: dict[ConstrainedStrValue, ConstrainedFloatValue] | None = None, resultTypes: list[ResultTypeValue] | None = None, measuredQubits: ConstrainedListValue[ConstrainedIntValue] | None = None, outputs: ConstrainedListValue[dict[ConstrainedStrValue, StrictBool | ConstrainedIntValue | ConstrainedFloatValue | None | list[StrictBool | None] | list[ConstrainedIntValue | None] | list[ConstrainedFloatValue | None]]] | None = None, taskMetadata: TaskMetadata, additionalMetadata: AdditionalMetadata)[source]

Bases: BraketSchemaBase

The gate model task result schema

braketSchemaHeader

Schema header. Users do not need to set this value. Only default is allowed.

Type:

BraketSchemaHeader

measurements (list[list[int]]

List of lists, where each list represents a shot and each index of the list represents a qubit. Default is None.

measurementProbabilities

A dictionary of probabilistic results. Key is the measurements in a big endian binary string. Value is the probability the measurement occurred. Default is None.

Type:

dict[str, float]

measuredQubits

The indices of the measured qubits. Indicates which qubits are in measurements. Default is None.

Type:

list[int]

resultTypes

Requested result types and their values. Default is None.

Type:

list[ResultTypeValue]

outputs

Per-shot values of OpenQASM 3 output-declared variables. Each element is one shot, mapping each output variable name to its value (a scalar, or a homogeneous list for registers). An undefined value is represented by None. Default is None.

Type:

list[dict[str, OutputValue]]

taskMetadata

The task metadata

Type:

TaskMetadata

additionalMetadata

Additional metadata of the task

Type:

AdditionalMetadata

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

braketSchemaHeader: BraketSchemaHeader
measurements: ConstrainedListValue[ConstrainedListValue[ConstrainedIntValue]] | None
measurementProbabilities: dict[ConstrainedStrValue, ConstrainedFloatValue] | None
resultTypes: list[ResultTypeValue] | None
measuredQubits: ConstrainedListValue[ConstrainedIntValue] | None
outputs: ConstrainedListValue[dict[ConstrainedStrValue, StrictBool | ConstrainedIntValue | ConstrainedFloatValue | None | list[StrictBool | None] | list[ConstrainedIntValue | None] | list[ConstrainedFloatValue | None]]] | None
taskMetadata: TaskMetadata
additionalMetadata: AdditionalMetadata
classmethod validate_non_empty_shot(shot)[source]

Rejects empty per-shot dicts. Every declared output variable appears in each shot (its value or None), so an empty shot signals malformed data.

Parameters:

shot (dict) – One per-shot output dict from the outputs list.

Returns:

dict – The same shot, validated to be non-empty.

Raises:

ValueError – If the shot dict is empty.