From 991566374dcb3a41160b201be29c50ab8eb8907c Mon Sep 17 00:00:00 2001 From: Documentation Bot Date: Tue, 7 Mar 2017 15:26:08 +0000 Subject: [PATCH] Generated gh-pages for commit b5da731 Author: Jens Hedegaard Nielsen Multiparameter fixes (#512) --- _modules/qcodes/instrument/parameter.html | 25 +++++++++++++--- _modules/qcodes/loops.html | 29 ++++++++++++------- .../qcodes.instrument_drivers.ithaco.html | 2 +- ...codes.instrument_drivers.signal_hound.html | 4 +-- .../qcodes.instrument_drivers.tektronix.html | 4 +-- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/_modules/qcodes/instrument/parameter.html b/_modules/qcodes/instrument/parameter.html index 538db647a31..63109003915 100644 --- a/_modules/qcodes/instrument/parameter.html +++ b/_modules/qcodes/instrument/parameter.html @@ -597,7 +597,9 @@

Source code for qcodes.instrument.parameter

             per setpoint array. Ignored if a setpoint is a DataArray, which
             already has a label.
 
-            TODO (alexcjohnson) we need setpoint_units (and in MultiParameter)
+        setpoint_units (Optional[Tuple[str]]): one label (like ``v``)
+            per setpoint array. Ignored if a setpoint is a DataArray, which
+            already has a unit.
 
         docstring (Optional[str]): documentation string for the __doc__
             field of the object. The __doc__ field of the instance is used by
@@ -612,14 +614,14 @@ 

Source code for qcodes.instrument.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):
+                 setpoint_units=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',
+        self._meta_attrs.extend(['setpoint_names', 'setpoint_labels', 'setpoint_units',
                                  'label', 'unit'])
 
         self.label = name if label is None else label
@@ -652,10 +654,15 @@ 

Source code for qcodes.instrument.parameter

                 not is_sequence_of(setpoint_labels, (nt, str),
                                    shape=sp_shape)):
             raise ValueError('setpoint_labels must be a tuple of strings')
+        if (setpoint_units is not None and
+                not is_sequence_of(setpoint_units, (nt, str),
+                                   shape=sp_shape)):
+            raise ValueError('setpoint_units must be a tuple of strings')
 
         self.setpoints = setpoints
         self.setpoint_names = setpoint_names
         self.setpoint_labels = setpoint_labels
+        self.setpoint_units = setpoint_units
 
         self.__doc__ = os.linesep.join((
             'Parameter class:',
@@ -755,6 +762,10 @@ 

Source code for qcodes.instrument.parameter

             ``labels``) per setpoint array. Ignored if a setpoint is a
             DataArray, which already has a label.
 
+        setpoint_units (Optional[Tuple[Tuple[str]]]): one unit (like
+            ``V``) per setpoint array. Ignored if a setpoint is a
+            DataArray, which already has a unit.
+
         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
@@ -768,6 +779,7 @@ 

Source code for qcodes.instrument.parameter

     def __init__(self, name, names, shapes, instrument=None,
                  labels=None, units=None,
                  setpoints=None, setpoint_names=None, setpoint_labels=None,
+                 setpoint_units=None,
                  docstring=None, snapshot_get=True, metadata=None):
         super().__init__(name, instrument, snapshot_get, metadata)
 
@@ -775,7 +787,7 @@ 

Source code for qcodes.instrument.parameter

             raise AttributeError('MultiParameters do not support set '
                                  'at this time.')
 
-        self._meta_attrs.extend(['setpoint_names', 'setpoint_labels',
+        self._meta_attrs.extend(['setpoint_names', 'setpoint_labels', 'setpoint_units',
                                  'names', 'labels', 'units'])
 
         if not is_sequence_of(names, str):
@@ -807,9 +819,14 @@ 

Source code for qcodes.instrument.parameter

             raise ValueError(
                 'setpoint_labels must be a tuple of tuples of strings')
 
+        if not _is_nested_sequence_or_none(setpoint_units, (nt, str), shapes):
+            raise ValueError(
+                'setpoint_units must be a tuple of tuples of strings')
+
         self.setpoints = setpoints
         self.setpoint_names = setpoint_names
         self.setpoint_labels = setpoint_labels
+        self.setpoint_units = setpoint_units
 
         self.__doc__ = os.linesep.join((
             'MultiParameter class:',
diff --git a/_modules/qcodes/loops.html b/_modules/qcodes/loops.html
index 0497a8da0ab..462d3f85235 100644
--- a/_modules/qcodes/loops.html
+++ b/_modules/qcodes/loops.html
@@ -720,18 +720,25 @@ 

Source code for qcodes.loops

             action_indices = ((),)
         else:
             raise ValueError('a gettable parameter must have .name or .names')
-
+        if hasattr(action, 'names') and hasattr(action, 'units'):
+            units = action.units
+        elif hasattr(action, 'unit'):
+            units = (action.unit,)
+        else:
+            units = tuple(['']*len(names))
         num_arrays = len(names)
         shapes = getattr(action, 'shapes', None)
         sp_vals = getattr(action, 'setpoints', None)
         sp_names = getattr(action, 'setpoint_names', None)
         sp_labels = getattr(action, 'setpoint_labels', None)
+        sp_units = getattr(action, 'setpoint_units', None)
 
         if shapes is None:
             shapes = (getattr(action, 'shape', ()),) * num_arrays
             sp_vals = (sp_vals,) * num_arrays
             sp_names = (sp_names,) * num_arrays
             sp_labels = (sp_labels,) * num_arrays
+            sp_units = (sp_units,) * num_arrays
         else:
             sp_blank = (None,) * num_arrays
             # _fill_blank both supplies defaults and tests length
@@ -740,26 +747,28 @@ 

Source code for qcodes.loops

             sp_vals = self._fill_blank(sp_vals, sp_blank)
             sp_names = self._fill_blank(sp_names, sp_blank)
             sp_labels = self._fill_blank(sp_labels, sp_blank)
+            sp_units = self._fill_blank(sp_units, sp_blank)
 
         # now loop through these all, to make the DataArrays
         # record which setpoint arrays we've made, so we don't duplicate
         all_setpoints = {}
-        for name, full_name, label, shape, i, sp_vi, sp_ni, sp_li in zip(
-                names, full_names, labels, shapes, action_indices,
-                sp_vals, sp_names, sp_labels):
+        for name, full_name, label, unit, shape, i, sp_vi, sp_ni, sp_li, sp_ui in zip(
+                names, full_names, labels, units, shapes, action_indices,
+                sp_vals, sp_names, sp_labels, sp_units):
 
             if shape is None or shape == ():
-                shape, sp_vi, sp_ni, sp_li = (), (), (), ()
+                shape, sp_vi, sp_ni, sp_li, sp_ui= (), (), (), (), ()
             else:
                 sp_blank = (None,) * len(shape)
                 sp_vi = self._fill_blank(sp_vi, sp_blank)
                 sp_ni = self._fill_blank(sp_ni, sp_blank)
                 sp_li = self._fill_blank(sp_li, sp_blank)
+                sp_ui = self._fill_blank(sp_ui, sp_blank)
 
             setpoints = ()
             # loop through dimensions of shape to make the setpoint arrays
-            for j, (vij, nij, lij) in enumerate(zip(sp_vi, sp_ni, sp_li)):
-                sp_def = (shape[: 1 + j], j, setpoints, vij, nij, lij)
+            for j, (vij, nij, lij, uij) in enumerate(zip(sp_vi, sp_ni, sp_li, sp_ui)):
+                sp_def = (shape[: 1 + j], j, setpoints, vij, nij, lij, uij)
                 if sp_def not in all_setpoints:
                     all_setpoints[sp_def] = self._make_setpoint_array(*sp_def)
                     out.append(all_setpoints[sp_def])
@@ -767,7 +776,7 @@ 

Source code for qcodes.loops

 
             # finally, make the output data array with these setpoints
             out.append(DataArray(name=name, full_name=full_name, label=label,
-                                 shape=shape, action_indices=i,
+                                 shape=shape, action_indices=i, unit=unit,
                                  set_arrays=setpoints, parameter=action))
 
         return out
@@ -781,7 +790,7 @@ 

Source code for qcodes.loops

             raise ValueError('Wrong number of inputs supplied')
 
     def _make_setpoint_array(self, shape, i, prev_setpoints, vals, name,
-                             label):
+                             label, unit):
         if vals is None:
             vals = self._default_setpoints(shape)
         elif isinstance(vals, DataArray):
@@ -809,7 +818,7 @@ 

Source code for qcodes.loops

             name = 'index{}'.format(i)
 
         return DataArray(name=name, label=label, set_arrays=prev_setpoints,
-                         shape=shape, preset_data=vals)
+                         shape=shape, preset_data=vals, unit=unit, is_setpoint=True)
 
     def _default_setpoints(self, shape):
         if len(shape) == 1:
diff --git a/api/generated/qcodes.instrument_drivers.ithaco.html b/api/generated/qcodes.instrument_drivers.ithaco.html
index 8135c07eed5..729e21e1af7 100644
--- a/api/generated/qcodes.instrument_drivers.ithaco.html
+++ b/api/generated/qcodes.instrument_drivers.ithaco.html
@@ -217,7 +217,7 @@ 

SubmodulesParameters: