Exemple #1
0
 def test_create_algorithm_object_produces_initialized_non_child_alorithm_outside_PyExec(
         self):
     alg = simpleapi._create_algorithm_object("Rebin")
     self._is_initialized_test(alg,
                               1,
                               expected_class=IAlgorithm,
                               expected_child=False)
def _do_unary_operation(op, self, lhs_vars):
    """
    Perform the unary operation

    :param op: name of the algorithm to run
    :param self: The object that this operation was called on
    :param lhs_vars: is expected to be a tuple containing the number of lhs variables and
            their names as the first and second element respectively
    """
    global _workspace_op_tmps
    import mantid.simpleapi as simpleapi

    if lhs_vars[0] > 0:
        # Assume the first and clear the temporaries as this
        # must be the final assignment
        output_name = lhs_vars[1][0]
        clear_tmps = True
    else:
        # Give it a temporary name and keep track of it
        clear_tmps = False
        output_name = _workspace_op_prefix + str(len(_workspace_op_tmps))
        _workspace_op_tmps.append(output_name)

    # Do the operation
    ads = _api.AnalysisDataServiceImpl.Instance()

    alg = simpleapi._create_algorithm_object(
        op)  # gets the child status correct for PythonAlgorithms
    alg.setPropertyValue("InputWorkspace", self.name())
    alg.setPropertyValue("OutputWorkspace", output_name)
    alg.execute()
    resultws = ads[output_name]

    if clear_tmps:
        for name in _workspace_op_tmps:
            if name in ads and output_name != name:
                ads.remove(name)
        _workspace_op_tmps = []

    return resultws
def _do_unary_operation(op, self, lhs_vars):
    """
    Perform the unary operation

    :param op: name of the algorithm to run
    :param self: The object that this operation was called on
    :param lhs_vars: is expected to be a tuple containing the number of lhs variables and
            their names as the first and second element respectively
    """
    global _workspace_op_tmps
    import mantid.simpleapi as simpleapi

    if lhs_vars[0] > 0:
        # Assume the first and clear the temporaries as this
        # must be the final assignment
        output_name = lhs_vars[1][0]
        clear_tmps = True
    else:
        # Give it a temporary name and keep track of it
        clear_tmps = False
        output_name = _workspace_op_prefix + str(len(_workspace_op_tmps))
        _workspace_op_tmps.append(output_name)

    # Do the operation
    ads = AnalysisDataServiceImpl.Instance()

    # gets the child status correct for PythonAlgorithms
    alg = simpleapi._create_algorithm_object(op)
    alg.setProperty("InputWorkspace", self)
    alg.setPropertyValue("OutputWorkspace", output_name)
    alg.execute()
    resultws = ads[output_name]

    if clear_tmps:
        for name in _workspace_op_tmps:
            if name in ads and output_name != name:
                ads.remove(name)
        _workspace_op_tmps = []

    return resultws
Exemple #4
0
 def PyExec(self):
     self.alg = simpleapi._create_algorithm_object("Rebin")
Exemple #5
0
 def test_create_algorithm_with_version_produces_initialized_alorithm(self):
     alg = simpleapi._create_algorithm_object("LoadRaw", 3)
     self._is_initialized_test(alg,
                               3,
                               expected_class=IAlgorithm,
                               expected_child=False)
 def PyExec(self):
     self.alg = simpleapi._create_algorithm_object("Rebin")
 def test_create_algorithm_with_version_produces_initialized_alorithm(self):
     alg = simpleapi._create_algorithm_object("LoadRaw", 3)
     self._is_initialized_test(alg, 3, expected_class=AlgorithmProxy,
                               expected_child=False)
 def test_create_algorithm_object_produces_initialized_non_child_alorithm_outside_PyExec(self):
     alg = simpleapi._create_algorithm_object("Rebin")
     self._is_initialized_test(alg, 1, expected_class=AlgorithmProxy,
                               expected_child=False)