def test_that_create_x_and_y_parameter_combinations_will_not_create_the_parameter_workspaces( self): self.model.result_table_names = self.result_table_names self.model.current_result_table_index = 0 table = create_results_table() add_ws_to_ads("Result1", table) self.model.create_x_and_y_parameter_combinations() self.assertTrue( not check_if_workspace_exist("Result1; Parameter Combinations")) self.assertTrue( not check_if_workspace_exist("Result1; workspace_name vs A0")) self.assertTrue( not check_if_workspace_exist("Result1; workspace_name vs A1")) self.assertTrue( not check_if_workspace_exist("Result1; A0 vs workspace_name")) self.assertTrue(not check_if_workspace_exist("Result1; A0 vs A1")) self.assertTrue( not check_if_workspace_exist("Result1; A1 vs workspace_name")) self.assertTrue(not check_if_workspace_exist("Result1; A1 vs A0")) self.assertTrue(not check_if_workspace_exist( "Result1; workspace_name vs workspace_name")) self.assertTrue(not check_if_workspace_exist("Result1; A0 vs A0")) self.assertTrue(not check_if_workspace_exist("Result1; A1 vs A1"))
def setUp(self): self.results_context = ResultsContext() self.result_table_names = ["Name1", "Name2"] workspace = WorkspaceFactory.create("Workspace2D", NVectors=3, YLength=5, XLength=5) add_ws_to_ads("Name1", workspace) add_ws_to_ads("Name2", workspace)
def test_that_get_workspace_names_to_display_from_context_only_returns_the_names_that_exist_in_the_ADS( self): self.model.context.results_context.result_table_names = self.result_table_names table_workspace = WorkspaceFactory.createTable() add_ws_to_ads("Result1", table_workspace) self.assertEqual( self.model.get_workspace_names_to_display_from_context(), ["Result1"])
def _create_workspace_group_to_store_combination_workspaces(self) -> WorkspaceGroup: """Return the Workspace Group used to store the different parameter combination matrix workspaces.""" group_name = self.parameter_combination_group_name() if group_name is None: return None if check_if_workspace_exist(group_name): workspace_group = retrieve_ws(group_name) else: workspace_group = WorkspaceGroup() add_ws_to_ads(group_name, workspace_group) return workspace_group
def test_that_create_x_and_y_parameter_combination_workspace_will_create_the_expected_parameter_workspaces( self): self.model.result_table_names = self.result_table_names self.model.current_result_table_index = 0 table = create_results_table() add_ws_to_ads("Result1", table) self.model.create_x_and_y_parameter_combinations() self.model.create_x_and_y_parameter_combination_workspace( "workspace_name", "A0") self.model.create_x_and_y_parameter_combination_workspace("A1", "A0") self.model.create_x_and_y_parameter_combination_workspace( "workspace_name", "A1") self.model.create_x_and_y_parameter_combination_workspace( "Sigma", "Lambda") self.model.create_x_and_y_parameter_combination_workspace( "f1.Sigma", "f1.Lambda") self.assertTrue( check_if_workspace_exist("Result1; Parameter Combinations")) self.assertTrue( check_if_workspace_exist("Result1; A0 vs workspace_name")) self.assertTrue( check_if_workspace_exist("Result1; A1 vs workspace_name")) self.assertTrue(check_if_workspace_exist("Result1; A0 vs A1")) self.assertTrue(check_if_workspace_exist("Result1; Lambda vs Sigma")) self.assertTrue( check_if_workspace_exist("Result1; f1.Lambda vs f1.Sigma")) self.assertTrue( not check_if_workspace_exist("Result1; workspace_name vs A0")) self.assertTrue( not check_if_workspace_exist("Result1; workspace_name vs A1")) self.assertTrue(not check_if_workspace_exist("Result1; A1 vs A0")) self.assertTrue(not check_if_workspace_exist( "Result1; workspace_name vs workspace_name")) self.assertTrue(not check_if_workspace_exist("Result1; A0 vs A0")) self.assertTrue(not check_if_workspace_exist("Result1; A1 vs A1")) unit_test_ws = retrieve_ws("Result1; Lambda vs Sigma") self.assertTrue( str(unit_test_ws.getAxis(0).getUnit().symbol()) == '\\mu s^{-1}') self.assertTrue( str(unit_test_ws.YUnit()) == 'Lambda ($\\mu$ $s^{-1}$)') unit_test_ws = retrieve_ws("Result1; f1.Lambda vs f1.Sigma") self.assertTrue( str(unit_test_ws.getAxis(0).getUnit().symbol()) == '\\mu s^{-1}') self.assertTrue( str(unit_test_ws.YUnit()) == 'f1.Lambda ($\\mu$ $s^{-1}$)')
def test_that_create_x_and_y_parameter_combinations_will_create_the_expected_parameter_data( self): self.model.result_table_names = self.result_table_names self.model.current_result_table_index = 0 table = create_results_table() add_ws_to_ads("Result1", table) self.model.create_x_and_y_parameter_combinations() x_parameters = self.model.x_parameters() y_parameters = self.model.y_parameters() self.assertEqual(list(x_parameters), ["workspace_name", "A0", "A1"]) self.assertEqual(list(y_parameters), ["workspace_name", "A0", "A1"]) self.assertAlmostEqual( self.model.fitting_context.x_parameters["A0"][0], 0.1, delta=0.000001) self.assertAlmostEqual( self.model.fitting_context.x_parameters["A0"][1], 0.3, delta=0.000001) self.assertAlmostEqual( self.model.fitting_context.x_parameters["A0"][2], 0.5, delta=0.000001) self.assertAlmostEqual( self.model.fitting_context.y_parameters["A1"][0], 0.2, delta=0.000001) self.assertAlmostEqual( self.model.fitting_context.y_parameters["A1"][1], 0.4, delta=0.000001) self.assertAlmostEqual( self.model.fitting_context.y_parameters["A1"][2], 0.6, delta=0.000001) self.assertEqual( self.model.fitting_context.y_parameters["workspace_name"], [ "MUSR62260; Group; bottom; Asymmetry; MA", "MUSR62260; Group; top; Asymmetry; MA", "MUSR62260; Group; fwd; Asymmetry; MA" ])
def add_copy_to_ads(self) -> None: """Adds the output workspaces for this fit to the ADS. Must be a copy so the fit history remains a history.""" workspace_group = WorkspaceGroup() add_ws_to_ads(self.output_group_name(), workspace_group) for output_workspace in self.output_workspaces: add_ws_to_ads(output_workspace.workspace_name, output_workspace.workspace_copy()) workspace_group.add(output_workspace.workspace_name) add_ws_to_ads(self.parameter_workspace.workspace_name, self.parameter_workspace.workspace_copy()) workspace_group.add(self.parameter_workspace.workspace_name) add_ws_to_ads(self.covariance_workspace.workspace_name, self.covariance_workspace.workspace_copy()) workspace_group.add(self.covariance_workspace.workspace_name)