NoiseHelpers
- braket.circuits.noise_helpers.no_noise_applied_warning(noise_applied)[source]
Helper function to give a warning is noise is not applied.
- Parameters:
noise_applied (bool) – True if the noise has been applied.
- Return type:
None
- braket.circuits.noise_helpers.wrap_with_list(an_item)[source]
Helper function to make the input parameter a list.
- Parameters:
an_item (Any) – The item to wrap.
- Return type:
list[Any]- Returns:
list[Any] – The item wrapped in a list.
- braket.circuits.noise_helpers.check_noise_target_gates(noise, target_gates)[source]
Helper function to check 1. whether all the elements in target_gates are a Gate type; 2. if
noiseis multi-qubit noise andtarget_gatescontain gates with the number of qubits is the same asnoise.qubit_count.
- braket.circuits.noise_helpers.check_noise_target_unitary(noise, target_unitary)[source]
Helper function to check 1. whether the input matrix is a np.ndarray type; 2. whether the target_unitary is a unitary;
- Parameters:
noise (Noise) – A Noise class object to be applied to the circuit.
target_unitary (ndarray) – matrix of the target unitary gates
- Return type:
None
- braket.circuits.noise_helpers.check_noise_target_qubits(circuit, target_qubits=None)[source]
Helper function to check whether all the target_qubits are positive integers.
- Parameters:
circuit (Circuit) – A circuit where
noiseis to be checked.target_qubits (QubitSetInput | None) – Index or indices of qubit(s).
- Return type:
QubitSet
- Returns:
QubitSet – The target qubits.
- braket.circuits.noise_helpers.apply_noise_to_moments(circuit, noise, target_qubits, position)[source]
Apply initialization/readout noise to the circuit.
When
noise.qubit_count== 1,noiseis added to all qubits intarget_qubits.When
noise.qubit_count> 1,noise.qubit_countmust be the same as the length oftarget_qubits.- Parameters:
circuit (Circuit) – A circuit to
noiseis applied to.noise (Iterable[type[Noise]]) – Noise channel(s) to be applied to the circuit.
target_qubits (QubitSet) – Index or indices of qubits.
noiseis applied to.position (str) – The position to add the noise to. May be ‘initialization’ or ‘readout_noise’.
- Return type:
- Returns:
Circuit – modified circuit.
- braket.circuits.noise_helpers.apply_noise_to_gates(circuit, noise, target_gates, target_qubits)[source]
Apply noise after target gates in target qubits.
When
noise.qubit_count== 1,noiseis applied to target_qubits aftertarget_gates.When
noise.qubit_count> 1, all elements intarget_gates, if is given, must have the same number of qubits asnoise.qubit_count.- Parameters:
circuit (Circuit) – A circuit where
noiseis applied to.noise (Iterable[type[Noise]]) – Noise channel(s) to be applied to the circuit.
target_gates (Iterable[type[Gate]] | np.ndarray) – List of gates, or a unitary matrix which
noiseis applied to.target_qubits (QubitSet) – Index or indices of qubits which
noiseis applied to.
- Return type:
- Returns:
Circuit – modified circuit.
- Raises:
Warning – If
noiseis multi-qubit noise while there is no gate with the same number of qubits intarget_qubitsor in the whole circuit whentarget_qubitsis not given. If notarget_gatesexist intarget_qubitsor in the whole circuit whentarget_qubitsis not given.