Skip to content

Commit bd43328

Browse files
jenshnielsenWilliamHPNielsen
authored andcommitted
Hypothesis warnings (#905)
* Add deadlines to tests that run longer than default * reduce verbosity of debug output Logging at every step is a bit too much * more useful debug message * higher deadline
1 parent b9ab98d commit bd43328

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

qcodes/data/data_set.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ def store(self, loop_indices, ids_values):
392392
log.debug('Attempting to write')
393393
self.write()
394394
self.last_write = time.time()
395-
else:
396-
log.debug('.store method: This is not the right time to write')
395+
# The below could be useful but as it writes at every single
396+
# step of the loop its too verbose even at debug
397+
# else:
398+
# log.debug('.store method: This is not the right time to write')
397399

398400
def default_parameter_name(self, paramname='amplitude'):
399401
""" Return name of default parameter for plotting

qcodes/data/gnuplot_format.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ def write(self, data_set, io_manager, location, force_write=False,
273273
# Every group gets its own datafile
274274
for group in groups:
275275
log.debug('Attempting to write the following '
276-
'group: {}'.format(group))
276+
'group: {}'.format(group.name))
277+
# it might be useful to output the whole group as below but it is
278+
# very verbose
279+
#log.debug('containing {}'.format(group))
277280

278281
if filename:
279282
fn = io_manager.join(location, filename + self.extension)
@@ -316,7 +319,8 @@ def write(self, data_set, io_manager, location, force_write=False,
316319

317320
one_point = self._data_point(group, indices)
318321
f.write(self.separator.join(one_point) + self.terminator)
319-
log.debug('Wrote to file')
322+
log.debug('Wrote to file from '
323+
'{} to {}'.format(save_range[0], save_range[1]+1))
320324
# now that we've saved the data, mark it as such in the data.
321325
# we mark the data arrays and the inner setpoint array. Outer
322326
# setpoint arrays have different dimension (so would need a

qcodes/loops.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
842842
set_name = self.data_set.action_id_map[action_indices]
843843
if hasattr(self.sweep_values, 'aggregate'):
844844
value = self.sweep_values.aggregate(*set_val)
845-
log.debug('Calling .store method of DataSet because '
846-
'sweep_values.parameters exist')
845+
# below is useful but too verbose even at debug
846+
# log.debug('Calling .store method of DataSet because '
847+
# 'sweep_values.parameters exist')
847848
self.data_set.store(new_indices, {set_name: value})
848849
# set_val list of values to set [param1_setpoint, param2_setpoint ..]
849850
for j, val in enumerate(set_val):
@@ -853,9 +854,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
853854
else:
854855
set_name = self.data_set.action_id_map[action_indices]
855856
data_to_store[set_name] = value
856-
857-
log.debug('Calling .store method of DataSet because a sweep step'
858-
' was taken')
857+
# below is useful but too verbose even at debug
858+
# log.debug('Calling .store method of DataSet because a sweep step'
859+
# ' was taken')
859860
self.data_set.store(new_indices, data_to_store)
860861

861862
if not self._nest_first:
@@ -864,8 +865,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
864865

865866
try:
866867
for f in callables:
867-
log.debug('Going through callables at this sweep step.'
868-
' Calling {}'.format(f))
868+
# below is useful but too verbose even at debug
869+
# log.debug('Going through callables at this sweep step.'
870+
# ' Calling {}'.format(f))
869871
f(first_delay=delay,
870872
loop_indices=new_indices,
871873
current_values=new_values)
@@ -903,9 +905,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
903905
self.bg_task()
904906

905907
# the loop is finished - run the .then actions
906-
log.debug('Finishing loop, running the .then actions...')
908+
#log.debug('Finishing loop, running the .then actions...')
907909
for f in self._compile_actions(self.then_actions, ()):
908-
log.debug('...running .then action {}'.format(f))
910+
#log.debug('...running .then action {}'.format(f))
909911
f()
910912

911913
# run the bg_final_task from the bg_task:

qcodes/tests/test_channels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_loop_measure_channels_individually(self):
162162
self.assertEqual(getattr(data, 'testchanneldummy_Chan{}_temperature'.format(chan)).ndarray.shape, (21,))
163163

164164
@given(values=hst.lists(hst.floats(0, 300), min_size=4, max_size=4))
165-
@settings(max_examples=10)
165+
@settings(max_examples=10, deadline=300)
166166
def test_loop_measure_channels_by_name(self, values):
167167
p1 = Parameter(name='p1', vals=Numbers(-10, 10), get_cmd=None, set_cmd=None)
168168
for i in range(4):
@@ -180,7 +180,7 @@ def test_loop_measure_channels_by_name(self, values):
180180

181181
@given(loop_channels=hst.lists(hst.integers(0, 3), min_size=2, max_size=2, unique=True),
182182
measure_channel=hst.integers(0, 3))
183-
@settings(max_examples=10)
183+
@settings(max_examples=10, deadline=400)
184184
def test_nested_loop_over_channels(self, loop_channels, measure_channel):
185185
channel_to_label = {0: 'A', 1: 'B', 2: 'C', 3: "D"}
186186
loop = Loop(self.instrument.channels[loop_channels[0]].temperature.sweep(0, 10, 0.5))

qcodes/tests/test_combined_loop.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def tearDownClass(cls):
2828
min_size=2, max_size=2, unique=True).map(sorted),
2929
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
3030
min_size=2, max_size=2, unique=True).map(sorted))
31-
@settings(max_examples=10)
31+
@settings(max_examples=10, deadline=300)
3232
def testLoopCombinedParameterPrintTask(self, npoints, x_start_stop, y_start_stop, z_start_stop):
3333

3434
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
@@ -64,7 +64,7 @@ def btaskfunc():
6464
min_size=2, max_size=2, unique=True).map(sorted),
6565
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
6666
min_size=2, max_size=2, unique=True).map(sorted))
67-
@settings(max_examples=10)
67+
@settings(max_examples=10, deadline=300)
6868
def testLoopCombinedParameterTwice(self, npoints, x_start_stop, y_start_stop, z_start_stop):
6969
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
7070
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)
@@ -102,7 +102,7 @@ def inner():
102102
min_size=2, max_size=2, unique=True).map(sorted),
103103
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
104104
min_size=2, max_size=2, unique=True).map(sorted))
105-
@settings(max_examples=10)
105+
@settings(max_examples=10, deadline=300)
106106
def testLoopCombinedParameterAndMore(self, npoints, x_start_stop, y_start_stop, z_start_stop):
107107
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
108108
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)
@@ -134,15 +134,15 @@ def inner():
134134
np.testing.assert_array_equal(data.arrays['dmm_somethingelse'].ndarray, np.ones(npoints))
135135
np.testing.assert_array_equal(data.arrays['dmm_voltage_2'].ndarray, np.arange(2, npoints * 2 + 1, 2))
136136

137-
@given(npoints=hst.integers(2, 100),
138-
npoints_outer=hst.integers(2,100),
137+
@given(npoints=hst.integers(2, 50),
138+
npoints_outer=hst.integers(2,25),
139139
x_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
140140
min_size=2, max_size=2, unique=True).map(sorted),
141141
y_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
142142
min_size=2, max_size=2, unique=True).map(sorted),
143143
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
144144
min_size=2, max_size=2, unique=True).map(sorted))
145-
@settings(max_examples=10)
145+
@settings(max_examples=10, deadline=1000)
146146
def testLoopCombinedParameterInside(self, npoints, npoints_outer, x_start_stop, y_start_stop, z_start_stop):
147147
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints_outer)
148148
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)

0 commit comments

Comments
 (0)