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

Mark array parameter setpoints as such #501

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion qcodes/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def _make_setpoint_array(self, shape, i, prev_setpoints, vals, name,
name = 'index{}'.format(i)

return DataArray(name=name, label=label, set_arrays=prev_setpoints,
shape=shape, preset_data=vals)
shape=shape, preset_data=vals, is_setpoint=True)

def _default_setpoints(self, shape):
if len(shape) == 1:
Expand Down
18 changes: 9 additions & 9 deletions qcodes/tests/test_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_sync_no_overwrite(self):
self.gates.chan2[0:1:1], 0.000001))
data = loop.get_data_set(name='testsweep', write_period=0.01)
_ = loop.with_bg_task(data.sync).run()
assert not np.isnan(data.chan2).any()
assert not np.isnan(data.chan2_set).any()

def sleeper(t):
time.sleep(t)
Expand Down Expand Up @@ -467,7 +467,7 @@ def test_composite_params(self):
self.assertEqual(data.p1_set.tolist(), [1, 2])
self.assertEqual(data.one.tolist(), [1, 1])
self.assertEqual(data.onetwo.tolist(), [[1, 2]] * 2)
self.assertEqual(data.index0.tolist(), [[0, 1]] * 2)
self.assertEqual(data.index0_set.tolist(), [[0, 1]] * 2)

# give it setpoints, names, and labels
mg.setpoints = (None, ((10, 11),))
Expand All @@ -478,8 +478,8 @@ def test_composite_params(self):

data = loop.run_temp()

self.assertEqual(data.highest.tolist(), [[10, 11]] * 2)
self.assertEqual(data.highest.label, sp_label)
self.assertEqual(data.highest_set.tolist(), [[10, 11]] * 2)
self.assertEqual(data.highest_set.label, sp_label)

# setpoints as DataArray - name and label here override
# setpoint_names and setpoint_labels attributes
Expand All @@ -490,8 +490,8 @@ def test_composite_params(self):
mg.setpoints = (None, (sp_dataarray,))

data = loop.run_temp()
self.assertEqual(data.bgn.tolist(), [[6, 7]] * 2)
self.assertEqual(data.bgn.label, new_sp_label)
self.assertEqual(data.bgn_set.tolist(), [[6, 7]] * 2)
self.assertEqual(data.bgn_set.label, new_sp_label)

# muck things up and test for errors
mg.setpoints = (None, ((1, 2, 3),))
Expand Down Expand Up @@ -522,16 +522,16 @@ def test_composite_params(self):

self.assertEqual(data.p1_set.tolist(), [1, 2])
self.assertEqual(data.arr.tolist(), [[4, 5, 6]] * 2)
self.assertEqual(data.index0.tolist(), [[0, 1, 2]] * 2)
self.assertEqual(data.index0_set.tolist(), [[0, 1, 2]] * 2)

mg = MultiGetter(arr2d=((21, 22), (23, 24)))
loop = Loop(self.p1[1:3:1], 0.001).each(mg)
data = loop.run_temp()

self.assertEqual(data.p1_set.tolist(), [1, 2])
self.assertEqual(data.arr2d.tolist(), [[[21, 22], [23, 24]]] * 2)
self.assertEqual(data.index0.tolist(), [[0, 1]] * 2)
self.assertEqual(data.index1.tolist(), [[[0, 1]] * 2] * 2)
self.assertEqual(data.index0_set.tolist(), [[0, 1]] * 2)
self.assertEqual(data.index1_set.tolist(), [[[0, 1]] * 2] * 2)

def test_bad_actors(self):
def f():
Expand Down
4 changes: 2 additions & 2 deletions qcodes/tests/test_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_simple_scalar(self):
def test_simple_array(self):
data = Measure(MultiGetter(arr=(1.2, 3.4))).run_temp()

self.assertEqual(data.index0.tolist(), [0, 1])
self.assertEqual(data.index0_set.tolist(), [0, 1])
self.assertEqual(data.arr.tolist(), [1.2, 3.4])
self.assertEqual(len(data.arrays), 2, data.arrays)

Expand All @@ -44,6 +44,6 @@ def test_array_and_scalar(self):

self.assertEqual(data.single_set.tolist(), [0])
self.assertEqual(data.P1.tolist(), [42])
self.assertEqual(data.index0.tolist(), [0, 1])
self.assertEqual(data.index0_set.tolist(), [0, 1])
self.assertEqual(data.arr.tolist(), [5, 6])
self.assertEqual(len(data.arrays), 4, data.arrays)