Esempio n. 1
0
    def PyExec(self):

        alg = self.createChildAlgorithm('ChildAlg')
        alg.initialize()
        args = {}
        kwargs = {}
        _set_properties(alg, *args, **kwargs)
        alg.execute()
Esempio n. 2
0
    def PyExec(self):

        alg = self.createChildAlgorithm('ChildAlg')
        alg.initialize()
        args = {}
        kwargs = {}
        _set_properties(alg, *args, **kwargs)
        alg.execute()
Esempio n. 3
0
    def PyExec(self):
        ws_name = self.getProperty("OutputWorkspace").value
        alg = self.createChildAlgorithm('ChildAlg')
        alg.initialize()
        args = {}
        kwargs = {}
        _set_properties(alg, *args, **kwargs)
        alg.execute()

        ws = CreateWorkspace([0, 1, 2], [0, 1, 2], OutputWorkspace=ws_name)
        self.setProperty('OutputWorkspace', ws)
Esempio n. 4
0
                def execute(self,
                            reducer,
                            inputworkspace=None,
                            outputworkspace=None):
                    """
                        Create a new instance of the requested algorithm object,
                        set the algorithm properties replacing the input and output
                        workspaces.
                        The execution will work for any combination of mandatory/optional
                        properties.
                        @param reducer: Reducer object managing the reduction
                        @param inputworkspace: input workspace name [optional]
                        @param outputworkspace: output workspace name [optional]
                    """
                    # If we don't have a data file, look up the workspace handle
                    if self._data_file is None:
                        if inputworkspace in reducer._data_files:
                            data_file = reducer._data_files[inputworkspace]
                            if data_file is None:
                                return
                        else:
                            raise RuntimeError, "SANSReductionSteps.LoadRun doesn't recognize workspace handle %s" % workspace
                    else:
                        data_file = self._data_file

                    alg = mantid.api.AlgorithmManager.create(algorithm)
                    if not isinstance(alg, mantid.api.AlgorithmProxy):
                        raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(
                            type(alg))

                    propertyOrder = alg.orderedProperties()

                    # add the args to the kw list so everything can be set in a single way
                    for (key, arg) in zip(propertyOrder[:len(args)], args):
                        kwargs[key] = arg

                    # Override input and output workspaces
                    if "Workspace" in kwargs:
                        kwargs["Workspace"] = inputworkspace
                    if "OutputWorkspace" in kwargs:
                        kwargs["OutputWorkspace"] = inputworkspace
                    if "Filename" in kwargs:
                        kwargs["Filename"] = data_file

                    if "AlternateName" in kwargs and \
                        kwargs["AlternateName"] in propertyOrder:
                        kwargs[kwargs["AlternateName"]] = data_file

                    self.algorithm = alg
                    simpleapi._set_properties(alg, *(), **kwargs)
                    alg.execute()
                    if "OutputMessage" in propertyOrder:
                        return alg.getPropertyValue("OutputMessage")
                    return "%s applied" % alg.name()
Esempio n. 5
0
                def execute(self, reducer, inputworkspace=None, outputworkspace=None):
                    """
                        Create a new instance of the requested algorithm object,
                        set the algorithm properties replacing the input and output
                        workspaces.
                        The execution will work for any combination of mandatory/optional
                        properties.
                        @param reducer: Reducer object managing the reduction
                        @param inputworkspace: input workspace name [optional]
                        @param outputworkspace: output workspace name [optional]
                    """
                    # If we don't have a data file, look up the workspace handle
                    if self._data_file is None:
                        if inputworkspace in reducer._data_files:
                            data_file = reducer._data_files[inputworkspace]
                            if data_file is None:
                                return
                        else:
                            raise RuntimeError, "SANSReductionSteps.LoadRun doesn't recognize workspace handle %s" % workspace
                    else:
                        data_file = self._data_file

                    alg = mantid.api.AlgorithmManager.create(algorithm)
                    if not isinstance(alg, mantid.api.AlgorithmProxy):
                        raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(type(alg))

                    propertyOrder = alg.orderedProperties()

                    # add the args to the kw list so everything can be set in a single way
                    for (key, arg) in zip(propertyOrder[:len(args)], args):
                        kwargs[key] = arg

                    # Override input and output workspaces
                    if "Workspace" in kwargs:
                        kwargs["Workspace"] = inputworkspace
                    if "OutputWorkspace" in kwargs:
                        kwargs["OutputWorkspace"] = inputworkspace
                    if "Filename" in kwargs:
                        kwargs["Filename"] = data_file

                    if "AlternateName" in kwargs and \
                        kwargs["AlternateName"] in propertyOrder:
                        kwargs[kwargs["AlternateName"]] = data_file

                    self.algorithm = alg
                    simpleapi._set_properties(alg, *(), **kwargs)
                    alg.execute()
                    if "OutputMessage" in propertyOrder:
                        return alg.getPropertyValue("OutputMessage")
                    return "%s applied" % alg.name()
Esempio n. 6
0
                def execute(self,
                            reducer,
                            inputworkspace=None,
                            outputworkspace=None):
                    """
                        Create a new instance of the requested algorithm object,
                        set the algorithm properties replacing the input and output
                        workspaces.
                        The execution will work for any combination of mandatory/optional
                        properties.
                        @param reducer: Reducer object managing the reduction
                        @param inputworkspace: input workspace name [optional]
                        @param outputworkspace: output workspace name [optional]
                    """
                    if outputworkspace is None:
                        outputworkspace = inputworkspace
                    alg = mantid.AlgorithmManager.create(algorithm)
                    if not isinstance(alg, mantid.api.AlgorithmProxy):
                        raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(
                            type(alg))

                    propertyOrder = alg.orderedProperties()

                    # add the args to the kw list so everything can be set in a single way
                    for (key, arg) in zip(propertyOrder[:len(args)], args):
                        kwargs[key] = arg

                    # Override input and output workspaces
                    if "Workspace" in kwargs:
                        kwargs["Workspace"] = inputworkspace
                    if "InputWorkspace" in kwargs:
                        kwargs["InputWorkspace"] = inputworkspace
                    if "OutputWorkspace" in kwargs:
                        kwargs["OutputWorkspace"] = outputworkspace

                    self.algorithm = alg
                    simpleapi._set_properties(alg, *(), **kwargs)
                    alg.execute()
                    if "OutputMessage" in propertyOrder:
                        return alg.getPropertyValue("OutputMessage")
                    return "%s applied" % alg.name()
Esempio n. 7
0
                def execute(self, reducer, inputworkspace=None, outputworkspace=None):
                    """
                        Create a new instance of the requested algorithm object,
                        set the algorithm properties replacing the input and output
                        workspaces.
                        The execution will work for any combination of mandatory/optional
                        properties.
                        @param reducer: Reducer object managing the reduction
                        @param inputworkspace: input workspace name [optional]
                        @param outputworkspace: output workspace name [optional]
                    """
                    if outputworkspace is None:
                        outputworkspace = inputworkspace
                    alg = mantid.AlgorithmManager.create(algorithm)
                    if not isinstance(alg, mantid.api.AlgorithmProxy):
                        raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(type(alg))

                    propertyOrder = alg.orderedProperties()

                    # add the args to the kw list so everything can be set in a single way
                    for (key, arg) in zip(propertyOrder[:len(args)], args):
                        kwargs[key] = arg

                    # Override input and output workspaces
                    if "Workspace" in kwargs:
                        kwargs["Workspace"] = inputworkspace
                    if "InputWorkspace" in kwargs:
                        kwargs["InputWorkspace"] = inputworkspace
                    if "OutputWorkspace" in kwargs:
                        kwargs["OutputWorkspace"] = outputworkspace

                    self.algorithm = alg
                    simpleapi._set_properties(alg,*(),**kwargs)
                    alg.execute()
                    if "OutputMessage" in propertyOrder:
                        return alg.getPropertyValue("OutputMessage")
                    return "%s applied" % alg.name()