From 0b6e3915f714ad224a4c91708dbb829a115483a0 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Mon, 20 Feb 2017 16:22:54 +0100 Subject: [PATCH] Fix: Partial fix for #499 propagate units to subarray --- qcodes/loops.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qcodes/loops.py b/qcodes/loops.py index 0b5c554c63c..4a6de7137ea 100644 --- a/qcodes/loops.py +++ b/qcodes/loops.py @@ -553,8 +553,15 @@ def _parameter_arrays(self, action): 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) + num_units = len(units) + assert num_arrays == num_units shapes = getattr(action, 'shapes', None) sp_vals = getattr(action, 'setpoints', None) sp_names = getattr(action, 'setpoint_names', None) @@ -577,8 +584,8 @@ def _parameter_arrays(self, action): # 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, + for name, full_name, label, unit, shape, i, sp_vi, sp_ni, sp_li in zip( + names, full_names, labels, units, shapes, action_indices, sp_vals, sp_names, sp_labels): if shape is None or shape == (): @@ -600,7 +607,7 @@ def _parameter_arrays(self, action): # 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