Skip to content

Commit ac47cf7

Browse files
committed
fix rst formatting in docstrings
1 parent 55bf280 commit ac47cf7

4 files changed

Lines changed: 56 additions & 34 deletions

File tree

qcodes/instrument/delegate/delegate_channel_instrument.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class DelegateChannelInstrument(DelegateInstrument):
1010
1111
Example usage in instrument YAML:
1212
13+
.. code-block:: yaml
14+
1315
switch:
1416
type: qcodes.instrument.delegate.DelegateChannelInstrument
1517
init:
@@ -21,15 +23,24 @@ class DelegateChannelInstrument(DelegateInstrument):
2123
- gnd
2224
- bus
2325
24-
The above will create a new instrument called "switch" that generates a
26+
The above will create a new instrument called ``switch`` that generates a
2527
method for a delegate parameter:
28+
29+
.. code-block:: python
30+
2631
switch.state()
2732
2833
that returns a named tuple:
34+
35+
.. code-block:: python
36+
2937
state(dac_output=..., smc=..., gnd=..., bus=...)
3038
3139
where the values of each of the tuple items are delegated to the
3240
instrument parameters:
41+
42+
.. code-block:: python
43+
3344
dac.dac_output()
3445
dac.smc()
3546
dac.gnd()

qcodes/instrument/delegate/delegate_instrument.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,49 @@ class DelegateInstrument(InstrumentBase):
2222
2323
Example usage in instrument YAML:
2424
25-
field:
26-
type: qcodes.instrument.delegate.DelegateInstrument
27-
init:
28-
parameters:
29-
X:
30-
- field_X.field
31-
ramp_rate:
32-
- field_X.ramp_rate
33-
set_initial_values_on_load: true
34-
initial_values:
35-
ramp_rate: 0.02
36-
setters:
37-
X:
38-
method: field_X.set_field
39-
block: false
40-
units:
41-
X: T
42-
ramp_rate: T/min
25+
.. code-block:: yaml
26+
27+
field:
28+
type: qcodes.instrument.delegate.DelegateInstrument
29+
init:
30+
parameters:
31+
X:
32+
- field_X.field
33+
ramp_rate:
34+
- field_X.ramp_rate
35+
set_initial_values_on_load: true
36+
initial_values:
37+
ramp_rate: 0.02
38+
setters:
39+
X:
40+
method: field_X.set_field
41+
block: false
42+
units:
43+
X: T
44+
ramp_rate: T/min
4345
4446
this will generate an instrument named "field" with methods:
47+
48+
.. code-block:: python
49+
4550
field.X()
4651
field.ramp_rate()
4752
4853
that are delegate parameters for:
54+
55+
.. code-block:: python
56+
4957
field_X.field()
5058
field_X.ramp_rate()
5159
52-
Additionally, this will set field_X.ramp_rate(0.02) on load and
53-
override the field.X.set() method with
60+
Additionally, this will set ``field_X.ramp_rate(0.02)``` on load and
61+
override the ``field.X.set()`` method with
62+
63+
.. code-block:: python
64+
5465
field_X.set_field(value, block=False),
55-
as opposed to field.X.field.set() which ramps with block=True.
66+
67+
as opposed to ``field.X.field.set()`` which ramps with ``block=True``.
5668
5769
Args:
5870
name: Instrument name
@@ -64,7 +76,7 @@ class DelegateInstrument(InstrumentBase):
6476
parameters. Defaults to None.
6577
set_initial_values_on_load: Flag to set initial values when the
6678
instrument is loaded. Defaults to False.
67-
setters: Optional setter methods to use instead of calling the .set()
79+
setters: Optional setter methods to use instead of calling the ``.set()``
6880
method on the endpoint parameters. Defaults to None.
6981
units: Optional units to set for parameters.
7082
metadata: Optional metadata to pass to instrument. Defaults to None.

qcodes/instrument/delegate/grouped_parameter.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
Dict,
55
Iterable,
66
Optional,
7-
OrderedDict,
87
Tuple,
98
Union,
109
Sequence,
1110
Callable,
1211
TYPE_CHECKING
1312
)
14-
from collections import namedtuple
13+
from collections import namedtuple, OrderedDict
1514
from qcodes.instrument.parameter import (
1615
DelegateParameter,
1716
ParamDataType,
@@ -46,33 +45,33 @@ def __init__(
4645

4746

4847
class DelegateGroup(Group):
49-
"""The DelegateGroup combines :class:`.DelegateParameter`s that
48+
"""The DelegateGroup combines :class:`.DelegateParameter` s that
5049
are to be gotten or set using one :class:`.GroupedParameter`.
5150
Each :class:`.DelegateParameter` maps to one source parameter
5251
that is individually set or gotten on an instrument. These
5352
parameters can originate from the same or different instruments.
5453
5554
The class :class:`.DelegateGroup` is used within the
5655
:class:`GroupedParameter` class in order to get and set the
57-
:class:`.DelegateParameter`s either via their default get and set
56+
:class:`.DelegateParameter` s either via their default get and set
5857
methods or via a custom get or set method.
5958
6059
The value to be set can be passed to the set method either via a
6160
dictionary, where the keys are the names of the
62-
:class:`.DelegateParameter`s contained in the :class:`DelegateGroup`,
61+
:class:`.DelegateParameter` s contained in the :class:`DelegateGroup`,
6362
or a single value, if a custom setter is defined or if the group
6463
only contains a single :class:`.DelegateParameter`.
6564
6665
The value returned by the get method is passed through a formatter.
6766
By default, the formatter returns the :class:`.DelegateParameter`
6867
values in a namedtuple, where the keys are the names of the
69-
:class:`.DelegateParameter`s. In the special case where the
68+
:class:`.DelegateParameter` s. In the special case where the
7069
:class:`.DelegateGroup` only contains one :class:`.DelegateParameter`,
7170
the formatter simply returns the individual value. Optionally,
7271
the formatter can be customized and specified via the constructor.
73-
The formatter takes as input the values of the :class:`.DelegateParameter`s
72+
The formatter takes as input the values of the :class:`.DelegateParameter` s
7473
as positional arguments in the order at which the
75-
:class:`.DelegateParameter`s are specified.
74+
:class:`.DelegateParameter` s are specified.
7675
7776
Args:
7877
name: Name of the DelegateGroup
@@ -157,12 +156,12 @@ def source_parameters(self) -> Tuple[Optional[Parameter], ...]:
157156

158157
class GroupedParameter(_BaseParameter):
159158
"""
160-
The GroupedParameter wraps one or more :class:`.DelegateParameter`s,
159+
The GroupedParameter wraps one or more :class:`.DelegateParameter` s,
161160
such that those parameters can be accessed as if they were one
162161
parameter.
163162
164163
The :class:`GroupedParameter` uses a :class:`DelegateGroup` to keep
165-
track of the :class:`.DelegateParameter`s. Mainly, this class is a
164+
track of the :class:`.DelegateParameter` s. Mainly, this class is a
166165
thin wrapper around the :class:`DelegateGroup`, and mainly exists
167166
in order to allow for it to be used as a :class:`_BaseParameter`.
168167

qcodes/instrument/delegate/instrument_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class InstrumentGroup(InstrumentBase):
1313
InstrumentGroup is an instrument driver to represent a series of instruments
1414
that are grouped together. This instrument is mainly used as a wrapper for
1515
sub instruments/submodules and particularly built for use with grouping
16-
multiple :class:`DelegateInstrument`s.
16+
multiple :class:`DelegateInstrument` s.
1717
1818
Args:
1919
name: Name referring to this group of items

0 commit comments

Comments
 (0)