diff --git a/_modules/qcodes/data/data_array.html b/_modules/qcodes/data/data_array.html index e2a8c578dc6..d84f1f594ae 100644 --- a/_modules/qcodes/data/data_array.html +++ b/_modules/qcodes/data/data_array.html @@ -140,7 +140,7 @@
import numpy as np
import collections
-from qcodes.utils.helpers import DelegateAttributes, full_class
+from qcodes.utils.helpers import DelegateAttributes, full_class, warn_units
[docs]class DataArray(DelegateAttributes):
@@ -168,7 +168,7 @@ Source code for qcodes.data.data_array
Args:
parameter (Optional[Parameter]): The parameter whose values will
populate this array, if any. Will copy ``name``, ``full_name``,
- ``label``, ``units``, and ``snapshot`` from here unless you
+ ``label``, ``unit``, and ``snapshot`` from here unless you
provide them explicitly.
name (Optional[str]): The short name of this array.
@@ -207,7 +207,9 @@ Source code for qcodes.data.data_array
handle converting this to array_id internally (maybe it
already does?)
- units (Optional[str]): The units of the values stored in this array.
+ unit (Optional[str]): The unit of the values stored in this array.
+
+ units (Optional[str]): DEPRECATED, redirects to ``unit``.
is_setpoint (bool): True if this is a setpoint array, False if it
is measured. Default False.
@@ -223,7 +225,7 @@ Source code for qcodes.data.data_array
'array_id',
'name',
'shape',
- 'units',
+ 'unit',
'label',
'action_indices',
'is_setpoint')
@@ -233,7 +235,7 @@ Source code for qcodes.data.data_array
COPY_ATTRS_FROM_INPUT = (
'name',
'label',
- 'units')
+ 'unit')
# keys in the parameter snapshot to omit from our snapshot
SNAP_OMIT_KEYS = (
@@ -247,13 +249,17 @@ Source code for qcodes.data.data_array
[docs] def __init__(self, parameter=None, name=None, full_name=None, label=None,
snapshot=None, array_id=None, set_arrays=(), shape=None,
- action_indices=(), units=None, is_setpoint=False,
+ action_indices=(), unit=None, units=None, is_setpoint=False,
preset_data=None):
self.name = name
self.full_name = full_name or name
self.label = label
self.shape = shape
- self.units = units
+ if units is not None:
+ warn_units('DataArray', self)
+ if unit is None:
+ unit = units
+ self.unit = unit
self.array_id = array_id
self.is_setpoint = is_setpoint
self.action_indices = action_indices
@@ -656,7 +662,12 @@ Source code for qcodes.data.data_array
if getattr(self, 'synced_index', None) is not None:
last_index = max(last_index, self.synced_index)
- return (last_index + 1) / self.ndarray.size
+ return (last_index + 1) / self.ndarray.size
+
+ @property
+ def units(self):
+ warn_units('DataArray', self)
+ return self.unit
diff --git a/_modules/qcodes/data/data_set.html b/_modules/qcodes/data/data_set.html
index 8b51d21ab76..c4190aa7863 100644
--- a/_modules/qcodes/data/data_set.html
+++ b/_modules/qcodes/data/data_set.html
@@ -422,7 +422,7 @@ Source code for qcodes.data.data_set
self.metadata = {}
- self.arrays = {}
+ self.arrays = _PrettyPrintDict()
if arrays:
self.action_id_map = self._clean_array_ids(arrays)
for array in arrays:
@@ -1003,6 +1003,21 @@ Source code for qcodes.data.data_set
out += out_template.format(info=arr_info_i, lens=column_lengths)
return out
+
+
+class _PrettyPrintDict(dict):
+ """
+ simple wrapper for a dict to repr its items on separate lines
+ with a bit of indentation
+ """
+ def __repr__(self):
+ body = '\n '.join([repr(k) + ': ' + self._indent(repr(v))
+ for k, v in self.items()])
+ return '{\n ' + body + '\n}'
+
+ def _indent(self, s):
+ lines = s.split('\n')
+ return '\n '.join(lines)
diff --git a/_modules/qcodes/data/hdf5_format.html b/_modules/qcodes/data/hdf5_format.html
index c381d3007d2..f393a70c573 100644
--- a/_modules/qcodes/data/hdf5_format.html
+++ b/_modules/qcodes/data/hdf5_format.html
@@ -201,7 +201,13 @@ Source code for qcodes.data.hdf5_format
# write ensures these attributes always exist
name = dat_arr.attrs['name'].decode()
label = dat_arr.attrs['label'].decode()
- units = dat_arr.attrs['units'].decode()
+
+ # get unit from units if no unit field, for backward compatibility
+ if 'unit' in dat_arr.attrs:
+ unit = dat_arr.attrs['unit'].decode()
+ else:
+ unit = dat_arr.attrs['units'].decode()
+
is_setpoint = str_to_bool(dat_arr.attrs['is_setpoint'].decode())
# if not is_setpoint:
set_arrays = dat_arr.attrs['set_arrays']
@@ -214,7 +220,7 @@ Source code for qcodes.data.hdf5_format
if array_id not in data_set.arrays.keys(): # create new array
d_array = DataArray(
name=name, array_id=array_id, label=label, parameter=None,
- units=units,
+ unit=unit,
is_setpoint=is_setpoint, set_arrays=(),
preset_data=vals)
data_set.add_array(d_array)
@@ -222,7 +228,7 @@ Source code for qcodes.data.hdf5_format
d_array = data_set.arrays[array_id]
d_array.name = name
d_array.label = label
- d_array.units = units
+ d_array.unit = unit
d_array.is_setpoint = is_setpoint
d_array.ndarray = vals
d_array.shape = dat_arr.attrs['shape']
@@ -335,9 +341,6 @@ Source code for qcodes.data.hdf5_format
group: group in the hdf5 file where the dset will be created
creates a hdf5 datasaset that represents the data array.
-
- note that the attribute "units" is used for shape determination
- in the case of tuple-like variables.
'''
# Check for empty meta attributes, use array_id if name and/or label
# is not specified
@@ -345,24 +348,19 @@ Source code for qcodes.data.hdf5_format
label = array.label
else:
label = array.array_id
+
if array.name is not None:
name = array.name
else:
name = array.array_id
- if array.units is None:
- array.units = [''] # used for shape determination
- units = array.units
+
# Create the hdf5 dataset
- if isinstance(units, str):
- n_cols = 1
- else:
- n_cols = len(array.units)
dset = group.create_dataset(
- array.array_id, (0, n_cols),
- maxshape=(None, n_cols))
+ array.array_id, (0, 1),
+ maxshape=(None, 1))
dset.attrs['label'] = _encode_to_utf8(str(label))
dset.attrs['name'] = _encode_to_utf8(str(name))
- dset.attrs['units'] = _encode_to_utf8(str(units))
+ dset.attrs['unit'] = _encode_to_utf8(str(array.unit or ''))
dset.attrs['is_setpoint'] = _encode_to_utf8(str(array.is_setpoint))
set_arrays = []
diff --git a/_modules/qcodes/instrument/mock.html b/_modules/qcodes/instrument/mock.html
index 9370b5b3b14..e53ec95154a 100644
--- a/_modules/qcodes/instrument/mock.html
+++ b/_modules/qcodes/instrument/mock.html
@@ -142,7 +142,7 @@ Source code for qcodes.instrument.mock
from datetime import datetime
from .base import Instrument
-from .parameter import Parameter
+from .parameter import MultiParameter
from qcodes import Loop
from qcodes.data.data_array import DataArray
from qcodes.process.server import ServerManager, BaseServer
@@ -422,22 +422,21 @@ Source code for qcodes.instrument.mock
"""
self.ask('method_call', 'delattr', attr)
-[docs]class ArrayGetter(Parameter):
+[docs]class ArrayGetter(MultiParameter):
"""
Example parameter that just returns a single array
- TODO: in theory you can make this same Parameter with
+ TODO: in theory you can make this an ArrayParameter with
name, label & shape (instead of names, labels & shapes) and altered
setpoints (not wrapped in an extra tuple) and this mostly works,
but when run in a loop it doesn't propagate setpoints to the
- DataSet. We could track down this bug, but perhaps a better solution
- would be to only support the simplest and the most complex Parameter
- forms (ie cases 1 and 5 in the Parameter docstring) and do away with
- the intermediate forms that make everything more confusing.
+ DataSet. This is a bug
"""
def __init__(self, measured_param, sweep_values, delay):
name = measured_param.name
- super().__init__(names=(name,))
+ super().__init__(names=(name,),
+ shapes=((len(sweep_values),),),
+ name=name)
self._instrument = getattr(measured_param, '_instrument', None)
self.measured_param = measured_param
self.sweep_values = sweep_values
diff --git a/_modules/qcodes/instrument/parameter.html b/_modules/qcodes/instrument/parameter.html
index 2a927eb4c37..4dc1aa7d1ca 100644
--- a/_modules/qcodes/instrument/parameter.html
+++ b/_modules/qcodes/instrument/parameter.html
@@ -140,45 +140,54 @@ Source code for qcodes.instrument.parameter
"""
Measured and/or controlled parameters
-The Parameter class is meant for direct parameters of instruments (ie
-subclasses of Instrument) but elsewhere in Qcodes we can use anything
-as a parameter if it has the right attributes:
-
-To use Parameters in data acquisition loops, they should have:
-
- - .name - like a variable name, ie no spaces or weird characters
- - .label - string to use as an axis label (optional, defaults to .name)
- (except for composite measurements, see below)
-
-Controlled parameters should have a .set(value) method, which takes a single
-value to apply to this parameter. To use this parameter for sweeping, also
-connect its __getitem__ to SweepFixedValues as below.
-
-Measured parameters should have .get() which can return:
-
-- a single value:
-
- - parameter should have .name and optional .label as above
-
-- several values of different meaning (raw and measured, I and Q,
- a set of fit parameters, that sort of thing, that all get measured/calculated
- at once):
-
- - parameter should have .names and optional .labels, each a sequence with
- the same length as returned by .get()
-
-- an array of values of one type:
-
- - parameter should have .name and optional .label as above, but also
- .shape attribute, which is an integer (or tuple of integers) describing
- the shape of the returned array (which must be fixed)
- optionally also .setpoints, array(s) of setpoint values for this data
- otherwise we will use integers from 0 in each direction as the setpoints
-
-- several arrays of values (all the same shape):
-
- - define .names (and .labels) AND .shape (and .setpoints)
-
+Anything that you want to either measure or control within QCoDeS should
+satisfy the Parameter interface. Most of the time that is easiest to do
+by either using or subclassing one of the classes defined here, but you can
+also use any class with the right attributes.
+
+TODO (alexcjohnson) update this with the real duck-typing requirements or
+create an ABC for Parameter and MultiParameter - or just remove this statement
+if everyone is happy to use these classes.
+
+This file defines four classes of parameters:
+
+``Parameter``, ``ArrayParameter``, and ``MultiParameter`` must be subclassed:
+
+- ``Parameter`` is the base class for scalar-valued parameters, if you have
+ custom code to read or write a single value. Provides ``sweep`` and
+ ``__getitem__`` (slice notation) methods to use a settable parameter as
+ the swept variable in a ``Loop``. To use, fill in ``super().__init__``,
+ and provide a ``get`` method, a ``set`` method, or both.
+
+- ``ArrayParameter`` is a base class for array-valued parameters, ie anything
+ for which each ``get`` call returns an array of values that all have the
+ same type and meaning. Currently not settable, only gettable. Can be used
+ in ``Measure``, or in ``Loop`` - in which case these arrays are nested
+ inside the loop's setpoint array. To use, provide a ``get`` method that
+ returns an array or regularly-shaped sequence, and describe that array in
+ ``super().__init__``.
+
+- ``MultiParameter`` is the base class for multi-valued parameters. Currently
+ not settable, only gettable, but can return an arbitrary collection of
+ scalar and array values and can be used in ``Measure`` or ``Loop`` to
+ feed data to a ``DataSet``. To use, provide a ``get`` method
+ that returns a sequence of values, and describe those values in
+ ``super().__init__``.
+
+``StandardParameter`` and ``ManualParameter`` can be instantiated directly:
+
+- ``StandardParameter`` is the default class for instrument parameters
+ (see ``Instrument.add_parameter``). Can be gettable, settable, or both.
+ Provides a standardized interface to construct strings to pass to the
+ instrument's ``write`` and ``ask`` methods (but can also be given other
+ functions to execute on ``get`` or ``set``), to convert the string
+ responses to meaningful output, and optionally to ramp a setpoint with
+ stepped ``write`` calls from a single ``set``. Does not need to be
+ subclassed, just instantiated.
+
+- ``ManualParameter`` is for values you want to keep track of but cannot
+ set or get electronically. Holds the last value it was ``set`` to, and
+ returns it on ``get``.
"""
from datetime import datetime, timedelta
@@ -191,210 +200,64 @@ Source code for qcodes.instrument.parameter
import numpy
from qcodes.utils.deferred_operations import DeferredOperations
-from qcodes.utils.helpers import (permissive_range, wait_secs, is_sequence_of,
- DelegateAttributes, full_class, named_repr)
+from qcodes.utils.helpers import (permissive_range, wait_secs, is_sequence,
+ is_sequence_of, DelegateAttributes,
+ full_class, named_repr, warn_units)
from qcodes.utils.metadata import Metadatable
from qcodes.utils.command import Command, NoCommandError
-from qcodes.utils.validators import Validator, Numbers, Ints, Enum, Anything
+from qcodes.utils.validators import Validator, Numbers, Ints, Enum
from qcodes.instrument.sweep_values import SweepFixedValues
from qcodes.data.data_array import DataArray
-[docs]def no_setter(*args, **kwargs):
- raise NotImplementedError('This Parameter has no setter defined.')
-
-
-[docs]def no_getter(*args, **kwargs):
- raise NotImplementedError(
- 'This Parameter has no getter, use .get_latest to get the most recent '
- 'set value.')
-
-
-[docs]class Parameter(Metadatable, DeferredOperations):
+class _BaseParameter(Metadatable, DeferredOperations):
"""
- Define one generic parameter, not necessarily part of
- an instrument. can be settable and/or gettable.
-
- A settable Parameter has a .set method, and supports only a single value
- at a time (see below)
-
- A gettable Parameter has a .get method, which may return:
-
- 1. a single value
- 2. a sequence of values with different names (for example,
- raw and interpreted, I and Q, several fit parameters...)
- 3. an array of values all with the same name, but at different
- setpoints (for example, a time trace or fourier transform that
- was acquired in the hardware and all sent to the computer at once)
- 4. 2 & 3 together: a sequence of arrays. All arrays should be the same
- shape.
- 5. a sequence of differently shaped items
-
- Because .set only supports a single value, if a Parameter is both
- gettable AND settable, .get should return a single value too (case 1)
-
- Parameters have a .get_latest method that simply returns the most recent
- set or measured value. This can either be called ( param.get_latest() )
- or used in a Loop as if it were a (gettable-only) parameter itself:
-
- Loop(...).each(param.get_latest)
-
-
- The constructor arguments change somewhat between these cases:
-
- Todo:
- no idea how to document such a constructor
+ Shared behavior for simple and multi parameters. Not intended to be used
+ directly, normally you should use ``StandardParameter`` or
+ ``ManualParameter``, or create your own subclass of ``Parameter`` or
+ ``MultiParameter``.
Args:
- name: (1&3) the local name of this parameter, should be a valid
- identifier, ie no spaces or special characters
-
- names: (2,4,5) a tuple of names
-
- label: (1&3) string to use as an axis label for this parameter
- defaults to name
-
- labels: (2,4,5) a tuple of labels
-
- units: (1&3) string that indicates units of parameter for use in axis
- label and snapshot
-
- shape: (3&4) a tuple of integers for the shape of array returned by
- .get().
-
- shapes: (5) a tuple of tuples, each one as in `shape`.
- Single values should be denoted by None or ()
-
- setpoints: (3,4,5) the setpoints for the returned array of values.
- 3&4 - a tuple of arrays. The first array is be 1D, the second 2D,
- etc.
- 5 - a tuple of tuples of arrays
- Defaults to integers from zero in each respective direction
- Each may be either a DataArray, a numpy array, or a sequence
- (sequences will be converted to numpy arrays)
- NOTE: if the setpoints will be different each measurement, leave
- this out and return the setpoints (with extra names) in the get.
-
- setpoint_names: (3,4,5) one identifier (like `name`) per setpoint
- array. Ignored if `setpoints` are DataArrays, which already have
- names.
-
- setpoint_labels: (3&4) one label (like `label`) per setpoint array.
- Overridden if `setpoints` are DataArrays and already have labels.
-
- vals: allowed values for setting this parameter (only relevant
- if it has a setter), defaults to Numbers()
-
- docstring (Optional[string]): documentation string for the __doc__
- field of the object. The __doc__ field of the instance is used by
- some help systems, but not all
-
- snapshot_get (bool): Prevent any update to the parameter
- for example if it takes too long to update
-
+ name (str): the local name of the parameter. Should be a valid
+ identifier, ie no spaces or special characters. If this parameter
+ is part of an Instrument or Station, this should match how it will
+ be referenced from that parent, ie ``instrument.name`` or
+ ``instrument.parameters[name]``
+
+ instrument (Optional[Instrument]): the instrument this parameter
+ belongs to, if any
+
+ snapshot_get (Optional[bool]): False prevents any update to the
+ parameter during a snapshot, even if the snapshot was called with
+ ``update=True``, for example if it takes too long to update.
+ Default True.
+
+ metadata (Optional[dict]): extra information to include with the
+ JSON snapshot of the parameter
"""
-[docs] def __init__(self,
- name=None, names=None,
- label=None, labels=None,
- units=None,
- shape=None, shapes=None,
- setpoints=None, setpoint_names=None, setpoint_labels=None,
- vals=None, docstring=None, snapshot_get=True, **kwargs):
- super().__init__(**kwargs)
+ def __init__(self, name, instrument, snapshot_get, metadata):
+ super().__init__(metadata)
self._snapshot_get = snapshot_get
+ self.name = str(name)
+ self._instrument = instrument
self.has_get = hasattr(self, 'get')
self.has_set = hasattr(self, 'set')
- self._meta_attrs = ['setpoint_names', 'setpoint_labels']
-
- # always let the parameter have a single name (in fact, require this!)
- # even if it has names too
- self.name = str(name)
-
- if names is not None:
- # check for names first - that way you can provide both name
- # AND names for instrument parameters - name is how you get the
- # object (from the parameters dict or the delegated attributes),
- # and names are the items it returns
- self.names = names
- self.labels = names if labels is None else names
- self.units = units if units is not None else [''] * len(names)
-
- self.set_validator(vals or Anything())
- self.__doc__ = os.linesep.join((
- 'Parameter class:' + os.linesep,
- '* `names` %s' % ', '.join(self.names),
- '* `labels` %s' % ', '.join(self.labels),
- '* `units` %s' % ', '.join(self.units)))
- self._meta_attrs.extend(['names', 'labels', 'units'])
-
- elif name is not None:
- self.label = name if label is None else label
- self.units = units if units is not None else ''
- # vals / validate only applies to simple single-value parameters
- self.set_validator(vals)
-
- # generate default docstring
- self.__doc__ = os.linesep.join((
- 'Parameter class:' + os.linesep,
- '* `name` %s' % self.name,
- '* `label` %s' % self.label,
- # TODO is this unit s a typo? shouldnt that be unit?
- '* `units` %s' % self.units,
- '* `vals` %s' % repr(self._vals)))
- self._meta_attrs.extend(['name', 'label', 'units', 'vals'])
-
- else:
- raise ValueError('either name or names is required')
-
- if shape is not None or shapes is not None:
- nt = type(None)
-
- if shape is not None:
- if not is_sequence_of(shape, int):
- raise ValueError('shape must be a tuple of ints, not ' +
- repr(shape))
- self.shape = shape
- depth = 1
- container_str = 'tuple'
- else:
- if not is_sequence_of(shapes, int, depth=2):
- raise ValueError('shapes must be a tuple of tuples '
- 'of ints, not ' + repr(shape))
- self.shapes = shapes
- depth = 2
- container_str = 'tuple of tuples'
-
- sp_types = (nt, DataArray, collections.Sequence,
- collections.Iterator)
- if (setpoints is not None and
- not is_sequence_of(setpoints, sp_types, depth)):
- raise ValueError(
- 'setpoints must be a {} of arrays'.format(container_str))
- if (setpoint_names is not None and
- not is_sequence_of(setpoint_names, (nt, str), depth)):
- raise ValueError('setpoint_names must be a {} '
- 'of strings'.format(container_str))
- if (setpoint_labels is not None and
- not is_sequence_of(setpoint_labels, (nt, str), depth)):
- raise ValueError('setpoint_labels must be a {} '
- 'of strings'.format(container_str))
-
- self.setpoints = setpoints
- self.setpoint_names = setpoint_names
- self.setpoint_labels = setpoint_labels
+ if not (self.has_get or self.has_set):
+ raise AttributeError('A parameter must have either a get or a '
+ 'set method, or both.')
# record of latest value and when it was set or measured
# what exactly this means is different for different subclasses
# but they all use the same attributes so snapshot is consistent.
self._latest_value = None
self._latest_ts = None
+ self.get_latest = GetLatest(self)
- if docstring is not None:
- self.__doc__ = docstring + os.linesep + os.linesep + self.__doc__
-
- self.get_latest = GetLatest(self)
+ # subclasses should extend this list with extra attributes they
+ # want automatically included in the snapshot
+ self._meta_attrs = ['name', 'instrument']
def __repr__(self):
return named_repr(self)
@@ -404,14 +267,14 @@ Source code for qcodes.instrument.parameter
if self.has_get:
return self.get()
else:
- raise NoCommandError('no get cmd found in' +
- ' Parameter {}'.format(self.name))
+ raise NotImplementedError('no get cmd found in' +
+ ' Parameter {}'.format(self.name))
else:
if self.has_set:
self.set(*args)
else:
- raise NoCommandError('no set cmd found in' +
- ' Parameter {}'.format(self.name))
+ raise NotImplementedError('no set cmd found in' +
+ ' Parameter {}'.format(self.name))
def _latest(self):
return {
@@ -422,7 +285,7 @@ Source code for qcodes.instrument.parameter
# get_attrs ignores leading underscores, unless they're in this list
_keep_attrs = ['__doc__', '_vals']
-[docs] def get_attrs(self):
+ def get_attrs(self):
"""
Attributes recreated as properties in the RemoteParameter proxy.
@@ -435,21 +298,23 @@ Source code for qcodes.instrument.parameter
out = []
for attr in dir(self):
+ # while we're keeping units as a deprecated attribute in some
+ # classes, avoid calling it here so we don't get spurious errors
if ((attr[0] == '_' and attr not in self._keep_attrs) or
- callable(getattr(self, attr))):
+ (attr != 'units' and callable(getattr(self, attr)))):
continue
out.append(attr)
- return out
+ return out
-[docs] def snapshot_base(self, update=False):
+ def snapshot_base(self, update=False):
"""
State of the parameter as a JSON-compatible dict.
Args:
update (bool): If True, update the state by calling
- parameter.get().
- If False, just use the latest values in memory.
+ parameter.get().
+ If False, just use the latest values in memory.
Returns:
dict: base snapshot
@@ -465,21 +330,121 @@ Source code for qcodes.instrument.parameter
state['ts'] = state['ts'].strftime('%Y-%m-%d %H:%M:%S')
for attr in set(self._meta_attrs):
- if attr == 'instrument' and getattr(self, '_instrument', None):
+ if attr == 'instrument' and self._instrument:
state.update({
'instrument': full_class(self._instrument),
'instrument_name': self._instrument.name
})
elif hasattr(self, attr):
- state[attr] = getattr(self, attr)
+ val = getattr(self, attr)
+ attr_strip = attr.lstrip('_') # eg _vals - do not include _
+ if isinstance(val, Validator):
+ state[attr_strip] = repr(val)
+ else:
+ state[attr_strip] = val
- return state
+ return state
def _save_val(self, value):
self._latest_value = value
self._latest_ts = datetime.now()
+ @property
+ def full_name(self):
+ """Include the instrument name with the Parameter name if possible."""
+ try:
+ inst_name = self._instrument.name
+ if inst_name:
+ return inst_name + '_' + self.name
+ except AttributeError:
+ pass
+
+ return self.name
+
+
+[docs]class Parameter(_BaseParameter):
+ """
+ A parameter that represents a single degree of freedom.
+ Not necessarily part of an instrument.
+
+ Subclasses should define either a ``set`` method, a ``get`` method, or
+ both.
+
+ Parameters have a ``.get_latest`` method that simply returns the most
+ recent set or measured value. This can be called ( ``param.get_latest()`` )
+ or used in a ``Loop`` as if it were a (gettable-only) parameter itself:
+
+ ``Loop(...).each(param.get_latest)``
+
+ Note: If you want ``.get`` or ``.set`` to save the measurement for
+ ``.get_latest``, you must explicitly call ``self._save_val(value)``
+ inside ``.get`` and ``.set``.
+
+ Args:
+ name (str): the local name of the parameter. Should be a valid
+ identifier, ie no spaces or special characters. If this parameter
+ is part of an Instrument or Station, this is how it will be
+ referenced from that parent, ie ``instrument.name`` or
+ ``instrument.parameters[name]``
+
+ instrument (Optional[Instrument]): the instrument this parameter
+ belongs to, if any
+
+ label (Optional[str]): Normally used as the axis label when this
+ parameter is graphed, along with ``unit``.
+
+ unit (Optional[str]): The unit of measure. Use ``''`` for unitless.
+
+ units (Optional[str]): DEPRECATED, redirects to ``unit``.
+
+ vals (Optional[Validator]): Allowed values for setting this parameter.
+ Only relevant if settable. Defaults to ``Numbers()``
+
+ docstring (Optional[str]): documentation string for the __doc__
+ field of the object. The __doc__ field of the instance is used by
+ some help systems, but not all
+
+ snapshot_get (Optional[bool]): False prevents any update to the
+ parameter during a snapshot, even if the snapshot was called with
+ ``update=True``, for example if it takes too long to update.
+ Default True.
+
+ metadata (Optional[dict]): extra information to include with the
+ JSON snapshot of the parameter
+ """
+[docs] def __init__(self, name, instrument=None, label=None,
+ unit=None, units=None, vals=None, docstring=None,
+ snapshot_get=True, metadata=None):
+ super().__init__(name, instrument, snapshot_get, metadata)
+
+ self._meta_attrs.extend(['label', 'unit', '_vals'])
+
+ self.label = name if label is None else label
+
+ if units is not None:
+ warn_units('Parameter', self)
+ if unit is None:
+ unit = units
+ self.unit = unit if unit is not None else ''
+
+ self.set_validator(vals)
+
+ # generate default docstring
+ self.__doc__ = os.linesep.join((
+ 'Parameter class:',
+ '',
+ '* `name` %s' % self.name,
+ '* `label` %s' % self.label,
+ '* `unit` %s' % self.unit,
+ '* `vals` %s' % repr(self._vals)))
+
+ if docstring is not None:
+ self.__doc__ = os.linesep.join((
+ docstring,
+ '',
+ self.__doc__))
+
[docs] def set_validator(self, vals):
"""
Set a validator `vals` for this parameter.
@@ -502,7 +467,7 @@ Source code for qcodes.instrument.parameter
value (any): value to validate
"""
- if hasattr(self, '_instrument'):
+ if self._instrument:
context = (getattr(self._instrument, 'name', '') or
str(self._instrument.__class__)) + '.' + self.name
else:
@@ -545,26 +510,299 @@ Source code for qcodes.instrument.parameter
return SweepFixedValues(self, keys)
@property
- def full_name(self):
- """Include the instrument name with the Parameter name if possible."""
- if getattr(self, 'name', None) is None:
- return None
+ def units(self):
+ warn_units('Parameter', self)
+ return self.unit
- try:
- inst_name = self._instrument.name
- if inst_name:
- return inst_name + '_' + self.name
- except AttributeError:
- pass
- return self.name
+[docs]class ArrayParameter(_BaseParameter):
+ """
+ A gettable parameter that returns an array of values.
+ Not necessarily part of an instrument.
+
+ Subclasses should define a ``.get`` method, which returns an array.
+ When used in a ``Loop`` or ``Measure`` operation, this will be entered
+ into a single ``DataArray``, with extra dimensions added by the ``Loop``.
+ The constructor args describe the array we expect from each ``.get`` call
+ and how it should be handled.
+
+ For now you must specify upfront the array shape, and this cannot change
+ from one call to the next. Later we intend to require only that you specify
+ the dimension, and the size of each dimension can vary from call to call.
+
+ Note: If you want ``.get`` to save the measurement for ``.get_latest``,
+ you must explicitly call ``self._save_val(items)`` inside ``.get``.
+
+ Args:
+ name (str): the local name of the parameter. Should be a valid
+ identifier, ie no spaces or special characters. If this parameter
+ is part of an Instrument or Station, this is how it will be
+ referenced from that parent, ie ``instrument.name`` or
+ ``instrument.parameters[name]``
+
+ shape (Tuple[int]): The shape (as used in numpy arrays) of the array
+ to expect. Scalars should be denoted by (), 1D arrays as (n,),
+ 2D arrays as (n, m), etc.
+
+ instrument (Optional[Instrument]): the instrument this parameter
+ belongs to, if any
+
+ label (Optional[str]): Normally used as the axis label when this
+ parameter is graphed, along with ``unit``.
+
+ unit (Optional[str]): The unit of measure. Use ``''`` for unitless.
+
+ units (Optional[str]): DEPRECATED, redirects to ``unit``.
+
+ setpoints (Optional[Tuple[setpoint_array]]):
+ ``setpoint_array`` can be a DataArray, numpy.ndarray, or sequence.
+ The setpoints for each dimension of the returned array. An
+ N-dimension item should have N setpoint arrays, where the first is
+ 1D, the second 2D, etc.
+ If omitted for any or all items, defaults to integers from zero in
+ each respective direction.
+ Note: if the setpoints will be different each measurement, leave
+ this out and return the setpoints (with extra names) in ``.get``.
+
+ setpoint_names (Optional[Tuple[str]]): one identifier (like
+ ``name``) per setpoint array. Ignored if a setpoint is a
+ DataArray, which already has a name.
+
+ setpoint_labels (Optional[Tuple[str]]): one label (like ``labels``)
+ per setpoint array. Ignored if a setpoint is a DataArray, which
+ already has a label.
+
+ TODO (alexcjohnson) we need setpoint_units (and in MultiParameter)
+
+ docstring (Optional[str]): documentation string for the __doc__
+ field of the object. The __doc__ field of the instance is used by
+ some help systems, but not all
+
+ snapshot_get (bool): Prevent any update to the parameter, for example
+ if it takes too long to update. Default True.
+
+ metadata (Optional[dict]): extra information to include with the
+ JSON snapshot of the parameter
+ """
+ def __init__(self, name, shape, instrument=None,
+ label=None, unit=None, units=None,
+ setpoints=None, setpoint_names=None, setpoint_labels=None,
+ docstring=None, snapshot_get=True, metadata=None):
+ super().__init__(name, instrument, snapshot_get, metadata)
+
+ if self.has_set: # TODO (alexcjohnson): can we support, ala Combine?
+ raise AttributeError('ArrayParameters do not support set '
+ 'at this time.')
+
+ self._meta_attrs.extend(['setpoint_names', 'setpoint_labels',
+ 'label', 'unit'])
+
+ self.label = name if label is None else label
+
+ if units is not None:
+ warn_units('ArrayParameter', self)
+ if unit is None:
+ unit = units
+ self.unit = unit if unit is not None else ''
+
+ nt = type(None)
+
+ if not is_sequence_of(shape, int):
+ raise ValueError('shapes must be a tuple of ints, not ' +
+ repr(shape))
+ self.shape = shape
+
+ # require one setpoint per dimension of shape
+ sp_shape = (len(shape),)
+
+ sp_types = (nt, DataArray, collections.Sequence,
+ collections.Iterator)
+ if (setpoints is not None and
+ not is_sequence_of(setpoints, sp_types, shape=sp_shape)):
+ raise ValueError('setpoints must be a tuple of arrays')
+ if (setpoint_names is not None and
+ not is_sequence_of(setpoint_names, (nt, str), shape=sp_shape)):
+ raise ValueError('setpoint_names must be a tuple of strings')
+ if (setpoint_labels is not None and
+ not is_sequence_of(setpoint_labels, (nt, str),
+ shape=sp_shape)):
+ raise ValueError('setpoint_labels must be a tuple of strings')
+
+ self.setpoints = setpoints
+ self.setpoint_names = setpoint_names
+ self.setpoint_labels = setpoint_labels
+
+ self.__doc__ = os.linesep.join((
+ 'Parameter class:',
+ '',
+ '* `name` %s' % self.name,
+ '* `label` %s' % self.label,
+ '* `unit` %s' % self.unit,
+ '* `shape` %s' % repr(self.shape)))
+
+ if docstring is not None:
+ self.__doc__ = os.linesep.join((
+ docstring,
+ '',
+ self.__doc__))
+
+ @property
+ def units(self):
+ warn_units('ArrayParameter', self)
+ return self.unit
+
+
+def _is_nested_sequence_or_none(obj, types, shapes):
+ """Validator for MultiParameter setpoints/names/labels"""
+ if obj is None:
+ return True
+
+ if not is_sequence_of(obj, tuple, shape=(len(shapes),)):
+ return False
+
+ for obji, shapei in zip(obj, shapes):
+ if not is_sequence_of(obji, types, shape=(len(shapei),)):
+ return False
+
+ return True
+
+
+[docs]class MultiParameter(_BaseParameter):
+ """
+ A gettable parameter that returns multiple values with separate names,
+ each of arbitrary shape.
+ Not necessarily part of an instrument.
+
+ Subclasses should define a ``.get`` method, which returns a sequence of
+ values. When used in a ``Loop`` or ``Measure`` operation, each of these
+ values will be entered into a different ``DataArray``. The constructor
+ args describe what data we expect from each ``.get`` call and how it
+ should be handled. ``.get`` should always return the same number of items,
+ and most of the constructor arguments should be tuples of that same length.
+
+ For now you must specify upfront the array shape of each item returned by
+ ``.get``, and this cannot change from one call to the next. Later we intend
+ to require only that you specify the dimension of each item returned, and
+ the size of each dimension can vary from call to call.
+
+ Note: If you want ``.get`` to save the measurement for ``.get_latest``,
+ you must explicitly call ``self._save_val(items)`` inside ``.get``.
+
+ Args:
+ name (str): the local name of the whole parameter. Should be a valid
+ identifier, ie no spaces or special characters. If this parameter
+ is part of an Instrument or Station, this is how it will be
+ referenced from that parent, ie ``instrument.name`` or
+ ``instrument.parameters[name]``
+
+ names (Tuple[str]): A name for each item returned by a ``.get``
+ call. Will be used as the basis of the ``DataArray`` names
+ when this parameter is used to create a ``DataSet``.
+
+ shapes (Tuple[Tuple[int]]): The shape (as used in numpy arrays) of
+ each item. Scalars should be denoted by (), 1D arrays as (n,),
+ 2D arrays as (n, m), etc.
+
+ instrument (Optional[Instrument]): the instrument this parameter
+ belongs to, if any
+
+ labels (Optional[Tuple[str]]): A label for each item. Normally used
+ as the axis label when a component is graphed, along with the
+ matching entry from ``units``.
+
+ units (Optional[Tuple[str]]): The unit of measure for each item.
+ Use ``''`` or ``None`` for unitless values.
+
+ setpoints (Optional[Tuple[Tuple[setpoint_array]]]):
+ ``setpoint_array`` can be a DataArray, numpy.ndarray, or sequence.
+ The setpoints for each returned array. An N-dimension item should
+ have N setpoint arrays, where the first is 1D, the second 2D, etc.
+ If omitted for any or all items, defaults to integers from zero in
+ each respective direction.
+ Note: if the setpoints will be different each measurement, leave
+ this out and return the setpoints (with extra names) in ``.get``.
+
+ setpoint_names (Optional[Tuple[Tuple[str]]]): one identifier (like
+ ``name``) per setpoint array. Ignored if a setpoint is a
+ DataArray, which already has a name.
+
+ setpoint_labels (Optional[Tuple[Tuple[str]]]): one label (like
+ ``labels``) per setpoint array. Ignored if a setpoint is a
+ DataArray, which already has a label.
+
+ docstring (Optional[str]): documentation string for the __doc__
+ field of the object. The __doc__ field of the instance is used by
+ some help systems, but not all
+
+ snapshot_get (bool): Prevent any update to the parameter, for example
+ if it takes too long to update. Default True.
+
+ metadata (Optional[dict]): extra information to include with the
+ JSON snapshot of the parameter
+ """
+ def __init__(self, name, names, shapes, instrument=None,
+ labels=None, units=None,
+ setpoints=None, setpoint_names=None, setpoint_labels=None,
+ docstring=None, snapshot_get=True, metadata=None):
+ super().__init__(name, instrument, snapshot_get, metadata)
+
+ if self.has_set: # TODO (alexcjohnson): can we support, ala Combine?
+ raise AttributeError('MultiParameters do not support set '
+ 'at this time.')
+
+ self._meta_attrs.extend(['setpoint_names', 'setpoint_labels',
+ 'names', 'labels', 'units'])
+
+ if not is_sequence_of(names, str):
+ raise ValueError('names must be a tuple of strings, not' +
+ repr(names))
+
+ self.names = names
+ self.labels = labels if labels is not None else names
+ self.units = units if units is not None else [''] * len(names)
+
+ nt = type(None)
+
+ if (not is_sequence_of(shapes, int, depth=2) or
+ len(shapes) != len(names)):
+ raise ValueError('shapes must be a tuple of tuples '
+ 'of ints, not ' + repr(shapes))
+ self.shapes = shapes
+
+ sp_types = (nt, DataArray, collections.Sequence,
+ collections.Iterator)
+ if not _is_nested_sequence_or_none(setpoints, sp_types, shapes):
+ raise ValueError('setpoints must be a tuple of tuples of arrays')
+
+ if not _is_nested_sequence_or_none(setpoint_names, (nt, str), shapes):
+ raise ValueError(
+ 'setpoint_names must be a tuple of tuples of strings')
+
+ if not _is_nested_sequence_or_none(setpoint_labels, (nt, str), shapes):
+ raise ValueError(
+ 'setpoint_labels must be a tuple of tuples of strings')
+
+ self.setpoints = setpoints
+ self.setpoint_names = setpoint_names
+ self.setpoint_labels = setpoint_labels
+
+ self.__doc__ = os.linesep.join((
+ 'MultiParameter class:',
+ '',
+ '* `name` %s' % self.name,
+ '* `names` %s' % ', '.join(self.names),
+ '* `labels` %s' % ', '.join(self.labels),
+ '* `units` %s' % ', '.join(self.units)))
+
+ if docstring is not None:
+ self.__doc__ = os.linesep.join((
+ docstring,
+ '',
+ self.__doc__))
@property
def full_names(self):
"""Include the instrument name with the Parameter names if possible."""
- if getattr(self, 'names', None) is None:
- return None
-
try:
inst_name = self._instrument.name
if inst_name:
@@ -575,16 +813,27 @@ Source code for qcodes.instrument.parameter
return self.names
+[docs]def no_setter(*args, **kwargs):
+ raise NotImplementedError('This Parameter has no setter defined.')
+
+
+[docs]def no_getter(*args, **kwargs):
+ raise NotImplementedError(
+ 'This Parameter has no getter, use .get_latest to get the most recent '
+ 'set value.')
+
+
[docs]class StandardParameter(Parameter):
"""
Define one measurement parameter.
Args:
- name (string): the local name of this parameter
- instrument (Optional[Instrument]): an instrument that handles this
- function. Default None.
+ name (str): the local name of this parameter
- get_cmd (Optional[Union[string, function]]): a string or function to
+ instrument (Optional[Instrument]): the instrument this parameter
+ belongs to, if any
+
+ get_cmd (Optional[Union[str, function]]): a string or function to
get this parameter. You can only use a string if an instrument is
provided, then this string will be passed to instrument.ask
@@ -592,7 +841,7 @@ Source code for qcodes.instrument.parameter
from get to the final output value.
See also val_mapping
- set_cmd (Optional[Union[string, function]]): command to set this
+ set_cmd (Optional[Union[str, function]]): command to set this
parameter, either:
- a string (containing one field to .format, like "{}" etc)
@@ -675,12 +924,10 @@ Source code for qcodes.instrument.parameter
if get_parser is not None and not isinstance(get_cmd, str):
logging.warning('get_parser is set, but will not be used ' +
'(name %s)' % name)
- super().__init__(name=name, vals=vals, **kwargs)
-
- self._instrument = instrument
+ super().__init__(name=name, instrument=instrument, vals=vals, **kwargs)
- self._meta_attrs.extend(['instrument', 'sweep_step', 'sweep_delay',
- 'max_sweep_delay'])
+ self._meta_attrs.extend(['sweep_step', 'sweep_delay',
+ 'max_sweep_delay'])
# stored value from last .set() or .get()
# normally only used by set with a sweep, to avoid
@@ -702,8 +949,7 @@ Source code for qcodes.instrument.parameter
self._save_val(value)
return value
except Exception as e:
- e.args = e.args + (
- 'getting {}:{}'.format(self._instrument.name, self.name),)
+ e.args = e.args + ('getting {}'.format(self.full_name),)
raise e
def _valmapping_get_parser(self, val):
@@ -727,7 +973,7 @@ Source code for qcodes.instrument.parameter
val = int(val)
return self._get_mapping[val]
except (ValueError, KeyError):
- raise KeyError("Unmapped value from instrument: {!r}".format(val))
+ raise KeyError('Unmapped value from instrument: {!r}'.format(val))
def _valmapping_with_preparser(self, val):
return self._valmapping_get_parser(self._get_preparser(val))
@@ -760,8 +1006,7 @@ Source code for qcodes.instrument.parameter
time.sleep(remainder)
except Exception as e:
e.args = e.args + (
- 'setting {}:{} to {}'.format(self._instrument.name,
- self.name, repr(value)),)
+ 'setting {} to {}'.format(self.full_name, repr(value)),)
raise e
def _sweep_steps(self, value):
@@ -821,8 +1066,7 @@ Source code for qcodes.instrument.parameter
time.sleep(remainder)
except Exception as e:
e.args = e.args + (
- 'setting {}:{} to {}'.format(self._instrument.name,
- self.name, repr(value)),)
+ 'setting {} to {}'.format(self.full_name, repr(value)),)
raise e
[docs] def set_step(self, step, max_val_age=None):
@@ -936,21 +1180,20 @@ Source code for qcodes.instrument.parameter
Define one parameter that reflects a manual setting / configuration.
Args:
- name (string): the local name of this parameter
+ name (str): the local name of this parameter
instrument (Optional[Instrument]): the instrument this applies to,
if any.
- initial_value (Optional[string]): starting value, the
+ initial_value (Optional[str]): starting value, the
only invalid value allowed, and None is only allowed as an initial
value, it cannot be set later
**kwargs: Passed to Parameter parent class
"""
def __init__(self, name, instrument=None, initial_value=None, **kwargs):
- super().__init__(name=name, **kwargs)
- self._instrument = instrument
- self._meta_attrs.extend(['instrument', 'initial_value'])
+ super().__init__(name=name, instrument=instrument, **kwargs)
+ self._meta_attrs.extend(['initial_value'])
if initial_value is not None:
self.validate(initial_value)
@@ -959,6 +1202,7 @@ Source code for qcodes.instrument.parameter
[docs] def set(self, value):
"""
Validate and saves value
+
Args:
value (any): value to validate and save
"""
@@ -998,8 +1242,10 @@ Source code for qcodes.instrument.parameter
return self.get()
-[docs]def combine(*parameters, name, label=None, units=None, aggregator=None):
- """Combine parameters into one swepable parameter
+[docs]def combine(*parameters, name, label=None, unit=None, units=None,
+ aggregator=None):
+ """
+ Combine parameters into one sweepable parameter
Args:
*paramters (qcodes.Parameter): the parameters to combine
@@ -1015,7 +1261,8 @@ Source code for qcodes.instrument.parameter
sequantially.
"""
parameters = list(parameters)
- multi_par = CombinedParameter(parameters, name, label, units, aggregator)
+ multi_par = CombinedParameter(parameters, name, label, unit, units,
+ aggregator)
return multi_par
@@ -1023,8 +1270,8 @@ Source code for qcodes.instrument.parameter
""" A combined parameter
Args:
- *paramters (qcodes.Parameter): the parameters to combine
- name (str): the name of the paramter
+ *parameters (qcodes.Parameter): the parameters to combine
+ name (str): the name of the parameter
label (Optional[str]): the label of the combined parameter
unit (Optional[str]): the unit of the combined parameter
aggregator (Optional[Callable[list[any]]]): a function to aggregate
@@ -1033,11 +1280,11 @@ Source code for qcodes.instrument.parameter
A combined parameter sets all the combined parameters at every point of the
sweep.
The sets are called in the same order the parameters are, and
- sequantially.
+ sequentially.
"""
[docs] def __init__(self, parameters, name, label=None,
- units=None, aggregator=None):
+ unit=None, units=None, aggregator=None):
super().__init__()
# TODO(giulioungaretti)temporary hack
# starthack
@@ -1047,7 +1294,12 @@ Source code for qcodes.instrument.parameter
self.parameter.full_name = name
self.parameter.name = name
self.parameter.label = label
- self.parameter.units = units
+
+ if units is not None:
+ warn_units('CombinedParameter', self)
+ if unit is None:
+ unit = units
+ self.parameter.unit = unit
# endhack
self.parameters = parameters
self.sets = [parameter.set for parameter in self.parameters]
@@ -1063,6 +1315,7 @@ Source code for qcodes.instrument.parameter
Args:
index (int): the index of the setpoints one wants to set
+
Returns:
list: values that where actually set
"""
@@ -1092,7 +1345,7 @@ Source code for qcodes.instrument.parameter
if len(array) > 1:
dim = set([len(a) for a in array])
if len(dim) != 1:
- raise ValueError("Arrays have different number of setpoints")
+ raise ValueError('Arrays have different number of setpoints')
array = numpy.array(array).transpose()
else:
# cast to array in case users
@@ -1139,10 +1392,10 @@ Source code for qcodes.instrument.parameter
"""
meta_data = collections.OrderedDict()
meta_data['__class__'] = full_class(self)
- meta_data["units"] = self.parameter.units
- meta_data["label"] = self.parameter.label
- meta_data["full_name"] = self.parameter.full_name
- meta_data["aggreagator"] = repr(getattr(self, 'f', None))
+ meta_data['unit'] = self.parameter.unit
+ meta_data['label'] = self.parameter.label
+ meta_data['full_name'] = self.parameter.full_name
+ meta_data['aggreagator'] = repr(getattr(self, 'f', None))
for param in self.parameters:
meta_data[param.full_name] = param.snapshot()
diff --git a/_modules/qcodes/instrument/visa.html b/_modules/qcodes/instrument/visa.html
index f79d920685b..f1b99efd52b 100644
--- a/_modules/qcodes/instrument/visa.html
+++ b/_modules/qcodes/instrument/visa.html
@@ -188,7 +188,7 @@ Source code for qcodes.instrument.visa
self.add_parameter('timeout',
get_cmd=self._get_visa_timeout,
set_cmd=self._set_visa_timeout,
- units='s',
+ unit='s',
vals=vals.MultiType(vals.Numbers(min_value=0),
vals.Enum(None)))
diff --git a/_modules/qcodes/instrument_drivers/rohde_schwarz/ZNB20.html b/_modules/qcodes/instrument_drivers/rohde_schwarz/ZNB20.html
index d51164b36bd..3f50995a0f3 100644
--- a/_modules/qcodes/instrument_drivers/rohde_schwarz/ZNB20.html
+++ b/_modules/qcodes/instrument_drivers/rohde_schwarz/ZNB20.html
@@ -141,10 +141,10 @@ Source code for qcodes.instrument_drivers.rohde_schwarz.ZNB20
from qcodes.utils import validators as vals
from cmath import phase
import numpy as np
-from qcodes import Parameter
+from qcodes import MultiParameter, Parameter
-[docs]class FrequencySweep(Parameter):
+[docs]class FrequencySweep(MultiParameter):
"""
Hardware controlled parameter class for Rohde Schwarz RSZNB20 trace.
@@ -208,7 +208,7 @@ Source code for qcodes.instrument_drivers.rohde_schwarz.ZNB20
self.add_parameter(name='power',
label='Power',
- units='dBm',
+ unit='dBm',
get_cmd='SOUR:POW?',
set_cmd='SOUR:POW {:.4f}',
get_parser=int,
@@ -216,7 +216,7 @@ Source code for qcodes.instrument_drivers.rohde_schwarz.ZNB20
self.add_parameter(name='bandwidth',
label='Bandwidth',
- units='Hz',
+ unit='Hz',
get_cmd='SENS:BAND?',
set_cmd='SENS:BAND {:.4f}',
get_parser=int,
@@ -224,7 +224,7 @@ Source code for qcodes.instrument_drivers.rohde_schwarz.ZNB20
self.add_parameter(name='avg',
label='Averages',
- units='',
+ unit='',
get_cmd='AVER:COUN?',
set_cmd='AVER:COUN {:.4f}',
get_parser=int,
diff --git a/_modules/qcodes/tests/instrument_mocks.html b/_modules/qcodes/tests/instrument_mocks.html
index ba8d20b8402..4f185782a60 100644
--- a/_modules/qcodes/tests/instrument_mocks.html
+++ b/_modules/qcodes/tests/instrument_mocks.html
@@ -143,7 +143,7 @@ Source code for qcodes.tests.instrument_mocks
from qcodes.instrument.base import Instrument
from qcodes.instrument.mock import MockInstrument, MockModel
from qcodes.utils.validators import Numbers
-from qcodes.instrument.parameter import Parameter, ManualParameter
+from qcodes.instrument.parameter import MultiParameter, ManualParameter
[docs]class AMockModel(MockModel):
@@ -358,18 +358,18 @@ Source code for qcodes.tests.instrument_mocks
# Instrument parameters
for parname in ['x', 'y', 'z']:
- self.add_parameter(parname, units='a.u.',
+ self.add_parameter(parname, unit='a.u.',
parameter_class=ManualParameter,
vals=Numbers(), initial_value=0)
- self.add_parameter('noise', units='a.u.',
+ self.add_parameter('noise', unit='a.u.',
label='white noise amplitude',
parameter_class=ManualParameter,
vals=Numbers(), initial_value=0)
- self.add_parameter('parabola', units='a.u.',
+ self.add_parameter('parabola', unit='a.u.',
get_cmd=self._measure_parabola)
- self.add_parameter('skewed_parabola', units='a.u.',
+ self.add_parameter('skewed_parabola', unit='a.u.',
get_cmd=self._measure_skewed_parabola)
def _measure_parabola(self):
@@ -397,15 +397,15 @@ Source code for qcodes.tests.instrument_mocks
# Instrument parameters
for parname in ['x', 'y', 'z']:
- self.add_parameter(parname, units='a.u.',
+ self.add_parameter(parname, unit='a.u.',
parameter_class=ManualParameter,
vals=Numbers(), initial_value=0)
self.add_parameter('gain', parameter_class=ManualParameter,
initial_value=1)
- self.add_parameter('parabola', units='a.u.',
+ self.add_parameter('parabola', unit='a.u.',
get_cmd=self._get_parabola)
- self.add_parameter('skewed_parabola', units='a.u.',
+ self.add_parameter('skewed_parabola', unit='a.u.',
get_cmd=self._get_skew_parabola)
def _get_parabola(self):
@@ -440,7 +440,7 @@ Source code for qcodes.tests.instrument_mocks
vals=Numbers(-800, 400))
-[docs]class MultiGetter(Parameter):
+[docs]class MultiGetter(MultiParameter):
"""
Test parameters with complicated return values
instantiate with kwargs::
@@ -456,15 +456,10 @@ Source code for qcodes.tests.instrument_mocks
"""
def __init__(self, **kwargs):
- if len(kwargs) == 1:
- name, self._return = list(kwargs.items())[0]
- super().__init__(name=name)
- self.shape = np.shape(self._return)
- else:
- names = tuple(sorted(kwargs.keys()))
- super().__init__(names=names)
- self._return = tuple(kwargs[k] for k in names)
- self.shapes = tuple(np.shape(v) for v in self._return)
+ names = tuple(sorted(kwargs.keys()))
+ self._return = tuple(kwargs[k] for k in names)
+ shapes = tuple(np.shape(v) for v in self._return)
+ super().__init__(name='multigetter', names=names, shapes=shapes)
diff --git a/_modules/qcodes/tests/test_combined_par.html b/_modules/qcodes/tests/test_combined_par.html
index b130ec950ad..b69471cce1a 100644
--- a/_modules/qcodes/tests/test_combined_par.html
+++ b/_modules/qcodes/tests/test_combined_par.html
@@ -228,18 +228,18 @@ Source code for qcodes.tests.test_combined_par
[docs] def testMeta(self):
name = "combined"
label = "Linear Combination"
- units = "a.u"
+ unit = "a.u"
aggregator = linear
sweep_values = combine(*self.parameters,
name=name,
label=label,
- units=units,
+ unit=unit,
aggregator=aggregator
)
snap = sweep_values.snapshot()
out = OrderedDict()
out['__class__'] = full_class(sweep_values)
- out["units"] = units
+ out["unit"] = unit
out["label"] = label
out["full_name"] = name
out["aggreagator"] = repr(linear)
diff --git a/_modules/qcodes/tests/test_data.html b/_modules/qcodes/tests/test_data.html
index 193b1b89556..c6fdfb9fb77 100644
--- a/_modules/qcodes/tests/test_data.html
+++ b/_modules/qcodes/tests/test_data.html
@@ -775,7 +775,6 @@
Source code for qcodes.tests.test_data
self.assertEqual(data.fraction_complete(), 0.75)
[docs] def mock_sync(self):
- # import pdb; pdb.set_trace()
i = self.sync_index
self.syncing_array[i] = i
self.sync_index = i + 1
diff --git a/_modules/qcodes/tests/test_hdf5formatter.html b/_modules/qcodes/tests/test_hdf5formatter.html
index 4047fbb5944..dea5f452953 100644
--- a/_modules/qcodes/tests/test_hdf5formatter.html
+++ b/_modules/qcodes/tests/test_hdf5formatter.html
@@ -331,7 +331,7 @@ Source code for qcodes.tests.test_hdf5formatter
<
formatter=self.formatter)
d_array = DataArray(name='dummy',
array_id='x_set', # existing array id in data
- label='bla', units='a.u.', is_setpoint=False,
+ label='bla', unit='a.u.', is_setpoint=False,
set_arrays=(), preset_data=np.zeros(5))
data2.add_array(d_array)
# test if d_array refers to same as array x_set in dataset
diff --git a/_modules/qcodes/tests/test_helpers.html b/_modules/qcodes/tests/test_helpers.html
index 1d5ca891338..c3d3b531e46 100644
--- a/_modules/qcodes/tests/test_helpers.html
+++ b/_modules/qcodes/tests/test_helpers.html
@@ -648,13 +648,17 @@ Source code for qcodes.tests.test_helpers
([1, 2, 3], int),
((1, 2, 3), int),
([1, 2.0], (int, float)),
- ([{}, None], (type(None), dict))
+ ([{}, None], (type(None), dict)),
+ # omit type (or set None) and we don't test type at all
+ ([1, '2', dict],),
+ ([1, '2', dict], None)
]
for args in good:
with self.subTest(args=args):
self.assertTrue(is_sequence_of(*args))
bad = [
+ (1,),
(1, int),
([1, 2.0], int),
([1, 2], float),
@@ -664,21 +668,20 @@ Source code for qcodes.tests.test_helpers
with self.subTest(args=args):
self.assertFalse(is_sequence_of(*args))
- # second arg must be a type or tuple of types - failing this doesn't
- # return False, it raises an error
+ # second arg, if provided, must be a type or tuple of types
+ # failing this doesn't return False, it raises an error
with self.assertRaises(TypeError):
is_sequence_of([1], 1)
with self.assertRaises(TypeError):
- is_sequence_of([1], (1, 2))
- with self.assertRaises(TypeError):
- is_sequence_of([1])
+ is_sequence_of([1], (1, 2))
[docs] def test_depth(self):
good = [
([1, 2], int, 1),
([[1, 2], [3, 4]], int, 2),
([[1, 2.0], []], (int, float), 2),
- ([[[1]]], int, 3)
+ ([[[1]]], int, 3),
+ ([[1, 2], [3, 4]], None, 2)
]
for args in good:
with self.subTest(args=args):
@@ -691,7 +694,45 @@ Source code for qcodes.tests.test_helpers
]
for args in bad:
with self.subTest(args=args):
- self.assertFalse(is_sequence_of(*args))
+ self.assertFalse(is_sequence_of(*args))
+
+[docs] def test_shape(self):
+ good = [
+ ([1, 2], int, (2,)),
+ ([[1, 2, 3], [4, 5, 6.0]], (int, float), (2, 3)),
+ ([[[1]]], int, (1, 1, 1)),
+ ([[1], [2]], None, (2, 1)),
+ # if you didn't have `list` as a type, the shape of this one
+ # would be (2, 2) - that's tested in bad below
+ ([[1, 2], [3, 4]], list, (2,)),
+ (((0, 1, 2), ((0, 1), (0, 1), (0, 1))), tuple, (2,)),
+ (((0, 1, 2), ((0, 1), (0, 1), (0, 1))), (tuple, int), (2, 3))
+ ]
+ for obj, types, shape in good:
+ with self.subTest(obj=obj):
+ self.assertTrue(is_sequence_of(obj, types, shape=shape))
+
+ bad = [
+ ([1], int, (2,)),
+ ([[1]], int, (1,)),
+ ([[1, 2], [1]], int, (2, 2)),
+ ([[1]], float, (1, 1)),
+ ([[1, 2], [3, 4]], int, (2, )),
+ (((0, 1, 2), ((0, 1), (0, 1))), (tuple, int), (2, 3))
+ ]
+ for obj, types, shape in bad:
+ with self.subTest(obj=obj):
+ self.assertFalse(is_sequence_of(obj, types, shape=shape))
+
+[docs] def test_shape_depth(self):
+ # there's no reason to provide both shape and depth, but
+ # we allow it if they are self-consistent
+ with self.assertRaises(ValueError):
+ is_sequence_of([], int, depth=1, shape=(2, 2))
+
+ self.assertFalse(is_sequence_of([1], int, depth=1, shape=(2,)))
+ self.assertTrue(is_sequence_of([1], int, depth=1, shape=(1,)))
+
# tests related to JSON encoding
[docs]class TestJSONencoder(TestCase):
@@ -703,20 +744,19 @@ Source code for qcodes.tests.test_helpers
od = OrderedDict()
od['a'] = 0
od['b'] = 1
- testinput=[10, float(10.), 'hello', od]
- testoutput=['10', '10.0', '"hello"', '{"a": 0, "b": 1}']
+ testinput = [10, float(10.), 'hello', od]
+ testoutput = ['10', '10.0', '"hello"', '{"a": 0, "b": 1}']
# int
for d, r in zip(testinput, testoutput):
- v=e.encode(d)
+ v = e.encode(d)
if type(d) == dict:
self.assertDictEqual(v, r)
else:
self.assertEqual(v, r)
-
# test numpy array
- x=np.array([1,0,0])
- v=e.encode(x)
+ x = np.array([1, 0, 0])
+ v = e.encode(x)
self.assertEqual(v, '[1, 0, 0]')
# test class
@@ -726,6 +766,7 @@ Source code for qcodes.tests.test_helpers
# return value
e.encode(dummy())
+
[docs]class TestCompareDictionaries(TestCase):
[docs] def test_same(self):
# NOTE(alexcjohnson): the numpy array and list compare equal,
diff --git a/_modules/qcodes/tests/test_instrument.html b/_modules/qcodes/tests/test_instrument.html
index 6844da1431d..9687f7d14ef 100644
--- a/_modules/qcodes/tests/test_instrument.html
+++ b/_modules/qcodes/tests/test_instrument.html
@@ -706,8 +706,9 @@ Source code for qcodes.tests.test_instrument
'label': 'IDN',
'name': 'IDN',
'ts': None,
- 'units': '',
- 'value': None
+ 'unit': '',
+ 'value': None,
+ 'vals': '<Anything>'
},
'amplitude': {
'__class__': (
@@ -717,8 +718,9 @@ Source code for qcodes.tests.test_instrument
'label': 'amplitude',
'name': 'amplitude',
'ts': None,
- 'units': '',
- 'value': None
+ 'unit': '',
+ 'value': None,
+ 'vals': '<Numbers>'
}
},
'functions': {'echo': {}}
@@ -744,8 +746,9 @@ Source code for qcodes.tests.test_instrument
'label': 'noise',
'name': 'noise',
'ts': None,
- 'units': '',
- 'value': None
+ 'unit': '',
+ 'value': None,
+ 'vals': '<Numbers>'
})
noise.set(100)
@@ -882,32 +885,32 @@ Source code for qcodes.tests.test_instrument
self.assertIn('not the same function as the original method',
method.__doc__)
- # units is a remote attribute of parameters
+ # unit is a remote attribute of parameters
# this one is initially blank
- self.assertEqual(parameter.units, '')
- parameter.units = 'Smoots'
- self.assertEqual(parameter.units, 'Smoots')
- self.assertNotIn('units', parameter.__dict__)
- self.assertEqual(instrument.getattr(parameter.name + '.units'),
+ self.assertEqual(parameter.unit, '')
+ parameter.unit = 'Smoots'
+ self.assertEqual(parameter.unit, 'Smoots')
+ self.assertNotIn('unit', parameter.__dict__)
+ self.assertEqual(instrument.getattr(parameter.name + '.unit'),
'Smoots')
# we can delete it remotely, and this is reflected in dir()
- self.assertIn('units', dir(parameter))
- del parameter.units
- self.assertNotIn('units', dir(parameter))
+ self.assertIn('unit', dir(parameter))
+ del parameter.unit
+ self.assertNotIn('unit', dir(parameter))
with self.assertRaises(AttributeError):
- parameter.units
+ parameter.unit
# and set it again, it's still remote.
- parameter.units = 'Furlongs per fortnight'
- self.assertIn('units', dir(parameter))
- self.assertEqual(parameter.units, 'Furlongs per fortnight')
- self.assertNotIn('units', parameter.__dict__)
- self.assertEqual(instrument.getattr(parameter.name + '.units'),
+ parameter.unit = 'Furlongs per fortnight'
+ self.assertIn('unit', dir(parameter))
+ self.assertEqual(parameter.unit, 'Furlongs per fortnight')
+ self.assertNotIn('unit', parameter.__dict__)
+ self.assertEqual(instrument.getattr(parameter.name + '.unit'),
'Furlongs per fortnight')
# we get the correct result if someone else sets it on the server
- instrument._write_server('setattr', parameter.name + '.units', 'T')
- self.assertEqual(parameter.units, 'T')
- self.assertEqual(parameter.getattr('units'), 'T')
+ instrument._write_server('setattr', parameter.name + '.unit', 'T')
+ self.assertEqual(parameter.unit, 'T')
+ self.assertEqual(parameter.getattr('unit'), 'T')
# attributes not specified as remote are local
with self.assertRaises(AttributeError):
diff --git a/_modules/qcodes/tests/test_loop.html b/_modules/qcodes/tests/test_loop.html
index fc2af6620fb..45402eb25c0 100644
--- a/_modules/qcodes/tests/test_loop.html
+++ b/_modules/qcodes/tests/test_loop.html
@@ -379,7 +379,7 @@ Source code for qcodes.tests.test_loop
bg1 = get_bg(return_first=True)
self.assertIn(bg1, [p1, p2])
- halt_bg(timeout=0.01)
+ halt_bg(timeout=0.05)
bg2 = get_bg()
self.assertIn(bg2, [p1, p2])
# is this robust? requires that active_children always returns the same
@@ -388,7 +388,7 @@ Source code for qcodes.tests.test_loop
self.assertEqual(len(mp.active_children()), 1)
- halt_bg(timeout=0.01)
+ halt_bg(timeout=0.05)
self.assertIsNone(get_bg())
self.assertEqual(len(mp.active_children()), 0)
@@ -598,7 +598,7 @@ Source code for qcodes.tests.test_loop
mg = MultiGetter(one=1, onetwo=(1, 2))
self.assertTrue(hasattr(mg, 'names'))
self.assertTrue(hasattr(mg, 'shapes'))
- self.assertEqual(mg.name, 'None')
+ self.assertEqual(mg.name, 'multigetter')
self.assertFalse(hasattr(mg, 'shape'))
loop = Loop(self.p1[1:3:1], 0.001).each(mg)
data = loop.run_temp()
@@ -650,12 +650,12 @@ Source code for qcodes.tests.test_loop
with self.assertRaises(ValueError):
loop.run_temp()
- # this one has name and shape
+ # this one still has names and shapes
mg = MultiGetter(arr=(4, 5, 6))
self.assertTrue(hasattr(mg, 'name'))
- self.assertTrue(hasattr(mg, 'shape'))
- self.assertFalse(hasattr(mg, 'names'))
- self.assertFalse(hasattr(mg, 'shapes'))
+ self.assertFalse(hasattr(mg, 'shape'))
+ self.assertTrue(hasattr(mg, 'names'))
+ self.assertTrue(hasattr(mg, 'shapes'))
loop = Loop(self.p1[1:3:1], 0.001).each(mg)
data = loop.run_temp()
diff --git a/_modules/qcodes/tests/test_parameter.html b/_modules/qcodes/tests/test_parameter.html
index ea1bf4c6995..51301a58d41 100644
--- a/_modules/qcodes/tests/test_parameter.html
+++ b/_modules/qcodes/tests/test_parameter.html
@@ -144,115 +144,525 @@ Source code for qcodes.tests.test_parameter
from unittest import TestCase
from qcodes import Function
-from qcodes.instrument.parameter import (Parameter, ManualParameter,
- StandardParameter)
+from qcodes.instrument.parameter import (
+ Parameter, ArrayParameter, MultiParameter,
+ ManualParameter, StandardParameter)
+from qcodes.utils.helpers import LogCapture
from qcodes.utils.validators import Numbers
-[docs]class TestParamConstructor(TestCase):
-
-[docs] def test_name_s(self):
- p = Parameter('simple')
- self.assertEqual(p.name, 'simple')
+[docs]class GettableParam(Parameter):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self._get_count = 0
+
+
+
+
+[docs]class SimpleManualParam(Parameter):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self._save_val(0)
+ self._v = 0
+
+
+
+
+
+
+[docs]class SettableParam(Parameter):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self._save_val(0)
+ self._v = 0
+
+
+
+
+blank_instruments = (
+ None, # no instrument at all
+ namedtuple('noname', '')(), # no .name
+ namedtuple('blank', 'name')('') # blank .name
+)
+named_instrument = namedtuple('yesname', 'name')('astro')
+
+
+[docs]class TestParameter(TestCase):
+
+
+[docs] def test_default_attributes(self):
+ # Test the default attributes, providing only a name
+ name = 'repetitions'
+ p = GettableParam(name)
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.label, name)
+ self.assertEqual(p.unit, '')
+ self.assertEqual(p.full_name, name)
+
+ # default validator is all numbers
+ p.validate(-1000)
+ with self.assertRaises(TypeError):
+ p.validate('not a number')
+
+ # docstring exists, even without providing one explicitly
+ self.assertIn(name, p.__doc__)
+
+ # test snapshot_get by looking at _get_count
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 1)
+ snap_expected = {
+ 'name': name,
+ 'label': name,
+ 'unit': '',
+ 'value': 42,
+ 'vals': repr(Numbers())
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
+
+[docs] def test_explicit_attributes(self):
+ # Test the explicit attributes, providing everything we can
+ name = 'volt'
+ label = 'Voltage'
+ unit = 'V'
+ docstring = 'DOCS!'
+ metadata = {'gain': 100}
+ p = GettableParam(name, label=label, unit=unit,
+ vals=Numbers(5, 10), docstring=docstring,
+ snapshot_get=False, metadata=metadata)
+
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.label, label)
+ self.assertEqual(p.unit, unit)
+ self.assertEqual(p.full_name, name)
with self.assertRaises(ValueError):
- # you need a name of some sort
- Parameter()
+ p.validate(-1000)
+ p.validate(6)
+ with self.assertRaises(TypeError):
+ p.validate('not a number')
- # or names
- names = ['H1', 'L1']
- p = Parameter(names=names)
- self.assertEqual(p.names, names)
- # if you don't provide a name, it's called 'None'
- # TODO: we should probably require an explicit name.
- self.assertEqual(p.name, 'None')
+ self.assertIn(name, p.__doc__)
+ self.assertIn(docstring, p.__doc__)
- # or both, that's OK too.
- names = ['Peter', 'Paul', 'Mary']
- p = Parameter(name='complex', names=names)
- self.assertEqual(p.names, names)
- # You can always have a name along with names
- self.assertEqual(p.name, 'complex')
-
- shape = (10,)
- setpoints = (range(10),)
- setpoint_names = ('my_sp',)
- setpoint_labels = ('A label!',)
- p = Parameter('makes_array', shape=shape, setpoints=setpoints,
- setpoint_names=setpoint_names,
- setpoint_labels=setpoint_labels)
- self.assertEqual(p.shape, shape)
- self.assertFalse(hasattr(p, 'shapes'))
- self.assertEqual(p.setpoints, setpoints)
- self.assertEqual(p.setpoint_names, setpoint_names)
- self.assertEqual(p.setpoint_labels, setpoint_labels)
+ # test snapshot_get by looking at _get_count
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 0)
+ snap_expected = {
+ 'name': name,
+ 'label': label,
+ 'unit': unit,
+ 'vals': repr(Numbers(5, 10)),
+ 'metadata': metadata
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
- shapes = ((2,), (3,))
- setpoints = ((range(2),), (range(3),))
- setpoint_names = (('sp1',), ('sp2',))
- setpoint_labels = (('first label',), ('second label',))
- p = Parameter('makes arrays', shapes=shapes, setpoints=setpoints,
- setpoint_names=setpoint_names,
- setpoint_labels=setpoint_labels)
- self.assertEqual(p.shapes, shapes)
- self.assertFalse(hasattr(p, 'shape'))
- self.assertEqual(p.setpoints, setpoints)
- self.assertEqual(p.setpoint_names, setpoint_names)
- self.assertEqual(p.setpoint_labels, setpoint_labels)
+ # attributes only available in MultiParameter
+ for attr in ['names', 'labels', 'setpoints', 'setpoint_names',
+ 'setpoint_labels', 'full_names']:
+ self.assertFalse(hasattr(p, attr), attr)
+
+[docs] def test_units(self):
+ with LogCapture() as logs:
+ p = GettableParam('p', units='V')
+
+ self.assertIn('deprecated', logs.value)
+ self.assertEqual(p.unit, 'V')
+
+ with LogCapture() as logs:
+ self.assertEqual(p.units, 'V')
+
+ self.assertIn('deprecated', logs.value)
+
+ with LogCapture() as logs:
+ p = GettableParam('p', unit='Tesla', units='Gauss')
+
+ self.assertIn('deprecated', logs.value)
+ self.assertEqual(p.unit, 'Tesla')
+
+ with LogCapture() as logs:
+ self.assertEqual(p.units, 'Tesla')
-
+
+[docs] def test_repr(self):
for i in [0, "foo", "", "fåil"]:
with self.subTest(i=i):
- param = Parameter(name=i)
+ param = GettableParam(name=i)
s = param.__repr__()
st = '<{}.{}: {} at {}>'.format(
param.__module__, param.__class__.__name__,
param.name, id(param))
self.assertEqual(s, st)
- blank_instruments = (
- None, # no instrument at all
- namedtuple('noname', '')(), # no .name
- namedtuple('blank', 'name')('') # blank .name
- )
- named_instrument = namedtuple('yesname', 'name')('astro')
-
-[docs] def test_full_name(self):
+[docs] def test_has_set_get(self):
+ # you can't instantiate a Parameter directly anymore, only a subclass,
+ # because you need a get or a set method.
+ with self.assertRaises(AttributeError):
+ Parameter('no_get_or_set')
+
+ gp = GettableParam('1')
+ self.assertTrue(gp.has_get)
+ self.assertFalse(gp.has_set)
+ with self.assertRaises(NotImplementedError):
+ gp(1)
+
+ sp = SettableParam('2')
+ self.assertFalse(sp.has_get)
+ self.assertTrue(sp.has_set)
+ with self.assertRaises(NotImplementedError):
+ sp()
+
+ sgp = SimpleManualParam('3')
+ self.assertTrue(sgp.has_get)
+ self.assertTrue(sgp.has_set)
+ sgp(22)
+ self.assertEqual(sgp(), 22)
+
+[docs] def test_full_name(self):
# three cases where only name gets used for full_name
- for instrument in self.blank_instruments:
- p = Parameter(name='fred')
+ for instrument in blank_instruments:
+ p = GettableParam(name='fred')
p._instrument = instrument
self.assertEqual(p.full_name, 'fred')
- p.name = None
- self.assertEqual(p.full_name, None)
-
# and finally an instrument that really has a name
- p = Parameter(name='wilma')
- p._instrument = self.named_instrument
- self.assertEqual(p.full_name, 'astro_wilma')
+ p = GettableParam(name='wilma')
+ p._instrument = named_instrument
+ self.assertEqual(p.full_name, 'astro_wilma')
+
+[docs] def test_bad_validator(self):
+ with self.assertRaises(TypeError):
+ GettableParam('p', vals=[1, 2, 3])
+
+
+[docs]class SimpleArrayParam(ArrayParameter):
+ def __init__(self, return_val, *args, **kwargs):
+ self._return_val = return_val
+ self._get_count = 0
+ super().__init__(*args, **kwargs)
+
+[docs] def get(self):
+ self._get_count += 1
+ self._save_val(self._return_val)
+ return self._return_val
+
+
+[docs]class SettableArray(SimpleArrayParam):
+ # this is not allowed - just created to raise an error in the test below
+
- p.name = None
- self.assertEqual(p.full_name, None)
-[docs] def test_full_names(self):
- for instrument in self.blank_instruments:
- # no instrument
- p = Parameter(name='simple')
+[docs]class TestArrayParameter(TestCase):
+[docs] def test_default_attributes(self):
+ name = 'array_param'
+ shape = (2, 3)
+ p = SimpleArrayParam([[1, 2, 3], [4, 5, 6]], name, shape)
+
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.shape, shape)
+
+ self.assertEqual(p.label, name)
+ self.assertEqual(p.unit, '')
+ self.assertIsNone(p.setpoints)
+ self.assertIsNone(p.setpoint_names)
+ self.assertIsNone(p.setpoint_labels)
+
+ self.assertEqual(p.full_name, name)
+
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 1)
+ snap_expected = {
+ 'name': name,
+ 'label': name,
+ 'unit': '',
+ 'value': [[1, 2, 3], [4, 5, 6]]
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
+
+ self.assertIn(name, p.__doc__)
+
+[docs] def test_explicit_attrbutes(self):
+ name = 'tiny_array'
+ shape = (2,)
+ label = 'it takes two to tango'
+ unit = 'steps'
+ setpoints = [(0, 1)]
+ setpoint_names = ['sp_index']
+ setpoint_labels = ['Setpoint Label']
+ docstring = 'Whats up Doc?'
+ metadata = {'size': 2}
+ p = SimpleArrayParam([6, 7], name, shape, label=label, unit=unit,
+ setpoints=setpoints,
+ setpoint_names=setpoint_names,
+ setpoint_labels=setpoint_labels,
+ docstring=docstring, snapshot_get=False,
+ metadata=metadata)
+
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.shape, shape)
+ self.assertEqual(p.label, label)
+ self.assertEqual(p.unit, unit)
+ self.assertEqual(p.setpoints, setpoints)
+ self.assertEqual(p.setpoint_names, setpoint_names)
+ self.assertEqual(p.setpoint_labels, setpoint_labels)
+
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 0)
+ snap_expected = {
+ 'name': name,
+ 'label': label,
+ 'unit': unit,
+ 'setpoint_names': setpoint_names,
+ 'setpoint_labels': setpoint_labels,
+ 'metadata': metadata
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
+
+ self.assertIn(name, p.__doc__)
+ self.assertIn(docstring, p.__doc__)
+
+[docs] def test_units(self):
+ with LogCapture() as logs:
+ p = SimpleArrayParam([6, 7], 'p', (2,), units='V')
+
+ self.assertIn('deprecated', logs.value)
+ self.assertEqual(p.unit, 'V')
+
+ with LogCapture() as logs:
+ self.assertEqual(p.units, 'V')
+
+ self.assertIn('deprecated', logs.value)
+
+ with LogCapture() as logs:
+ p = SimpleArrayParam([6, 7], 'p', (2,),
+ unit='Tesla', units='Gauss')
+
+ self.assertIn('deprecated', logs.value)
+ self.assertEqual(p.unit, 'Tesla')
+
+ with LogCapture() as logs:
+ self.assertEqual(p.units, 'Tesla')
+
+ self.assertIn('deprecated', logs.value)
+
+[docs] def test_has_set_get(self):
+ name = 'array_param'
+ shape = (3,)
+ with self.assertRaises(AttributeError):
+ ArrayParameter(name, shape)
+
+ p = SimpleArrayParam([1, 2, 3], name, shape)
+
+ self.assertTrue(p.has_get)
+ self.assertFalse(p.has_set)
+
+ with self.assertRaises(AttributeError):
+ SettableArray([1, 2, 3], name, shape)
+
+[docs] def test_full_name(self):
+ # three cases where only name gets used for full_name
+ for instrument in blank_instruments:
+ p = SimpleArrayParam([6, 7], 'fred', (2,))
p._instrument = instrument
- self.assertEqual(p.full_names, None)
+ self.assertEqual(p.full_name, 'fred')
- p = Parameter(names=['a', 'b'])
+ # and finally an instrument that really has a name
+ p = SimpleArrayParam([6, 7], 'wilma', (2,))
+ p._instrument = named_instrument
+ self.assertEqual(p.full_name, 'astro_wilma')
+
+[docs] def test_constructor_errors(self):
+ bad_constructors = [
+ {'shape': [[3]]}, # not a depth-1 sequence
+ {'shape': [3], 'setpoints': [1, 2, 3]}, # should be [[1, 2, 3]]
+ {'shape': [3], 'setpoint_names': 'index'}, # should be ['index']
+ {'shape': [3], 'setpoint_labels': 'the index'}, # ['the index']
+ {'shape': [3], 'setpoint_names': [None, 'index2']}
+ ]
+ for kwargs in bad_constructors:
+ with self.subTest(**kwargs):
+ with self.assertRaises(ValueError):
+ SimpleArrayParam([1, 2, 3], 'p', **kwargs)
+
+
+[docs]class SimpleMultiParam(MultiParameter):
+ def __init__(self, return_val, *args, **kwargs):
+ self._return_val = return_val
+ self._get_count = 0
+ super().__init__(*args, **kwargs)
+
+[docs] def get(self):
+ self._get_count += 1
+ self._save_val(self._return_val)
+ return self._return_val
+
+
+[docs]class SettableMulti(SimpleMultiParam):
+ # this is not allowed - just created to raise an error in the test below
+
+
+
+[docs]class TestMultiParameter(TestCase):
+[docs] def test_default_attributes(self):
+ name = 'mixed_dimensions'
+ names = ['0D', '1D', '2D']
+ shapes = ((), (3,), (2, 2))
+ p = SimpleMultiParam([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes)
+
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.names, names)
+ self.assertEqual(p.shapes, shapes)
+
+ self.assertEqual(p.labels, names)
+ self.assertEqual(p.units, [''] * 3)
+ self.assertIsNone(p.setpoints)
+ self.assertIsNone(p.setpoint_names)
+ self.assertIsNone(p.setpoint_labels)
+
+ self.assertEqual(p.full_name, name)
+
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 1)
+ snap_expected = {
+ 'name': name,
+ 'names': names,
+ 'labels': names,
+ 'units': [''] * 3,
+ 'value': [0, [1, 2, 3], [[4, 5], [6, 7]]]
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
+
+ self.assertIn(name, p.__doc__)
+
+ # only in simple parameters
+ self.assertFalse(hasattr(p, 'label'))
+ self.assertFalse(hasattr(p, 'unit'))
+
+[docs] def test_explicit_attributes(self):
+ name = 'mixed_dimensions'
+ names = ['0D', '1D', '2D']
+ shapes = ((), (3,), (2, 2))
+ labels = ['scalar', 'vector', 'matrix']
+ units = ['V', 'A', 'W']
+ setpoints = [(), ((4, 5, 6),), ((7, 8), None)]
+ setpoint_names = [(), ('sp1',), ('sp2', None)]
+ setpoint_labels = [(), ('setpoint1',), ('setpoint2', None)]
+ docstring = 'DOCS??'
+ metadata = {'sizes': [1, 3, 4]}
+ p = SimpleMultiParam([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes, labels=labels, units=units,
+ setpoints=setpoints,
+ setpoint_names=setpoint_names,
+ setpoint_labels=setpoint_labels,
+ docstring=docstring, snapshot_get=False,
+ metadata=metadata)
+
+ self.assertEqual(p.name, name)
+ self.assertEqual(p.names, names)
+ self.assertEqual(p.shapes, shapes)
+
+ self.assertEqual(p.labels, labels)
+ self.assertEqual(p.units, units)
+ self.assertEqual(p.setpoints, setpoints)
+ self.assertEqual(p.setpoint_names, setpoint_names)
+ self.assertEqual(p.setpoint_labels, setpoint_labels)
+
+ self.assertEqual(p._get_count, 0)
+ snap = p.snapshot(update=True)
+ self.assertEqual(p._get_count, 0)
+ snap_expected = {
+ 'name': name,
+ 'names': names,
+ 'labels': labels,
+ 'units': units,
+ 'setpoint_names': setpoint_names,
+ 'setpoint_labels': setpoint_labels,
+ 'metadata': metadata
+ }
+ for k, v in snap_expected.items():
+ self.assertEqual(snap[k], v)
+
+ self.assertIn(name, p.__doc__)
+ self.assertIn(docstring, p.__doc__)
+
+[docs] def test_has_set_get(self):
+ name = 'mixed_dimensions'
+ names = ['0D', '1D', '2D']
+ shapes = ((), (3,), (2, 2))
+ with self.assertRaises(AttributeError):
+ MultiParameter(name, names, shapes)
+
+ p = SimpleMultiParam([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes)
+
+ self.assertTrue(p.has_get)
+ self.assertFalse(p.has_set)
+
+ with self.assertRaises(AttributeError):
+ SettableMulti([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes)
+
+[docs] def test_full_name_s(self):
+ name = 'mixed_dimensions'
+ names = ['0D', '1D', '2D']
+ shapes = ((), (3,), (2, 2))
+
+ # three cases where only name gets used for full_name
+ for instrument in blank_instruments:
+ p = SimpleMultiParam([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes)
p._instrument = instrument
- self.assertEqual(p.full_names, ['a', 'b'])
+ self.assertEqual(p.full_name, name)
- p = Parameter(name='simple')
- p._instrument = self.named_instrument
- self.assertEqual(p.full_names, None)
+ self.assertEqual(p.full_names, names)
+
+ # and finally an instrument that really has a name
+ p = SimpleMultiParam([0, [1, 2, 3], [[4, 5], [6, 7]]],
+ name, names, shapes)
+ p._instrument = named_instrument
+ self.assertEqual(p.full_name, 'astro_mixed_dimensions')
+
+ self.assertEqual(p.full_names, ['astro_0D', 'astro_1D', 'astro_2D'])
+
+[docs] def test_constructor_errors(self):
+ bad_constructors = [
+ {'names': 'a', 'shapes': ((3,), ())},
+ {'names': ('a', 'b'), 'shapes': (3, 2)},
+ {'names': ('a', 'b'), 'shapes': ((3,), ()),
+ 'setpoints': [(1, 2, 3), ()]},
+ {'names': ('a', 'b'), 'shapes': ((3,), ()),
+ 'setpoint_names': (None, ('index',))},
+ {'names': ('a', 'b'), 'shapes': ((3,), ()),
+ 'setpoint_labels': (None, None, None)}
+ ]
+ for kwargs in bad_constructors:
+ with self.subTest(**kwargs):
+ with self.assertRaises(ValueError):
+ SimpleMultiParam([1, 2, 3], 'p', **kwargs)
- p = Parameter(names=['penn', 'teller'])
- p._instrument = self.named_instrument
- self.assertEqual(p.full_names, ['astro_penn', 'astro_teller'])
[docs]class TestManualParameter(TestCase):
@@ -270,24 +680,98 @@ Source code for qcodes.tests.test_parameter
with self.assertRaises(ValueError):
f(20)
+
[docs]class TestStandardParam(TestCase):
+
+
+
-[docs] def test_param_cmd_with_parsing(self):
- def set_p(val):
- self._p = val
+
- def get_p():
- return self._p
+
- def parse_set_p(val):
- return '{:d}'.format(val)
+
- p = StandardParameter('p_int', get_cmd=get_p, get_parser=int,
- set_cmd=set_p, set_parser=parse_set_p)
+[docs] def test_param_cmd_with_parsing(self):
+ p = StandardParameter('p_int', get_cmd=self.get_p, get_parser=int,
+ set_cmd=self.set_p, set_parser=self.parse_set_p)
p(5)
self.assertEqual(self._p, '5')
- self.assertEqual(p(), 5)
+ self.assertEqual(p(), 5)
+
+[docs] def test_settable(self):
+ p = StandardParameter('p', set_cmd=self.set_p)
+
+ p(10)
+ self.assertEqual(self._p, 10)
+ with self.assertRaises(NotImplementedError):
+ p()
+ with self.assertRaises(NotImplementedError):
+ p.get()
+
+ self.assertTrue(p.has_set)
+ self.assertFalse(p.has_get)
+
+[docs] def test_gettable(self):
+ p = StandardParameter('p', get_cmd=self.get_p)
+ self._p = 21
+
+ self.assertEqual(p(), 21)
+ self.assertEqual(p.get(), 21)
+
+ with self.assertRaises(NotImplementedError):
+ p(10)
+ with self.assertRaises(NotImplementedError):
+ p.set(10)
+
+ self.assertTrue(p.has_get)
+ self.assertFalse(p.has_set)
+
+[docs] def test_val_mapping_basic(self):
+ p = StandardParameter('p', set_cmd=self.set_p, get_cmd=self.get_p,
+ val_mapping={'off': 0, 'on': 1})
+
+ p('off')
+ self.assertEqual(self._p, 0)
+ self.assertEqual(p(), 'off')
+
+ self._p = 1
+ self.assertEqual(p(), 'on')
+
+ # implicit mapping to ints
+ self._p = '0'
+ self.assertEqual(p(), 'off')
+
+ # unrecognized response
+ self._p = 2
+ with self.assertRaises(KeyError):
+ p()
+
+[docs] def test_val_mapping_with_parsers(self):
+ # you can't use set_parser with val_mapping... just too much
+ # indirection since you also have set_cmd
+ with self.assertRaises(TypeError):
+ StandardParameter('p', set_cmd=self.set_p, get_cmd=self.get_p,
+ val_mapping={'off': 0, 'on': 1},
+ set_parser=self.parse_set_p)
+
+ # but you *can* use get_parser with val_mapping
+ p = StandardParameter('p', set_cmd=self.set_p_prefixed,
+ get_cmd=self.get_p, get_parser=self.strip_prefix,
+ val_mapping={'off': 0, 'on': 1})
+
+ p('off')
+ self.assertEqual(self._p, 'PVAL: 0')
+ self.assertEqual(p(), 'off')
+
+ self._p = 'PVAL: 1'
+ self.assertEqual(p(), 'on')
diff --git a/_modules/qcodes/tests/test_visa.html b/_modules/qcodes/tests/test_visa.html
index f4a3036f73c..7e5100145ee 100644
--- a/_modules/qcodes/tests/test_visa.html
+++ b/_modules/qcodes/tests/test_visa.html
@@ -209,20 +209,20 @@ Source code for qcodes.tests.test_visa
args1 = [
'be more positive!',
"writing 'STAT:-10.000' to <MockVisa: Joe>",
- 'setting Joe:state to -10'
+ 'setting Joe_state to -10'
]
# error args for set(0)
args2 = [
"writing 'STAT:0.000' to <MockVisa: Joe>",
- 'setting Joe:state to 0'
+ 'setting Joe_state to 0'
]
# error args for get -> 15
args3 = [
"I'm out of fingers",
"asking 'STAT?' to <MockVisa: Joe>",
- 'getting Joe:state'
+ 'getting Joe_state'
]
[docs] def test_ask_write_local(self):
diff --git a/_modules/qcodes/utils/deferred_operations.html b/_modules/qcodes/utils/deferred_operations.html
index 39e003e39b1..255a989d33f 100644
--- a/_modules/qcodes/utils/deferred_operations.html
+++ b/_modules/qcodes/utils/deferred_operations.html
@@ -144,8 +144,8 @@ Source code for qcodes.utils.deferred_operations
[docs]def is_function(f, arg_count, coroutine=False):
"""
- Check and require a function that can accept the specified number of positional
- arguments, which either is or is not a coroutine
+ Check and require a function that can accept the specified number of
+ positional arguments, which either is or is not a coroutine
type casting "functions" are allowed, but only in the 1-argument form
Args:
@@ -215,7 +215,7 @@ Source code for qcodes.utils.deferred_operations
>>> (d*5)()
210
>>> (d>10)()
- rue
+ True
>>> ((84/d) + (d*d))()
1766
@@ -231,12 +231,15 @@ Source code for qcodes.utils.deferred_operations
self.args = args
self.call_parts = call_parts
+ # only bind self.get if we explicitly initialize the object as a
+ # DeferredOperations, so that an object without a `get` method
+ # that simply inherits DeferredOperations behavior will not
+ # accidentally look gettable.
+ self.get = self.__call__
+
def __call__(self):
return self.call_func(*self.args)
-
-
def __bool__(self):
raise TypeError('This is a DeferredOperations object, you must '
'call or .get() it before testing its truthiness',
diff --git a/_modules/qcodes/utils/helpers.html b/_modules/qcodes/utils/helpers.html
index ae3687d79ac..2063643b9f4 100644
--- a/_modules/qcodes/utils/helpers.html
+++ b/_modules/qcodes/utils/helpers.html
@@ -212,25 +212,50 @@ Source code for qcodes.utils.helpers
not isinstance(obj, (str, bytes, io.IOBase)))
-[docs]def is_sequence_of(obj, types, depth=1):
+[docs]def is_sequence_of(obj, types=None, depth=None, shape=None):
"""
Test if object is a sequence of entirely certain class(es).
Args:
obj (any): the object to test.
- types (class or tuple of classes): allowed type(s)
- depth (int, optional): level of nesting, ie if depth=2 we expect
- a sequence of sequences. Default 1.
+
+ types (Optional[Union[class, Tuple[class]]]): allowed type(s)
+ if omitted, we just test the depth/shape
+
+ depth (Optional[int]): level of nesting, ie if ``depth=2`` we expect
+ a sequence of sequences. Default 1 unless ``shape`` is supplied.
+
+ shape (Optional[Tuple[int]]): the shape of the sequence, ie its
+ length in each dimension. If ``depth`` is omitted, but ``shape``
+ included, we set ``depth = len(shape)``
+
Returns:
bool, True if every item in ``obj`` matches ``types``
"""
if not is_sequence(obj):
return False
+
+ if shape in (None, ()):
+ next_shape = None
+ if depth is None:
+ depth = 1
+ else:
+ if depth is None:
+ depth = len(shape)
+ elif depth != len(shape):
+ raise ValueError('inconsistent depth and shape')
+
+ if len(obj) != shape[0]:
+ return False
+
+ next_shape = shape[1:]
+
for item in obj:
if depth > 1:
- if not is_sequence_of(item, types, depth=depth - 1):
+ if not is_sequence_of(item, types, depth=depth - 1,
+ shape=next_shape):
return False
- elif not isinstance(item, types):
+ elif types is not None and not isinstance(item, types):
return False
return True
@@ -368,6 +393,10 @@ Source code for qcodes.utils.helpers
def __init__(self, logger=logging.getLogger()):
self.logger = logger
+ self.stashed_handlers = self.logger.handlers[:]
+ for handler in self.stashed_handlers:
+ self.logger.removeHandler(handler)
+
def __enter__(self):
self.log_capture = io.StringIO()
self.string_handler = logging.StreamHandler(self.log_capture)
@@ -378,7 +407,10 @@ Source code for qcodes.utils.helpers
def __exit__(self, type, value, tb):
self.logger.removeHandler(self.string_handler)
self.value = self.log_capture.getvalue()
- self.log_capture.close()
+ self.log_capture.close()
+
+ for handler in self.stashed_handlers:
+ self.logger.addHandler(handler)
[docs]def make_unique(s, existing):
@@ -561,6 +593,11 @@ Source code for qcodes.utils.helpers
else:
dicts_equal = False
return dicts_equal, dict_differences
+
+
+[docs]def warn_units(class_name, instance):
+ logging.warning('`units` is deprecated for the `' + class_name +
+ '` class, use `unit` instead. ' + repr(instance))
diff --git a/_modules/qcodes/utils/nested_attrs.html b/_modules/qcodes/utils/nested_attrs.html
index 6f9c6f5ad2d..c894a9a51ad 100644
--- a/_modules/qcodes/utils/nested_attrs.html
+++ b/_modules/qcodes/utils/nested_attrs.html
@@ -183,8 +183,6 @@ Source code for qcodes.utils.nested_attrs
"""
parts = self._split_attr(attr)
- # import pdb; pdb.set_trace()
-
try:
return self._follow_parts(parts)
diff --git a/_sources/api/generated/qcodes.DataArray.rst.txt b/_sources/api/generated/qcodes.DataArray.rst.txt
index 779fa87922a..1752a95db2e 100644
--- a/_sources/api/generated/qcodes.DataArray.rst.txt
+++ b/_sources/api/generated/qcodes.DataArray.rst.txt
@@ -41,5 +41,6 @@ qcodes.DataArray
~DataArray.delegate_attr_dicts
~DataArray.delegate_attr_objects
~DataArray.omit_delegate_attrs
+ ~DataArray.units
\ No newline at end of file
diff --git a/_sources/api/generated/qcodes.Parameter.rst.txt b/_sources/api/generated/qcodes.Parameter.rst.txt
index e476cc61f2b..3736cee46a6 100644
--- a/_sources/api/generated/qcodes.Parameter.rst.txt
+++ b/_sources/api/generated/qcodes.Parameter.rst.txt
@@ -14,7 +14,6 @@ qcodes.Parameter
.. autosummary::
~Parameter.__init__
- ~Parameter.get
~Parameter.get_attrs
~Parameter.load_metadata
~Parameter.set_validator
@@ -32,6 +31,6 @@ qcodes.Parameter
.. autosummary::
~Parameter.full_name
- ~Parameter.full_names
+ ~Parameter.units
\ No newline at end of file
diff --git a/_sources/api/generated/qcodes.StandardParameter.rst.txt b/_sources/api/generated/qcodes.StandardParameter.rst.txt
index da51eb80a31..156d8e38d97 100644
--- a/_sources/api/generated/qcodes.StandardParameter.rst.txt
+++ b/_sources/api/generated/qcodes.StandardParameter.rst.txt
@@ -35,6 +35,6 @@ qcodes.StandardParameter
.. autosummary::
~StandardParameter.full_name
- ~StandardParameter.full_names
+ ~StandardParameter.units
\ No newline at end of file
diff --git a/_sources/api/generated/qcodes.utils.helpers.rst.txt b/_sources/api/generated/qcodes.utils.helpers.rst.txt
index 964eb78e1c7..103aba3485a 100644
--- a/_sources/api/generated/qcodes.utils.helpers.rst.txt
+++ b/_sources/api/generated/qcodes.utils.helpers.rst.txt
@@ -23,6 +23,7 @@ qcodes.utils.helpers
strip_attrs
tprint
wait_secs
+ warn_units
diff --git a/api/generated/qcodes.CombinedParameter.html b/api/generated/qcodes.CombinedParameter.html
index 61e9266cef9..06ca3fa14f2 100644
--- a/api/generated/qcodes.CombinedParameter.html
+++ b/api/generated/qcodes.CombinedParameter.html
@@ -164,18 +164,18 @@
qcodes.CombinedParameter¶
-
-class
qcodes.
CombinedParameter
(parameters, name, label=None, units=None, aggregator=None)[source]¶
+class qcodes.
CombinedParameter
(parameters, name, label=None, unit=None, units=None, aggregator=None)[source]¶
A combined parameter
Parameters:
-- *paramters (qcodes.Parameter) – the parameters to combine
-- name (str) – the name of the paramter
+- *parameters (qcodes.Parameter) – the parameters to combine
+- name (str) – the name of the parameter
- label (Optional[str]) – the label of the combined parameter
- unit (Optional[str]) – the unit of the combined parameter
-- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
+
- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
the set values into one
@@ -185,10 +185,10 @@ qcodes.CombinedParameter
-
-
__init__
(parameters, name, label=None, units=None, aggregator=None)[source]¶
+__init__
(parameters, name, label=None, unit=None, units=None, aggregator=None)[source]¶
Methods
@@ -198,7 +198,7 @@ qcodes.CombinedParameter
-__init__
(parameters, name[, label, units, ...])
+__init__
(parameters, name[, label, unit, ...])
load_metadata
(metadata)
diff --git a/api/generated/qcodes.DataArray.html b/api/generated/qcodes.DataArray.html
index 87f193bb83c..a567525b0ba 100644
--- a/api/generated/qcodes.DataArray.html
+++ b/api/generated/qcodes.DataArray.html
@@ -164,7 +164,7 @@
qcodes.DataArray¶
-
-class
qcodes.
DataArray
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), units=None, is_setpoint=False, preset_data=None)[source]¶
+class qcodes.
DataArray
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), unit=None, units=None, is_setpoint=False, preset_data=None)[source]¶
A container for one parameter in a measurement loop.
If this is a measured parameter, This object doesn’t contain
the data of the setpoints it was measured at, but it references
@@ -186,7 +186,7 @@
qcodes.DataArrayParameters:
- parameter (Optional[Parameter]) – The parameter whose values will
populate this array, if any. Will copy
name
, full_name
,
-label
, units
, and snapshot
from here unless you
+label
, unit
, and snapshot
from here unless you
provide them explicitly.
- name (Optional[str]) – The short name of this array.
TODO: use full_name as name, and get rid of short name
@@ -216,7 +216,8 @@ qcodes.DataArraystr]) – The units of the values stored in this array.
+
- unit (Optional[str]) – The unit of the values stored in this array.
+- units (Optional[str]) – DEPRECATED, redirects to
unit
.
- is_setpoint (bool) – True if this is a setpoint array, False if it
is measured. Default False.
- preset_data (Optional[Union[ndarray, sequence]]) – Contents of the
@@ -230,7 +231,7 @@
qcodes.DataArray
-
-
__init__
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), units=None, is_setpoint=False, preset_data=None)[source]¶
+__init__
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), unit=None, units=None, is_setpoint=False, preset_data=None)[source]¶
Methods
@@ -306,6 +307,9 @@ qcodes.DataArrayomit_delegate_attrs
+units
+
+
diff --git a/api/generated/qcodes.DataSet.html b/api/generated/qcodes.DataSet.html
index af31c6e7265..c6bd87b9d67 100644
--- a/api/generated/qcodes.DataSet.html
+++ b/api/generated/qcodes.DataSet.html
@@ -203,7 +203,7 @@ qcodes.DataSetqcodes.DataArray]) – arrays to add to the DataSet.
Can be added later with self.add_array(array)
.
-
formatter (Formatter, optional) – sets the file format/structure to
+ formatter (Formatter, optional) – sets the file format/structure to
write (and read) with. Default DataSet.default_formatter
which
is initially GNUPlotFormat()
.
write_period (float or None, optional) – Only if mode=LOCAL
, seconds
diff --git a/api/generated/qcodes.Parameter.html b/api/generated/qcodes.Parameter.html
index f776ab83ac0..8cd9f5ce3e2 100644
--- a/api/generated/qcodes.Parameter.html
+++ b/api/generated/qcodes.Parameter.html
@@ -164,73 +164,46 @@
qcodes.Parameter¶
-
-class
qcodes.
Parameter
(name=None, names=None, label=None, labels=None, units=None, shape=None, shapes=None, setpoints=None, setpoint_names=None, setpoint_labels=None, vals=None, docstring=None, snapshot_get=True, **kwargs)[source]¶
-Define one generic parameter, not necessarily part of
-an instrument. can be settable and/or gettable.
-A settable Parameter has a .set method, and supports only a single value
-at a time (see below)
-A gettable Parameter has a .get method, which may return:
-
-- a single value
-- a sequence of values with different names (for example,
-raw and interpreted, I and Q, several fit parameters...)
-- an array of values all with the same name, but at different
-setpoints (for example, a time trace or fourier transform that
-was acquired in the hardware and all sent to the computer at once)
-- 2 & 3 together: a sequence of arrays. All arrays should be the same
-shape.
-- a sequence of differently shaped items
-
-Because .set only supports a single value, if a Parameter is both
-gettable AND settable, .get should return a single value too (case 1)
-Parameters have a .get_latest method that simply returns the most recent
-set or measured value. This can either be called ( param.get_latest() )
-or used in a Loop as if it were a (gettable-only) parameter itself:
+class qcodes.
Parameter
(name, instrument=None, label=None, unit=None, units=None, vals=None, docstring=None, snapshot_get=True, metadata=None)[source]¶
+A parameter that represents a single degree of freedom.
+Not necessarily part of an instrument.
+Subclasses should define either a set
method, a get
method, or
+both.
+Parameters have a .get_latest
method that simply returns the most
+recent set or measured value. This can be called ( param.get_latest()
)
+or used in a Loop
as if it were a (gettable-only) parameter itself:
-Loop(...).each(param.get_latest)
-The constructor arguments change somewhat between these cases:
-
-Todo
-no idea how to document such a constructor
-
+Loop(...).each(param.get_latest)
+Note: If you want .get
or .set
to save the measurement for
+.get_latest
, you must explicitly call self._save_val(value)
+inside .get
and .set
.
Parameters:
-- name – (1&3) the local name of this parameter, should be a valid
-identifier, ie no spaces or special characters
-- names – (2,4,5) a tuple of names
-- label – (1&3) string to use as an axis label for this parameter
-defaults to name
-- labels – (2,4,5) a tuple of labels
-- units – (1&3) string that indicates units of parameter for use in axis
-label and snapshot
-- shape – (3&4) a tuple of integers for the shape of array returned by
-.get().
-- shapes – (5) a tuple of tuples, each one as in shape.
-Single values should be denoted by None or ()
-- setpoints – (3,4,5) the setpoints for the returned array of values.
-3&4 - a tuple of arrays. The first array is be 1D, the second 2D,
-etc.
-5 - a tuple of tuples of arrays
-Defaults to integers from zero in each respective direction
-Each may be either a DataArray, a numpy array, or a sequence
-(sequences will be converted to numpy arrays)
-NOTE: if the setpoints will be different each measurement, leave
-this out and return the setpoints (with extra names) in the get.
-- setpoint_names – (3,4,5) one identifier (like name) per setpoint
-array. Ignored if setpoints are DataArrays, which already have
-names.
-- setpoint_labels – (3&4) one label (like label) per setpoint array.
-Overridden if setpoints are DataArrays and already have labels.
-- vals – allowed values for setting this parameter (only relevant
-if it has a setter), defaults to Numbers()
-- docstring (Optional[string]) – documentation string for the __doc__
+
- name (str) – the local name of the parameter. Should be a valid
+identifier, ie no spaces or special characters. If this parameter
+is part of an Instrument or Station, this is how it will be
+referenced from that parent, ie
instrument.name
or
+instrument.parameters[name]
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- label (Optional[str]) – Normally used as the axis label when this
+parameter is graphed, along with
unit
.
+- unit (Optional[str]) – The unit of measure. Use
''
for unitless.
+- units (Optional[str]) – DEPRECATED, redirects to
unit
.
+- vals (Optional[Validator]) – Allowed values for setting this parameter.
+Only relevant if settable. Defaults to
Numbers()
+- docstring (Optional[str]) – documentation string for the __doc__
field of the object. The __doc__ field of the instance is used by
some help systems, but not all
-- snapshot_get (bool) – Prevent any update to the parameter
-for example if it takes too long to update
+- snapshot_get (Optional[bool]) – False prevents any update to the
+parameter during a snapshot, even if the snapshot was called with
+
update=True
, for example if it takes too long to update.
+Default True.
+- metadata (Optional[dict]) – extra information to include with the
+JSON snapshot of the parameter
@@ -238,7 +211,7 @@ qcodes.Parameter
-
-
__init__
(name=None, names=None, label=None, labels=None, units=None, shape=None, shapes=None, setpoints=None, setpoint_names=None, setpoint_labels=None, vals=None, docstring=None, snapshot_get=True, **kwargs)[source]¶
+__init__
(name, instrument=None, label=None, unit=None, units=None, vals=None, docstring=None, snapshot_get=True, metadata=None)[source]¶
Methods
@@ -248,31 +221,28 @@ qcodes.Parameter
-__init__
([name, names, label, labels, ...])
-
-
-get
()
+__init__
(name[, instrument, label, unit, ...])
-get_attrs
()
+get_attrs
()
Attributes recreated as properties in the RemoteParameter proxy.
-load_metadata
(metadata)
+load_metadata
(metadata)
Load metadata
-set_validator
(vals)
+set_validator
(vals)
Set a validator vals for this parameter.
-snapshot
([update])
+snapshot
([update])
Decorate a snapshot dictionary with metadata.
-snapshot_base
([update])
+snapshot_base
([update])
State of the parameter as a JSON-compatible dict.
-sweep
(start, stop[, step, num])
+sweep
(start, stop[, step, num])
Create a collection of parameter values to be iterated over.
-validate
(value)
+validate
(value)
Validate value
@@ -287,8 +257,8 @@ qcodes.Parameterfull_name
Include the instrument name with the Parameter name if possible.
-full_names
-Include the instrument name with the Parameter names if possible.
+units
+
diff --git a/api/generated/qcodes.StandardParameter.html b/api/generated/qcodes.StandardParameter.html
index 3cfd0363f12..f234567b53b 100644
--- a/api/generated/qcodes.StandardParameter.html
+++ b/api/generated/qcodes.StandardParameter.html
@@ -171,16 +171,16 @@ qcodes.StandardParameter
Parameters:
-- name (string) – the local name of this parameter
-- instrument (Optional[Instrument]) – an instrument that handles this
-function. Default None.
-- get_cmd (Optional[Union[string, function]]) – a string or function to
+
- name (str) – the local name of this parameter
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- get_cmd (Optional[Union[str, function]]) – a string or function to
get this parameter. You can only use a string if an instrument is
provided, then this string will be passed to instrument.ask
- get_parser (Optional[function]) – function to transform the response
from get to the final output value.
See also val_mapping
-- set_cmd (Optional[Union[string, function]]) –
command to set this
+
- set_cmd (Optional[Union[str, function]]) –
command to set this
parameter, either:
-full_names
-Include the instrument name with the Parameter names if possible.
+units
+
diff --git a/api/generated/qcodes.combine.html b/api/generated/qcodes.combine.html
index b2f56f65884..9a5108c6322 100644
--- a/api/generated/qcodes.combine.html
+++ b/api/generated/qcodes.combine.html
@@ -164,8 +164,8 @@
qcodes.combine¶
-
-
qcodes.
combine
(*parameters, name, label=None, units=None, aggregator=None)[source]¶
-Combine parameters into one swepable parameter
+qcodes.
combine
(*parameters, name, label=None, unit=None, units=None, aggregator=None)[source]¶
+Combine parameters into one sweepable parameter
is_function
(f, arg_count[, coroutine])
-Check and require a function that can accept the specified number of positional
+Check and require a function that can accept the specified number of
iscoroutinefunction
(func)
Return True if func is a decorated coroutine function.
diff --git a/api/generated/qcodes.utils.helpers.html b/api/generated/qcodes.utils.helpers.html
index c86b3836b0f..1bffe7dd4a0 100644
--- a/api/generated/qcodes.utils.helpers.html
+++ b/api/generated/qcodes.utils.helpers.html
@@ -185,7 +185,7 @@
is_sequence
(obj)
Test if an object is a sequence.
-is_sequence_of
(obj, types[, depth])
+is_sequence_of
(obj[, types, depth, shape])
Test if object is a sequence of entirely certain class(es).
make_sweep
(start, stop[, step, num])
@@ -209,6 +209,9 @@
wait_secs
(finish_clock)
calculate the number of seconds until a given clock time
+warn_units
(class_name, instance)
+
+
Classes
diff --git a/api/public.html b/api/public.html
index 6160daf198c..2748a032ee4 100644
--- a/api/public.html
+++ b/api/public.html
@@ -299,8 +299,8 @@ InstrumentFunction
(name[, instrument, call_cmd, args, ...])
Defines a function that an instrument can execute.
-Parameter
([name, names, label, labels, ...])
-Define one generic parameter, not necessarily part of an instrument.
+Parameter
(name[, instrument, label, unit, ...])
+A parameter that represents a single degree of freedom.
StandardParameter
(name[, instrument, ...])
Define one measurement parameter.
@@ -311,8 +311,8 @@ InstrumentSweepValues
(parameter, \*\*kwargs)
Base class for sweeping a parameter.
-combine
(\*parameters, name[, label, units, ...])
-Combine parameters into one swepable parameter
+combine
(\*parameters, name[, label, unit, ...])
+Combine parameters into one sweepable parameter
CombinedParameter
(parameters, name[, label, ...])
A combined parameter
diff --git a/auto/qcodes.data.html b/auto/qcodes.data.html
index 7421ae7ba41..1f8bc2f4edc 100644
--- a/auto/qcodes.data.html
+++ b/auto/qcodes.data.html
@@ -144,7 +144,7 @@ Submodulesqcodes.data.data_array module¶
-
-class
qcodes.data.data_array.
DataArray
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), units=None, is_setpoint=False, preset_data=None)[source]¶
+class qcodes.data.data_array.
DataArray
(parameter=None, name=None, full_name=None, label=None, snapshot=None, array_id=None, set_arrays=(), shape=None, action_indices=(), unit=None, units=None, is_setpoint=False, preset_data=None)[source]¶
Bases: qcodes.utils.helpers.DelegateAttributes
A container for one parameter in a measurement loop.
If this is a measured parameter, This object doesn’t contain
@@ -167,7 +167,7 @@
SubmodulesParameters:
- parameter (Optional[Parameter]) – The parameter whose values will
populate this array, if any. Will copy
name
, full_name
,
-label
, units
, and snapshot
from here unless you
+label
, unit
, and snapshot
from here unless you
provide them explicitly.
- name (Optional[str]) – The short name of this array.
TODO: use full_name as name, and get rid of short name
@@ -197,7 +197,8 @@ Submodulesstr]) – The units of the values stored in this array.
+
- unit (Optional[str]) – The unit of the values stored in this array.
+- units (Optional[str]) – DEPRECATED, redirects to
unit
.
- is_setpoint (bool) – True if this is a setpoint array, False if it
is measured. Default False.
- preset_data (Optional[Union[ndarray, sequence]]) – Contents of the
@@ -211,12 +212,12 @@
Submodules
-
-
COPY_ATTRS_FROM_INPUT
= ('name', 'label', 'units')¶
+COPY_ATTRS_FROM_INPUT
= ('name', 'label', 'unit')¶
-
-
SNAP_ATTRS
= ('array_id', 'name', 'shape', 'units', 'label', 'action_indices', 'is_setpoint')¶
+SNAP_ATTRS
= ('array_id', 'name', 'shape', 'unit', 'label', 'action_indices', 'is_setpoint')¶
@@ -483,6 +484,11 @@ Submodules
+-
+
units
¶
+
+
@@ -553,7 +559,7 @@ Submodulesqcodes.DataArray]) – arrays to add to the DataSet.
Can be added later with self.add_array(array)
.
-- formatter (Formatter, optional) – sets the file format/structure to
+
- formatter (Formatter, optional) – sets the file format/structure to
write (and read) with. Default
DataSet.default_formatter
which
is initially GNUPlotFormat()
.
- write_period (float or None, optional) – Only if
mode=LOCAL
, seconds
@@ -691,7 +697,7 @@ SubmodulesReturns: name of the default parameter
-Return type: name ( Union[str, None] )
+Return type: name ( Union[str, None] )
@@ -932,7 +938,7 @@ Submodulesget_data_manager(). If False
, this DataSet
will
store itself. load_data
will not start a DataManager but may
query an existing one to determine (and pull) the live data.
-formatter (Formatter, optional) – sets the file format/structure to
+ formatter (Formatter, optional) – sets the file format/structure to
read with. Default DataSet.default_formatter
which
is initially GNUPlotFormat()
.
io (io_manager, optional) – base physical location of the DataSet
.
@@ -1000,7 +1006,7 @@ Submodulesqcodes.DataArray]) – arrays to add to the DataSet.
Can be added later with self.add_array(array)
.
-formatter (Formatter, optional) – sets the file format/structure to
+ formatter (Formatter, optional) – sets the file format/structure to
write (and read) with. Default DataSet.default_formatter
which
is initially GNUPlotFormat()
.
write_period (float or None, optional) – Only if mode=LOCAL
, seconds
@@ -1198,7 +1204,7 @@ Submodules
-Parameters: data_set (DataSet) – the data to read into. Should already have
+ Parameters: data_set (DataSet) – the data to read into. Should already have
attributes io
(an io manager), location
(string),
and arrays
(dict of {array_id: array}
, can be empty
or can already have some or all of the arrays present, they
@@ -1217,7 +1223,7 @@ Submodules
-Parameters: data_set (DataSet) – the data to read metadata into
+Parameters: data_set (DataSet) – the data to read metadata into
@@ -1235,10 +1241,10 @@ Submodules
Parameters:
-- data_set (DataSet) – the data we are reading into.
+- data_set (DataSet) – the data we are reading into.
- f (file-like) – a file-like object to read from, as provided by
io_manager.open
.
-- ids_read (set) –
array_id
s that we have already read.
+ - ids_read (set) –
array_id
s that we have already read.
When you read an array, check that it’s not in this set (except
setpoints, which can be in several files with different inner
loops) then add it to the set so other files know it should not
@@ -1265,7 +1271,7 @@ Submodules
Parameters:
-- data_set (DataSet) – the data we are writing.
+- data_set (DataSet) – the data we are writing.
- io_manager (io_manager) – base physical location to write to.
- location (str) – the file location within the io_manager.
- write_metadata (bool) – if True, then the metadata is written to disk
@@ -1287,7 +1293,7 @@ Submodules
Parameters:
-- data_set (DataSet) – the data we are writing.
+- data_set (DataSet) – the data we are writing.
- io_manager (io_manager) – base physical location to write to.
- location (str) – the file location within the io_manager.
- read_first (bool, optional) – whether to first look for previously
@@ -1399,7 +1405,7 @@
Submodules
Parameters:
-- data_set (DataSet) – the data we’re storing
+- data_set (DataSet) – the data we’re storing
- io_manager (io_manager) – the base location to write to
- location (str) – the file location within io_manager
@@ -1418,7 +1424,7 @@ Submodules
Parameters:
-- data_set (DataSet) – the data we’re storing
+- data_set (DataSet) – the data we’re storing
- io_manager (io_manager) – the base location to write to
- location (str) – the file location within io_manager
- read_first (bool, optional) – read previously saved metadata before
diff --git a/auto/qcodes.html b/auto/qcodes.html
index b80ee595669..a47540c1a00 100644
--- a/auto/qcodes.html
+++ b/auto/qcodes.html
@@ -989,7 +989,7 @@
Submodules
-
-
dummy_parameter
= <qcodes.instrument.parameter.ManualParameter: single at 47233106617568>¶
+dummy_parameter
= <qcodes.instrument.parameter.ManualParameter: single at 47277989295944>¶
@@ -1018,7 +1018,7 @@ Submodulesstr]) – if location is default or another provider
function, name is a string to add to location to make it more
readable/meaningful to users
-- formatter (Optional[Formatter]) – knows how to read and write the
+
- formatter (Optional[Formatter]) – knows how to read and write the
file format. Default can be set in DataSet.default_formatter
- io (Optional[io_manager]) – knows how to connect to the storage
(disk vs cloud etc)
@@ -1063,7 +1063,7 @@ Submodules
Parameters:
-- *components (list[Any]) – components to add immediately to the Station.
+
- *components (list[Any]) – components to add immediately to the Station.
can be added later via self.add_component
- monitor (None) – Not implememnted, the object that monitors the system continuously
- default (bool) – is this station the default, which gets
diff --git a/auto/qcodes.instrument.html b/auto/qcodes.instrument.html
index 21c83e35df7..1e85e0fff68 100644
--- a/auto/qcodes.instrument.html
+++ b/auto/qcodes.instrument.html
@@ -1046,16 +1046,13 @@
Submodules
-
class
qcodes.instrument.mock.
ArrayGetter
(measured_param, sweep_values, delay)[source]¶
-Bases: qcodes.instrument.parameter.Parameter
+Bases: qcodes.instrument.parameter.MultiParameter
Example parameter that just returns a single array
-TODO: in theory you can make this same Parameter with
+
TODO: in theory you can make this an ArrayParameter with
name, label & shape (instead of names, labels & shapes) and altered
setpoints (not wrapped in an extra tuple) and this mostly works,
but when run in a loop it doesn’t propagate setpoints to the
-DataSet. We could track down this bug, but perhaps a better solution
-would be to only support the simplest and the most complex Parameter
-forms (ie cases 1 and 5 in the Parameter docstring) and do away with
-the intermediate forms that make everything more confusing.
+DataSet. This is a bug
-
get
()[source]¶
@@ -1279,61 +1276,137 @@ Submodules
qcodes.instrument.parameter module¶
Measured and/or controlled parameters
-The Parameter class is meant for direct parameters of instruments (ie
-subclasses of Instrument) but elsewhere in Qcodes we can use anything
-as a parameter if it has the right attributes:
-To use Parameters in data acquisition loops, they should have:
-
-
-- .name - like a variable name, ie no spaces or weird characters
-- .label - string to use as an axis label (optional, defaults to .name)
-(except for composite measurements, see below)
-
-
-Controlled parameters should have a .set(value) method, which takes a single
-value to apply to this parameter. To use this parameter for sweeping, also
-connect its __getitem__ to SweepFixedValues as below.
-Measured parameters should have .get() which can return:
-
-a single value:
-
-
-- parameter should have .name and optional .label as above
-
-
+Anything that you want to either measure or control within QCoDeS should
+satisfy the Parameter interface. Most of the time that is easiest to do
+by either using or subclassing one of the classes defined here, but you can
+also use any class with the right attributes.
+TODO (alexcjohnson) update this with the real duck-typing requirements or
+create an ABC for Parameter and MultiParameter - or just remove this statement
+if everyone is happy to use these classes.
+This file defines four classes of parameters:
+Parameter
, ArrayParameter
, and MultiParameter
must be subclassed:
+
+
+Parameter
is the base class for scalar-valued parameters, if you have
+- custom code to read or write a single value. Provides
sweep
and
+__getitem__
(slice notation) methods to use a settable parameter as
+the swept variable in a Loop
. To use, fill in super().__init__
,
+and provide a get
method, a set
method, or both.
+
-several values of different meaning (raw and measured, I and Q,
-a set of fit parameters, that sort of thing, that all get measured/calculated
-at once):
-
-
-- parameter should have .names and optional .labels, each a sequence with
-the same length as returned by .get()
-
-
+
+ArrayParameter
is a base class for array-valued parameters, ie anything
+- for which each
get
call returns an array of values that all have the
+same type and meaning. Currently not settable, only gettable. Can be used
+in Measure
, or in Loop
- in which case these arrays are nested
+inside the loop’s setpoint array. To use, provide a get
method that
+returns an array or regularly-shaped sequence, and describe that array in
+super().__init__
.
+
+
+
+MultiParameter
is the base class for multi-valued parameters. Currently
+- not settable, only gettable, but can return an arbitrary collection of
+scalar and array values and can be used in
Measure
or Loop
to
+feed data to a DataSet
. To use, provide a get
method
+that returns a sequence of values, and describe those values in
+super().__init__
.
+
-an array of values of one type:
-
-
-- parameter should have .name and optional .label as above, but also
-.shape attribute, which is an integer (or tuple of integers) describing
-the shape of the returned array (which must be fixed)
-optionally also .setpoints, array(s) of setpoint values for this data
-otherwise we will use integers from 0 in each direction as the setpoints
-
+StandardParameter
and ManualParameter
can be instantiated directly:
+
+
+StandardParameter
is the default class for instrument parameters
+- (see
Instrument.add_parameter
). Can be gettable, settable, or both.
+Provides a standardized interface to construct strings to pass to the
+instrument’s write
and ask
methods (but can also be given other
+functions to execute on get
or set
), to convert the string
+responses to meaningful output, and optionally to ramp a setpoint with
+stepped write
calls from a single set
. Does not need to be
+subclassed, just instantiated.
+
+
+
+ManualParameter
is for values you want to keep track of but cannot
+- set or get electronically. Holds the last value it was
set
to, and
+returns it on get
.
+
-several arrays of values (all the same shape):
-
-
-- define .names (and .labels) AND .shape (and .setpoints)
-
+
+-
+class
qcodes.instrument.parameter.
ArrayParameter
(name, shape, instrument=None, label=None, unit=None, units=None, setpoints=None, setpoint_names=None, setpoint_labels=None, docstring=None, snapshot_get=True, metadata=None)[source]¶
+Bases: qcodes.instrument.parameter._BaseParameter
+A gettable parameter that returns an array of values.
+Not necessarily part of an instrument.
+Subclasses should define a .get
method, which returns an array.
+When used in a Loop
or Measure
operation, this will be entered
+into a single DataArray
, with extra dimensions added by the Loop
.
+The constructor args describe the array we expect from each .get
call
+and how it should be handled.
+For now you must specify upfront the array shape, and this cannot change
+from one call to the next. Later we intend to require only that you specify
+the dimension, and the size of each dimension can vary from call to call.
+Note: If you want .get
to save the measurement for .get_latest
,
+you must explicitly call self._save_val(items)
inside .get
.
+
+
+
+
+Parameters:
+- name (str) – the local name of the parameter. Should be a valid
+identifier, ie no spaces or special characters. If this parameter
+is part of an Instrument or Station, this is how it will be
+referenced from that parent, ie
instrument.name
or
+instrument.parameters[name]
+- shape (Tuple[int]) – The shape (as used in numpy arrays) of the array
+to expect. Scalars should be denoted by (), 1D arrays as (n,),
+2D arrays as (n, m), etc.
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- label (Optional[str]) – Normally used as the axis label when this
+parameter is graphed, along with
unit
.
+- unit (Optional[str]) – The unit of measure. Use
''
for unitless.
+- units (Optional[str]) – DEPRECATED, redirects to
unit
.
+- setpoints (Optional[Tuple[setpoint_array]]) –
setpoint_array
can be a DataArray, numpy.ndarray, or sequence.
+The setpoints for each dimension of the returned array. An
+N-dimension item should have N setpoint arrays, where the first is
+1D, the second 2D, etc.
+If omitted for any or all items, defaults to integers from zero in
+each respective direction.
+Note: if the setpoints will be different each measurement, leave
+this out and return the setpoints (with extra names) in .get
.
+- setpoint_names (Optional[Tuple[str]]) – one identifier (like
+
name
) per setpoint array. Ignored if a setpoint is a
+DataArray, which already has a name.
+- setpoint_labels (Optional[Tuple[str]]) –
one label (like labels
)
+per setpoint array. Ignored if a setpoint is a DataArray, which
+already has a label.
+TODO (alexcjohnson) we need setpoint_units (and in MultiParameter)
+- docstring (Optional[str]) – documentation string for the __doc__
+field of the object. The __doc__ field of the instance is used by
+some help systems, but not all
+- snapshot_get (bool) – Prevent any update to the parameter, for example
+if it takes too long to update. Default True.
+- metadata (Optional[dict]) – extra information to include with the
+JSON snapshot of the parameter
+
+
+
+
+
+-
+
units
¶
+
+
+
+
-
-class
qcodes.instrument.parameter.
CombinedParameter
(parameters, name, label=None, units=None, aggregator=None)[source]¶
+class qcodes.instrument.parameter.
CombinedParameter
(parameters, name, label=None, unit=None, units=None, aggregator=None)[source]¶
Bases: qcodes.utils.metadata.Metadatable
A combined parameter
@@ -1341,11 +1414,11 @@ Submodules
Parameters:
-- *paramters (qcodes.Parameter) – the parameters to combine
-- name (str) – the name of the paramter
+- *parameters (qcodes.Parameter) – the parameters to combine
+- name (str) – the name of the parameter
- label (Optional[str]) – the label of the combined parameter
- unit (Optional[str]) – the unit of the combined parameter
-- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
+
- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
the set values into one
@@ -1355,7 +1428,7 @@ Submodules
-
set
(index: int)[source]¶
@@ -1368,7 +1441,7 @@ SubmodulesReturns: values that where actually set
-Return type: list
+Return type: list
@@ -1470,10 +1543,10 @@ Submodules
Parameters:
-- name (string) – the local name of this parameter
+- name (str) – the local name of this parameter
- instrument (Optional[Instrument]) – the instrument this applies to,
if any.
-- initial_value (Optional[string]) – starting value, the
+
- initial_value (Optional[str]) – starting value, the
only invalid value allowed, and None is only allowed as an initial
value, it cannot be set later
- **kwargs – Passed to Parameter parent class
@@ -1491,123 +1564,147 @@ Submodules
-
set
(value)[source]¶
-Validate and saves value
-:param value: value to validate and save
-:type value: any
+Validate and saves value
+
+
+
+
+Parameters: value (any) – value to validate and save
+
+
+
--
-class
qcodes.instrument.parameter.
Parameter
(name=None, names=None, label=None, labels=None, units=None, shape=None, shapes=None, setpoints=None, setpoint_names=None, setpoint_labels=None, vals=None, docstring=None, snapshot_get=True, **kwargs)[source]¶
-Bases: qcodes.utils.metadata.Metadatable
, qcodes.utils.deferred_operations.DeferredOperations
-Define one generic parameter, not necessarily part of
-an instrument. can be settable and/or gettable.
-A settable Parameter has a .set method, and supports only a single value
-at a time (see below)
-A gettable Parameter has a .get method, which may return:
-
-- a single value
-- a sequence of values with different names (for example,
-raw and interpreted, I and Q, several fit parameters...)
-- an array of values all with the same name, but at different
-setpoints (for example, a time trace or fourier transform that
-was acquired in the hardware and all sent to the computer at once)
-- 2 & 3 together: a sequence of arrays. All arrays should be the same
-shape.
-- a sequence of differently shaped items
-
-Because .set only supports a single value, if a Parameter is both
-gettable AND settable, .get should return a single value too (case 1)
-Parameters have a .get_latest method that simply returns the most recent
-set or measured value. This can either be called ( param.get_latest() )
-or used in a Loop as if it were a (gettable-only) parameter itself:
-
-Loop(...).each(param.get_latest)
-The constructor arguments change somewhat between these cases:
-
-Todo
-no idea how to document such a constructor
-
+-
+class
qcodes.instrument.parameter.
MultiParameter
(name, names, shapes, instrument=None, labels=None, units=None, setpoints=None, setpoint_names=None, setpoint_labels=None, docstring=None, snapshot_get=True, metadata=None)[source]¶
+Bases: qcodes.instrument.parameter._BaseParameter
+A gettable parameter that returns multiple values with separate names,
+each of arbitrary shape.
+Not necessarily part of an instrument.
+Subclasses should define a .get
method, which returns a sequence of
+values. When used in a Loop
or Measure
operation, each of these
+values will be entered into a different DataArray
. The constructor
+args describe what data we expect from each .get
call and how it
+should be handled. .get
should always return the same number of items,
+and most of the constructor arguments should be tuples of that same length.
+For now you must specify upfront the array shape of each item returned by
+.get
, and this cannot change from one call to the next. Later we intend
+to require only that you specify the dimension of each item returned, and
+the size of each dimension can vary from call to call.
+Note: If you want .get
to save the measurement for .get_latest
,
+you must explicitly call self._save_val(items)
inside .get
.
Parameters:
-- name – (1&3) the local name of this parameter, should be a valid
-identifier, ie no spaces or special characters
-- names – (2,4,5) a tuple of names
-- label – (1&3) string to use as an axis label for this parameter
-defaults to name
-- labels – (2,4,5) a tuple of labels
-- units – (1&3) string that indicates units of parameter for use in axis
-label and snapshot
-- shape – (3&4) a tuple of integers for the shape of array returned by
-.get().
-- shapes – (5) a tuple of tuples, each one as in shape.
-Single values should be denoted by None or ()
-- setpoints – (3,4,5) the setpoints for the returned array of values.
-3&4 - a tuple of arrays. The first array is be 1D, the second 2D,
-etc.
-5 - a tuple of tuples of arrays
-Defaults to integers from zero in each respective direction
-Each may be either a DataArray, a numpy array, or a sequence
-(sequences will be converted to numpy arrays)
-NOTE: if the setpoints will be different each measurement, leave
-this out and return the setpoints (with extra names) in the get.
-- setpoint_names – (3,4,5) one identifier (like name) per setpoint
-array. Ignored if setpoints are DataArrays, which already have
-names.
-- setpoint_labels – (3&4) one label (like label) per setpoint array.
-Overridden if setpoints are DataArrays and already have labels.
-- vals – allowed values for setting this parameter (only relevant
-if it has a setter), defaults to Numbers()
-- docstring (Optional[string]) – documentation string for the __doc__
+
- name (str) – the local name of the whole parameter. Should be a valid
+identifier, ie no spaces or special characters. If this parameter
+is part of an Instrument or Station, this is how it will be
+referenced from that parent, ie
instrument.name
or
+instrument.parameters[name]
+- names (Tuple[str]) – A name for each item returned by a
.get
+call. Will be used as the basis of the DataArray
names
+when this parameter is used to create a DataSet
.
+- shapes (Tuple[Tuple[int]]) – The shape (as used in numpy arrays) of
+each item. Scalars should be denoted by (), 1D arrays as (n,),
+2D arrays as (n, m), etc.
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- labels (Optional[Tuple[str]]) – A label for each item. Normally used
+as the axis label when a component is graphed, along with the
+matching entry from
units
.
+- units (Optional[Tuple[str]]) – The unit of measure for each item.
+Use
''
or None
for unitless values.
+- setpoints (Optional[Tuple[Tuple[setpoint_array]]]) –
setpoint_array
can be a DataArray, numpy.ndarray, or sequence.
+The setpoints for each returned array. An N-dimension item should
+have N setpoint arrays, where the first is 1D, the second 2D, etc.
+If omitted for any or all items, defaults to integers from zero in
+each respective direction.
+Note: if the setpoints will be different each measurement, leave
+this out and return the setpoints (with extra names) in .get
.
+- setpoint_names (Optional[Tuple[Tuple[str]]]) – one identifier (like
+
name
) per setpoint array. Ignored if a setpoint is a
+DataArray, which already has a name.
+- setpoint_labels (Optional[Tuple[Tuple[str]]]) – one label (like
+
labels
) per setpoint array. Ignored if a setpoint is a
+DataArray, which already has a label.
+- docstring (Optional[str]) – documentation string for the __doc__
field of the object. The __doc__ field of the instance is used by
some help systems, but not all
-- snapshot_get (bool) – Prevent any update to the parameter
-for example if it takes too long to update
+- snapshot_get (bool) – Prevent any update to the parameter, for example
+if it takes too long to update. Default True.
+- metadata (Optional[dict]) – extra information to include with the
+JSON snapshot of the parameter
-
--
-
__getitem__
(keys)[source]¶
-Slice a Parameter to get a SweepValues object
-to iterate over during a sweep
-
-
--
-
full_name
¶
-Include the instrument name with the Parameter name if possible.
+-
+
full_names
¶
+Include the instrument name with the Parameter names if possible.
-
--
-
full_names
¶
-Include the instrument name with the Parameter names if possible.
-
--
-
get_attrs
()[source]¶
-Attributes recreated as properties in the RemoteParameter proxy.
-Grab the names of all attributes that the RemoteParameter needs
-to function like the main one (in loops etc)
+
+-
+class
qcodes.instrument.parameter.
Parameter
(name, instrument=None, label=None, unit=None, units=None, vals=None, docstring=None, snapshot_get=True, metadata=None)[source]¶
+Bases: qcodes.instrument.parameter._BaseParameter
+A parameter that represents a single degree of freedom.
+Not necessarily part of an instrument.
+Subclasses should define either a set
method, a get
method, or
+both.
+Parameters have a .get_latest
method that simply returns the most
+recent set or measured value. This can be called ( param.get_latest()
)
+or used in a Loop
as if it were a (gettable-only) parameter itself:
+
+Loop(...).each(param.get_latest)
+Note: If you want .get
or .set
to save the measurement for
+.get_latest
, you must explicitly call self._save_val(value)
+inside .get
and .set
.
-Returns: All public attribute names, plus docstring and _vals
-
-Return type: list
+Parameters:
+- name (str) – the local name of the parameter. Should be a valid
+identifier, ie no spaces or special characters. If this parameter
+is part of an Instrument or Station, this is how it will be
+referenced from that parent, ie
instrument.name
or
+instrument.parameters[name]
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- label (Optional[str]) – Normally used as the axis label when this
+parameter is graphed, along with
unit
.
+- unit (Optional[str]) – The unit of measure. Use
''
for unitless.
+- units (Optional[str]) – DEPRECATED, redirects to
unit
.
+- vals (Optional[Validator]) – Allowed values for setting this parameter.
+Only relevant if settable. Defaults to
Numbers()
+- docstring (Optional[str]) – documentation string for the __doc__
+field of the object. The __doc__ field of the instance is used by
+some help systems, but not all
+- snapshot_get (Optional[bool]) – False prevents any update to the
+parameter during a snapshot, even if the snapshot was called with
+
update=True
, for example if it takes too long to update.
+Default True.
+- metadata (Optional[dict]) – extra information to include with the
+JSON snapshot of the parameter
+
+
+
+-
+
__getitem__
(keys)[source]¶
+Slice a Parameter to get a SweepValues object
+to iterate over during a sweep
@@ -1624,26 +1721,6 @@ Submodules
--
-
snapshot_base
(update=False)[source]¶
-State of the parameter as a JSON-compatible dict.
-
-
-
-
-Parameters: update (bool) – If True, update the state by calling
-parameter.get().
-If False, just use the latest values in memory.
-
-Returns: base snapshot
-
-Return type: dict
-
-
-
-
-
-
sweep
(start, stop, step=None, num=None)[source]¶
@@ -1686,6 +1763,11 @@ Submodules
+-
+
units
¶
+
+
-
validate
(value)[source]¶
@@ -1712,16 +1794,16 @@ Submodules
Parameters:
-- name (string) – the local name of this parameter
-- instrument (Optional[Instrument]) – an instrument that handles this
-function. Default None.
-- get_cmd (Optional[Union[string, function]]) – a string or function to
+
- name (str) – the local name of this parameter
+- instrument (Optional[Instrument]) – the instrument this parameter
+belongs to, if any
+- get_cmd (Optional[Union[str, function]]) – a string or function to
get this parameter. You can only use a string if an instrument is
provided, then this string will be passed to instrument.ask
- get_parser (Optional[function]) – function to transform the response
from get to the final output value.
See also val_mapping
-- set_cmd (Optional[Union[string, function]]) –
command to set this
+
- set_cmd (Optional[Union[str, function]]) –
command to set this
parameter, either:
- a string (containing one field to .format, like “{}” etc)
@@ -1855,8 +1937,8 @@
Submodules
-
-
qcodes.instrument.parameter.
combine
(*parameters, name, label=None, units=None, aggregator=None)[source]¶
-Combine parameters into one swepable parameter
+qcodes.instrument.parameter.
combine
(*parameters, name, label=None, unit=None, units=None, aggregator=None)[source]¶
+Combine parameters into one sweepable parameter
@@ -1866,7 +1948,7 @@ Submodulesstr) – the name of the paramter
- label (Optional[str]) – the label of the combined parameter
- unit (Optional[str]) – the unit of the combined parameter
-- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
+
- aggregator (Optional[Callable[list[any]]]) – a function to aggregate
the set values into one
@@ -2682,7 +2764,7 @@ Submodules>>> .feedback(set_values, measured_values)
-
+
Todo
- Link to adawptive sweep
diff --git a/auto/qcodes.instrument_drivers.AlazarTech.html b/auto/qcodes.instrument_drivers.AlazarTech.html
index 491714a2c52..2eb7df0d13a 100644
--- a/auto/qcodes.instrument_drivers.AlazarTech.html
+++ b/auto/qcodes.instrument_drivers.AlazarTech.html
@@ -425,7 +425,7 @@ SubmodulesReturns: list of board info for each connected board
-Return type: list
+Return type: list
diff --git a/auto/qcodes.instrument_drivers.rohde_schwarz.html b/auto/qcodes.instrument_drivers.rohde_schwarz.html
index 240f30dff49..17024dd2e8a 100644
--- a/auto/qcodes.instrument_drivers.rohde_schwarz.html
+++ b/auto/qcodes.instrument_drivers.rohde_schwarz.html
@@ -602,7 +602,7 @@ Submodules
-
class
qcodes.instrument_drivers.rohde_schwarz.ZNB20.
FrequencySweep
(name, instrument, start, stop, npts)[source]¶
-Bases: qcodes.instrument.parameter.Parameter
+Bases: qcodes.instrument.parameter.MultiParameter
Hardware controlled parameter class for Rohde Schwarz RSZNB20 trace.
Instrument returns an list of transmission data in the form of a list of
complex numbers taken from a frequency sweep.
diff --git a/auto/qcodes.instrument_drivers.signal_hound.html b/auto/qcodes.instrument_drivers.signal_hound.html
index 359b0216f4a..3f0e7ca9ea8 100644
--- a/auto/qcodes.instrument_drivers.signal_hound.html
+++ b/auto/qcodes.instrument_drivers.signal_hound.html
@@ -282,12 +282,12 @@ Submodules
-
-
saStatus
= {'saBandwidthClamped': 4, 'saInvalidDetectorErr': -95, 'saParameterClamped': 3, 'saNullPtrErr': -1, 'saDeviceNotFoundErr': -8, 'saTrackingGeneratorNotFound': -10, 'saNoCorrections': 1, 'saInvalidModeErr': -7, 'saExternalReferenceNotFound': -89, 'saNotConfiguredErr': -6, 'saOvenColdErr': -20, 'saInvalidScaleErr': -94, 'saInvalidDeviceErr': -2, 'saInvalidParameterErr': -4, 'saDeviceNotConfiguredErr': -6, 'saUnknownErr': -666, 'saFrequencyRangeErr': -99, 'saTooManyDevicesErr': -5, 'saNoError': 0, 'saUSBCommErr': -11, 'saDeviceNotIdleErr': -9, 'saCompressionWarning': 2, 'saBandwidthErr': -91, 'saInternetErr': -12, 'saDeviceNotOpenErr': -3}¶
+saStatus
= {'saExternalReferenceNotFound': -89, 'saOvenColdErr': -20, 'saNoError': 0, 'saTooManyDevicesErr': -5, 'saUnknownErr': -666, 'saDeviceNotConfiguredErr': -6, 'saDeviceNotOpenErr': -3, 'saBandwidthClamped': 4, 'saParameterClamped': 3, 'saInternetErr': -12, 'saUSBCommErr': -11, 'saTrackingGeneratorNotFound': -10, 'saInvalidScaleErr': -94, 'saInvalidDetectorErr': -95, 'saNullPtrErr': -1, 'saNoCorrections': 1, 'saCompressionWarning': 2, 'saBandwidthErr': -91, 'saDeviceNotIdleErr': -9, 'saInvalidDeviceErr': -2, 'saNotConfiguredErr': -6, 'saInvalidModeErr': -7, 'saFrequencyRangeErr': -99, 'saInvalidParameterErr': -4, 'saDeviceNotFoundErr': -8}¶
-
-
saStatus_inverted
= {0: 'saNoError', 1: 'saNoCorrections', 2: 'saCompressionWarning', 3: 'saParameterClamped', 4: 'saBandwidthClamped', -99: 'saFrequencyRangeErr', -95: 'saInvalidDetectorErr', -94: 'saInvalidScaleErr', -91: 'saBandwidthErr', -666: 'saUnknownErr', -89: 'saExternalReferenceNotFound', -20: 'saOvenColdErr', -12: 'saInternetErr', -1: 'saNullPtrErr', -10: 'saTrackingGeneratorNotFound', -9: 'saDeviceNotIdleErr', -8: 'saDeviceNotFoundErr', -7: 'saInvalidModeErr', -6: 'saDeviceNotConfiguredErr', -5: 'saTooManyDevicesErr', -4: 'saInvalidParameterErr', -3: 'saDeviceNotOpenErr', -2: 'saInvalidDeviceErr', -11: 'saUSBCommErr'}¶
+saStatus_inverted
= {0: 'saNoError', 1: 'saNoCorrections', 2: 'saCompressionWarning', 3: 'saParameterClamped', 4: 'saBandwidthClamped', -1: 'saNullPtrErr', -99: 'saFrequencyRangeErr', -95: 'saInvalidDetectorErr', -94: 'saInvalidScaleErr', -91: 'saBandwidthErr', -666: 'saUnknownErr', -89: 'saExternalReferenceNotFound', -20: 'saOvenColdErr', -12: 'saInternetErr', -11: 'saUSBCommErr', -10: 'saTrackingGeneratorNotFound', -9: 'saDeviceNotIdleErr', -8: 'saDeviceNotFoundErr', -7: 'saInvalidModeErr', -6: 'saNotConfiguredErr', -5: 'saTooManyDevicesErr', -4: 'saInvalidParameterErr', -3: 'saDeviceNotOpenErr', -2: 'saInvalidDeviceErr'}¶
diff --git a/auto/qcodes.instrument_drivers.tektronix.html b/auto/qcodes.instrument_drivers.tektronix.html
index ae456bb9f63..9b053384aa5 100644
--- a/auto/qcodes.instrument_drivers.tektronix.html
+++ b/auto/qcodes.instrument_drivers.tektronix.html
@@ -208,12 +208,12 @@ Submodules
-
-
AWG_FILE_FORMAT_CHANNEL
= {'MARKER2_AMPLITUDE_N': 'd', 'DELAY_IN_TIME_N': 'd', 'ANALOG_METHOD_N': 'h', 'MARKER1_OFFSET_N': 'd', 'ANALOG_HIGH_N': 'd', 'ANALOG_DIRECT_OUTPUT_N': 'h', 'MARKER2_LOW_N': 'd', 'OUTPUT_WAVEFORM_NAME_N': 's', 'MARKER1_AMPLITUDE_N': 'd', 'PHASE_N': 'd', 'ANALOG_AMPLITUDE_N': 'd', 'DIGITAL_OFFSET_N': 'd', 'DIGITAL_AMPLITUDE_N': 'd', 'ANALOG_LOW_N': 'd', 'PHASE_DELAY_INPUT_METHOD_N': 'h', 'MARKER1_LOW_N': 'd', 'DC_OUTPUT_LEVEL_N': 'd', 'MARKER2_SKEW_N': 'd', 'DIGITAL_METHOD_N': 'h', 'MARKER2_HIGH_N': 'd', 'CHANNEL_SKEW_N': 'd', 'MARKER2_METHOD_N': 'h', 'MARKER1_SKEW_N': 'd', 'DIGITAL_LOW_N': 'd', 'DELAY_IN_POINTS_N': 'd', 'ANALOG_OFFSET_N': 'd', 'DIGITAL_HIGH_N': 'd', 'EXTERNAL_ADD_N': 'h', 'MARKER1_METHOD_N': 'h', 'MARKER2_OFFSET_N': 'd', 'MARKER1_HIGH_N': 'd', 'ANALOG_FILTER_N': 'h', 'CHANNEL_STATE_N': 'h'}¶
+AWG_FILE_FORMAT_CHANNEL
= {'ANALOG_HIGH_N': 'd', 'DIGITAL_AMPLITUDE_N': 'd', 'MARKER2_OFFSET_N': 'd', 'DIGITAL_HIGH_N': 'd', 'PHASE_N': 'd', 'DELAY_IN_TIME_N': 'd', 'ANALOG_LOW_N': 'd', 'MARKER1_HIGH_N': 'd', 'OUTPUT_WAVEFORM_NAME_N': 's', 'MARKER2_HIGH_N': 'd', 'ANALOG_DIRECT_OUTPUT_N': 'h', 'MARKER2_SKEW_N': 'd', 'DELAY_IN_POINTS_N': 'd', 'MARKER1_OFFSET_N': 'd', 'CHANNEL_STATE_N': 'h', 'ANALOG_FILTER_N': 'h', 'ANALOG_AMPLITUDE_N': 'd', 'MARKER2_AMPLITUDE_N': 'd', 'EXTERNAL_ADD_N': 'h', 'MARKER1_LOW_N': 'd', 'MARKER2_METHOD_N': 'h', 'DIGITAL_METHOD_N': 'h', 'DC_OUTPUT_LEVEL_N': 'd', 'ANALOG_OFFSET_N': 'd', 'MARKER2_LOW_N': 'd', 'MARKER1_METHOD_N': 'h', 'DIGITAL_OFFSET_N': 'd', 'MARKER1_AMPLITUDE_N': 'd', 'CHANNEL_SKEW_N': 'd', 'DIGITAL_LOW_N': 'd', 'ANALOG_METHOD_N': 'h', 'MARKER1_SKEW_N': 'd', 'PHASE_DELAY_INPUT_METHOD_N': 'h'}¶
-
-
AWG_FILE_FORMAT_HEAD
= {'TRIGGER_INPUT_THRESHOLD': 'd', 'INTERLEAVE_ADJ_AMPLITUDE': 'd', 'INTERLEAVE_ADJ_PHASE': 'd', 'WAIT_VALUE': 'h', 'CLOCK_SOURCE': 'h', 'TRIGGER_INPUT_IMPEDANCE': 'h', 'HOLD_REPETITION_RATE': 'h', 'EVENT_INPUT_POLARITY': 'h', 'REFERENCE_SOURCE': 'h', 'RUN_STATE': 'h', 'TRIGGER_SOURCE': 'h', 'EVENT_INPUT_THRESHOLD': 'd', 'REPETITION_RATE': 'd', 'REFERENCE_MULTIPLIER_RATE': 'h', 'COUPLING': 'h', 'EXTERNAL_REFERENCE_TYPE': 'h', 'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h', 'SAMPLING_RATE': 'd', 'RUN_MODE': 'h', 'TRIGGER_INPUT_SLOPE': 'h', 'DIVIDER_RATE': 'h', 'EVENT_INPUT_IMPEDANCE': 'h', 'TRIGGER_INPUT_POLARITY': 'h', 'JUMP_TIMING': 'h', 'ZEROING': 'h', 'INTERNAL_TRIGGER_RATE': 'd', 'INTERLEAVE': 'h'}¶
+AWG_FILE_FORMAT_HEAD
= {'HOLD_REPETITION_RATE': 'h', 'TRIGGER_INPUT_POLARITY': 'h', 'RUN_STATE': 'h', 'TRIGGER_INPUT_IMPEDANCE': 'h', 'ZEROING': 'h', 'REFERENCE_MULTIPLIER_RATE': 'h', 'REFERENCE_SOURCE': 'h', 'EVENT_INPUT_IMPEDANCE': 'h', 'INTERNAL_TRIGGER_RATE': 'd', 'INTERLEAVE_ADJ_PHASE': 'd', 'INTERLEAVE': 'h', 'TRIGGER_INPUT_THRESHOLD': 'd', 'RUN_MODE': 'h', 'TRIGGER_INPUT_SLOPE': 'h', 'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h', 'REPETITION_RATE': 'd', 'EXTERNAL_REFERENCE_TYPE': 'h', 'WAIT_VALUE': 'h', 'EVENT_INPUT_THRESHOLD': 'd', 'JUMP_TIMING': 'h', 'DIVIDER_RATE': 'h', 'SAMPLING_RATE': 'd', 'TRIGGER_SOURCE': 'h', 'EVENT_INPUT_POLARITY': 'h', 'CLOCK_SOURCE': 'h', 'INTERLEAVE_ADJ_AMPLITUDE': 'd', 'COUPLING': 'h'}¶
diff --git a/auto/qcodes.tests.html b/auto/qcodes.tests.html
index 6f48829ea18..d3ed1081a30 100644
--- a/auto/qcodes.tests.html
+++ b/auto/qcodes.tests.html
@@ -424,7 +424,7 @@ Submodules
-
class
qcodes.tests.instrument_mocks.
MultiGetter
(**kwargs)[source]¶
-Bases: qcodes.instrument.parameter.Parameter
+Bases: qcodes.instrument.parameter.MultiParameter
Test parameters with complicated return values
instantiate with kwargs:
MultiGetter(name1=return_val1, name2=return_val2)
@@ -1421,6 +1421,16 @@ Submodulestest_depth()[source]¶
+
+
+
+
-
test_simple
()[source]¶
@@ -2487,6 +2497,124 @@ Submodules
qcodes.tests.test_parameter module¶
Test suite for parameter
+
+
+
+
+
+
+
+
+
+-
+class
qcodes.tests.test_parameter.
SimpleArrayParam
(return_val, *args, **kwargs)[source]¶
+-
+
+
+
+
+
+
+
+-
+class
qcodes.tests.test_parameter.
SimpleMultiParam
(return_val, *args, **kwargs)[source]¶
+-
+
+
+
+
+
+-
+class
qcodes.tests.test_parameter.
TestArrayParameter
(methodName='runTest')[source]¶
+Bases: unittest.case.TestCase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
class
qcodes.tests.test_parameter.
TestManualParameter
(methodName='runTest')[source]¶
@@ -2499,37 +2627,78 @@ Submodules
--
-class
qcodes.tests.test_parameter.
TestParamConstructor
(methodName='runTest')[source]¶
+-
+class
qcodes.tests.test_parameter.
TestMultiParameter
(methodName='runTest')[source]¶
Bases: unittest.case.TestCase
-
--
-
blank_instruments
= (None, noname(), blank(name=''))¶
+
-
+
+
+-
+class
qcodes.tests.test_parameter.
TestParameter
(methodName='runTest')[source]¶
+Bases: unittest.case.TestCase
+
+
+
+
+
+
+
@@ -2538,11 +2707,56 @@ Submodules
class qcodes.tests.test_parameter.
TestStandardParam
(methodName='runTest')[source]¶
Bases: unittest.case.TestCase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2909,7 +3123,7 @@ Submodules
-
-
not_strings
= [0, 1, 10000000000.0, b'', b'\xc3\x98rsted F\xc3\xa6lled', b'\xe5\xa4\x8f\xe6\x97\xa5\xe7\x95\x85\xe9\x94\x80\xe6\xa6\x9c\xe5\xa4\xa7\xe7\x89\x8c\xe7\xbe\x8e', [], [1, 2, 3], {}, {'b': 2, 'a': 1}, True, False, None, <class 'qcodes.tests.test_validators.AClass'>, <qcodes.tests.test_validators.AClass object>, <function a_func>]¶
+not_strings
= [0, 1, 10000000000.0, b'', b'\xc3\x98rsted F\xc3\xa6lled', b'\xe5\xa4\x8f\xe6\x97\xa5\xe7\x95\x85\xe9\x94\x80\xe6\xa6\x9c\xe5\xa4\xa7\xe7\x89\x8c\xe7\xbe\x8e', [], [1, 2, 3], {}, {'a': 1, 'b': 2}, True, False, None, <class 'qcodes.tests.test_validators.AClass'>, <qcodes.tests.test_validators.AClass object>, <function a_func>]¶
@@ -3004,17 +3218,17 @@ Submodulesunittest.case.TestCase
-
-
args1
= ['be more positive!', "writing 'STAT:-10.000' to <MockVisa: Joe>", 'setting Joe:state to -10']¶
+args1
= ['be more positive!', "writing 'STAT:-10.000' to <MockVisa: Joe>", 'setting Joe_state to -10']¶
-
-
args2
= ["writing 'STAT:0.000' to <MockVisa: Joe>", 'setting Joe:state to 0']¶
+args2
= ["writing 'STAT:0.000' to <MockVisa: Joe>", 'setting Joe_state to 0']¶
-
-
args3
= ["I'm out of fingers", "asking 'STAT?' to <MockVisa: Joe>", 'getting Joe:state']¶
+args3
= ["I'm out of fingers", "asking 'STAT?' to <MockVisa: Joe>", 'getting Joe_state']¶
diff --git a/auto/qcodes.utils.html b/auto/qcodes.utils.html
index 22902dcc3ac..bd84533c48f 100644
--- a/auto/qcodes.utils.html
+++ b/auto/qcodes.utils.html
@@ -298,7 +298,7 @@ Submodules>>> (d*5)()
210
>>> (d>10)()
-rue
+True
>>> ((84/d) + (d*d))()
1766
@@ -322,18 +322,13 @@ Submodules
--
-
get
()[source]¶
-
-
-
qcodes.utils.deferred_operations.
is_function
(f, arg_count, coroutine=False)[source]¶
-Check and require a function that can accept the specified number of positional
-arguments, which either is or is not a coroutine
+
Check and require a function that can accept the specified number of
+positional arguments, which either is or is not a coroutine
type casting “functions” are allowed, but only in the 1-argument form