def test_migrate_smoothing(self): name = "orangecontrib.spectroscopy.preprocess.me_emsc.me_emsc" settings = {"storedsettings": {"preprocessors": [(name, {"ranges": [[0, 1, 2]]})]}} OWPreprocess.migrate_settings(settings, 6) self.assertEqual( settings["storedsettings"]["preprocessors"][0], (name, {"ranges": [[0, 1, 2, 0]]}))
def test_migrate_rubberband(self): settings = { "storedsettings": { "preprocessors": [("orangecontrib.infrared.rubberband", {})] } } OWPreprocess.migrate_settings(settings, 1) self.assertEqual(settings["storedsettings"]["preprocessors"], [("orangecontrib.infrared.baseline", { 'baseline_type': 1 })])
def test_migrate_spectral_transforms(self): settings = {"storedsettings": { "preprocessors": [("orangecontrib.infrared.transmittance", {}), ("orangecontrib.infrared.absorbance", {})]}} OWPreprocess.migrate_settings(settings, 3) self.assertEqual( settings["storedsettings"]["preprocessors"], [("orangecontrib.spectroscopy.transforms", {'from_type': 0, 'to_type': 1}), ("orangecontrib.spectroscopy.transforms", {'from_type': 1, 'to_type': 0})])
def test_workflow_compat_change_preprocess(self): settings = {} OWPreprocess.migrate_settings(settings, 5) self.assertTrue(settings["process_reference"]) settings = { "storedsettings": { "preprocessors": [("orangecontrib.infrared.cut", {})] } } OWPreprocess.migrate_settings(settings, 5) self.assertTrue(settings["process_reference"]) # multiple preprocessors: set to support old workflows settings = { "storedsettings": { "preprocessors": [("orangecontrib.infrared.cut", {}), ("orangecontrib.infrared.cut", {})] } } OWPreprocess.migrate_settings(settings, 5) self.assertFalse(settings["process_reference"]) # migrating the same settings keeps the setting false OWPreprocess.migrate_settings(settings, 6) self.assertFalse(settings["process_reference"])
def test_migrate_savitzygolay(self): name = "orangecontrib.infrared.savitzkygolay" def create_setting(con): return {"storedsettings": {"preprocessors": [(name, con)]}} def obtain_setting(settings): return settings["storedsettings"]["preprocessors"][0][1] settings = create_setting({}) OWPreprocess.migrate_settings(settings, 3) new_name = settings["storedsettings"]["preprocessors"][0][0] self.assertEqual(new_name, "orangecontrib.spectroscopy.savitzkygolay") self.assertEqual(obtain_setting(settings), {'deriv': 0, 'polyorder': 2, 'window': 5}) settings = create_setting({'deriv': 4, 'polyorder': 4, 'window': 4}) OWPreprocess.migrate_settings(settings, 3) self.assertEqual(obtain_setting(settings), {'deriv': 3, 'polyorder': 4, 'window': 5}) settings = create_setting({'deriv': 4, 'polyorder': 4, 'window': 100}) OWPreprocess.migrate_settings(settings, 3) self.assertEqual(obtain_setting(settings), {'deriv': 3, 'polyorder': 4, 'window': 99}) settings = create_setting({'deriv': 4.1, 'polyorder': 4.1, 'window': 2.2}) OWPreprocess.migrate_settings(settings, 3) self.assertEqual(obtain_setting(settings), {'deriv': 2, 'polyorder': 2, 'window': 3})
def test_migrate_rubberbard(self): settings = {"storedsettings": {"preprocessors": [("orangecontrib.infrared.rubberband", {})]}} OWPreprocess.migrate_settings(settings, 1) self.assertEqual(settings["storedsettings"]["preprocessors"], [("orangecontrib.infrared.baseline", {'baseline_type': 1})])