braket.circuits.noise_model.unitary_gate_criteria module

class braket.circuits.noise_model.unitary_gate_criteria.UnitaryGateCriteria(unitary: Unitary, qubits: Qubit | int | Iterable[Qubit | int] | None = None)[source]

Bases: CircuitInstructionCriteria

This class models noise Criteria based on unitary gates represented as a matrix.

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

Parameters:
  • unitary (Unitary) – A unitary gate matrix represented as a Braket Unitary.

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

Raises:

ValueError – If unitary is not a Unitary type.

applicable_key_types() Iterable[CriteriaKey][source]

Returns keys based on criterion.

Returns:

Iterable[CriteriaKey] – This Criteria operates on unitary 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: UNITARY_GATE will return a set containing the bytes of the unitary matrix representing the unitary gate. 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 Unitary gates provided in the constructor and the target is a qubit (or set of qubits) provided in the constructor. If qubits were not provided in the constructor, then this method will ignore the Instruction target.

classmethod from_dict(criteria: dict) Criteria[source]

Deserializes a dictionary into a Criteria object.

Parameters:

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

Returns:

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