Skip to content

Commit

Permalink
Hypothesis warnings (#905)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jenshnielsen authored and WilliamHPNielsen committed Dec 6, 2017
1 parent b9ab98d commit bd43328
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
6 changes: 4 additions & 2 deletions qcodes/data/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ def store(self, loop_indices, ids_values):
log.debug('Attempting to write')
self.write()
self.last_write = time.time()
else:
log.debug('.store method: This is not the right time to write')
# The below could be useful but as it writes at every single
# step of the loop its too verbose even at debug
# else:
# log.debug('.store method: This is not the right time to write')

def default_parameter_name(self, paramname='amplitude'):
""" Return name of default parameter for plotting
Expand Down
8 changes: 6 additions & 2 deletions qcodes/data/gnuplot_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ def write(self, data_set, io_manager, location, force_write=False,
# Every group gets its own datafile
for group in groups:
log.debug('Attempting to write the following '
'group: {}'.format(group))
'group: {}'.format(group.name))
# it might be useful to output the whole group as below but it is
# very verbose
#log.debug('containing {}'.format(group))

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

one_point = self._data_point(group, indices)
f.write(self.separator.join(one_point) + self.terminator)
log.debug('Wrote to file')
log.debug('Wrote to file from '
'{} to {}'.format(save_range[0], save_range[1]+1))
# now that we've saved the data, mark it as such in the data.
# we mark the data arrays and the inner setpoint array. Outer
# setpoint arrays have different dimension (so would need a
Expand Down
20 changes: 11 additions & 9 deletions qcodes/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
set_name = self.data_set.action_id_map[action_indices]
if hasattr(self.sweep_values, 'aggregate'):
value = self.sweep_values.aggregate(*set_val)
log.debug('Calling .store method of DataSet because '
'sweep_values.parameters exist')
# below is useful but too verbose even at debug
# log.debug('Calling .store method of DataSet because '
# 'sweep_values.parameters exist')
self.data_set.store(new_indices, {set_name: value})
# set_val list of values to set [param1_setpoint, param2_setpoint ..]
for j, val in enumerate(set_val):
Expand All @@ -853,9 +854,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
else:
set_name = self.data_set.action_id_map[action_indices]
data_to_store[set_name] = value

log.debug('Calling .store method of DataSet because a sweep step'
' was taken')
# below is useful but too verbose even at debug
# log.debug('Calling .store method of DataSet because a sweep step'
# ' was taken')
self.data_set.store(new_indices, data_to_store)

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

try:
for f in callables:
log.debug('Going through callables at this sweep step.'
' Calling {}'.format(f))
# below is useful but too verbose even at debug
# log.debug('Going through callables at this sweep step.'
# ' Calling {}'.format(f))
f(first_delay=delay,
loop_indices=new_indices,
current_values=new_values)
Expand Down Expand Up @@ -903,9 +905,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
self.bg_task()

# the loop is finished - run the .then actions
log.debug('Finishing loop, running the .then actions...')
#log.debug('Finishing loop, running the .then actions...')
for f in self._compile_actions(self.then_actions, ()):
log.debug('...running .then action {}'.format(f))
#log.debug('...running .then action {}'.format(f))
f()

# run the bg_final_task from the bg_task:
Expand Down
4 changes: 2 additions & 2 deletions qcodes/tests/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_loop_measure_channels_individually(self):
self.assertEqual(getattr(data, 'testchanneldummy_Chan{}_temperature'.format(chan)).ndarray.shape, (21,))

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

@given(loop_channels=hst.lists(hst.integers(0, 3), min_size=2, max_size=2, unique=True),
measure_channel=hst.integers(0, 3))
@settings(max_examples=10)
@settings(max_examples=10, deadline=400)
def test_nested_loop_over_channels(self, loop_channels, measure_channel):
channel_to_label = {0: 'A', 1: 'B', 2: 'C', 3: "D"}
loop = Loop(self.instrument.channels[loop_channels[0]].temperature.sweep(0, 10, 0.5))
Expand Down
12 changes: 6 additions & 6 deletions qcodes/tests/test_combined_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def tearDownClass(cls):
min_size=2, max_size=2, unique=True).map(sorted),
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted))
@settings(max_examples=10)
@settings(max_examples=10, deadline=300)
def testLoopCombinedParameterPrintTask(self, npoints, x_start_stop, y_start_stop, z_start_stop):

x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
Expand Down Expand Up @@ -64,7 +64,7 @@ def btaskfunc():
min_size=2, max_size=2, unique=True).map(sorted),
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted))
@settings(max_examples=10)
@settings(max_examples=10, deadline=300)
def testLoopCombinedParameterTwice(self, npoints, x_start_stop, y_start_stop, z_start_stop):
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)
Expand Down Expand Up @@ -102,7 +102,7 @@ def inner():
min_size=2, max_size=2, unique=True).map(sorted),
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted))
@settings(max_examples=10)
@settings(max_examples=10, deadline=300)
def testLoopCombinedParameterAndMore(self, npoints, x_start_stop, y_start_stop, z_start_stop):
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints)
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)
Expand Down Expand Up @@ -134,15 +134,15 @@ def inner():
np.testing.assert_array_equal(data.arrays['dmm_somethingelse'].ndarray, np.ones(npoints))
np.testing.assert_array_equal(data.arrays['dmm_voltage_2'].ndarray, np.arange(2, npoints * 2 + 1, 2))

@given(npoints=hst.integers(2, 100),
npoints_outer=hst.integers(2,100),
@given(npoints=hst.integers(2, 50),
npoints_outer=hst.integers(2,25),
x_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted),
y_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted),
z_start_stop=hst.lists(hst.integers(min_value=-800, max_value=400),
min_size=2, max_size=2, unique=True).map(sorted))
@settings(max_examples=10)
@settings(max_examples=10, deadline=1000)
def testLoopCombinedParameterInside(self, npoints, npoints_outer, x_start_stop, y_start_stop, z_start_stop):
x_set = np.linspace(x_start_stop[0], x_start_stop[1], npoints_outer)
y_set = np.linspace(y_start_stop[0], y_start_stop[1], npoints)
Expand Down

0 comments on commit bd43328

Please sign in to comment.