diff --git a/Framework/Crystal/test/ClusterIntegrationBaseTest.h b/Framework/Crystal/test/ClusterIntegrationBaseTest.h index f188e5cc847f430352375475582427e88dd1f930..280eee5e9f9f16023170127553a7553f47b34329 100644 --- a/Framework/Crystal/test/ClusterIntegrationBaseTest.h +++ b/Framework/Crystal/test/ClusterIntegrationBaseTest.h @@ -14,8 +14,11 @@ #include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/Workspace.h" +#include "MantidKernel/UnitLabelTypes.h" #include "MantidKernel/V3D.h" #include "MantidDataObjects/PeaksWorkspace.h" +#include "MantidGeometry/MDGeometry/HKL.h" + #include <boost/assign/list_of.hpp> #include <boost/tuple/tuple.hpp> @@ -78,7 +81,14 @@ protected: .convert_to_container<std::vector<double>>(); mdworkspaceAlg->setProperty("Extents", extents); mdworkspaceAlg->setPropertyValue("Names", "H,K,L"); - mdworkspaceAlg->setPropertyValue("Units", "-,-,-"); + std::string units = Mantid::Kernel::Units::Symbol::RLU.ascii() + "," + + Mantid::Kernel::Units::Symbol::RLU.ascii() + "," + + Mantid::Kernel::Units::Symbol::RLU.ascii(); + mdworkspaceAlg->setProperty("Units", units); + std::string frames = Mantid::Geometry::HKL::HKLName + "," + + Mantid::Geometry::HKL::HKLName + "," + + Mantid::Geometry::HKL::HKLName; + mdworkspaceAlg->setProperty("Frames", frames); mdworkspaceAlg->setPropertyValue("OutputWorkspace", "IntegratePeaksMDTest_MDEWS"); mdworkspaceAlg->execute(); diff --git a/Framework/Crystal/test/PeakClusterProjectionTest.h b/Framework/Crystal/test/PeakClusterProjectionTest.h index d8706454d67717c0aa1fe5cc66af7e3b4d644d2a..59f8d147ea65fb9569a46780d2214ddde88f26c6 100644 --- a/Framework/Crystal/test/PeakClusterProjectionTest.h +++ b/Framework/Crystal/test/PeakClusterProjectionTest.h @@ -9,10 +9,13 @@ #include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/IPeaksWorkspace.h" #include "MantidGeometry/Crystal/IPeak.h" - +#include "MantidGeometry/MDGeometry/HKL.h" +#include "MantidGeometry/MDGeometry/MDFrameFactory.h" #include "MantidDataObjects/PeaksWorkspace.h" #include "MantidTestHelpers/MDEventsTestHelper.h" #include "MantidTestHelpers/ComponentCreationHelper.h" +#include "MantidKernel/UnitLabelTypes.h" + #include <boost/math/special_functions/fpclassify.hpp> #include <boost/assign/list_of.hpp> #include <math.h> @@ -89,8 +92,9 @@ public: PeakClusterProjectionTest() { FrameworkManager::Instance(); } void test_throws_if_mdws_has_no_coordinate_system() { + Mantid::Geometry::UnknownFrame frame("testunit"); IMDHistoWorkspace_sptr inWS = - MDEventsTestHelper::makeFakeMDHistoWorkspace(1, 3, 1); + MDEventsTestHelper::makeFakeMDHistoWorkspaceWithMDFrame(1, 3, frame, 1); inWS->setCoordinateSystem(Mantid::Kernel::None); TSM_ASSERT_THROWS("Must have a known coordinate system", @@ -99,8 +103,12 @@ public: } void test_throws_if_mdws_is_less_than_three_dimensional() { + auto frameFactory = Mantid::Geometry::makeMDFrameFactoryChain(); + Mantid::Geometry::MDFrameArgument frameArg( + Mantid::Geometry::HKL::HKLName, Mantid::Kernel::Units::Symbol::RLU); + auto frame = frameFactory->create(frameArg); IMDHistoWorkspace_sptr inWS = - MDEventsTestHelper::makeFakeMDHistoWorkspace(1, 2, 1); + MDEventsTestHelper::makeFakeMDHistoWorkspaceWithMDFrame(1, 2, *frame, 1); inWS->setCoordinateSystem(Mantid::Kernel::HKL); TSM_ASSERT_THROWS("Must be +3 dimensional", diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index 6d620b6a7c82f0e1835accfae1ae2813c15a4b0c..fea8f0e69704aa77f6a72a2fabe173b3d4c5bed8 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -145,6 +145,11 @@ makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10, coord_t max = 10.0, double errorSquared = 1.0, std::string name = "", double numEvents = 1.0); +Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( + double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, + size_t numBins = 10, coord_t max = 10.0, double errorSquared = 1.0, + std::string name = "", double numEvents = 1.0); + /// More general fake n-dimensionsal MDHistoWorkspace Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index 5ee9abd0eaaf9d10a0f7878a86bf54b18ab9b3c7..7981087129fa6c36ae7dca1dd91f88f4d9173499 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -218,49 +218,11 @@ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins, coord_t max, double errorSquared, std::string name, double numEvents) { - // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( Mantid::Geometry::GeneralFrame::GeneralFrameDistance, "m"); - - MDHistoWorkspace *ws = NULL; - if (numDims == 1) { - ws = new MDHistoWorkspace(MDHistoDimension_sptr( - new MDHistoDimension("x", "x", frame, 0.0, max, numBins))); - } else if (numDims == 2) { - ws = new MDHistoWorkspace(MDHistoDimension_sptr(new MDHistoDimension( - "x", "x", frame, 0.0, max, numBins)), - MDHistoDimension_sptr(new MDHistoDimension( - "y", "y", frame, 0.0, max, numBins))); - } else if (numDims == 3) { - ws = new MDHistoWorkspace(MDHistoDimension_sptr(new MDHistoDimension( - "x", "x", frame, 0.0, max, numBins)), - MDHistoDimension_sptr(new MDHistoDimension( - "y", "y", frame, 0.0, max, numBins)), - MDHistoDimension_sptr(new MDHistoDimension( - "z", "z", frame, 0.0, max, numBins))); - } else if (numDims == 4) { - ws = new MDHistoWorkspace( - MDHistoDimension_sptr( - new MDHistoDimension("x", "x", frame, 0.0, max, numBins)), - MDHistoDimension_sptr( - new MDHistoDimension("y", "y", frame, 0.0, max, numBins)), - MDHistoDimension_sptr( - new MDHistoDimension("z", "z", frame, 0.0, max, numBins)), - MDHistoDimension_sptr( - new MDHistoDimension("t", "t", frame, 0.0, max, numBins))); - } - - if (!ws) - throw std::runtime_error( - " invalid or unsupported number of dimensions given"); - - MDHistoWorkspace_sptr ws_sptr(ws); - ws_sptr->setTo(signal, errorSquared, numEvents); - ws_sptr->addExperimentInfo(ExperimentInfo_sptr(new ExperimentInfo())); - if (!name.empty()) - AnalysisDataService::Instance().addOrReplace(name, ws_sptr); - return ws_sptr; + return makeFakeMDHistoWorkspaceWithMDFrame( + signal, numDims, frame, numBins, max, errorSquared, name, numEvents); } //------------------------------------------------------------------------------------- @@ -339,6 +301,65 @@ MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( return ws_sptr; } + +//------------------------------------------------------------------------------------- +/** Creates a fake MDHistoWorkspace with MDFrame selection + * + * @param signal :: signal in every point + * @param numDims :: number of dimensions to create. They will range from 0 to + *max + * @param numBins :: bins in each dimensions + * @param max :: max position in each dimension + * @param errorSquared :: error squared in every point + * @param name :: optional name + * @param numEvents :: optional number of events in each bin. Default 1.0 + * @return the MDHisto + */ +Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( + double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, + size_t numBins, coord_t max, double errorSquared, std::string name, + double numEvents) { + MDHistoWorkspace *ws = NULL; + if (numDims == 1) { + ws = new MDHistoWorkspace(MDHistoDimension_sptr( + new MDHistoDimension("x", "x", frame, 0.0, max, numBins))); + } else if (numDims == 2) { + ws = new MDHistoWorkspace(MDHistoDimension_sptr(new MDHistoDimension( + "x", "x", frame, 0.0, max, numBins)), + MDHistoDimension_sptr(new MDHistoDimension( + "y", "y", frame, 0.0, max, numBins))); + } else if (numDims == 3) { + ws = new MDHistoWorkspace(MDHistoDimension_sptr(new MDHistoDimension( + "x", "x", frame, 0.0, max, numBins)), + MDHistoDimension_sptr(new MDHistoDimension( + "y", "y", frame, 0.0, max, numBins)), + MDHistoDimension_sptr(new MDHistoDimension( + "z", "z", frame, 0.0, max, numBins))); + } else if (numDims == 4) { + ws = new MDHistoWorkspace( + MDHistoDimension_sptr( + new MDHistoDimension("x", "x", frame, 0.0, max, numBins)), + MDHistoDimension_sptr( + new MDHistoDimension("y", "y", frame, 0.0, max, numBins)), + MDHistoDimension_sptr( + new MDHistoDimension("z", "z", frame, 0.0, max, numBins)), + MDHistoDimension_sptr( + new MDHistoDimension("t", "t", frame, 0.0, max, numBins))); + } + + if (!ws) + throw std::runtime_error( + " invalid or unsupported number of dimensions given"); + + MDHistoWorkspace_sptr ws_sptr(ws); + ws_sptr->setTo(signal, errorSquared, numEvents); + ws_sptr->addExperimentInfo(ExperimentInfo_sptr(new ExperimentInfo())); + if (!name.empty()) + AnalysisDataService::Instance().addOrReplace(name, ws_sptr); + return ws_sptr; +} + + /** * Delete a file from disk * @param filename : File name to check and delete