Skip to content

Commit 852b163

Browse files
Merge pull request #1085 from qiboteam/fix_doc
Updating API documentation
2 parents d8e8dda + 416b21f commit 852b163

File tree

1 file changed

+17
-40
lines changed

1 file changed

+17
-40
lines changed

doc/source/tutorials/advanced.rst

+17-40
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,49 @@ Qibocal also allows executing protocols without the standard :ref:`interface <in
99
In the following tutorial we show how to run a single protocol using Qibocal as a library.
1010
For this particular example we will focus on the `t1_signal protocol
1111
<https://github.com/qiboteam/qibocal/blob/main/src/qibocal/protocols/coherence/t1_signal.py>`_ (see also :ref:`t1`).
12+
The fastest way consists in using the `Executor` class in the following way
1213

1314
.. code-block:: python
1415
15-
import pathlib
16-
from qibolab import create_platform
17-
1816
from qibocal.auto.execute import Executor
1917
from qibocal.auto.mode import ExecutionMode
20-
from qibocal.protocols import t1_signal
2118
22-
# allocate platform
23-
platform = create_platform("....")
19+
with Executor.open(
20+
"myexec", # arbitrary name for executor
21+
path="test_t1_signal", # path where the data will be stored
22+
platform="dummy", # platform to be used
23+
targets=[0], # qubits on which the experiment will be executed
24+
) as e:
2425
25-
#creare executor
26-
executor = Executor.create(
27-
platform=platform,
28-
output=pathlib.Path("experiment_data")
29-
)
26+
# your experiments go here
3027
3128
The executor is responsible of running the routines on a platform and eventually store the history of multiple experiments.
32-
``t1_signal``, that we import, is a :class:`qibocal.auto.operation.Routine` object which contains all the necessary
33-
methods to execute the experiment.
29+
The context manager `with` provides an easy way to connect and disconnect from the platform.
3430

3531
In order to run an experiment the user needs to specify its parameters.
3632
The user can check which parameters need to be provided either by checking the
3733
documentation of the specific protocol or by simply inspecting ``protocol.parameters_type``.
38-
For ``t1_signal`` we define the parameters in the following way:
34+
To run a `t1_signal` experiment is necessary to use invoke the protocol inside the `with` statement
3935

4036
.. code-block:: python
4137
42-
t1_params = {
43-
"id": "t1_experiment",
44-
"targets": [0], # we are defining here which qubits to analyze
45-
"operation": "t1_signal",
46-
"parameters": {
47-
"delay_before_readout_start": 0,
48-
"delay_before_readout_end": 20_000,
49-
"delay_before_readout_step": 50,
50-
},
51-
}
52-
53-
54-
After defining the parameters, the user can perform the acquisition using
55-
``executor.run_protocol`` which accepts the following parameters:
56-
57-
* ``protocol`` (:class:`qibocal.auto.operation.Routine`): protocol
58-
* ``parameters`` (Dict): parameters dictionary
59-
* ``mode`` (:class:`qibocal.auto.mode.ExecutionMode`): can be ExecutionMode.ACQUIRE or ExecutionMode.FIT
60-
61-
.. code-block:: python
38+
output = e.t1_signal(delay_before_readout_start=0,
39+
delay_before_readout_end=20_000,
40+
delay_before_readout_step=50)
6241
63-
executor.run_protocol(t1_signal, t1_params, ExecutionMode.ACQUIRE)
64-
executor.run_protocol(t1_signal, t1_params, ExecutionMode.FIT)
6542
66-
In this way we have first executed the acquisition part of the experiment and then performed the fit on the acquired data.
43+
By default acquisition and fitting are performed.
6744

6845
The user can now use the raw data acquired by the quantum processor to perform
6946
an arbitrary post-processing analysis. This is one of the main advantages of this API
7047
compared to the cli execution.
7148

72-
The history, that contains both the raw data (added with :attr:`qibocal.auto.mode.ExecutionMode.ACQUIRE`) and the fit data (added with :attr:`qibocal.auto.mode.ExecutionMode.FIT`) can be accessed:
49+
Both the raw data and the fit data can be accessed from the history attribute of the `Executor`.
7350

7451
.. code-block:: python
7552
76-
history = executor.history
77-
t1_res = history["t1_experiment"] # id of the protocol
53+
history = e.history
54+
t1_res = history["t1_signal"][0]
7855
7956
data = t1_res.data # raw data
8057
results = t1_res.results # fit data

0 commit comments

Comments
 (0)