From ef4316c847e4b4d001a755f5e045003d89e3878a Mon Sep 17 00:00:00 2001 From: Harry Jeffery <henry.jeffery@stfc.ac.uk> Date: Mon, 30 Mar 2015 14:45:05 +0100 Subject: [PATCH] Refs #11355 Transfer non orthogonal slice test --- .../Framework/MDAlgorithms/test/CutMDTest.h | 62 +++++++++++++++++++ .../test/python/mantid/api/CutMDTest.py | 36 ----------- 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h index 8f86411ba71..adcfd50c85a 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h @@ -296,6 +296,68 @@ public: AnalysisDataService::Instance().remove(wsName); } + + void test_non_orthogonal_slice() { + const std::string wsName = "__CutMDTest_non_orthog_slice"; + + FrameworkManager::Instance().exec("CreateMDWorkspace", 10, + "OutputWorkspace", wsName.c_str(), + "Dimensions", "3", + "Extents", "-1,1,-1,1,-1,1", + "Names", "H,K,L", + "Units", "U,U,U"); + + FrameworkManager::Instance().exec("SetUB", 14, + "Workspace", wsName.c_str(), + "a", "1", "b", "1", "c", "1", + "alpha", "90", "beta", "90", "gamma", "90"); + + FrameworkManager::Instance().exec("SetSpecialCoordinates", 4, + "InputWorkspace", wsName.c_str(), + "SpecialCoordinates", "HKL"); + + ITableWorkspace_sptr proj = WorkspaceFactory::Instance().createTable(); + proj->addColumn("str", "name"); + proj->addColumn("str", "value"); + proj->addColumn("double", "offset"); + proj->addColumn("str", "type"); + + TableRow uRow = proj->appendRow(); + TableRow vRow = proj->appendRow(); + TableRow wRow = proj->appendRow(); + uRow << "u" << "1,1,0" << 0.0 << "r"; + vRow << "v" << "-1,1,0" << 0.0 << "r"; + wRow << "w" << "0,0,1" << 0.0 << "r"; + + auto algCutMD = FrameworkManager::Instance().createAlgorithm("CutMD"); + algCutMD->initialize(); + algCutMD->setRethrows(true); + algCutMD->setProperty("InputWorkspace", wsName); + algCutMD->setProperty("OutputWorkspace", wsName); + algCutMD->setProperty("Projection", proj); + algCutMD->setProperty("P1Bin", "0.1"); + algCutMD->setProperty("P2Bin", "0.1"); + algCutMD->setProperty("P3Bin", "0.1"); + algCutMD->setProperty("NoPix", true); + algCutMD->execute(); + TS_ASSERT(algCutMD->isExecuted()); + + IMDHistoWorkspace_sptr outWS = + AnalysisDataService::Instance().retrieveWS<IMDHistoWorkspace>(wsName); + TS_ASSERT(outWS.get()); + + TS_ASSERT_EQUALS(outWS->getDimension(0)->getMinimum(), -1); + TS_ASSERT_EQUALS(outWS->getDimension(0)->getMaximum(), 1); + TS_ASSERT_EQUALS(outWS->getDimension(1)->getMinimum(), -1); + TS_ASSERT_EQUALS(outWS->getDimension(1)->getMaximum(), 1); + TS_ASSERT_EQUALS(outWS->getDimension(2)->getMinimum(), -1); + TS_ASSERT_EQUALS(outWS->getDimension(2)->getMaximum(), 1); + TS_ASSERT_EQUALS("['zeta', 'zeta', 0]", outWS->getDimension(0)->getName()); + TS_ASSERT_EQUALS("['-eta', 'eta', 0]", outWS->getDimension(1)->getName()); + TS_ASSERT_EQUALS("[0, 0, 'xi']", outWS->getDimension(2)->getName()); + + AnalysisDataService::Instance().remove(wsName); + } }; #endif /* MANTID_MDALGORITHMS_CUTMDTEST_H_ */ 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 d23bda080c5..4d4f4e56e37 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py +++ b/Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py @@ -22,42 +22,6 @@ class CutMDTest(unittest.TestCase): def tearDown(self): DeleteWorkspace(self.__in_md ) - def test_non_orthogonal_slice(self): - # We create a fake workspace and check to see that the extents get transformed to the new coordinate system. - to_cut = CreateMDWorkspace(Dimensions=3, Extents=[-1,1,-1,1,-1,1], Names='H,K,L', Units='U,U,U') - # Set the UB - SetUB(Workspace=to_cut, a = 1, b = 1, c = 1, alpha =90, beta=90, gamma = 90) - SetSpecialCoordinates(InputWorkspace=to_cut, SpecialCoordinates='HKL') - - projection = CreateEmptyTableWorkspace() - # Correct number of columns, and names - projection.addColumn("str", "name") - projection.addColumn("str", "value") - projection.addColumn("double", "offset") - projection.addColumn("str", "type") - - projection.addRow(["u", "1,1,0", 0.0, "r"]) - projection.addRow(["v","-1,1,0", 0.0, "r"]) - projection.addRow(["w", "0,0,1", 0.0, "r"]) - - 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 - provided by the W transform (projection table) - ''' - self.assertEquals(-1, out_md.getDimension(0).getMinimum()) - self.assertEquals(1, out_md.getDimension(0).getMaximum()) - self.assertEquals(-1, out_md.getDimension(1).getMinimum()) - self.assertEquals(1, out_md.getDimension(1).getMaximum()) - self.assertEquals(-1, out_md.getDimension(2).getMinimum()) - self.assertEquals(1, out_md.getDimension(2).getMaximum()) - self.assertEquals("['zeta', 'zeta', 0]", out_md.getDimension(0).getName() ) - 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.") - def test_orthogonal_slice_with_cropping(self): # We create a fake workspace and check to see that using bin inputs for cropping works to_cut = CreateMDWorkspace(Dimensions=3, Extents=[-1,1,-1,1,-1,1], Names='H,K,L', Units='U,U,U') -- GitLab