From 627eab75ed212b85c19374bb80a9fa839398f305 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Sat, 20 Jan 2024 12:37:25 +0400 Subject: [PATCH 1/3] improved docstrings --- src/qibo/noise.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/qibo/noise.py b/src/qibo/noise.py index e7ed76909e..9cbbee25f6 100644 --- a/src/qibo/noise.py +++ b/src/qibo/noise.py @@ -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 @@ -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: @@ -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. @@ -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): From 617fc7a6762f2bb98de3efa45d46a67b05bf3185 Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Tue, 23 Jan 2024 15:06:06 +0400 Subject: [PATCH 2/3] another fix --- doc/source/api-reference/qibo.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/api-reference/qibo.rst b/doc/source/api-reference/qibo.rst index bbeeda603c..3ee49b39a9 100644 --- a/doc/source/api-reference/qibo.rst +++ b/doc/source/api-reference/qibo.rst @@ -849,7 +849,7 @@ U1q - Pauli-:math:`Z` rotation: :class:`qibo.gates.RZ` - Arbitrary :math:`ZZ` rotation: :class:`qibo.gates.RZZ` - - Fully-entangling :math:`ZZ`-interaction: :math:`R_{ZZ}(\\pi/2)` + - Fully-entangling :math:`ZZ`-interaction: :math:`R_{ZZ}(\pi/2)` _______________________ From d92d4aaf061bd3bd54f35c148028dc5bdb35991f Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Tue, 23 Jan 2024 17:42:56 +0400 Subject: [PATCH 3/3] another minor fix --- src/qibo/quantum_info/metrics.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qibo/quantum_info/metrics.py b/src/qibo/quantum_info/metrics.py index 4d2632fcaa..eb29f1b486 100644 --- a/src/qibo/quantum_info/metrics.py +++ b/src/qibo/quantum_info/metrics.py @@ -1176,14 +1176,15 @@ def frame_potential( .. math:: \\mathcal{F}_{\\mathcal{U}}^{(t)} = \\int_{U,V \\in \\mathcal{U}} \\, - \\text{d}U \\, \\text{d}V \\, \\text{abs}\\bigl[\\text{tr}(U^{\\dagger} \\, V)\\bigr]^{2t} \\, , + \\text{d}U \\, \\text{d}V \\, \\bigl| \\, \\text{tr}(U^{\\dagger} \\, V) + \\, \\bigr|^{2t} \\, , where :math:`\\mathcal{U}` is the group of unitaries defined by the parametrized circuit. The frame potential is approximated by the average .. math:: \\mathcal{F}_{\\mathcal{U}}^{(t)} \\approx \\frac{1}{N} \\, - \\sum_{k=1}^{N} \\, \\text{abs}\\bigl[ \\text{tr}(U_{k}^{\\dagger} \\, V_{k})\\bigr]^{2t} \\, , + \\sum_{k=1}^{N} \\, \\bigl| \\, \\text{tr}(U_{k}^{\\dagger} \\, V_{k}) \\, \\bigr|^{2t} \\, , where :math:`N` is the number of ``samples``.