diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py index a6398425c6cec98318a1292ad99602d8d8562e6d..f90c142b62d68162baf07f1b700fd9b814caae78 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py @@ -35,6 +35,8 @@ class CutMD(DataProcessorAlgorithm): direction=Direction.Output), doc='Output cut workspace') + self.declareProperty(name="NoPix", defaultValue=False, doc="If False creates a full MDEventWorkspaces as output. True to create an MDHistoWorkspace as output. This is DND only in Horace terminology.") + def __to_mantid_slicing_binning(self, horace_binning, to_cut, dimension_index): dim = to_cut.getDimension(dimension_index) @@ -98,7 +100,6 @@ class CutMD(DataProcessorAlgorithm): extents.append(ws.getDimension(i + 3).getMinimum()) extents.append(ws.getDimension(i + 3).getMaximum()) - print extents return extents def __uvw_from_projection_table(self, projection_table): @@ -144,7 +145,7 @@ class CutMD(DataProcessorAlgorithm): def PyExec(self): to_cut = self.getProperty("InputWorkspace").value - + nopix = self.getProperty("NoPix").value coord_system = to_cut.getSpecialCoordinateSystem() if not coord_system == SpecialCoordinateSystem.HKL: raise ValueError("Input Workspace must be in reciprocal lattice dimensions (HKL)") @@ -178,14 +179,11 @@ class CutMD(DataProcessorAlgorithm): extents = self.__calculate_extents(v, u, w, to_cut) - nopix = True # TODO from input parameter. - - cut_alg_name = "SliceMD" - if nopix: - cut_alg_name= "BinMD" + projection_labels = self.__make_labels(projection) + cut_alg_name = "BinMD" if nopix else "SliceMD" cut_alg = AlgorithmManager.Instance().create(cut_alg_name) cut_alg.setChild(True) cut_alg.initialize() diff --git a/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py b/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py index 49640a27217850e517f51aaf880baf2e9d25d799..9092db7d033a3b598a9791573c0a9d08282f8ce9 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py +++ b/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py @@ -2,7 +2,7 @@ import unittest import testhelpers import numpy as np from mantid.simpleapi import * -from mantid.api import IMDHistoWorkspace +from mantid.api import IMDHistoWorkspace, IMDEventWorkspace class CutMDTest(unittest.TestCase): @@ -28,7 +28,7 @@ class CutMDTest(unittest.TestCase): def test_slice_to_original(self): out_md = CutMD(self.__in_md, P1Bin=[0.1], P2Bin=[0.1], P3Bin=[0.1]) - self.assertTrue(isinstance(out_md, IMDHistoWorkspace)) + self.assertTrue(isinstance(out_md, IMDEventWorkspace), "Should default to producing an IMDEventWorkspace.") # No rotation. Basis vectors should have been left the same, so no extent changes. self.assertEquals(self.__in_md.getDimension(0).getMinimum(), out_md.getDimension(0).getMinimum()) self.assertEquals(self.__in_md.getDimension(0).getMaximum(), out_md.getDimension(0).getMaximum()) @@ -39,6 +39,7 @@ class CutMDTest(unittest.TestCase): self.assertEquals("['zeta', 0, 0]", out_md.getDimension(0).getName() ) self.assertEquals("[0, 'eta', 0]", out_md.getDimension(1).getName() ) self.assertEquals("[0, 0, 'xi']", out_md.getDimension(2).getName() ) + self.assertTrue(isinstance(out_md, IMDEventWorkspace), "nopix defaults to True. Should get an IMDEventWorkspace") def test_wrong_projection_workspace_format_wrong_column_numbers(self): projection = CreateEmptyTableWorkspace() @@ -110,7 +111,7 @@ class CutMDTest(unittest.TestCase): projection.addRow([1, 1, 0, 0, "aaa"]) projection.addRow([0, 0, 1, 0, "aaa"]) - out_md = CutMD(to_cut, Projection=projection, P1Bin=[0.1], P2Bin=[0.1], P3Bin=[0.1]) + out_md = CutMD(to_cut, Projection=projection, P1Bin=[0.1], P2Bin=[0.1], P3Bin=[0.1], NoPix=True) ''' Here we check that the corners in HKL end up in the expected positions when transformed into the new scaled basis @@ -126,6 +127,8 @@ class CutMDTest(unittest.TestCase): self.assertEquals("['-eta', 'eta', 0]", out_md.getDimension(1).getName() ) self.assertEquals("[0, 0, 'xi']", out_md.getDimension(2).getName() ) + self.assertTrue(isinstance(out_md, IMDHistoWorkspace), "Expect that the output was an IMDHistoWorkspace given the NoPix flag.") +