Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct metadata for MultiParameter units #500

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions qcodes/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to get rid of it. In principle that should always be the case as units is constructed as
len(names)*" " (wrapped in the right tuples) if not supplied. All of this extra handling was just to fix a test that explicitly deletes names from the loop and checks for the ValueError above

shapes = getattr(action, 'shapes', None)
sp_vals = getattr(action, 'setpoints', None)
sp_names = getattr(action, 'setpoint_names', None)
Expand All @@ -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 == ():
Expand All @@ -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
Expand Down