def __init__(self, **kwargs): self._inst_settings = instrument_settings.InstrumentSettings( param_map=gem_param_mapping.attr_mapping, adv_conf_dict=gem_advanced_config.get_all_adv_variables(), kwargs=kwargs) super(Gem, self).__init__( user_name=self._inst_settings.user_name, calibration_dir=self._inst_settings.calibration_dir, output_dir=self._inst_settings.output_dir, inst_prefix="GEM") self._cached_run_details = {} self._sample_details = None
def __init__(self, **kwargs): self._inst_settings = instrument_settings.InstrumentSettings( param_map=pearl_param_mapping.attr_mapping, adv_conf_dict=pearl_advanced_config.get_all_adv_variables(), kwargs=kwargs) self._default_inst_settings = copy.deepcopy(self._inst_settings) super(Pearl, self).__init__( user_name=self._inst_settings.user_name, calibration_dir=self._inst_settings.calibration_dir, output_dir=self._inst_settings.output_dir, inst_prefix="PEARL") self._cached_run_details = {}
def __init__(self, **kwargs): self._inst_settings = instrument_settings.InstrumentSettings( param_map=polaris_param_mapping.attr_mapping, adv_conf_dict=polaris_advanced_config.get_all_adv_variables(), kwargs=kwargs) super(Polaris, self).__init__( user_name=self._inst_settings.user_name, calibration_dir=self._inst_settings.calibration_dir, output_dir=self._inst_settings.output_dir, inst_prefix="POLARIS") # Hold the last dictionary later to avoid us having to keep parsing the YAML self._run_details_cached_obj = {} self._sample_details = None
def test_updating_attributes_produces_warning(self): original_value = 123 new_value = 456 second_value = 567 param_entry = param_map_entry.ParamMapEntry( ext_name="user_facing_name", int_name="script_facing_name") # First check this works on init adv_config = {"user_facing_name": original_value} config_dict = {"user_facing_name": new_value} keyword_args = {"user_facing_name": second_value} inst_settings_obj = instrument_settings.InstrumentSettings( param_map=[param_entry], adv_conf_dict=adv_config) self.assertEqual(inst_settings_obj.script_facing_name, original_value) # Next try to update the attribute and check it gives a warning with warnings.catch_warnings(record=True) as warning_capture: warnings.simplefilter("always") inst_settings_obj.update_attributes(basic_config=config_dict) assertRegex(self, str(warning_capture[-1].message), "which was previously set to") assertRegex(self, str(warning_capture[-1].message), str(original_value)) assertRegex(self, str(warning_capture[-1].message), str(new_value)) warnings_current_length = len(warning_capture) # Then check that we only get one additional warning when replacing values again not two inst_settings_obj.update_attributes(kwargs=keyword_args) self.assertEqual(warnings_current_length + 1, len(warning_capture)) warnings_current_length = len(warning_capture) # Check that the suppress field works by setting it back to second value inst_settings_obj.update_attributes(kwargs=config_dict, suppress_warnings=True) self.assertEqual(warnings_current_length, len(warning_capture)) # Check we only get no additional warnings from setting the value to the same inst_settings_obj.update_attributes(kwargs=config_dict) self.assertEqual(warnings_current_length, len(warning_capture)) # Finally check it has took the new value (most recently set) self.assertEqual(inst_settings_obj.script_facing_name, new_value)
def __init__(self, **kwargs): self._inst_settings = instrument_settings.InstrumentSettings( param_map=hrpd_param_mapping.attr_mapping, kwargs=kwargs, adv_conf_dict=hrpd_advanced_config.get_all_adv_variables()) super(HRPD, self).__init__( user_name=self._inst_settings.user_name, calibration_dir=self._inst_settings.calibration_dir, output_dir=self._inst_settings.output_dir, inst_prefix="HRPD") # Cannot load older .nxs files into Mantid from HRPD # because of a long-term bug which was not reported. # Instead, ask Mantid to use .raw files in this case if not self._inst_settings.file_extension: self._inst_settings.file_extension = ".raw" self._cached_run_details = {} self._sample_details = None
def test_updating_attributes_produces_warning_on_init(self): original_value = 123 new_value = 456 param_entry = param_map_entry.ParamMapEntry( ext_name="user_facing_name", int_name="script_facing_name") # First check this works on init adv_config = {"user_facing_name": original_value} keyword_args = {"user_facing_name": new_value} with warnings.catch_warnings(record=True) as warning_capture: warnings.simplefilter("always") inst_settings_obj = instrument_settings.InstrumentSettings( param_map=[param_entry], kwargs=keyword_args, adv_conf_dict=adv_config) assertRegex(self, str(warning_capture[-1].message), "which was previously set to") assertRegex(self, str(warning_capture[-1].message), str(original_value)) assertRegex(self, str(warning_capture[-1].message), str(new_value)) self.assertEqual(inst_settings_obj.script_facing_name, new_value)