Skip to content
Snippets Groups Projects
Commit 96301264 authored by Dimitar Tasev's avatar Dimitar Tasev
Browse files

Create WS with a masked bin helper function, re #21593

parent bc27368e
No related merge requests found
......@@ -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_ */
......@@ -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
//===================================
......
......@@ -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 */
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment