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

Fix some docstrings #1053

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions doc/source/tutorials/instrument.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ Let's see a minimal example:

from proprietary_instruments import ControllerType, controller_driver

from qibolab.components import Config
from qibolab.execution_parameters import ExecutionParameters
from qibolab.identifier import Result
from qibolab.sequence import PulseSequence
from qibolab.sweeper import ParallelSweepers
from qibolab.instruments.abstract import Controller
from qibolab._core.components import Config
from qibolab._core.execution_parameters import ExecutionParameters
from qibolab._core.identifier import Result
from qibolab._core.sequence import PulseSequence
from qibolab._core.sweeper import ParallelSweepers
from qibolab._core.instruments.abstract import Controller
alecandido marked this conversation as resolved.
Show resolved Hide resolved


class MyController(Controller):
Expand Down
4 changes: 2 additions & 2 deletions src/qibolab/_core/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def assign_measurements(self, measurement_map, readout):
"""Assigning measurement outcomes to
:class:`qibo.states.MeasurementResult` for each gate.

This allows properly obtaining the measured shots from the :class:`qibolab.pulses.ReadoutPulse` object obtaned after pulse sequence execution.
This allows properly obtaining the measured shots from the :class:`qibolab.Readout` object obtaned after pulse sequence execution.

Args:
measurement_map (dict): Map from each measurement gate to the sequence of
readout pulses implementing it.
readout (:class:`qibolab.pulses.ReadoutPulse`): Readout result object
readout (:class:`qibolab.Readout`): Readout result object
containing the readout measurement shots. This is created in ``execute_circuit``.
"""
for gate, sequence in measurement_map.items():
Expand Down
26 changes: 6 additions & 20 deletions src/qibolab/_core/compilers/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,10 @@
class Compiler:
"""Compile native circuits into pulse sequences.

It transforms a :class:`qibo.models.Circuit` to a :class:`qibolab.pulses.PulseSequence`.
It transforms a :class:`qibo.models.Circuit` to a :class:`qibolab.PulseSequence`.

The transformation is done using a dictionary of rules which map each Qibo gate to a
pulse sequence and some virtual Z-phases.

A rule is a function that takes two argumens:
- gate (:class:`qibo.gates.abstract.Gate`): Gate object to be compiled.
- platform (:class:`qibolab.platforms.abstract.AbstractPlatform`): Platform object to read
native gate pulses from.

and returns:
- sequence (:class:`qibolab.pulses.PulseSequence`): Sequence of pulses that implement
the given gate.
- virtual_z_phases (dict): Dictionary mapping qubits to virtual Z-phases induced by the gate.

See :class:`qibolab.compilers.default` for an example of a compiler implementation.
"""

rules: dict[type[gates.Gate], Rule] = field(default_factory=dict)
Expand Down Expand Up @@ -88,7 +76,7 @@ def get_sequence(self, gate: gates.Gate, platform: Platform) -> PulseSequence:

Args:
gate (:class:`qibo.gates.Gate`): Qibo gate to convert to pulses.
platform (:class:`qibolab.platform.Platform`): Qibolab platform to read the native gates from.
platform (:class:`qibolab.Platform`): Qibolab platform to read the native gates from.
"""
# get local sequence for the current gate
rule = self.rules[type(gate)]
Expand Down Expand Up @@ -180,14 +168,12 @@ def compile(
"""Transform a circuit to pulse sequence.

Args:
circuit (qibo.models.Circuit): Qibo circuit that respects the platform's
connectivity and native gates.
platform (qibolab.platforms.abstract.AbstractPlatform): Platform used
to load the native pulse representations.
circuit: Qibo circuit that respects the platform's connectivity and native gates.
platform: Platform used to load the native pulse representations.

Returns:
sequence (qibolab.pulses.PulseSequence): Pulse sequence that implements the circuit.
measurement_map (dict): Map from each measurement gate to the sequence of readout pulse implementing it.
sequence: Pulse sequence that implements the circuit.
measurement_map: Map from each measurement gate to the sequence of readout pulse implementing it.
"""
sequence = PulseSequence()

Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/_core/instruments/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def play(
) -> dict[int, Result]:
"""Play a pulse sequence and retrieve feedback.

If :class:`qibolab.sweeper.Sweeper` objects are passed as arguments, they are
If :class:`qibolab.Sweeper` objects are passed as arguments, they are
executed in real-time. If not possible, an error is raised.

Returns a mapping with the id of the probe pulses used to acquired data.
Expand Down
8 changes: 1 addition & 7 deletions src/qibolab/_core/instruments/qm/program/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,8 @@ def create_acquisition(
"""Create container for the variables used for saving acquisition in the
QUA program.

Args:
operation (str):
element (str):
options (:class:`qibolab.execution_parameters.ExecutionParameters`): Execution
options containing acquisition type and averaging mode.

Returns:
:class:`qibolab.instruments.qm.acquisition.Acquisition` object containing acquisition variables.
``Acquisition`` object containing acquisition variables.
"""
average = options.averaging_mode is AveragingMode.CYCLIC
kwargs = {}
Expand Down
3 changes: 1 addition & 2 deletions src/qibolab/_core/pulses/pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class Pulse(_PulseLike):
envelope: Envelope
"""The pulse envelope shape.

See
:class:`qibolab.pulses.envelope.Envelopes` for list of available shapes.
stavros11 marked this conversation as resolved.
Show resolved Hide resolved
See :class:`qibolab.Envelope` for list of available shapes.
"""
relative_phase: float = 0.0
"""Relative phase of the pulse, in radians."""
Expand Down
6 changes: 3 additions & 3 deletions src/qibolab/_core/sweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def _alternative_fields(a: _Field, b: _Field):
class Sweeper(Model):
"""Data structure for Sweeper object.

This object is passed as an argument to the method :func:`qibolab.platforms.platform.Platform.execute`
This object is passed as an argument to the method :func:`qibolab.Platform.execute`
which enables the user to sweep a specific parameter for one or more pulses. For information on how to
perform sweeps see :func:`qibolab.platforms.platform.Platform.execute`.
perform sweeps see :func:`qibolab.Platform.execute`.

Example:
.. testcode::
Expand All @@ -72,7 +72,7 @@ class Sweeper(Model):
values: array of parameter values to sweep over.
range: tuple of ``(start, stop, step)`` to sweep over the array ``np.arange(start, stop, step)``.
Can be provided instead of ``values`` for more efficient sweeps on some instruments.
pulses : list of `qibolab.pulses.Pulse` to be swept.
pulses : list of `qibolab.Pulse` to be swept.
channels: list of channel names for which the parameter should be swept.
"""

Expand Down
3 changes: 0 additions & 3 deletions tests/test_platform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""Tests :class:`qibolab.platforms.multiqubit.MultiqubitPlatform` and
:class:`qibolab.platforms.platform.DesignPlatform`."""

import inspect
import os
import pathlib
Expand Down