diff --git a/Code/Mantid/scripts/reduction/instruments/example/ExampleRedStep.py b/Code/Mantid/scripts/reduction/instruments/example/ExampleRedStep.py index bf4380030b9509a2a8725b2eba9c5c6b43a2d953..ca1815780c3352ebdd6878842057a4ccdd696763 100644 --- a/Code/Mantid/scripts/reduction/instruments/example/ExampleRedStep.py +++ b/Code/Mantid/scripts/reduction/instruments/example/ExampleRedStep.py @@ -28,12 +28,13 @@ class ExampleLoader(PythonAlgorithm): return "ExampleLoader" def PyInit(self): - self.declareProperty("File_name", "") + self.declareProperty("Filename", "") self.declareProperty("OutputWorkspace", "") def PyExec(self): - filename = self.getProperty("File_name") + filename = self.getProperty("Filename") output_ws = self.getProperty("OutputWorkspace") + LoadAscii(filename, output_ws) print filename, output_ws diff --git a/Code/Mantid/scripts/reduction/instruments/example/example_reducer.py b/Code/Mantid/scripts/reduction/instruments/example/example_reducer.py index 1051928401841be6febd83763bcd0b9552a635c1..2e050d6d2a1fc63baa6d46afe4a1a6bad3bdf810 100644 --- a/Code/Mantid/scripts/reduction/instruments/example/example_reducer.py +++ b/Code/Mantid/scripts/reduction/instruments/example/example_reducer.py @@ -85,14 +85,18 @@ if __name__ == '__main__': r = ExampleReducer() # Append a fake data file - r.append_data_file("~/sample_data.txt") + r.append_data_file("AsciiExample.txt") # Example of a standard algorithm used as a reduction step. Note that InputWorkspace and OutputWorkspace # are overwritten by the Reducer. They can be set to Non at this point. #r.set_first_step(CreateWorkspace, OutputWorkspace=None, DataX='1', DataY='1', DataE='1') - step = ExampleLoader() - step.initialize() - r.set_first_step(step) + + #step = ExampleLoader() + #step.initialize() + #r.set_first_step(step) + + r.set_first_step(LoadAscii, Filename=None, OutputWorkspace=None) + #r._first_step.setProperty("Separator", "Tab") # Set up an algorithm to be used as part of a reduction step alg = mtd._createAlgProxy("Scale") diff --git a/Code/Mantid/scripts/reduction/reducer.py b/Code/Mantid/scripts/reduction/reducer.py index 3fcc23aaaf9555bf2c31ee28a7723875d4b80b15..cf7163674befb4796760c3849a13345c44d1fc3d 100644 --- a/Code/Mantid/scripts/reduction/reducer.py +++ b/Code/Mantid/scripts/reduction/reducer.py @@ -51,19 +51,16 @@ def validate_loader(f): # If we have an algorithm proxy, get the actual algorithm algorithm = algorithm._getHeldObject() - if isinstance(algorithm, types.StringType): - raise RuntimeError, "Use an algorithm function you moron" - if isinstance(algorithm, types.StringType): # If we have a string, assume it's an algorithm name class _AlgorithmStep(ReductionStep): def __init__(self): self.algorithm = None self._data_file = None - if "filename" in kwargs: - self._data_file = kwargs["filename"] def get_algorithm(self): return self.algorithm + def setProperty(self, key, value): + kwargs[key]=value def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, @@ -97,16 +94,16 @@ def validate_loader(f): kwargs[key] = arg # Override input and output workspaces - if "Workspace" in propertyOrder: - algorithm.setPropertyValue("Workspace", MantidFramework._makeString(inputworkspace).lstrip('? ')) - if "OutputWorkspace" in propertyOrder: - algorithm.setPropertyValue("OutputWorkspace", MantidFramework._makeString(inputworkspace).lstrip('? ')) - if "Filename" in propertyOrder: - algorithm.setPropertyValue("Filename", data_file) + 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: - algorithm.setPropertyValue(kwargs["AlternateName"], data_file) + kwargs[kwargs["AlternateName"]] = data_file # set the properties of the algorithm ialg = proxy._getHeldObject() @@ -115,6 +112,8 @@ def validate_loader(f): ialg.setPropertyValue(key, MantidFramework._makeString(kwargs[key]).lstrip('? ')) proxy.execute() + if "OutputMessage" in propertyOrder: + return proxy.getPropertyValue("OutputMessage") return "%s applied" % proxy.name() return f(reducer, _AlgorithmStep()) @@ -124,10 +123,10 @@ def validate_loader(f): def __init__(self): self.algorithm = algorithm self._data_file = None - if "filename" in kwargs: - self._data_file = kwargs["filename"] def get_algorithm(self): return self.algorithm + def setProperty(self, key, value): + kwargs[key]=value def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, @@ -218,6 +217,8 @@ def validate_step(f): self.algorithm = None def get_algorithm(self): return self.algorithm + def setProperty(self, key, value): + kwargs[key]=value def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, @@ -268,6 +269,8 @@ def validate_step(f): self.algorithm = algorithm def get_algorithm(self): return self.algorithm + def setProperty(self, key, value): + kwargs[key]=value def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object,