braket.circuits.noise_model.observable_criteria module

class braket.circuits.noise_model.observable_criteria.ObservableCriteria(observables: Observable | Iterable[Observable] | None = None, qubits: Qubit | int | Iterable[Qubit | int] | None = None)[source]

Bases: ResultTypeCriteria

This class models noise Criteria based on the Braket SDK Observable classes.

Creates Observable-based Criteria. See instruction_matches() for more details.

Parameters:
  • observables (Optional[Union[Observable, Iterable[Observable]]]) – A set of relevant Observables. Observables must only operate on a single qubit. Optional. If observables are not specified, this criteria will match on any observable.

  • qubits (Optional[QubitSetInput]) – A set of relevant qubits. If no qubits are provided, all (possible) qubits are considered to be relevant.

Throws:

ValueError: If the operators operate on more than one qubit.

applicable_key_types() Iterable[CriteriaKey][source]

Returns an Iterable of criteria keys.

Returns:

Iterable[CriteriaKey] – This Criteria operates on Observables and Qubits.

get_keys(key_type: CriteriaKey) CriteriaKeyResult | set[Any][source]

Gets the keys for a given CriteriaKey.

Parameters:

key_type (CriteriaKey) – The relevant Criteria Key.

Returns:

Union[CriteriaKeyResult, set[Any]] – The return value is based on the key type: OBSERVABLE will return a set of Observable classes that are relevant to this Criteria, or CriteriaKeyResult.ALL if the Criteria is relevant for all (possible) observables. QUBIT will return a set of qubit targets that are relevant to this Criteria, or CriteriaKeyResult.ALL if the Criteria is relevant for all (possible) qubits. All other keys will return an empty set.

to_dict() dict[source]

Converts a dictionary representing an object of this class into an instance of this class.

Returns:

dict – A dictionary representing the serialized version of this Criteria.

result_type_matches(result_type: ResultType) bool[source]

Returns true if a result type matches the criteria.

Parameters:

result_type (ResultType) – A result type or list of result types to match.

Returns:

bool – Returns true if the result type is one of the Observables provided in the constructor and the target is a qubit (or set of qubits)provided in the constructor. If observables were not provided in the constructor, then this method will accept any Observable. If qubits were not provided in the constructor, then this method will accept any result type target.

classmethod from_dict(criteria: dict) Criteria[source]

Deserializes a dictionary into a Criteria object.

Parameters:

criteria (dict) – A dictionary representation of a GateCriteria.

Returns:

Criteria – A deserialized GateCriteria represented by the passed in serialized data.