From 963012649e0ac246d291b094a712dcfa09ce84ab Mon Sep 17 00:00:00 2001 From: Dimitar Tasev <dimtasev@gmail.com> Date: Thu, 8 Nov 2018 14:51:14 +0000 Subject: [PATCH] Create WS with a masked bin helper function, re #21593 --- .../Algorithms/test/WorkspaceCreationHelperTest.h | 14 ++++++++++++++ .../testhelpers/WorkspaceCreationHelperModule.cpp | 5 +++++ .../MantidTestHelpers/WorkspaceCreationHelper.h | 3 +++ .../TestHelpers/src/WorkspaceCreationHelper.cpp | 6 ++++++ 4 files changed, 28 insertions(+) diff --git a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h index 1d496870565..8b5ed46efbb 100644 --- a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h +++ b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h @@ -50,6 +50,20 @@ public: 1, 2, false, std::set<int64_t>(), false); TS_ASSERT(!ws2->hasDx(0)); } + + void test_create2DWorkspace123WithMaskedBin() { + int numHist = 3; + int numBins = 4; + // mask bin at workspace index 0, bin 1 + Workspace2D_sptr ws = + WorkspaceCreationHelper::create2DWorkspace123WithMaskedBin( + numHist, numBins, 0, 1); + TS_ASSERT(ws); + TS_ASSERT_EQUALS(ws->getNumberHistograms(), numHist); + TS_ASSERT_EQUALS(ws->blocksize(), numBins); + TS_ASSERT_EQUALS(ws->hasMaskedBins(0), true); + TS_ASSERT_EQUALS(ws->hasMaskedBins(1), false); + } }; #endif /* MANTID_ALGORITHMS_WORKSPACECREATIONHELPERTEST_H_ */ diff --git a/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelperModule.cpp b/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelperModule.cpp index a5dfe28bbbb..bd57c037ee9 100644 --- a/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelperModule.cpp +++ b/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelperModule.cpp @@ -41,6 +41,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(makeFakeMDHistoWorkspace_overloads, BOOST_PYTHON_FUNCTION_OVERLOADS( create2DWorkspaceWithRectangularInstrument_overloads, create2DWorkspaceWithRectangularInstrument, 3, 3) + GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") @@ -56,6 +57,7 @@ BOOST_PYTHON_MODULE(WorkspaceCreationHelper) { // Function pointers to disambiguate the calls using Signature1_2D = Workspace2D_sptr (*)(int, int, bool, bool); using Signature2_2D = Workspace2D_sptr (*)(int, int, int); + using Signature3_2D = Workspace2D_sptr (*)(int, int, int, int); def("create2DWorkspaceWithFullInstrument", reinterpret_cast<Signature1_2D>(&create2DWorkspaceWithFullInstrument), @@ -65,6 +67,9 @@ BOOST_PYTHON_MODULE(WorkspaceCreationHelper) { (Signature2_2D)&create2DWorkspaceWithRectangularInstrument, create2DWorkspaceWithRectangularInstrument_overloads()); + def("create2DWorkspace123WithMaskedBin", + reinterpret_cast<Signature3_2D>(&create2DWorkspace123WithMaskedBin)); + //=================================== Event Workspaces //=================================== diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index 49ffdb60fef..aa751d31563 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -271,6 +271,9 @@ Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceThetaVsTOF(int nHist, Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithRectangularInstrument(int numBanks, int numPixels, int numBins); +Mantid::DataObjects::Workspace2D_sptr +create2DWorkspace123WithMaskedBin(int numHist, int numBins, + int maskedWorkspaceIndex, int maskedBinIndex); /** Create an Eventworkspace with an instrument that contains * RectangularDetector's */ diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index b0e962e69ae..0010da478d8 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -1542,4 +1542,10 @@ createEPPTableWorkspace(const std::vector<EPPTableRow> &rows) { } return ws; } +Mantid::DataObjects::Workspace2D_sptr +create2DWorkspace123WithMaskedBin(int numHist, int numBins, int maskedWorkspaceIndex, int maskedBinIndex) { + auto &ws = create2DWorkspace123(numHist, numBins); + ws->flagMasked(maskedWorkspaceIndex, maskedBinIndex); + return ws; +} } // namespace WorkspaceCreationHelper -- GitLab