braket.circuits.noise_model.gate_criteria module

class braket.circuits.noise_model.gate_criteria.GateCriteria(gates: Gate | Iterable[Gate] | None = None, qubits: Qubit | int | Iterable[Qubit | int] | None = None)[source]

Bases: CircuitInstructionCriteria

This class models noise Criteria based on named Braket SDK Gates.

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

Parameters:
  • gates (Optional[Union[Gate, Iterable[Gate]]]) – A set of relevant Gates. All the Gates must have the same fixed_qubit_count(). Optional. If gates are not provided this matcher will match on all gates.

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

Raises:
  • ValueError – If the gates don’t all operate on the same number of qubits, or if

  • qubits are not valid targets for the provided gates.

applicable_key_types() Iterable[CriteriaKey][source]

Returns an Iterable of criteria keys.

Returns:

Iterable[CriteriaKey] – This Criteria operates on Gates 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: GATE will return a set of Gate classes that are relevant to this Criteria. 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 list.

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.

instruction_matches(instruction: Instruction) bool[source]

Returns true if an Instruction matches the criteria.

Parameters:

instruction (Instruction) – An Instruction to match.

Returns:

bool – Returns true if the operator is one of the Gates provided in the constructor and the target is a qubit (or set of qubits) provided in the constructor. If gates were not provided in the constructor, then this method will accept any Gate. If qubits were not provided in the constructor, then this method will accept any Instruction 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.