示例#1
0
def create_test_fits(input_workspaces,
                     function_name,
                     parameters,
                     output_workspace_names=None,
                     global_parameters=None):
    """
    Create a list of fits
    :param input_workspaces: The input workspaces
    :param function_name: The name of the function
    :param parameters: The parameters list
    :param output_workspace_names: A list of workspace names
    :param global_parameters: An optional list of tied parameters
    :return: A list of Fits
    """
    output_workspace_names = output_workspace_names if output_workspace_names is not None else [
        'test-output-ws'
    ]
    # Convert parameters to fit table-like structure
    fit_table = [{
        'Name': name,
        'Value': value,
        'Error': error
    } for name, (value, error) in iteritems(parameters)]

    fits = []
    for name in input_workspaces:
        parameter_workspace = mock.NonCallableMagicMock()
        parameter_workspace.workspace.__iter__.return_value = fit_table
        parameter_workspace.workspace_name = name + '_Parameters'
        fits.append(
            FitInformation(parameter_workspace, function_name, name,
                           output_workspace_names, global_parameters))

    return fits
示例#2
0
def _move_globals_to_front(unique_params):
    """
    Move the global parameters to the front of the list
    :param unique_params: An list containing the current parameters in the original order
    :return: The updated parameters list reordered
    """
    return OrderedDict(
        sorted(iteritems(unique_params), key=lambda x: not x[1].is_global))
def create_test_fit_parameters(test_parameters, global_parameters=None):
    # needs to look like a standard fit table
    fit_table = [{
        'Name': name,
        'Value': value,
        'Error': error
    } for name, (value, error) in iteritems(test_parameters)]

    parameter_workspace = mock.MagicMock()
    parameter_workspace.workspace.__iter__.return_value = fit_table
    return FitParameters(parameter_workspace, global_parameters)
示例#4
0
 def _add_axes_scale_menu(self, menu):
     """Add the Axes scale options menu to the given menu"""
     axes_menu = QMenu("Axes", menu)
     axes_actions = QActionGroup(axes_menu)
     current_scale_types = self._get_axes_scale_types()
     for label, scale_types in iteritems(AXES_SCALE_MENU_OPTS):
         action = axes_menu.addAction(label, partial(self._quick_change_axes, scale_types))
         if current_scale_types == scale_types:
             action.setCheckable(True)
             action.setChecked(True)
         axes_actions.addAction(action)
     menu.addMenu(axes_menu)
示例#5
0
 def _add_colorbar_axes_scale_menu(self, menu, ax):
     """Add the Axes scale options menu to the given menu"""
     axes_menu = QMenu("Color bar", menu)
     axes_actions = QActionGroup(axes_menu)
     images = ax.get_images() + [
         col for col in ax.collections if isinstance(col, Collection)
     ]
     for label, scale_type in iteritems(COLORBAR_SCALE_MENU_OPTS):
         action = axes_menu.addAction(
             label, partial(self._change_colorbar_axes, scale_type))
         if type(images[0].norm) == scale_type:
             action.setCheckable(True)
             action.setChecked(True)
         axes_actions.addAction(action)
     menu.addMenu(axes_menu)