From 4170268604b56ae86b059168c88ab2b4f0e38b35 Mon Sep 17 00:00:00 2001 From: cint-transport Date: Tue, 11 Jun 2024 12:03:04 -0600 Subject: [PATCH 01/19] fix(driver): fixed srs830 snap and offset_expand bugs --- pyscan/drivers/stanford830.py | 9 ++++++--- .../testing/driver_test_logs/keithley2260b_test_log.txt | 1 + .../testing/driver_test_logs/stanford830_test_log.txt | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index d30775d9..9d32bd34 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -396,7 +396,10 @@ def get_channel_offset_expand(self, channel): response = self.query('OEXP? {}'.format(channel)).strip('\n') response = response.split(',') - return self._channel1_offset, self._channel1_expand + setattr(self, '_channel{}_offset', response[0]) + setattr(self, '_channel{}_expand', response[1]) + + return response def set_channel_offset_expand(self, channel, offset, expand): ''' @@ -584,13 +587,13 @@ def snap(self, *args): sources = ['x', 'y', 'r', 'theta', 'aux1', 'aux2', 'aux3', 'aux4', 'frequency', 'display1', 'display2'] - assert (len(args) >= 2) and (len(args <= 6)), 'Snap accepts 2 to 6 readable sources' + assert (len(args) >= 2) and (len(args) <= 6), 'Snap accepts 2 to 6 readable sources' for source in args: assert source in sources, ( 'Readable sources include x, y, r, theta, aux1, aux2, aux3, aux4, frequency, display1, display2') - indicies = [sources.index(arg) + 1 for arg in args] + indicies = [str(sources.index(arg) + 1) for arg in args] query_string = 'SNAP? ' + ', '.join(indicies) responses = self.query(query_string).strip('\n') diff --git a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt index 83777243..20fd0c8a 100644 --- a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt @@ -1 +1,2 @@ +Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 11:53:18 Passed with keithley2260b version v0.1.0 tested on pyscan version v0.3.0 at 2024-05-24 13:50:29 \ No newline at end of file diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 639425e1..40e1dce9 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1,4 @@ +Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:01:08 +Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:58:06 +Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:49:53 Passed with stanford830 version v0.1.0 tested on pyscan version v0.3.0 at 2024-05-28 12:35:11 \ No newline at end of file From b67d78e003e7284d7d9e2aa9cd14f9e177680956 Mon Sep 17 00:00:00 2001 From: cint-transport Date: Tue, 11 Jun 2024 13:24:09 -0600 Subject: [PATCH 02/19] doc(drivers): fixed documentation on stanford830 --- pyscan/drivers/stanford830.py | 392 ++++-------------- .../keithley2260b_test_log.txt | 2 + .../driver_test_logs/stanford830_test_log.txt | 2 + 3 files changed, 87 insertions(+), 309 deletions(-) diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 9d32bd34..6a67c9f5 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -16,27 +16,35 @@ class Stanford830(InstrumentDriver): Attributes ---------- (Properties) + id: read-only + Gets the id string of the device. phase : float - Range: [-180, 180] - reference_source : int - Indexed_values: ['external', 'internal']. Returns float. + Gets/sets the phase of the device. Range: [-180, 180] + reference_source : str + Get/sets the reference source. Indexed_values: ['external', 'internal']. frequency : float - Range: [0.001, 102000] + Gets/sets/ the frequency. Range: [0.001, 102000] reference_slope : int - Indexed_values: ['sine zero', 'ttl rising', 'ttl falling']. Returns float. + Gets/sets the slope of the frequency refeference. + Indexed_values: ['sine zero', 'ttl rising', 'ttl falling']. harmonic : int - Range: [1, 19999] + Gets/sets the demodulation harmonic. Range: [1, 19999] amplitude : float - Range: [0.004, 5.0] - input_configuration : int - Indexed_values: ['A', 'A-B', 'Ie6', 'Ie8']. Returns int. - input_ground : int + Gets/sets the output amplitude. Range: [0.004, 5.0] + input_configuration : str + Gets/sets the analog input mode. + Indexed_values: ['A', 'A-B', 'Ie6', 'Ie8']. + input_ground : str + Get/sets the input ground. Indexed_values: ['AC', 'DC'] - input_coupling : int + input_coupling : str + Gets/sets the input coupling. Indexed_values: ['AC', 'DC'] - input_line_filter : int + input_line_filter : str + Gets/sets the line filer of the input. Indexed_values: ['none', 'line', '2xline', 'both'] - sensitivity : int + sensitivity : float + Gets/sets the sensitivy (max input). Indexed_values: [2e-9, 5e-9, 10e-9, 20e-9, 50e-5, 100e-9, 200e-9, 500e-9, 1e-6, 2e-6, 5e-6, @@ -46,32 +54,81 @@ class Stanford830(InstrumentDriver): 10e-3, 20e-3, 50e-3, 100e-3, 200e-3, 500e-3, 1] - reserve_mode : int + reserve_mode : str + Gets/sets the dynamic reserver Indexed_values: ['high', 'normal', 'low'] - time_constant : int + time_constant : float + Gets/sets the time constant in seconds Indexed_values: [10e-6, 30e-6, 100e-6, 300e-6, 1e-3, 3e-3, 10e-3, 30e-3, 100e-3, 300e-3, 1, 3, 10, 30, 100, 300, 1000, 3000, 10000, 30000] filter_slope : int + Gets/sets the slope of the filter in dB/oct Indexed_values: [6, 12, 18, 24] - synchronous_filter : int + synchronous_filter : str + Gets/sets the synchronous filter state Indexed_values: ['off', 'on'] - sample_rate : int + display1_output_source: str + Gets/sets the displayed source on display 1 + Indexed values ['x', 'display'] + display2_output_source: str + Gets/sets the displayed source on display 2 + Indexed values['y', 'display'] + auxillary_voltage1 : float + Gets/sets the channel 1 auxillary output voltage + range - [-10.5, 10.500] + auxillary_voltage2 : float + Gets/sets the channel 2 auxillary output voltage + range - [-10.5, 10.500] + auxillary_voltage2 : float + Gets/sets the channel 3 auxillary output voltage + range - [-10.5, 10.500] + auxillary_voltage2 : float + Gets/sets the channel 4 auxillary output voltage + range - [-10.5, 10.500] + sample_rate : float + Get/sets the sample rate in Hz Indexed_values: [0.0625, .125, .250, .5, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 'trigger'] - end_buffer_mode : int + end_buffer_mode : str + Gets/sets the end mode for th data buffer Indexed_values: ['one shot', 'loop'] trigger_mode : int + Gets/sets the trigger mode state Indexed_values': ['off', 'on'] + buffer_points: read-only + Gets the number of points stored in the buffer. Methods ------- + get_display(display_number) + set_display(display_number, source, ratio) + get_channel_offset_expand(channel) + set_channel_offset_expand(channel, offset, expand) + read_aux_input(index) + auto_gain() + auto_reserve() + auto_phase() + auto_offset() + trigger() + start() + pause() + reset() + read(source) + read_display(display) + snap(*args) + read_ascii_buffer() + read_binary_buffer() + reset_to_default_settings() + clear_status_bytes() + set_buffer_mode(sample_rate) + wait_for_trigger() snap_xy() - Returns array of current read x and read y values. + ''' def __init__(self, instrument): @@ -79,7 +136,7 @@ def __init__(self, instrument): super().__init__(instrument) self.debug = False - self._version = "1.0.0" + self._version = "1.0.1" self.black_list_for_testing = ['_input_configuration', "_time_constant", "_amplitude", "_power_on_status_clear"] @@ -90,6 +147,12 @@ def initialize_properties(self): # Reference and Phase properties + self.add_device_property({ + 'name': 'id', + 'query_string': '*IDN?', + 'read_only': True, + 'return_type': str}) + self.add_device_property({ 'name': 'phase', 'write_string': 'PHAS {}', @@ -287,28 +350,6 @@ def initialize_properties(self): 'dict_values': {'off': 0, 'on': 1, '0': 0, '1': 1, 0: 0, 1: 1}, 'return_type': int}) - # Interface Properties - - self.add_device_property({ - 'name': 'local_remote_control', - 'write_string': 'LOCL {}', - 'query_string': 'LOCL?', - 'indexed_values': ['local', 'remote', 'local lockout'], - 'return_type': int}) - - self.add_device_property({ - 'name': 'gpib_overrided_state', - 'write_string': 'OVRM {}', - 'query_string': 'OVRM?', - 'dict_values': {'off': 0, 'on': 1, '0': 0, '1': 1, 0: 0, 1: 1}, - 'return_type': int}) - - self.add_device_property({ - 'name': 'power_on_status_clear', - 'write_string': '*PSC {}', - 'query_string': '*PSC?', - 'dict_values': {'off': 0, 'on': 1, '0': 0, '1': 1, 0: 0, 1: 1}, - 'return_type': int}) # Display and Output Methods def get_display(self, display_number): @@ -682,273 +723,6 @@ def clear_status_bytes(self): ''' self.write('*CLS') - def get_standard_status_event_enable_register(self, bit=None): - ''' - Gets the standard status event enable register byte by single bit or all bits - - Parameters - --------- - bit: int (None) - Bit to query, if None, returns all bit values - - Returns - ------- - int - ''' - - if bit is None: - return self.query('ESE?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('ESE? {}'.format(bit)) - - def set_standard_status_event_enable_register(self, value, bit=None): - ''' - Sets the standard event status enable register by single bit or all bits - - Parameters - ---------- - value: int - If bit==None, value must be between 0 and 255 and - sets all bits - bit: int (None) - Value must be between 0 and 7, and bit must be 0 or 1 - Sets the value of a single bit - ''' - if bit is None: - assert ( - value >= 0) and ( - value <= 255), 'Standard status event byte must be between 0 and 255 when no bit is supplied' - self.write('ESE {}'.format(value)) - else: - assert value in [0, 1], 'Standard status event value must be 0 or 1 when a bit index is supplied' - assert (bit >= 0) and (bit <= 7), 'Standard status event bit must be between 0 and 7' - self.write('ESE {}, {}'.format(bit, value)) - - def get_standard_event_status_byte(self, bit=None): - ''' - Queries the standard event status byte - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - if bit is None: - return self.query('ESR?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('ESR? {}'.format(bit)) - - def get_serial_poll_enable_register(self, bit=None): - ''' - Queries the standard event status byte - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - - if bit is None: - return self.query('SRE?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('SRE? {}'.format(bit)) - - def set_serial_poll_enable_register(self, value, bit=None): - ''' - Sets the serial poll enable register by single bit or all bits - - Parameters - ---------- - value: int - If bit==None, value must be between 0 and 255 and - sets all bits - bit: int (None) - Value must be between 0 and 7, and bit must be 0 or 1 - Sets the value of a single bit - ''' - - if bit is None: - assert ( - value >= 0) and ( - value <= 255), 'Serial event poll register value be between 0 and 255 when no bit is supplied' - self.write('SRE {}'.format(value)) - else: - assert value in [0, 1], 'Serial event poll register value must be 0 or 1 when a bit index is supplied' - assert (bit >= 0) and (bit <= 7), 'Serial even poll register bit must be between 0 and 7' - self.write('SRE {}, {}'.format(bit, value)) - - def get_status_poll_byte(self, bit=None): - ''' - Queries the status poll byte - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - - if bit is None: - return self.query('STB?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('STB? {}'.format(bit)) - - def get_error_status_enable_register(self, bit=None): - ''' - Queries the error status enable register settings - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - - if bit is None: - return self.query('ERRE?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('ERRE? {}'.format(bit)) - - def set_error_status_enable_register(self, value, bit=None): - ''' - Sets the error status enable register by single bit or all bits - - Parameters - ---------- - value: int - If bit==None, value must be between 0 and 255 and - sets all bits - bit: int (None) - Value must be between 0 and 7, and bit must be 0 or 1 - Sets the value of a single bit - ''' - - if bit is None: - assert ( - value >= 0) and ( - value <= 255), 'Error status enable register must be between 0 and 255 when no bit is supplied' - self.write('ERRE {}'.format(value)) - else: - assert value in [0, 1], 'Error status enable register must be 0 or 1 when a bit index is supplied' - assert (bit >= 0) and (bit <= 7), 'Error status enable register must be between 0 and 7' - self.write('ERRE {}, {}'.format(bit, value)) - - def get_error_status_byte(self, bit=None): - ''' - Queries the error status byte - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - if bit is None: - return self.query('ERRS?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('ERRS? {}'.format(bit)) - - def get_lia_status_enable_register(self, bit=None): - ''' - Queries the lockin amplifier enable register settings - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - - if bit is None: - return self.query('LIAE?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('LIAE? {}'.format(bit)) - - def set_lia_status_enable_register(self, value, bit=None): - ''' - Sets the lockin status enable register by single bit or all bits - - Parameters - ---------- - value: int - If bit==None, value must be between 0 and 255 and - sets all bits - bit: int (None) - Value must be between 0 and 7, and bit must be 0 or 1 - Sets the value of a single bit - ''' - - if bit is None: - assert ( - value >= 0) and ( - value <= 255), 'LIA status enable register must be between 0 and 255 when no bit is supplied' - self.write('LIAE {}'.format(value)) - else: - assert value in [0, 1], 'LIA status enable register must be 0 or 1 when a bit index is supplied' - assert (bit >= 0) and (bit <= 7), 'LIA status enable register must be between 0 and 7' - self.write('LIAE {}, {}'.format(bit, value)) - - def get_lia_status_byte(self, bit=None): - ''' - Queries the lockin amplifier byte - - Parameters - ---------- - bit: int (None) - If inlcuded, queries only the value at bit - otherwise, queries all values - - Returns - -------- - int - - ''' - - if bit is None: - return self.query('LIAS?') - else: - assert (bit >= 0) and (bit <= 7), 'Bit index must be 0-7' - return self.query('LIAS? {}'.format(bit)) - # Custom Multi-Settings Methods def set_buffer_mode(self, sample_rate): diff --git a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt index 20fd0c8a..3c3b6dac 100644 --- a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt @@ -1,2 +1,4 @@ +Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 12:27:11 +Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 12:25:42 Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 11:53:18 Passed with keithley2260b version v0.1.0 tested on pyscan version v0.3.0 at 2024-05-24 13:50:29 \ No newline at end of file diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 40e1dce9..a48e4e41 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1,3 +1,5 @@ +Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:42 +Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:20 Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:01:08 Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:58:06 Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:49:53 From 9f6e0a3f7ba45d32449f2101b89b822bdccb33a6 Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Mon, 1 Jul 2024 11:20:19 -0600 Subject: [PATCH 03/19] refactor(test): minor updates to auto_test_driver mostly refactoring and increasing robustness. --- pyscan/drivers/testing/auto_test_driver.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index f6d5bab0..651c07e7 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -100,12 +100,11 @@ def restore_initial_state(device, saved_settings): assert val == device[setter], err_msg restored_settings.append((setter, device[setter])) continue - - if 'read_only' in device["_{}_settings".format(setter)].keys(): + elif 'read_only' in device["_{}_settings".format(setter)].keys(): continue - - if 'ranges' in device["_{}_settings".format(setter)].keys(): + elif 'ranges' in device["_{}_settings".format(setter)].keys(): val = device["_{}_settings".format(setter)]['return_type'](val) + try: device[setter] = val except Exception: @@ -135,22 +134,24 @@ def reset_device_properties(device): if var_name in device.black_list_for_testing: blacklisted.append((var_name, device[var_name])) continue - if ('values' in keys) and ('indexed_' not in keys) and ('dict_' not in keys): + elif 'read_only' in keys: + continue + elif ('values' in keys) and ('indexed_' not in keys) and ('dict_' not in keys): device[var_name] = device[name]['values'][0] - elif 'range' in device[name].keys(): + elif 'range' in keys: device[var_name] = device[name]['range'][0] - elif 'ranges' in device[name].keys(): + elif 'ranges' in keys: # write to reset val later pass - elif 'indexed_values' in device[name].keys(): + elif 'indexed_values' in keys: device[var_name] = device[name]['indexed_values'][0] - elif 'dict_values' in device[name].keys(): + elif 'dict_values' in keys: for key in device[name]['dict_values'].keys(): device[var_name] = key break else: assert False, "no valid type present in setting: {}. Must be one of {}.".format( - name, ['values', 'range', 'ranges', 'indexed_values', 'dict_values']) + name, ['values', 'range', 'indexed_values', 'dict_values', 'read_only']) if len(blacklisted) > 0: print("These blacklisted settings and their corresponding values were not reset: ", blacklisted) From ea6106ccd268227b82e6b2f2988e93cd2fd45aa9 Mon Sep 17 00:00:00 2001 From: Jasmine Date: Fri, 23 Aug 2024 15:11:24 -0600 Subject: [PATCH 04/19] removed _power_on_status_clear from blacklist - nonexistent property --- pyscan/drivers/instrument_driver.py | 2 ++ pyscan/drivers/stanford830.py | 2 +- .../drivers/testing/driver_test_logs/stanford830_test_log.txt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyscan/drivers/instrument_driver.py b/pyscan/drivers/instrument_driver.py index 95421f8e..21b49e1c 100644 --- a/pyscan/drivers/instrument_driver.py +++ b/pyscan/drivers/instrument_driver.py @@ -141,6 +141,8 @@ def add_device_property(self, settings): set_function = self.set_indexed_values_property elif 'dict_values' in settings: set_function = self.set_dict_values_property + elif 'read_only' in settings: + pass # should something else be done? else: assert False, "Key 'values', 'range', indexed_values', 'read_only', or 'dict_values' must be in settings." diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 6a67c9f5..3dca3476 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -138,7 +138,7 @@ def __init__(self, instrument): self.debug = False self._version = "1.0.1" - self.black_list_for_testing = ['_input_configuration', "_time_constant", "_amplitude", "_power_on_status_clear"] + self.black_list_for_testing = ['_input_configuration', "_time_constant", "_amplitude"] self.initialize_properties() self.update_properties() diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index a48e4e41..5e448be1 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1,3 +1,4 @@ +Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:05:02 Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:42 Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:20 Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:01:08 From 9a219b11d246e17215e523ace137c533764c253c Mon Sep 17 00:00:00 2001 From: Jasmine Date: Fri, 23 Aug 2024 16:12:30 -0600 Subject: [PATCH 05/19] modified tests in stanford830 notebook to fail upon unexpected values --- .../srs830_test_notebook.ipynb | 211 ++++++++++-------- .../driver_test_logs/stanford830_test_log.txt | 1 + 2 files changed, 113 insertions(+), 99 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index 2ccac567..68bcacfe 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 15, "metadata": { "metadata": {} }, @@ -22,31 +22,23 @@ "\n", "import pyscan as ps\n", "from pyscan.drivers.testing.auto_test_driver import test_driver\n", - "from pyvisa import ResourceManager, VisaIOError" + "from pyvisa import ResourceManager, VisaIOError\n", + "import pytest" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "metadata": {} }, "outputs": [ { - "ename": "VisaIOError", - "evalue": "VI_ERROR_RSRC_BUSY (-1073807246): The resource is valid, but VISA cannot currently access it.", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mVisaIOError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[2], line 6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# print(rs)\u001b[39;00m\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m r \u001b[38;5;129;01min\u001b[39;00m rs:\n\u001b[1;32m----> 6\u001b[0m res \u001b[38;5;241m=\u001b[39m rm\u001b[38;5;241m.\u001b[39mopen_resource(r)\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m: \n\u001b[0;32m 8\u001b[0m name \u001b[38;5;241m=\u001b[39m res\u001b[38;5;241m.\u001b[39mquery(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m*IDN?\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\highlevel.py:3292\u001b[0m, in \u001b[0;36mResourceManager.open_resource\u001b[1;34m(self, resource_name, access_mode, open_timeout, resource_pyclass, **kwargs)\u001b[0m\n\u001b[0;32m 3286\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m present:\n\u001b[0;32m 3287\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 3288\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m%r\u001b[39;00m\u001b[38;5;124m is not a valid attribute for type \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 3289\u001b[0m \u001b[38;5;241m%\u001b[39m (key, res\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m)\n\u001b[0;32m 3290\u001b[0m )\n\u001b[1;32m-> 3292\u001b[0m res\u001b[38;5;241m.\u001b[39mopen(access_mode, open_timeout)\n\u001b[0;32m 3294\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key, value \u001b[38;5;129;01min\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m 3295\u001b[0m \u001b[38;5;28msetattr\u001b[39m(res, key, value)\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\resources\\resource.py:281\u001b[0m, in \u001b[0;36mResource.open\u001b[1;34m(self, access_mode, open_timeout)\u001b[0m\n\u001b[0;32m 277\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m - opening ...\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resource_name, extra\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_logging_extra)\n\u001b[0;32m 278\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resource_manager\u001b[38;5;241m.\u001b[39mignore_warning(\n\u001b[0;32m 279\u001b[0m constants\u001b[38;5;241m.\u001b[39mStatusCode\u001b[38;5;241m.\u001b[39msuccess_device_not_present\n\u001b[0;32m 280\u001b[0m ):\n\u001b[1;32m--> 281\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession, status \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resource_manager\u001b[38;5;241m.\u001b[39mopen_bare_resource(\n\u001b[0;32m 282\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resource_name, access_mode, open_timeout\n\u001b[0;32m 283\u001b[0m )\n\u001b[0;32m 285\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m status \u001b[38;5;241m==\u001b[39m constants\u001b[38;5;241m.\u001b[39mStatusCode\u001b[38;5;241m.\u001b[39msuccess_device_not_present:\n\u001b[0;32m 286\u001b[0m \u001b[38;5;66;03m# The device was not ready when we opened the session.\u001b[39;00m\n\u001b[0;32m 287\u001b[0m \u001b[38;5;66;03m# Now it gets five seconds more to become ready.\u001b[39;00m\n\u001b[0;32m 288\u001b[0m \u001b[38;5;66;03m# Every 0.1 seconds we probe it with viClear.\u001b[39;00m\n\u001b[0;32m 289\u001b[0m start_time \u001b[38;5;241m=\u001b[39m time\u001b[38;5;241m.\u001b[39mtime()\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\highlevel.py:3217\u001b[0m, in \u001b[0;36mResourceManager.open_bare_resource\u001b[1;34m(self, resource_name, access_mode, open_timeout)\u001b[0m\n\u001b[0;32m 3188\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mopen_bare_resource\u001b[39m(\n\u001b[0;32m 3189\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 3190\u001b[0m resource_name: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m 3191\u001b[0m access_mode: constants\u001b[38;5;241m.\u001b[39mAccessModes \u001b[38;5;241m=\u001b[39m constants\u001b[38;5;241m.\u001b[39mAccessModes\u001b[38;5;241m.\u001b[39mno_lock,\n\u001b[0;32m 3192\u001b[0m open_timeout: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m constants\u001b[38;5;241m.\u001b[39mVI_TMO_IMMEDIATE,\n\u001b[0;32m 3193\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tuple[VISASession, StatusCode]:\n\u001b[0;32m 3194\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Open the specified resource without wrapping into a class.\u001b[39;00m\n\u001b[0;32m 3195\u001b[0m \n\u001b[0;32m 3196\u001b[0m \u001b[38;5;124;03m Parameters\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 3215\u001b[0m \n\u001b[0;32m 3216\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 3217\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvisalib\u001b[38;5;241m.\u001b[39mopen(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession, resource_name, access_mode, open_timeout)\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\ctwrapper\\functions.py:1850\u001b[0m, in \u001b[0;36mopen\u001b[1;34m(library, session, resource_name, access_mode, open_timeout)\u001b[0m\n\u001b[0;32m 1846\u001b[0m out_session \u001b[38;5;241m=\u001b[39m ViSession()\n\u001b[0;32m 1848\u001b[0m \u001b[38;5;66;03m# [ViSession, ViRsrc, ViAccessMode, ViUInt32, ViPSession]\u001b[39;00m\n\u001b[0;32m 1849\u001b[0m \u001b[38;5;66;03m# ViRsrc converts from (str, unicode, bytes) to bytes\u001b[39;00m\n\u001b[1;32m-> 1850\u001b[0m ret \u001b[38;5;241m=\u001b[39m library\u001b[38;5;241m.\u001b[39mviOpen(\n\u001b[0;32m 1851\u001b[0m session, resource_name, access_mode, open_timeout, byref(out_session)\n\u001b[0;32m 1852\u001b[0m )\n\u001b[0;32m 1853\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out_session\u001b[38;5;241m.\u001b[39mvalue, ret\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\ctwrapper\\highlevel.py:226\u001b[0m, in \u001b[0;36mIVIVisaLibrary._return_handler\u001b[1;34m(self, ret_value, func, arguments)\u001b[0m\n\u001b[0;32m 223\u001b[0m \u001b[38;5;66;03m# Set session back to a safe value\u001b[39;00m\n\u001b[0;32m 224\u001b[0m session \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m--> 226\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandle_return_value(session, ret_value)\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pyvisa\\highlevel.py:251\u001b[0m, in \u001b[0;36mVisaLibraryBase.handle_return_value\u001b[1;34m(self, session, status_code)\u001b[0m\n\u001b[0;32m 248\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_last_status_in_session[session] \u001b[38;5;241m=\u001b[39m rv\n\u001b[0;32m 250\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m rv \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m--> 251\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m errors\u001b[38;5;241m.\u001b[39mVisaIOError(rv)\n\u001b[0;32m 253\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m rv \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39missue_warning_on:\n\u001b[0;32m 254\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m session \u001b[38;5;129;01mand\u001b[39;00m rv \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_ignore_warning_in_session[session]:\n", - "\u001b[1;31mVisaIOError\u001b[0m: VI_ERROR_RSRC_BUSY (-1073807246): The resource is valid, but VISA cannot currently access it." + "name": "stdout", + "output_type": "stream", + "text": [ + "GPIB0::8::INSTR Stanford_Research_Systems,SR830,s/n86813,ver1.07 \n", + "\n" ] } ], @@ -100,18 +92,21 @@ "name": "stdout", "output_type": "stream", "text": [ - "Initial state for the Stanford830 was: [('phase', 180.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.984), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 0.01), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('sample_rate', 0.25), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'on')]\n", - "These blacklisted settings and their corresponding values were not reset: [('_input_configuration', 'A-B'), ('_time_constant', 30), ('_sample_rate', 0.25)]\n", - "Reset state for the Stanford830 was: [('phase', 180.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.984), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 0.01), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('sample_rate', 0.25), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'on')]\n", - "Beginning tests for: Stanford830\n", - "4 range properties found and tested out of 18 total settings found.\n", - "0 values properties found and tested out of 18 total settings found.\n", - "9 indexed values properties found and tested out of 18 total settings found.\n", - "2 dict values properties found and tested out of 18 total settings found.\n", - "3 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", - "15 properties tested out of 18 total settings.\n", - "Settings restored to: [('phase', 180.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.984), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 0.01), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('sample_rate', 0.25), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'on')]\n", - "Tests passed, instrument Stanford830 should be ready to go.\n" + "dict_keys(['instrument', '_driver_class', 'debug', '_instrument_driver_version', '_version', 'black_list_for_testing', '_id_settings', '_phase_settings', '_reference_source_settings', '_frequency_settings', '_reference_slope_settings', '_harmonic_settings', '_amplitude_settings', '_input_configuration_settings', '_input_ground_settings', '_input_coupling_settings', '_input_line_filter_settings', '_sensitivity_settings', '_reserve_mode_settings', '_time_constant_settings', '_filter_slope_settings', '_synchronous_filter_settings', '_display1_output_source_settings', '_display2_output_source_settings', '_auxillary_voltage1_settings', '_auxillary_voltage2_settings', '_auxillary_voltage3_settings', '_auxillary_voltage4_settings', '_sample_rate_settings', '_end_buffer_mode_settings', '_trigger_mode_settings', '_id', '_phase', '_reference_source', '_frequency', '_reference_slope', '_harmonic', '_amplitude', '_input_configuration', '_input_ground', '_input_coupling', '_input_line_filter', '_sensitivity', '_reserve_mode', '_time_constant', '_filter_slope', '_synchronous_filter', '_display1_output_source', '_display2_output_source', '_auxillary_voltage1', '_auxillary_voltage2', '_auxillary_voltage3', '_auxillary_voltage4', '_sample_rate', '_end_buffer_mode', '_trigger_mode'])\n", + "Initial state for the Stanford830 was: [('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", + "The new test log for this driver is: Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:11:37\n" + ] + }, + { + "ename": "AssertionError", + "evalue": "no valid type present in setting: _id_settings. Must be one of ['values', 'range', 'ranges', 'indexed_values', 'dict_values'].", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[5], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m srs830 \u001b[38;5;241m=\u001b[39m ps\u001b[38;5;241m.\u001b[39mStanford830(res)\n\u001b[1;32m----> 3\u001b[0m \u001b[43mtest_driver\u001b[49m\u001b[43m(\u001b[49m\u001b[43msrs830\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32mc:\\snl\\users\\jjmah\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:526\u001b[0m, in \u001b[0;36mtest_driver\u001b[1;34m(device, skip_log, expected_attributes, expected_values)\u001b[0m\n\u001b[0;32m 523\u001b[0m write_log(device, exception)\n\u001b[0;32m 525\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m exception \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m--> 526\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m, exception\n\u001b[0;32m 527\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 528\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\033\u001b[39;00m\u001b[38;5;124m[1;32mTests passed, instrument \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m looks ready to go.\u001b[39m\u001b[38;5;130;01m\\033\u001b[39;00m\u001b[38;5;124m[0m\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(device\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m))\n", + "\u001b[1;31mAssertionError\u001b[0m: no valid type present in setting: _id_settings. Must be one of ['values', 'range', 'ranges', 'indexed_values', 'dict_values']." ] } ], @@ -123,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 17, "metadata": { "metadata": {} }, @@ -132,39 +127,54 @@ "name": "stdout", "output_type": "stream", "text": [ - "('r', 'aux1')\n", - "('x', 'none')\n", "Sucessfully failed setting channel 1 to y\n", - "('theta', 'aux3')\n", - "('y', 'none')\n", - "Sucessfully failed setting channel 2 to x\n" + "Sucessfully failed setting channel 2 to x\n", + "Successfully tested get and set display\n" ] } ], "source": [ "# Test get and set display\n", "\n", - "srs830.set_display(1, 'r', 'aux1')\n", - "print(srs830.get_display(1))\n", + "srs830.set_display(1, 'r', 'aux1') # number, source, ratio\n", + "source, ratio = srs830.get_display(1)\n", + "assert source == 'r'\n", + "assert ratio == 'aux1'\n", + "\n", + "\n", "srs830.set_display(1, 'x', 'none')\n", - "print(srs830.get_display(1))\n", - "try:\n", + "source, ratio = srs830.get_display(1)\n", + "assert source == 'x'\n", + "assert ratio == 'none'\n", + "\n", + "\n", + "with pytest.raises(AssertionError):\n", " srs830.set_display(1, 'y', 'none')\n", - "except AssertionError:\n", - " print('Sucessfully failed setting channel 1 to y')\n", + "print('Sucessfully failed setting channel 1 to y')\n", + " \n", + " \n", "srs830.set_display(2, 'theta', 'aux3')\n", - "print(srs830.get_display(2))\n", + "source, ratio = srs830.get_display(2)\n", + "assert source == 'theta'\n", + "assert ratio == 'aux3'\n", + "\n", + "\n", "srs830.set_display(2, 'y', 'none')\n", - "print(srs830.get_display(2))\n", - "try:\n", + "source, ratio = srs830.get_display(2)\n", + "assert source == 'y'\n", + "assert ratio == 'none'\n", + "\n", + "\n", + "with pytest.raises(AssertionError):\n", " srs830.set_display(2, 'x', 'none')\n", - "except AssertionError:\n", - " print('Sucessfully failed setting channel 2 to x')" + "print('Sucessfully failed setting channel 2 to x')\n", + "\n", + "print(\"Successfully tested get and set display\")\n" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 7, "metadata": { "metadata": {} }, @@ -173,8 +183,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "(100.0, 1)\n", - "(0.0, 0)\n" + "['0', '1']\n", + "['0', '0']\n" ] } ], @@ -183,34 +193,35 @@ "\n", "srs830.set_channel_offset_expand(1, 100, 10)\n", "print(srs830.get_channel_offset_expand(1))\n", + "\n", "srs830.set_channel_offset_expand(1, 0, 1)\n", "print(srs830.get_channel_offset_expand(1))\n" ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.00384523 6.10356e-05\n", - "-0.0144044 -0.000183106\n", - "0.0 0.0\n" + "2.18428e-09 2.18428e-09\n", + "-2.18439e-09 -2.18439e-09\n", + "2.18428e-09 2.18428e-09\n" ] } ], "source": [ "# Test auto offset\n", - "# First number should be some value, second number should be close to 0\n", + "# v0 should be some value, v_offset should be close to 0\n", "srs830.set_channel_offset_expand(1, 0, 1)\n", "v0 = srs830.read('x')\n", "srs830.auto_offset('x')\n", "v_offset = srs830.read('x')\n", "print(v0, v_offset)\n", - "srs830.set_channel_offset_expand(1, 0, 1)\n", + "assert abs(v_offset - 0) < 0.0001\n", "\n", "\n", "srs830.set_channel_offset_expand(2, 0, 1)\n", @@ -218,31 +229,33 @@ "srs830.auto_offset('y')\n", "v_offset = srs830.read('y')\n", "print(v0, v_offset)\n", - "srs830.set_channel_offset_expand(2, 0, 1)\n", + "assert abs(v_offset - 0) < 0.0001\n", "\n", "srs830.set_channel_offset_expand(1, 0, 1)\n", "v0 = srs830.read('r')\n", "srs830.auto_offset('r')\n", "v_offset = srs830.read('r')\n", "print(v0, v_offset)\n", - "srs830.set_display(1, 'r', 'none')\n", + "assert abs(v_offset - 0) < 0.0001\n", + "\n", + "\n", "srs830.set_channel_offset_expand(1, 0, 1)\n", "srs830.set_display(1, 'x', 'none')\n" ] }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.00366667\n", - "0.00266667\n", - "0.00433333\n", - "0.00266667\n" + "0.00166667\n", + "0.004\n", + "0.001\n", + "-0.0176667\n" ] } ], @@ -250,22 +263,24 @@ "# Test read aux inputs\n", "# shoudl show some random small value\n", "for i in range(1, 5):\n", - " print(srs830.read_aux_input(i))" + " aux_input = srs830.read_aux_input(i)\n", + " print(aux_input)\n", + " assert abs(aux_input - 0) < 0.1" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.00384523\n", - "-0.0144044\n", - "0.0\n", - "-74.97\n" + "2.18428e-09\n", + "-2.18439e-09\n", + "2.18428e-09\n", + "-2656.6929484751354\n" ] } ], @@ -280,15 +295,15 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.00384523\n", - "-0.0144044\n" + "2.18439e-09\n", + "-2.18451e-09\n" ] } ], @@ -301,24 +316,23 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[0.00384523, -0.0144044]\n", - "[0.00384523, 0.0]\n", - "[0.00384523, -74.97]\n", - "[0.00384523, 0.000666667]\n", - "[0.00384523, 0.004]\n", - "[0.00384523, -0.00633333]\n", - "[0.00384523, 0.000666667]\n", - "[0.00384523, 1000.0]\n", - "[0.00384523, 0.00384523]\n", - "[0.00384523, -0.0144044]\n", - "Couldnt snap 7 entries\n" + "[2.18428e-09, -2.18439e-09]\n", + "[2.18428e-09, 2.18428e-09]\n", + "[2.18428e-09, -2638.129100232685]\n", + "[2.18428e-09, 0.002]\n", + "[2.18428e-09, 0.001]\n", + "[2.18428e-09, 0.00166667]\n", + "[2.18428e-09, 0.0116667]\n", + "[2.18428e-09, 1000.0]\n", + "[2.18428e-09, 2.18439e-09]\n", + "[2.18428e-09, -2.18451e-09]\n" ] } ], @@ -331,32 +345,31 @@ "\n", "srs830.snap('x', 'y', 'r', 'theta', 'frequency', 'display1')\n", "\n", - "try:\n", + "\n", + "with pytest.raises(AssertionError):\n", " srs830.snap('x', 'y', 'r', 'theta', 'frequency', 'display1', 'display2')\n", - "except:\n", - " print('Couldnt snap 7 entries')" + " # snap only accepts 6 entries" ] }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 14, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "Stanford_Research_Systems,SR830,s/n86813,ver1.07 \n" + ] } ], "source": [ "# test get ID\n", "\n", - "srs830.get_identificaiton_string()" + "id = srs830.get_identificaiton_string()\n", + "assert id == 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '\n", + "print(id)" ] }, { @@ -438,9 +451,9 @@ ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "pyscan-jm", "language": "python", - "name": "python3" + "name": "pyscan-jm" }, "language_info": { "codemirror_mode": { @@ -452,7 +465,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 5e448be1..015e5850 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1,3 +1,4 @@ +Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:11:37 Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:05:02 Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:42 Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:20 From 74c835d8329d82b28fb0260d8db6b7e21302d011 Mon Sep 17 00:00:00 2001 From: rsbrost Date: Tue, 17 Sep 2024 13:35:25 -0600 Subject: [PATCH 06/19] fix(test)(driver): fixed both test cases and srs830 driver so it is now passing the test cases. A debug setting is included to debug the test_driver() function; however, this will bypass the test log. An updated error message is included to point to setting the debug parameter to true for debugging purposes. --- .../srs830_test_notebook.ipynb | 60 ++++++++++++------- pyscan/drivers/stanford830.py | 23 ++++--- pyscan/drivers/testing/auto_test_driver.py | 52 +++++++++------- .../driver_test_logs/stanford830_test_log.txt | 9 +-- 4 files changed, 78 insertions(+), 66 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index 68bcacfe..dfaf5898 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 15, + "execution_count": 1, "metadata": { "metadata": {} }, @@ -11,8 +11,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" + "Could not load Keysight SD1\n", + "Could not load Keysight SD1\n", + "pylablib not found, AttocubeANC350 not loaded\n", + "Basler Camera software not found, BaserCamera not loaded\n", + "Helios Camera not installed\n", + "msl not installed, Thorlabs BSC203 driver not loaded\n", + "seabreeze module not found, Ocean Optics not imported\n", + "Thorlabs Kinesis not found, ThorlabsBSC203 not loaded\n", + "Thorlabs Kinesis not found, ThorlabsBPC303 not loaded\n", + "Thorlabs Kinesis not found, ThorlabsMFF101 not loaded\n" ] } ], @@ -61,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": { "metadata": {} }, @@ -72,7 +80,7 @@ "'Stanford_Research_Systems,SR830,s/n86813,ver1.07 \\n'" ] }, - "execution_count": 4, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -83,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 23, "metadata": { "metadata": {} }, @@ -92,21 +100,27 @@ "name": "stdout", "output_type": "stream", "text": [ - "dict_keys(['instrument', '_driver_class', 'debug', '_instrument_driver_version', '_version', 'black_list_for_testing', '_id_settings', '_phase_settings', '_reference_source_settings', '_frequency_settings', '_reference_slope_settings', '_harmonic_settings', '_amplitude_settings', '_input_configuration_settings', '_input_ground_settings', '_input_coupling_settings', '_input_line_filter_settings', '_sensitivity_settings', '_reserve_mode_settings', '_time_constant_settings', '_filter_slope_settings', '_synchronous_filter_settings', '_display1_output_source_settings', '_display2_output_source_settings', '_auxillary_voltage1_settings', '_auxillary_voltage2_settings', '_auxillary_voltage3_settings', '_auxillary_voltage4_settings', '_sample_rate_settings', '_end_buffer_mode_settings', '_trigger_mode_settings', '_id', '_phase', '_reference_source', '_frequency', '_reference_slope', '_harmonic', '_amplitude', '_input_configuration', '_input_ground', '_input_coupling', '_input_line_filter', '_sensitivity', '_reserve_mode', '_time_constant', '_filter_slope', '_synchronous_filter', '_display1_output_source', '_display2_output_source', '_auxillary_voltage1', '_auxillary_voltage2', '_auxillary_voltage3', '_auxillary_voltage4', '_sample_rate', '_end_buffer_mode', '_trigger_mode'])\n", "Initial state for the Stanford830 was: [('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", - "The new test log for this driver is: Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:11:37\n" - ] - }, - { - "ename": "AssertionError", - "evalue": "no valid type present in setting: _id_settings. Must be one of ['values', 'range', 'ranges', 'indexed_values', 'dict_values'].", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[5], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m srs830 \u001b[38;5;241m=\u001b[39m ps\u001b[38;5;241m.\u001b[39mStanford830(res)\n\u001b[1;32m----> 3\u001b[0m \u001b[43mtest_driver\u001b[49m\u001b[43m(\u001b[49m\u001b[43msrs830\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32mc:\\snl\\users\\jjmah\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:526\u001b[0m, in \u001b[0;36mtest_driver\u001b[1;34m(device, skip_log, expected_attributes, expected_values)\u001b[0m\n\u001b[0;32m 523\u001b[0m write_log(device, exception)\n\u001b[0;32m 525\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m exception \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m--> 526\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m, exception\n\u001b[0;32m 527\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 528\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\033\u001b[39;00m\u001b[38;5;124m[1;32mTests passed, instrument \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m looks ready to go.\u001b[39m\u001b[38;5;130;01m\\033\u001b[39;00m\u001b[38;5;124m[0m\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(device\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m))\n", - "\u001b[1;31mAssertionError\u001b[0m: no valid type present in setting: _id_settings. Must be one of ['values', 'range', 'ranges', 'indexed_values', 'dict_values']." + "These blacklisted settings and their corresponding values were not reset: [('_amplitude', 0.496), ('_input_configuration', 'A-B'), ('_time_constant', 30)]\n", + "Reset state for the Stanford830 was: [('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", + "\n", + "\n", + "Beginning tests for: Stanford830 version 1.0.1\n", + "\n", + "7 range properties found and tested out of 25 total settings found.\n", + "0 values properties found and tested out of 25 total settings found.\n", + "12 indexed values properties found and tested out of 25 total settings found.\n", + "2 dict values properties found and tested out of 25 total settings found.\n", + "3 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", + "21 properties tested out of 25 total settings.\n", + "\n", + "Settings restored to: [('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", + "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 ')}\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-17 13:30:34\n", + "\u001b[1;32mTests passed, instrument Stanford830 looks ready to go.\n", + "\u001b[0m\n", + "Checking driver doc string.\n", + "\u001b[92m Docstring looking good. \u001b[0m\n" ] } ], @@ -451,9 +465,9 @@ ], "metadata": { "kernelspec": { - "display_name": "pyscan-jm", + "display_name": "rsbrostenv", "language": "python", - "name": "pyscan-jm" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -465,7 +479,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 3dca3476..adc99d25 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -16,32 +16,32 @@ class Stanford830(InstrumentDriver): Attributes ---------- (Properties) - id: read-only + id : read-only Gets the id string of the device. phase : float Gets/sets the phase of the device. Range: [-180, 180] reference_source : str - Get/sets the reference source. Indexed_values: ['external', 'internal']. + Get/sets the reference source. Indexed_values: ['external', 'internal']. frequency : float Gets/sets/ the frequency. Range: [0.001, 102000] reference_slope : int - Gets/sets the slope of the frequency refeference. + Gets/sets the slope of the frequency refeference. Indexed_values: ['sine zero', 'ttl rising', 'ttl falling']. harmonic : int Gets/sets the demodulation harmonic. Range: [1, 19999] amplitude : float Gets/sets the output amplitude. Range: [0.004, 5.0] input_configuration : str - Gets/sets the analog input mode. + Gets/sets the analog input mode. Indexed_values: ['A', 'A-B', 'Ie6', 'Ie8']. input_ground : str Get/sets the input ground. Indexed_values: ['AC', 'DC'] input_coupling : str - Gets/sets the input coupling. + Gets/sets the input coupling. Indexed_values: ['AC', 'DC'] input_line_filter : str - Gets/sets the line filer of the input. + Gets/sets the line filer of the input. Indexed_values: ['none', 'line', '2xline', 'both'] sensitivity : float Gets/sets the sensitivy (max input). @@ -70,10 +70,10 @@ class Stanford830(InstrumentDriver): synchronous_filter : str Gets/sets the synchronous filter state Indexed_values: ['off', 'on'] - display1_output_source: str + display1_output_source : str Gets/sets the displayed source on display 1 Indexed values ['x', 'display'] - display2_output_source: str + display2_output_source : str Gets/sets the displayed source on display 2 Indexed values['y', 'display'] auxillary_voltage1 : float @@ -82,12 +82,12 @@ class Stanford830(InstrumentDriver): auxillary_voltage2 : float Gets/sets the channel 2 auxillary output voltage range - [-10.5, 10.500] - auxillary_voltage2 : float + auxillary_voltage3 : float Gets/sets the channel 3 auxillary output voltage range - [-10.5, 10.500] - auxillary_voltage2 : float + auxillary_voltage4 : float Gets/sets the channel 4 auxillary output voltage - range - [-10.5, 10.500] + range - [-10.5, 10.500] sample_rate : float Get/sets the sample rate in Hz Indexed_values: [0.0625, .125, .250, .5, 1, @@ -350,7 +350,6 @@ def initialize_properties(self): 'dict_values': {'off': 0, 'on': 1, '0': 0, '1': 1, 0: 0, 1: 1}, 'return_type': int}) - # Display and Output Methods def get_display(self, display_number): ''' diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index c1dfa122..3162d696 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -70,7 +70,7 @@ def validate_blacklist(test_instrument): def save_initial_state(device): saved_settings = [] - print(device.__dict__.keys()) + # print(device.__dict__.keys()) for attribute_name in device.__dict__.keys(): if "_settings" in attribute_name: '''try: @@ -173,8 +173,8 @@ def check_attribute_values(device, attributes, ev): # designed for testing read only properties of any type def check_read_only_property(device, key): name = device[key]['name'] - settings = device[name + '_settings'] - return_type = device + settings = device['_' + name + '_settings'] + return_type = device[key]['return_type'] # I'm not sure that this will work. It might be that only the underscore property can be used to access # the property value. @@ -336,7 +336,7 @@ def check_properties(test_instrument): reset_settings = save_initial_state(test_instrument) print("Reset state for the {} was: {}".format(instrument_name, reset_settings)) - print("Beginning tests for: ", test_instrument.__class__.__name__) + print("\n\nBeginning tests for: ", test_instrument.__class__.__name__, " version ", test_instrument._version) settings = [] total_settings = 0 @@ -383,7 +383,7 @@ def check_properties(test_instrument): diff = set(restored_settings) ^ set(saved_settings) mid_string = 'properties found and tested out of' - print("{} range {} {} total settings found.".format(range_counter, mid_string, total_settings)) + print("\n{} range {} {} total settings found.".format(range_counter, mid_string, total_settings)) print("{} values {} {} total settings found.".format(values_counter, mid_string, total_settings)) print("{} indexed values {} {} total settings found.".format(idx_vals_counter, mid_string, total_settings)) print("{} dict values {} {} total settings found.".format(dict_vals_counter, mid_string, total_settings)) @@ -402,12 +402,12 @@ def check_properties(test_instrument): if isinstance(test_instrument, TestInstrumentDriver): assert values_counter == range_counter == idx_vals_counter == dict_vals_counter == 1 print("Drivers test unit seems to be working as expected.") - print("Settings restored to: {}".format(restored_settings)) + print("\nSettings restored to: {}".format(restored_settings)) if (len(diff) > 0): print("Restored settings are different for the following: ", diff) assert hasattr(test_instrument, '_version'), "The instrument had no attribute _version" - print("The previous instrument version was: ", test_instrument._version) + # print("The (previous) instrument version was: ", test_instrument._version) def write_log(device, exception): @@ -476,7 +476,7 @@ def check_attribute_doc_strings(test_instrument): try: doc_string = test_instrument.get_property_docstring(name) except Exception: - assert False, "Doc string could not be found for {}".format(name) + assert False, "Doc string could not be found or not properly formatted for {}".format(name) splits = doc_string.split('\n') assert name in splits[0], "attribute name not found on first line of doc_string for {}".format(name) @@ -508,29 +508,35 @@ def check_doc_strings(test_instrument): # write formatting test cases here. -def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None): +def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None, + debug=False): if expected_attributes is not None: check_has_attributes(device, expected_attributes) if expected_values is not None: check_attribute_values(device, expected_attributes, expected_values) - try: + if debug: check_properties(device) - exception = None - except Exception as e: - exception = str(e) - - # Note, based on this execution order - # the driver log can pass the driver for functional tests success before ensuring doc string is properly formatted - if skip_log is False: - write_log(device, exception) - - if exception is not None: - assert False, exception + print(f"\033[92m Tests passed, instrument {device.__class__.__name__} should be ready to go. \033[0m") else: - print("\033[1;32mTests passed, instrument {} looks ready to go.\033[0m".format(device.__class__.__name__)) + try: + check_properties(device) + exception = None + except Exception as e: + es = " To debug, rerun the tests with the debug parameter set to true: test_driver(driver, debug=True)" + exception = str(e) + es + + # Note, based on this execution order + # the driver log can pass the driver for functional tests success before ensuring doc string is properly formatted + if skip_log is False: + write_log(device, exception) + + if exception is not None: + assert False, exception + else: + print("\033[1;32mTests passed, instrument {} looks ready to go.\n\033[0m".format(device.__class__.__name__)) check_doc_strings(device) - print("Tests passed, instrument {} should be ready to go.".format(device.__class__.__name__)) + print(f"\033[92m Docstring looking good. \033[0m") diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 015e5850..53034945 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1,8 +1 @@ -Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:11:37 -Failed with stanford830 version v1.0.1 tested on pyscan version v0.5.0 at 2024-08-23 15:05:02 -Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:42 -Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:24:20 -Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 12:01:08 -Passed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:58:06 -Failed with stanford830 version v1.0.0 tested on pyscan version v0.5.0 at 2024-06-11 11:49:53 -Passed with stanford830 version v0.1.0 tested on pyscan version v0.3.0 at 2024-05-28 12:35:11 \ No newline at end of file +Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-17 13:30:34 \ No newline at end of file From ede6468887c33a4dac1cb46d1f5d663e55f2067d Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Tue, 17 Sep 2024 14:24:49 -0600 Subject: [PATCH 07/19] chore: flake8 fixes. --- pyscan/drivers/stanford830.py | 2 +- pyscan/drivers/testing/auto_test_driver.py | 5 +++-- test/measurement/test_experiment.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index adc99d25..6e9c8306 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -30,7 +30,7 @@ class Stanford830(InstrumentDriver): harmonic : int Gets/sets the demodulation harmonic. Range: [1, 19999] amplitude : float - Gets/sets the output amplitude. Range: [0.004, 5.0] + Gets/sets the output amplitude. Range: [0.004, 5.0] input_configuration : str Gets/sets the analog input mode. Indexed_values: ['A', 'A-B', 'Ie6', 'Ie8']. diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index 3162d696..b4b53632 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -528,7 +528,8 @@ def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attribut exception = str(e) + es # Note, based on this execution order - # the driver log can pass the driver for functional tests success before ensuring doc string is properly formatted + # the driver log can pass the driver for functional tests success + # before ensuring doc string is properly formatted if skip_log is False: write_log(device, exception) @@ -539,4 +540,4 @@ def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attribut check_doc_strings(device) - print(f"\033[92m Docstring looking good. \033[0m") + print("\033[92m Docstring looking good. \033[0m") diff --git a/test/measurement/test_experiment.py b/test/measurement/test_experiment.py index eddf0c11..3704e6df 100644 --- a/test/measurement/test_experiment.py +++ b/test/measurement/test_experiment.py @@ -8,7 +8,7 @@ import shutil import numpy as np import pytest -import time +# import time import re import os From 2d2f5815306ef0e3d1d22253bb02628a2c5fbb1b Mon Sep 17 00:00:00 2001 From: rsbrost Date: Wed, 25 Sep 2024 14:01:38 -0600 Subject: [PATCH 08/19] tests(refactor): fixed auto test driver to have more seamless and intuitive debugging. Now only logs tests when they pass. Note: The Stanford830 driver has a buffer_points attribute mentioned in the docstring but nowhere else and so is failing the test nb. Make sure this is fixed in the stanford830 branch. --- .../srs830_test_notebook.ipynb | 67 ++++++++++--------- pyscan/drivers/testing/auto_test_driver.py | 38 ++++------- .../driver_test_logs/stanford830_test_log.txt | 2 +- 3 files changed, 48 insertions(+), 59 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index dfaf5898..fd502b14 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 4, "metadata": { "metadata": {} }, @@ -116,11 +116,11 @@ "\n", "Settings restored to: [('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 ')}\n", - "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-17 13:30:34\n", - "\u001b[1;32mTests passed, instrument Stanford830 looks ready to go.\n", - "\u001b[0m\n", + "\u001b[92m Driver tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-25 13:55:54\n", + "\u001b[1;32m Driver test results logged. \u001b[0m\n", "Checking driver doc string.\n", - "\u001b[92m Docstring looking good. \u001b[0m\n" + "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n" ] } ], @@ -132,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 5, "metadata": { "metadata": {} }, @@ -188,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": { "metadata": {} }, @@ -214,7 +214,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -259,17 +259,17 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "0.00466667\n", + "-0.001\n", "0.00166667\n", - "0.004\n", - "0.001\n", - "-0.0176667\n" + "0.00233333\n" ] } ], @@ -284,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -294,7 +294,7 @@ "2.18428e-09\n", "-2.18439e-09\n", "2.18428e-09\n", - "-2656.6929484751354\n" + "-2597.219879105803\n" ] } ], @@ -309,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -330,7 +330,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -339,11 +339,11 @@ "text": [ "[2.18428e-09, -2.18439e-09]\n", "[2.18428e-09, 2.18428e-09]\n", - "[2.18428e-09, -2638.129100232685]\n", - "[2.18428e-09, 0.002]\n", - "[2.18428e-09, 0.001]\n", - "[2.18428e-09, 0.00166667]\n", - "[2.18428e-09, 0.0116667]\n", + "[2.18428e-09, -2670.7877221406993]\n", + "[2.18428e-09, -0.003]\n", + "[2.18428e-09, -0.00566667]\n", + "[2.18428e-09, -0.008]\n", + "[2.18428e-09, -0.00833333]\n", "[2.18428e-09, 1000.0]\n", "[2.18428e-09, 2.18439e-09]\n", "[2.18428e-09, -2.18451e-09]\n" @@ -367,7 +367,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -388,18 +388,19 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": 13, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 95, - "metadata": {}, - "output_type": "execute_result" + "ename": "AttributeError", + "evalue": "'Stanford830' object has no attribute 'buffer_points'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[13], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m# test buffer_points\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m srs830\u001b[39m.\u001b[39;49mbuffer_points\n\u001b[0;32m 4\u001b[0m srs830\u001b[39m.\u001b[39mwait_for_trigger()\n\u001b[0;32m 5\u001b[0m srs830\u001b[39m.\u001b[39mset_buffer_mode(\u001b[39m0.25\u001b[39m)\n", + "\u001b[1;31mAttributeError\u001b[0m: 'Stanford830' object has no attribute 'buffer_points'" + ] } ], "source": [ @@ -417,7 +418,7 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -437,7 +438,7 @@ }, { "cell_type": "code", - "execution_count": 92, + "execution_count": null, "metadata": {}, "outputs": [ { diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index b4b53632..ae3fa493 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -410,7 +410,7 @@ def check_properties(test_instrument): # print("The (previous) instrument version was: ", test_instrument._version) -def write_log(device, exception): +def write_log(device, exception=None): try: driver_file_name = str(type(device)).split("'")[1].split(".")[-2] except Exception: @@ -508,36 +508,24 @@ def check_doc_strings(test_instrument): # write formatting test cases here. -def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None, - debug=False): +def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None): if expected_attributes is not None: check_has_attributes(device, expected_attributes) if expected_values is not None: check_attribute_values(device, expected_attributes, expected_values) - if debug: - check_properties(device) - print(f"\033[92m Tests passed, instrument {device.__class__.__name__} should be ready to go. \033[0m") - else: - try: - check_properties(device) - exception = None - except Exception as e: - es = " To debug, rerun the tests with the debug parameter set to true: test_driver(driver, debug=True)" - exception = str(e) + es - - # Note, based on this execution order - # the driver log can pass the driver for functional tests success - # before ensuring doc string is properly formatted - if skip_log is False: - write_log(device, exception) - - if exception is not None: - assert False, exception - else: - print("\033[1;32mTests passed, instrument {} looks ready to go.\n\033[0m".format(device.__class__.__name__)) + check_properties(device) + print(f"\033[92m Driver tests passed, instrument: {device.__class__.__name__} looks ready to go. \033[0m") + + # Note, based on this execution order + # the driver log can pass the driver for functional tests success + # before ensuring doc string is properly formatted + if skip_log is False: + write_log(device) + + print("\033[1;32m Driver test results logged. \033[0m") check_doc_strings(device) - print("\033[92m Docstring looking good. \033[0m") + print("\033[92m Docstring tests passed and looking good. \033[0m") diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 53034945..d3f1e240 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-17 13:30:34 \ No newline at end of file +Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-25 13:55:54 \ No newline at end of file From 77ff7fd214647b8f657e51f09d688f1c5e82bb95 Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Thu, 26 Sep 2024 10:29:30 -0600 Subject: [PATCH 09/19] tests(doc): adding tests for docstrings to not only check that attributes and methods have corresponding doc strings, but that all attributes and methods listed in the docstring are implemented in the drivers contents. Needs to be tested. --- pyscan/drivers/testing/auto_test_driver.py | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index ae3fa493..6e19f00e 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -7,6 +7,7 @@ from pyscan.general.get_pyscan_version import get_pyscan_version import os from datetime import datetime +import re ''' WARNING! @@ -484,6 +485,38 @@ def check_attribute_doc_strings(test_instrument): assert [len(splits[1]) > 3], "doc string's second line is not long enough for {}".format(name) +def extract_attributes_from_docstring(doc_string): + # Assuming attributes are listed under 'Attributes' section + attributes = [] + in_attributes_section = False + for line in doc_string.split('\n'): + if 'Attributes' in line: + in_attributes_section = True + elif in_attributes_section: + if line.strip() == '': + break + match = re.match(r'\s*(\w+)\s*:', line) + if match: + attributes.append(match.group(1)) + return attributes + + +def extract_methods_from_docstring(doc_string): + # Assuming methods are listed under 'Methods' section + methods = [] + in_methods_section = False + for line in doc_string.split('\n'): + if 'Methods' in line: + in_methods_section = True + elif in_methods_section: + if line.strip() == '': + break + match = re.match(r'\s*(\w+)\s*\(', line) + if match: + methods.append(match.group(1)) + return methods + + # parses and checks the instruments doc string for proper formatting def check_doc_strings(test_instrument): print("Checking driver doc string.") @@ -505,6 +538,18 @@ def check_doc_strings(test_instrument): assert line.startswith(' ') or line == '', "Improper indentation of line {}".format(repr(line)) check_attribute_doc_strings(test_instrument) + + # Extract attributes and methods from the docstring + attributes = extract_attributes_from_docstring(doc_string) + methods = extract_methods_from_docstring(doc_string) + + # Check that each attribute and method in the docstring exists in the test_instrument + for attribute in attributes: + assert hasattr(test_instrument, attribute), f"Attribute '{attribute}' listed in docstring but not the driver." + + for method in methods: + assert hasattr(test_instrument, method), f"Method '{method}' listed in docstring but not the driver." + # write formatting test cases here. From 31d8af2f9f14bcb0231b9d18ba9a8ab990983175 Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Thu, 26 Sep 2024 10:36:39 -0600 Subject: [PATCH 10/19] tests(fix): fixing output to make use of pretty print pkg to have more readable line breaks. Must be tested. --- pyscan/drivers/testing/auto_test_driver.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index 6e19f00e..ba951585 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -8,6 +8,7 @@ import os from datetime import datetime import re +import pprint ''' WARNING! @@ -331,11 +332,14 @@ def check_properties(test_instrument): instrument_name = test_instrument.__class__.__name__ # values_idx, range_idx, idx_vals_idx, dict_vals_idx = [], [], [], [] saved_settings = save_initial_state(test_instrument) - print("Initial state for the {} was: {}".format(instrument_name, saved_settings)) + print("Initial state for the {} was: ".format(instrument_name)) + pprint.pprint(saved_settings) + print("\n") reset_device_properties(test_instrument) reset_settings = save_initial_state(test_instrument) - print("Reset state for the {} was: {}".format(instrument_name, reset_settings)) + print("Reset state for the {} was: ".format(instrument_name)) + pprint.pprint(reset_settings) print("\n\nBeginning tests for: ", test_instrument.__class__.__name__, " version ", test_instrument._version) @@ -403,9 +407,11 @@ def check_properties(test_instrument): if isinstance(test_instrument, TestInstrumentDriver): assert values_counter == range_counter == idx_vals_counter == dict_vals_counter == 1 print("Drivers test unit seems to be working as expected.") - print("\nSettings restored to: {}".format(restored_settings)) + print("\nSettings restored to: ") + pprint.pprint(restored_settings) if (len(diff) > 0): - print("Restored settings are different for the following: ", diff) + print("\nRestored settings are different for the following: ", diff) + print("\n") assert hasattr(test_instrument, '_version'), "The instrument had no attribute _version" # print("The (previous) instrument version was: ", test_instrument._version) From f315da6c8864fe9e17d84ccb1941c2e5965cf17f Mon Sep 17 00:00:00 2001 From: rsbrost Date: Thu, 26 Sep 2024 11:23:09 -0600 Subject: [PATCH 11/19] tests(feat)(fix)(doc): updated and validated auto test driver. Outputs now have a verbose option (defaults to True), to offer an option to clean up outputs which have been further refined in general. Testing for implementation and presence of attributes and methods in drivers docstrings is now implemented and validated. Furthermore, since we are now only logging the most recent passing of drivers, test logging has been updated to only save one line for simplicity, legibility, and maintainability, unless otherwise specified through the save_multiple_lines parameter. --- .../srs830_test_notebook.ipynb | 72 ++++++++++--------- pyscan/drivers/testing/auto_test_driver.py | 63 ++++++++++------ .../driver_test_logs/stanford830_test_log.txt | 2 +- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index fd502b14..51535b09 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 9, "metadata": { "metadata": {} }, @@ -11,16 +11,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Could not load Keysight SD1\n", - "Could not load Keysight SD1\n", - "pylablib not found, AttocubeANC350 not loaded\n", - "Basler Camera software not found, BaserCamera not loaded\n", - "Helios Camera not installed\n", - "msl not installed, Thorlabs BSC203 driver not loaded\n", - "seabreeze module not found, Ocean Optics not imported\n", - "Thorlabs Kinesis not found, ThorlabsBSC203 not loaded\n", - "Thorlabs Kinesis not found, ThorlabsBPC303 not loaded\n", - "Thorlabs Kinesis not found, ThorlabsMFF101 not loaded\n" + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" ] } ], @@ -31,12 +23,13 @@ "import pyscan as ps\n", "from pyscan.drivers.testing.auto_test_driver import test_driver\n", "from pyvisa import ResourceManager, VisaIOError\n", - "import pytest" + "import pytest\n", + "from time import sleep" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 10, "metadata": { "metadata": {} }, @@ -69,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 11, "metadata": { "metadata": {} }, @@ -80,7 +73,7 @@ "'Stanford_Research_Systems,SR830,s/n86813,ver1.07 \\n'" ] }, - "execution_count": 3, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -91,7 +84,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 18, "metadata": { "metadata": {} }, @@ -100,10 +93,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Initial state for the Stanford830 was: [('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", - "These blacklisted settings and their corresponding values were not reset: [('_amplitude', 0.496), ('_input_configuration', 'A-B'), ('_time_constant', 30)]\n", - "Reset state for the Stanford830 was: [('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", - "\n", + "Blacklisted settings that will not be tested or changed are: \n", + "[('_amplitude', 0.496), ('_input_configuration', 'A-B'), ('_time_constant', 30)]\n", "\n", "Beginning tests for: Stanford830 version 1.0.1\n", "\n", @@ -114,25 +105,38 @@ "3 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", "21 properties tested out of 25 total settings.\n", "\n", - "Settings restored to: [('phase', 0.0), ('reference_source', 'external'), ('frequency', 1000.0), ('reference_slope', 'sine zero'), ('harmonic', 1), ('amplitude', 0.496), ('input_configuration', 'A-B'), ('input_ground', 'AC'), ('input_coupling', 'AC'), ('input_line_filter', 'none'), ('sensitivity', 2e-09), ('reserve_mode', 'high'), ('time_constant', 30), ('filter_slope', 6), ('synchronous_filter', 'off'), ('display1_output_source', 'x'), ('display2_output_source', 'y'), ('auxillary_voltage1', -10.5), ('auxillary_voltage2', -10.5), ('auxillary_voltage3', -10.5), ('auxillary_voltage4', -10.5), ('sample_rate', 0.0625), ('end_buffer_mode', 'one shot'), ('trigger_mode', 'off')]\n", "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 ')}\n", + "\n", + "\n", "\u001b[92m Driver tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", - "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-25 13:55:54\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.3 at 2024-09-26 11:19:53\n", "\u001b[1;32m Driver test results logged. \u001b[0m\n", - "Checking driver doc string.\n", - "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n" + "Checking driver doc string.\n" + ] + }, + { + "ename": "AssertionError", + "evalue": "Attribute 'buffer_points' listed in docstring but not the driver.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[18], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m srs830 \u001b[39m=\u001b[39m ps\u001b[39m.\u001b[39mStanford830(res)\n\u001b[1;32m----> 3\u001b[0m test_driver(srs830, verbose\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m)\n", + "File \u001b[1;32mc:\\users\\rsbrost\\documents\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:603\u001b[0m, in \u001b[0;36mtest_driver\u001b[1;34m(device, skip_log, expected_attributes, expected_values, verbose)\u001b[0m\n\u001b[0;32m 599\u001b[0m write_log(device)\n\u001b[0;32m 601\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[1;32m Driver test results logged. \u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[0m\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m--> 603\u001b[0m check_doc_strings(device)\n\u001b[0;32m 605\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[92m Docstring tests passed and looking good. \u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[0m\u001b[39m\u001b[39m\"\u001b[39m)\n", + "File \u001b[1;32mc:\\users\\rsbrost\\documents\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:576\u001b[0m, in \u001b[0;36mcheck_doc_strings\u001b[1;34m(test_instrument)\u001b[0m\n\u001b[0;32m 574\u001b[0m \u001b[39m# Check that each attribute and method in the docstring exists in the test_instrument\u001b[39;00m\n\u001b[0;32m 575\u001b[0m \u001b[39mfor\u001b[39;00m attribute \u001b[39min\u001b[39;00m attributes:\n\u001b[1;32m--> 576\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mhasattr\u001b[39m(test_instrument, attribute), \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mAttribute \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mattribute\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m listed in docstring but not the driver.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 578\u001b[0m \u001b[39mfor\u001b[39;00m method \u001b[39min\u001b[39;00m methods:\n\u001b[0;32m 579\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mhasattr\u001b[39m(test_instrument, method), \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mMethod \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mmethod\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m listed in docstring but not the driver.\u001b[39m\u001b[39m\"\u001b[39m\n", + "\u001b[1;31mAssertionError\u001b[0m: Attribute 'buffer_points' listed in docstring but not the driver." ] } ], "source": [ "srs830 = ps.Stanford830(res)\n", "\n", - "test_driver(srs830)" + "test_driver(srs830, verbose=False)" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "metadata": {} }, @@ -188,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "metadata": {} }, @@ -214,7 +218,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -259,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -284,7 +288,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -309,7 +313,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -330,7 +334,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -367,7 +371,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -388,7 +392,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [ { diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index ba951585..04b8e7ab 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -156,7 +156,8 @@ def reset_device_properties(device): name, ['values', 'range', 'indexed_values', 'dict_values', 'read_only']) if len(blacklisted) > 0: - print("These blacklisted settings and their corresponding values were not reset: ", blacklisted) + print("Blacklisted settings that will not be tested or changed are: ") + pprint.pprint(blacklisted) # check that the initialized state has the expected attributes @@ -323,7 +324,7 @@ def check_dict_property(device, key): # implements above checks for all attributes by type -def check_properties(test_instrument): +def check_properties(test_instrument, verbose=True): # This is a critical step to ensuring safety when testing drivers with actual instruments validate_blacklist(test_instrument) @@ -332,16 +333,19 @@ def check_properties(test_instrument): instrument_name = test_instrument.__class__.__name__ # values_idx, range_idx, idx_vals_idx, dict_vals_idx = [], [], [], [] saved_settings = save_initial_state(test_instrument) - print("Initial state for the {} was: ".format(instrument_name)) - pprint.pprint(saved_settings) - print("\n") + if verbose: + print("Initial state for the {} was: ".format(instrument_name)) + pprint.pprint(saved_settings) + print("\n") reset_device_properties(test_instrument) reset_settings = save_initial_state(test_instrument) - print("Reset state for the {} was: ".format(instrument_name)) - pprint.pprint(reset_settings) + if verbose: + print("Reset state for the {} was: ".format(instrument_name)) + pprint.pprint(reset_settings) + print("\n") - print("\n\nBeginning tests for: ", test_instrument.__class__.__name__, " version ", test_instrument._version) + print("\nBeginning tests for: ", test_instrument.__class__.__name__, " version ", test_instrument._version) settings = [] total_settings = 0 @@ -407,8 +411,11 @@ def check_properties(test_instrument): if isinstance(test_instrument, TestInstrumentDriver): assert values_counter == range_counter == idx_vals_counter == dict_vals_counter == 1 print("Drivers test unit seems to be working as expected.") - print("\nSettings restored to: ") - pprint.pprint(restored_settings) + + if verbose: + print("\nSettings restored to: ") + pprint.pprint(restored_settings) + if (len(diff) > 0): print("\nRestored settings are different for the following: ", diff) print("\n") @@ -417,7 +424,7 @@ def check_properties(test_instrument): # print("The (previous) instrument version was: ", test_instrument._version) -def write_log(device, exception=None): +def write_log(device, exception=None, save_multiple_lines=False): try: driver_file_name = str(type(device)).split("'")[1].split(".")[-2] except Exception: @@ -445,12 +452,14 @@ def write_log(device, exception=None): path = os.path.join(directory, driver_file_name) if driver_file_name in driver_test_logs_file_names: - with open(path, 'r') as test_log: - existing_log = test_log.read() + if save_multiple_lines: + with open(path, 'r') as test_log: + existing_log = test_log.read() with open(path, 'w') as test_log: test_log.write(new_line + '\n') - test_log.write(existing_log) + if save_multiple_lines: + test_log.write(existing_log) else: print("No test log file detected for this driver. Creating a new one.") @@ -492,18 +501,29 @@ def check_attribute_doc_strings(test_instrument): def extract_attributes_from_docstring(doc_string): - # Assuming attributes are listed under 'Attributes' section + # Assuming attributes are listed with 4 leading spaces and followed by a colon attributes = [] in_attributes_section = False + for line in doc_string.split('\n'): + # Check if we've reached the Methods section + if 'Methods' in line: + break # Stop processing if we've reached Methods + + # Check for the start of Attributes section if 'Attributes' in line: in_attributes_section = True - elif in_attributes_section: + continue # Go to the next line to read attributes + + # If we are in the Attributes section, extract attributes + if in_attributes_section: if line.strip() == '': - break - match = re.match(r'\s*(\w+)\s*:', line) + continue # Skip empty lines + # Match lines that start with 4 spaces and contain a word followed by a colon + match = re.match(r'^\s{4}(\w+)\s*:', line) if match: attributes.append(match.group(1)) + return attributes @@ -511,6 +531,7 @@ def extract_methods_from_docstring(doc_string): # Assuming methods are listed under 'Methods' section methods = [] in_methods_section = False + for line in doc_string.split('\n'): if 'Methods' in line: in_methods_section = True @@ -520,6 +541,7 @@ def extract_methods_from_docstring(doc_string): match = re.match(r'\s*(\w+)\s*\(', line) if match: methods.append(match.group(1)) + return methods @@ -559,14 +581,15 @@ def check_doc_strings(test_instrument): # write formatting test cases here. -def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None): +def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attributes=None, expected_values=None, + verbose=True): if expected_attributes is not None: check_has_attributes(device, expected_attributes) if expected_values is not None: check_attribute_values(device, expected_attributes, expected_values) - check_properties(device) + check_properties(device, verbose) print(f"\033[92m Driver tests passed, instrument: {device.__class__.__name__} looks ready to go. \033[0m") # Note, based on this execution order diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index d3f1e240..b5ca3d47 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.2 at 2024-09-25 13:55:54 \ No newline at end of file +Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.3 at 2024-09-26 11:19:53 From 83e7c9cf3ae492771090e9fc68a71417423094c6 Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Thu, 26 Sep 2024 13:09:12 -0600 Subject: [PATCH 12/19] chore: empty commit to retest readthedocs build. From 47fe62ba4b9437de650e7d7ff19a658c79d1a85d Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Tue, 1 Oct 2024 09:30:19 -0600 Subject: [PATCH 13/19] tests(fix): fixed auto test driver doc string test to now test before logging results. --- pyscan/drivers/testing/auto_test_driver.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index 04b8e7ab..34d773e6 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -592,14 +592,13 @@ def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attribut check_properties(device, verbose) print(f"\033[92m Driver tests passed, instrument: {device.__class__.__name__} looks ready to go. \033[0m") + check_doc_strings(device) + print("\033[92m Docstring tests passed and looking good. \033[0m") + # Note, based on this execution order # the driver log can pass the driver for functional tests success # before ensuring doc string is properly formatted if skip_log is False: write_log(device) - print("\033[1;32m Driver test results logged. \033[0m") - - check_doc_strings(device) - - print("\033[92m Docstring tests passed and looking good. \033[0m") + print(f"\033[1;32m {device.__class__.__name__} test results logged. \033[0m") From 2afcea879d94bbca610305e7dafc7f2f19ad28de Mon Sep 17 00:00:00 2001 From: Ryan Brost Date: Tue, 1 Oct 2024 09:45:32 -0600 Subject: [PATCH 14/19] chore(test): updating keithley2260b driver test log. --- .../testing/driver_test_logs/keithley2260b_test_log.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt index 3c3b6dac..39cd1aa2 100644 --- a/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/keithley2260b_test_log.txt @@ -1,4 +1 @@ -Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 12:27:11 -Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 12:25:42 -Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 11:53:18 -Passed with keithley2260b version v0.1.0 tested on pyscan version v0.3.0 at 2024-05-24 13:50:29 \ No newline at end of file +Passed with keithley2260b version v0.1.1 tested on pyscan version v0.5.0 at 2024-06-11 12:27:11 \ No newline at end of file From dc2a5be3ece234081c51384ea714ed99190df741 Mon Sep 17 00:00:00 2001 From: cint-transport Date: Tue, 1 Oct 2024 10:05:33 -0600 Subject: [PATCH 15/19] fix(driver): fixed Stanford830 buffer points as read only, complete driver? --- .../srs830_test_notebook.ipynb | 190 +++++++----------- pyscan/drivers/stanford830.py | 10 +- pyscan/drivers/testing/auto_test_driver.py | 2 +- .../driver_test_logs/stanford830_test_log.txt | 2 +- 4 files changed, 79 insertions(+), 125 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index 51535b09..c754c065 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": { "metadata": {} }, @@ -11,8 +11,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" + "Could not load Keysight SD1\n", + "Could not load Keysight SD1\n", + "pylablib not found, AttocubeANC350 not loaded\n", + "Basler Camera software not found, BaserCamera not loaded\n", + "Helios Camera not installed\n", + "msl not installed, Thorlabs BSC203 driver not loaded\n", + "seabreeze module not found, Ocean Optics not imported\n", + "Thorlabs Kinesis not found, ThorlabsBSC203 not loaded\n", + "Thorlabs Kinesis not found, ThorlabsBPC303 not loaded\n", + "Thorlabs Kinesis not found, ThorlabsMFF101 not loaded\n" ] } ], @@ -29,7 +37,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": { "metadata": {} }, @@ -62,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "metadata": { "metadata": {} }, @@ -73,7 +81,7 @@ "'Stanford_Research_Systems,SR830,s/n86813,ver1.07 \\n'" ] }, - "execution_count": 11, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -84,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 4, "metadata": { "metadata": {} }, @@ -98,33 +106,21 @@ "\n", "Beginning tests for: Stanford830 version 1.0.1\n", "\n", - "7 range properties found and tested out of 25 total settings found.\n", - "0 values properties found and tested out of 25 total settings found.\n", - "12 indexed values properties found and tested out of 25 total settings found.\n", - "2 dict values properties found and tested out of 25 total settings found.\n", + "7 range properties found and tested out of 26 total settings found.\n", + "0 values properties found and tested out of 26 total settings found.\n", + "12 indexed values properties found and tested out of 26 total settings found.\n", + "2 dict values properties found and tested out of 26 total settings found.\n", "3 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", - "21 properties tested out of 25 total settings.\n", + "21 properties tested out of 26 total settings.\n", "\n", - "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 ')}\n", + "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('buffer_points', 16383)}\n", "\n", "\n", - "\u001b[92m Driver tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", - "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.3 at 2024-09-26 11:19:53\n", - "\u001b[1;32m Driver test results logged. \u001b[0m\n", - "Checking driver doc string.\n" - ] - }, - { - "ename": "AssertionError", - "evalue": "Attribute 'buffer_points' listed in docstring but not the driver.", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[18], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m srs830 \u001b[39m=\u001b[39m ps\u001b[39m.\u001b[39mStanford830(res)\n\u001b[1;32m----> 3\u001b[0m test_driver(srs830, verbose\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m)\n", - "File \u001b[1;32mc:\\users\\rsbrost\\documents\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:603\u001b[0m, in \u001b[0;36mtest_driver\u001b[1;34m(device, skip_log, expected_attributes, expected_values, verbose)\u001b[0m\n\u001b[0;32m 599\u001b[0m write_log(device)\n\u001b[0;32m 601\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[1;32m Driver test results logged. \u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[0m\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m--> 603\u001b[0m check_doc_strings(device)\n\u001b[0;32m 605\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[92m Docstring tests passed and looking good. \u001b[39m\u001b[39m\\033\u001b[39;00m\u001b[39m[0m\u001b[39m\u001b[39m\"\u001b[39m)\n", - "File \u001b[1;32mc:\\users\\rsbrost\\documents\\pyscan\\pyscan\\drivers\\testing\\auto_test_driver.py:576\u001b[0m, in \u001b[0;36mcheck_doc_strings\u001b[1;34m(test_instrument)\u001b[0m\n\u001b[0;32m 574\u001b[0m \u001b[39m# Check that each attribute and method in the docstring exists in the test_instrument\u001b[39;00m\n\u001b[0;32m 575\u001b[0m \u001b[39mfor\u001b[39;00m attribute \u001b[39min\u001b[39;00m attributes:\n\u001b[1;32m--> 576\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mhasattr\u001b[39m(test_instrument, attribute), \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mAttribute \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mattribute\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m listed in docstring but not the driver.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 578\u001b[0m \u001b[39mfor\u001b[39;00m method \u001b[39min\u001b[39;00m methods:\n\u001b[0;32m 579\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mhasattr\u001b[39m(test_instrument, method), \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mMethod \u001b[39m\u001b[39m'\u001b[39m\u001b[39m{\u001b[39;00mmethod\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\u001b[39m listed in docstring but not the driver.\u001b[39m\u001b[39m\"\u001b[39m\n", - "\u001b[1;31mAssertionError\u001b[0m: Attribute 'buffer_points' listed in docstring but not the driver." + "\u001b[92m Property implementation tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", + "Checking driver doc string.\n", + "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.8.0 at 2024-10-01 10:01:28\n", + "\u001b[1;32m Stanford830 test results logged. \u001b[0m\n" ] } ], @@ -136,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "metadata": {} }, @@ -192,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "metadata": {} }, @@ -201,7 +197,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['0', '1']\n", + "['100', '1']\n", "['0', '0']\n" ] } @@ -218,16 +214,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2.18428e-09 2.18428e-09\n", - "-2.18439e-09 -2.18439e-09\n", - "2.18428e-09 2.18428e-09\n" + "-1.09223e-07 -1.09223e-07\n", + "1.0922e-07 1.0922e-07\n", + "1.0922e-07 1.0922e-07\n" ] } ], @@ -263,17 +259,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.00466667\n", - "-0.001\n", - "0.00166667\n", - "0.00233333\n" + "0.002\n", + "0.00233333\n", + "0.003\n", + "0.00266667\n" ] } ], @@ -288,17 +284,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2.18428e-09\n", - "-2.18439e-09\n", - "2.18428e-09\n", - "-2597.219879105803\n" + "-1.09223e-07\n", + "1.0922e-07\n", + "1.0922e-07\n", + "7734.592992720247\n" ] } ], @@ -313,15 +309,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2.18439e-09\n", - "-2.18451e-09\n" + "-1.09223e-07\n", + "1.0922e-07\n" ] } ], @@ -334,23 +330,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[2.18428e-09, -2.18439e-09]\n", - "[2.18428e-09, 2.18428e-09]\n", - "[2.18428e-09, -2670.7877221406993]\n", - "[2.18428e-09, -0.003]\n", - "[2.18428e-09, -0.00566667]\n", - "[2.18428e-09, -0.008]\n", - "[2.18428e-09, -0.00833333]\n", - "[2.18428e-09, 1000.0]\n", - "[2.18428e-09, 2.18439e-09]\n", - "[2.18428e-09, -2.18451e-09]\n" + "[-1.09223e-07, 1.0922e-07]\n", + "[-1.09223e-07, 1.0922e-07]\n", + "[-1.09223e-07, 7733.217892850435]\n", + "[-1.09223e-07, 0.0]\n", + "[-1.09223e-07, 0.001]\n", + "[-1.09223e-07, 0.00166667]\n", + "[-1.09223e-07, 0.004]\n", + "[-1.09223e-07, 1000.0]\n", + "[-1.09223e-07, -1.09223e-07]\n", + "[-1.09223e-07, 1.0922e-07]\n" ] } ], @@ -371,7 +367,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -386,25 +382,24 @@ "# test get ID\n", "\n", "id = srs830.get_identificaiton_string()\n", - "assert id == 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '\n", + "assert 'Stanford_Research_Systems,SR830' in id\n", "print(id)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [ { - "ename": "AttributeError", - "evalue": "'Stanford830' object has no attribute 'buffer_points'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[13], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m# test buffer_points\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m srs830\u001b[39m.\u001b[39;49mbuffer_points\n\u001b[0;32m 4\u001b[0m srs830\u001b[39m.\u001b[39mwait_for_trigger()\n\u001b[0;32m 5\u001b[0m srs830\u001b[39m.\u001b[39mset_buffer_mode(\u001b[39m0.25\u001b[39m)\n", - "\u001b[1;31mAttributeError\u001b[0m: 'Stanford830' object has no attribute 'buffer_points'" - ] + "data": { + "text/plain": [ + "159" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -412,60 +407,13 @@ "\n", "srs830.buffer_points\n", "srs830.wait_for_trigger()\n", - "srs830.set_buffer_mode(0.25)\n", + "srs830.set_buffer_mode(8)\n", "srs830.wait_for_trigger()\n", "# srs830.start()\n", "srs830.trigger()\n", "sleep(20)\n", "srs830.buffer_points\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'0\\n'" - ] - }, - "execution_count": 91, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "srs830.query('SRAT?')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "0.0625" - ] - }, - "execution_count": 92, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "srs830.sample_rate" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 6e9c8306..6c05fbb5 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -100,7 +100,7 @@ class Stanford830(InstrumentDriver): trigger_mode : int Gets/sets the trigger mode state Indexed_values': ['off', 'on'] - buffer_points: read-only + buffer_points : read-only Gets the number of points stored in the buffer. Methods @@ -136,7 +136,7 @@ def __init__(self, instrument): super().__init__(instrument) self.debug = False - self._version = "1.0.1" + self._version = "1.0.2" self.black_list_for_testing = ['_input_configuration', "_time_constant", "_amplitude"] @@ -350,6 +350,12 @@ def initialize_properties(self): 'dict_values': {'off': 0, 'on': 1, '0': 0, '1': 1, 0: 0, 1: 1}, 'return_type': int}) + self.add_device_property({ + 'name': 'buffer_points', + 'query_string': 'SPTS?', + 'read_only': True, + 'return_type': int}) + # Display and Output Methods def get_display(self, display_number): ''' diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index 34d773e6..1dc7fbdc 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -590,7 +590,7 @@ def test_driver(device=TestInstrumentDriver(), skip_log=False, expected_attribut check_attribute_values(device, expected_attributes, expected_values) check_properties(device, verbose) - print(f"\033[92m Driver tests passed, instrument: {device.__class__.__name__} looks ready to go. \033[0m") + print(f"\033[92m Property implementation tests passed, instrument: {device.__class__.__name__} looks ready to go. \033[0m") check_doc_strings(device) print("\033[92m Docstring tests passed and looking good. \033[0m") diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index b5ca3d47..491ce41e 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.1 tested on pyscan version v0.7.3 at 2024-09-26 11:19:53 +Passed with stanford830 version v1.0.1 tested on pyscan version v0.8.0 at 2024-10-01 10:01:28 From 0f8cedda52b4b5d04598536205bb5d860ce5b31d Mon Sep 17 00:00:00 2001 From: cint-transport Date: Tue, 1 Oct 2024 18:32:32 -0600 Subject: [PATCH 16/19] fix(driver): black listed stanford830 sensitivity for autotesting, depends on time constant --- pyscan/drivers/stanford830.py | 6 +++++- pyscan/drivers/testing/auto_test_driver.py | 7 +++---- .../testing/driver_test_logs/stanford830_test_log.txt | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 6c05fbb5..327c9cff 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -138,7 +138,11 @@ def __init__(self, instrument): self.debug = False self._version = "1.0.2" - self.black_list_for_testing = ['_input_configuration', "_time_constant", "_amplitude"] + self.black_list_for_testing = [ + '_input_configuration', + "_time_constant", + "_amplitude", + "_sensitivity"] self.initialize_properties() self.update_properties() diff --git a/pyscan/drivers/testing/auto_test_driver.py b/pyscan/drivers/testing/auto_test_driver.py index 1dc7fbdc..dcc75bbe 100644 --- a/pyscan/drivers/testing/auto_test_driver.py +++ b/pyscan/drivers/testing/auto_test_driver.py @@ -97,8 +97,7 @@ def restore_initial_state(device, saved_settings): val = setting[1] if _name in device.black_list_for_testing: - err_msg = ("WARNING! BLACKLISTED PROPERTY WAS SOMEHOW CHANGED. Was {}, now {}\n".format(val, device[setter]) - + "PROCEED WITH CAUTION!") + err_msg = f"WARNING! BLACKLISTED PROPERTY WAS SOMEHOW CHANGED. Was {val}, now {device[setter]}\n" assert val == device[setter], err_msg restored_settings.append((setter, device[setter])) continue @@ -386,8 +385,8 @@ def check_properties(test_instrument, verbose=True): else: assert False, "no valid type present in setting: {}. Must be one of {}.".format( name, ['values', 'range', 'indexed_values', 'dict_values']) - - restored_settings = restore_initial_state(test_instrument, saved_settings) + print(name) + restored_settings = restore_initial_state(test_instrument, saved_settings) diff = set(restored_settings) ^ set(saved_settings) diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 491ce41e..ebf4c4d8 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.1 tested on pyscan version v0.8.0 at 2024-10-01 10:01:28 +Passed with stanford830 version v1.0.2 tested on pyscan version v0.8.0 at 2024-10-01 18:31:03 From be9b1376fb895486fd799050d483886951432723 Mon Sep 17 00:00:00 2001 From: cint-transport Date: Wed, 2 Oct 2024 10:41:59 -0600 Subject: [PATCH 17/19] fix(driver Stanford830): learned to spell, fixed test notebook bug --- .../srs830_test_notebook.ipynb | 141 +++++++----------- pyscan/drivers/stanford830.py | 36 ++--- .../driver_test_logs/stanford830_test_log.txt | 2 +- 3 files changed, 72 insertions(+), 107 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index c754c065..36adb908 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -74,65 +74,37 @@ "metadata": { "metadata": {} }, - "outputs": [ - { - "data": { - "text/plain": [ - "'Stanford_Research_Systems,SR830,s/n86813,ver1.07 \\n'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "name" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "metadata": {} - }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Blacklisted settings that will not be tested or changed are: \n", - "[('_amplitude', 0.496), ('_input_configuration', 'A-B'), ('_time_constant', 30)]\n", - "\n", - "Beginning tests for: Stanford830 version 1.0.1\n", + "[('_amplitude', 0.028),\n", + " ('_input_configuration', 'A-B'),\n", + " ('_sensitivity', 0.005),\n", + " ('_time_constant', 1)]\n", "\n", - "7 range properties found and tested out of 26 total settings found.\n", - "0 values properties found and tested out of 26 total settings found.\n", - "12 indexed values properties found and tested out of 26 total settings found.\n", - "2 dict values properties found and tested out of 26 total settings found.\n", - "3 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", - "21 properties tested out of 26 total settings.\n", - "\n", - "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('buffer_points', 16383)}\n", - "\n", - "\n", - "\u001b[92m Property implementation tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", - "Checking driver doc string.\n", - "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n", - "The new test log for this driver is: Passed with stanford830 version v1.0.1 tested on pyscan version v0.8.0 at 2024-10-01 10:01:28\n", - "\u001b[1;32m Stanford830 test results logged. \u001b[0m\n" + "Beginning tests for: Stanford830 version 1.0.2\n", + "_id_settings\n", + "_phase_settings\n", + "_reference_source_settings\n", + "_frequency_settings\n", + "_reference_slope_settings\n", + "_harmonic_settings\n", + "_input_ground_settings\n", + "_input_coupling_settings\n" ] } ], "source": [ "srs830 = ps.Stanford830(res)\n", - "\n", "test_driver(srs830, verbose=False)" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "metadata": {} }, @@ -188,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "metadata": {} }, @@ -214,16 +186,16 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-1.09223e-07 -1.09223e-07\n", - "1.0922e-07 1.0922e-07\n", - "1.0922e-07 1.0922e-07\n" + "-8.94074e-05 -4.76841e-07\n", + "0.000385048 2.3842e-07\n", + "-0.00506476 -9.53682e-07\n" ] } ], @@ -254,22 +226,25 @@ "\n", "\n", "srs830.set_channel_offset_expand(1, 0, 1)\n", - "srs830.set_display(1, 'x', 'none')\n" + "srs830.set_display(1, 'x', 'none')\n", + "\n", + "srs830.set_channel_offset_expand(2, 0, 1)\n", + "srs830.set_display(2, 'y', 'none')\n" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0.002\n", - "0.00233333\n", - "0.003\n", - "0.00266667\n" + "0.000666667\n", + "-0.000666667\n", + "0.00566667\n", + "0.000666667\n" ] } ], @@ -284,17 +259,17 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-1.09223e-07\n", - "1.0922e-07\n", - "1.0922e-07\n", - "7734.592992720247\n" + "-8.98843e-05\n", + "0.000384809\n", + "-7.15259e-07\n", + "5908.116590643592\n" ] } ], @@ -309,15 +284,15 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-1.09223e-07\n", - "1.0922e-07\n" + "-8.98843e-05\n", + "0.000384809\n" ] } ], @@ -330,23 +305,23 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[-1.09223e-07, 1.0922e-07]\n", - "[-1.09223e-07, 1.0922e-07]\n", - "[-1.09223e-07, 7733.217892850435]\n", - "[-1.09223e-07, 0.0]\n", - "[-1.09223e-07, 0.001]\n", - "[-1.09223e-07, 0.00166667]\n", - "[-1.09223e-07, 0.004]\n", - "[-1.09223e-07, 1000.0]\n", - "[-1.09223e-07, -1.09223e-07]\n", - "[-1.09223e-07, 1.0922e-07]\n" + "[-8.98843e-05, 0.000385048]\n", + "[-8.98843e-05, -9.53682e-07]\n", + "[-8.98843e-05, 5909.491690513403]\n", + "[-8.98843e-05, 0.000666667]\n", + "[-8.98843e-05, -0.000666667]\n", + "[-8.98843e-05, 0.00166667]\n", + "[-8.96459e-05, -0.01]\n", + "[-8.98843e-05, 1000.0]\n", + "[-8.98843e-05, -8.98843e-05]\n", + "[-8.98843e-05, 0.000384809]\n" ] } ], @@ -367,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -388,20 +363,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "159" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# test buffer_points\n", "\n", @@ -412,7 +376,8 @@ "# srs830.start()\n", "srs830.trigger()\n", "sleep(20)\n", - "srs830.buffer_points\n" + "srs830.buffer_points\n", + "srs830.pause()\n" ] } ], @@ -432,7 +397,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/pyscan/drivers/stanford830.py b/pyscan/drivers/stanford830.py index 327c9cff..cde1a890 100644 --- a/pyscan/drivers/stanford830.py +++ b/pyscan/drivers/stanford830.py @@ -76,17 +76,17 @@ class Stanford830(InstrumentDriver): display2_output_source : str Gets/sets the displayed source on display 2 Indexed values['y', 'display'] - auxillary_voltage1 : float - Gets/sets the channel 1 auxillary output voltage + auxiliary_voltage1 : float + Gets/sets the channel 1 auxiliary output voltage range - [-10.5, 10.500] - auxillary_voltage2 : float - Gets/sets the channel 2 auxillary output voltage + auxiliary_voltage2 : float + Gets/sets the channel 2 auxiliary output voltage range - [-10.5, 10.500] - auxillary_voltage3 : float - Gets/sets the channel 3 auxillary output voltage + auxiliary_voltage3 : float + Gets/sets the channel 3 auxiliary output voltage range - [-10.5, 10.500] - auxillary_voltage4 : float - Gets/sets the channel 4 auxillary output voltage + auxiliary_voltage4 : float + Gets/sets the channel 4 auxiliary output voltage range - [-10.5, 10.500] sample_rate : float Get/sets the sample rate in Hz @@ -136,7 +136,7 @@ def __init__(self, instrument): super().__init__(instrument) self.debug = False - self._version = "1.0.2" + self._version = "1.0.3" self.black_list_for_testing = [ '_input_configuration', @@ -297,31 +297,31 @@ def initialize_properties(self): 'indexed_values': ['y', 'display'], 'return_type': int}) - # Auxillary Input/Ouput Properties + # auxiliary Input/Ouput Properties self.add_device_property({ - 'name': 'auxillary_voltage1', + 'name': 'auxiliary_voltage1', 'write_string': 'AUXV 1, {}', 'query_string': 'AUXV? 1', 'range': [-10.5, 10.500], 'return_type': float}) self.add_device_property({ - 'name': 'auxillary_voltage2', + 'name': 'auxiliary_voltage2', 'write_string': 'AUXV 2, {}', 'query_string': 'AUXV? 2', 'range': [-10.5, 10.500], 'return_type': float}) self.add_device_property({ - 'name': 'auxillary_voltage3', + 'name': 'auxiliary_voltage3', 'write_string': 'AUXV 3, {}', 'query_string': 'AUXV? 3', 'range': [-10.5, 10.500], 'return_type': float}) self.add_device_property({ - 'name': 'auxillary_voltage4', + 'name': 'auxiliary_voltage4', 'write_string': 'AUXV 4, {}', 'query_string': 'AUXV? 4', 'range': [-10.5, 10.500], @@ -478,20 +478,20 @@ def set_channel_offset_expand(self, channel, offset, expand): self.write('OEXP {}, {}, {}'.format(channel, offset, index)) - # Auxillary Input/Ouptut Methods + # auxiliary Input/Ouptut Methods def read_aux_input(self, index): ''' - Reads the voltage input to an auxillary input channel + Reads the voltage input to an auxiliary input channel Parameters ---------- index: int - Auxillary input channel number 1, 2, 3, or 4 + auxiliary input channel number 1, 2, 3, or 4 ''' indicies = [1, 2, 3, 4] - assert index in indicies, 'Auxillary input index must be 1, 2, 3, or 4' + assert index in indicies, 'auxiliary input index must be 1, 2, 3, or 4' return float(self.query('OAUX ? {}'.format(index))) diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index ebf4c4d8..24d0fd81 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.2 tested on pyscan version v0.8.0 at 2024-10-01 18:31:03 +Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-02 10:40:42 From bcc599eae112af1c5ab08bde4425b08c4ca0f84d Mon Sep 17 00:00:00 2001 From: cint-transport Date: Wed, 2 Oct 2024 10:43:22 -0600 Subject: [PATCH 18/19] did i forget the notebook? --- .../srs830_test_notebook.ipynb | 96 ++++++++++++------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index 36adb908..544442c5 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -85,7 +85,7 @@ " ('_sensitivity', 0.005),\n", " ('_time_constant', 1)]\n", "\n", - "Beginning tests for: Stanford830 version 1.0.2\n", + "Beginning tests for: Stanford830 version 1.0.3\n", "_id_settings\n", "_phase_settings\n", "_reference_source_settings\n", @@ -93,7 +93,37 @@ "_reference_slope_settings\n", "_harmonic_settings\n", "_input_ground_settings\n", - "_input_coupling_settings\n" + "_input_coupling_settings\n", + "_input_line_filter_settings\n", + "_reserve_mode_settings\n", + "_filter_slope_settings\n", + "_synchronous_filter_settings\n", + "_display1_output_source_settings\n", + "_display2_output_source_settings\n", + "_auxiliary_voltage1_settings\n", + "_auxiliary_voltage2_settings\n", + "_auxiliary_voltage3_settings\n", + "_auxiliary_voltage4_settings\n", + "_sample_rate_settings\n", + "_end_buffer_mode_settings\n", + "_trigger_mode_settings\n", + "_buffer_points_settings\n", + "\n", + "7 range properties found and tested out of 26 total settings found.\n", + "0 values properties found and tested out of 26 total settings found.\n", + "11 indexed values properties found and tested out of 26 total settings found.\n", + "2 dict values properties found and tested out of 26 total settings found.\n", + "4 blacklisted settings not testing (likely due to interdependencies not suitable for automated testing)\n", + "20 properties tested out of 26 total settings.\n", + "\n", + "Restored settings are different for the following: {('id', 'Stanford_Research_Systems,SR830,s/n86813,ver1.07 '), ('buffer_points', 159)}\n", + "\n", + "\n", + "\u001b[92m Property implementation tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", + "Checking driver doc string.\n", + "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-02 10:40:42\n", + "\u001b[1;32m Stanford830 test results logged. \u001b[0m\n" ] } ], @@ -104,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "metadata": {} }, @@ -160,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "metadata": {} }, @@ -186,16 +216,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-8.94074e-05 -4.76841e-07\n", - "0.000385048 2.3842e-07\n", - "-0.00506476 -9.53682e-07\n" + "-8.9169e-05 -7.15259e-07\n", + "0.000385525 -2.3842e-07\n", + "-2.3842e-07 0.0\n" ] } ], @@ -234,7 +264,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -242,9 +272,9 @@ "output_type": "stream", "text": [ "0.000666667\n", - "-0.000666667\n", - "0.00566667\n", - "0.000666667\n" + "0.001\n", + "-0.002\n", + "0.00233333\n" ] } ], @@ -259,17 +289,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-8.98843e-05\n", - "0.000384809\n", - "-7.15259e-07\n", - "5908.116590643592\n" + "-8.9169e-05\n", + "0.000385048\n", + "-2.3842e-07\n", + "5901.928641229441\n" ] } ], @@ -284,15 +314,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "-8.98843e-05\n", - "0.000384809\n" + "-8.9169e-05\n", + "0.000385048\n" ] } ], @@ -305,23 +335,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[-8.98843e-05, 0.000385048]\n", - "[-8.98843e-05, -9.53682e-07]\n", - "[-8.98843e-05, 5909.491690513403]\n", - "[-8.98843e-05, 0.000666667]\n", - "[-8.98843e-05, -0.000666667]\n", - "[-8.98843e-05, 0.00166667]\n", - "[-8.96459e-05, -0.01]\n", - "[-8.98843e-05, 1000.0]\n", - "[-8.98843e-05, -8.98843e-05]\n", - "[-8.98843e-05, 0.000384809]\n" + "[-8.9169e-05, 0.000385048]\n", + "[-8.94074e-05, -4.76841e-07]\n", + "[-8.9169e-05, 5902.9599661318]\n", + "[-8.9169e-05, 0.00166667]\n", + "[-8.94074e-05, 0.004]\n", + "[-8.9169e-05, -0.000333333]\n", + "[-8.9169e-05, 0.00233333]\n", + "[-8.94074e-05, 1000.0]\n", + "[-8.9169e-05, -8.9169e-05]\n", + "[-8.94074e-05, 0.000384809]\n" ] } ], @@ -342,7 +372,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -363,7 +393,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ From f9b7771da1f58b03234b639c1440f580ea23f492 Mon Sep 17 00:00:00 2001 From: cint-transport Date: Thu, 3 Oct 2024 08:30:41 -0600 Subject: [PATCH 19/19] test(driver Stanford830): added print(buffer_points) to the end of the test notebook --- .../srs830_test_notebook.ipynb | 55 +++++++++++-------- .../driver_test_logs/stanford830_test_log.txt | 2 +- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/drivers_test_notebooks/srs830_test_notebook.ipynb b/drivers_test_notebooks/srs830_test_notebook.ipynb index 544442c5..9e5d8940 100644 --- a/drivers_test_notebooks/srs830_test_notebook.ipynb +++ b/drivers_test_notebooks/srs830_test_notebook.ipynb @@ -122,7 +122,7 @@ "\u001b[92m Property implementation tests passed, instrument: Stanford830 looks ready to go. \u001b[0m\n", "Checking driver doc string.\n", "\u001b[92m Docstring tests passed and looking good. \u001b[0m\n", - "The new test log for this driver is: Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-02 10:40:42\n", + "The new test log for this driver is: Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-03 08:29:18\n", "\u001b[1;32m Stanford830 test results logged. \u001b[0m\n" ] } @@ -223,9 +223,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "-8.9169e-05 -7.15259e-07\n", - "0.000385525 -2.3842e-07\n", - "-2.3842e-07 0.0\n" + "-8.9169e-05 -9.53682e-07\n", + "0.000385286 -7.15259e-07\n", + "-4.76841e-07 -2.3842e-07\n" ] } ], @@ -271,10 +271,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "0.000666667\n", - "0.001\n", - "-0.002\n", - "0.00233333\n" + "0.002\n", + "0.00233333\n", + "0.00166667\n", + "0.00133333\n" ] } ], @@ -296,10 +296,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "-8.9169e-05\n", + "-8.86922e-05\n", "0.000385048\n", "-2.3842e-07\n", - "5901.928641229441\n" + "5899.178441489818\n" ] } ], @@ -321,8 +321,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "-8.9169e-05\n", - "0.000385048\n" + "-8.86922e-05\n", + "0.000385286\n" ] } ], @@ -342,16 +342,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "[-8.9169e-05, 0.000385048]\n", - "[-8.94074e-05, -4.76841e-07]\n", - "[-8.9169e-05, 5902.9599661318]\n", - "[-8.9169e-05, 0.00166667]\n", - "[-8.94074e-05, 0.004]\n", - "[-8.9169e-05, -0.000333333]\n", + "[-8.86922e-05, 0.000385286]\n", + "[-8.9169e-05, -2.3842e-07]\n", + "[-8.89306e-05, 5900.55354135963]\n", + "[-8.89306e-05, 0.000666667]\n", "[-8.9169e-05, 0.00233333]\n", - "[-8.94074e-05, 1000.0]\n", - "[-8.9169e-05, -8.9169e-05]\n", - "[-8.94074e-05, 0.000384809]\n" + "[-8.89306e-05, -0.0156667]\n", + "[-8.9169e-05, 0.00133333]\n", + "[-8.89306e-05, 1000.0]\n", + "[-8.89306e-05, -8.89306e-05]\n", + "[-8.9169e-05, 0.000385286]\n" ] } ], @@ -395,7 +395,15 @@ "cell_type": "code", "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "159\n" + ] + } + ], "source": [ "# test buffer_points\n", "\n", @@ -407,7 +415,8 @@ "srs830.trigger()\n", "sleep(20)\n", "srs830.buffer_points\n", - "srs830.pause()\n" + "srs830.pause()\n", + "print(srs830.buffer_points)" ] } ], diff --git a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt index 24d0fd81..b579f033 100644 --- a/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt +++ b/pyscan/drivers/testing/driver_test_logs/stanford830_test_log.txt @@ -1 +1 @@ -Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-02 10:40:42 +Passed with stanford830 version v1.0.3 tested on pyscan version v0.8.0 at 2024-10-03 08:29:18