From bd43328b50152b64a3d1c694a57dff1452a3af59 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Wed, 6 Dec 2017 11:44:22 +0100 Subject: [PATCH] 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 --- qcodes/data/data_set.py | 6 ++++-- qcodes/data/gnuplot_format.py | 8 ++++++-- qcodes/loops.py | 20 +++++++++++--------- qcodes/tests/test_channels.py | 4 ++-- qcodes/tests/test_combined_loop.py | 12 ++++++------ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/qcodes/data/data_set.py b/qcodes/data/data_set.py index 3c62d9de8c9..d7ec0f9e3ce 100644 --- a/qcodes/data/data_set.py +++ b/qcodes/data/data_set.py @@ -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 diff --git a/qcodes/data/gnuplot_format.py b/qcodes/data/gnuplot_format.py index 17cf45df271..a3136d1b4fc 100644 --- a/qcodes/data/gnuplot_format.py +++ b/qcodes/data/gnuplot_format.py @@ -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) @@ -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 diff --git a/qcodes/loops.py b/qcodes/loops.py index 1d765a680bb..406e9459880 100644 --- a/qcodes/loops.py +++ b/qcodes/loops.py @@ -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): @@ -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: @@ -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) @@ -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: diff --git a/qcodes/tests/test_channels.py b/qcodes/tests/test_channels.py index 78e857049f6..a83e07843ff 100644 --- a/qcodes/tests/test_channels.py +++ b/qcodes/tests/test_channels.py @@ -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): @@ -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)) diff --git a/qcodes/tests/test_combined_loop.py b/qcodes/tests/test_combined_loop.py index ec20f969400..1ed15160dce 100644 --- a/qcodes/tests/test_combined_loop.py +++ b/qcodes/tests/test_combined_loop.py @@ -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) @@ -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) @@ -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) @@ -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)