Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor documentation fixes #1160

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/qibo/noise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections
from itertools import combinations
from math import log2
from typing import Optional, Union

from qibo import gates
from qibo.config import raise_error
Expand Down Expand Up @@ -211,7 +212,13 @@ def __init__(self):
self.errors = collections.defaultdict(list)
self.noise_model = {}

def add(self, error, gate=None, qubits=None, condition=None):
def add(
self,
error,
gate: Optional[gates.Gate] = None,
qubits: Optional[Union[int, tuple]] = None,
condition=None,
):
"""Add a quantum error for a specific gate and qubit to the noise model.

Args:
Expand All @@ -224,13 +231,14 @@ def add(self, error, gate=None, qubits=None, condition=None):
:class:`qibo.noise.ReadoutError`,
:class:`qibo.noise.ResetError`,
:class:`qibo.noise.UnitaryError`,
:class:`qibo.noise.KrausError` and
:class:`qibo.noise.KrausError`, and
:class:`qibo.noise.CustomError`.
gate (:class:`qibo.gates.Gate`): gate after which the noise will be added.
gate (:class:`qibo.gates.Gate`, optional): gate after which the noise will be added.
If ``None``, the noise will be added after each gate except
:class:`qibo.gates.Channel` and :class:`qibo.gates.M`.
qubits (tuple): qubits where the noise will be applied. If ``None``,
qubits (int or tuple, optional): qubits where the noise will be applied. If ``None``,
the noise will be added after every instance of the gate.
Defaults to ``None``.
condition (callable, optional): function that takes :class:`qibo.gates.Gate`
object as an input and returns ``True`` if noise should be added to it.

Expand Down Expand Up @@ -306,9 +314,8 @@ def apply(self, circuit):
circuit (:class:`qibo.models.circuit.Circuit`): quantum circuit

Returns:
A (:class:`qibo.models.circuit.Circuit`) which corresponds
to the initial circuit with noise gates added according
to the noise model.
(:class:`qibo.models.circuit.Circuit`): initial circuit with noise gates
added according to the noise model.
"""

if isinstance(self.noise_model, CompositeNoiseModel):
Expand Down