Skip to content
Snippets Groups Projects
Commit 0b2958ca authored by Matt King's avatar Matt King
Browse files

Functional tests complete

CompactMD now throws invalid arguement exception if the min extent is greater than max
.
Refs #13508
parent 462d7472
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,10 @@ createPBinStringVector(std::vector<Mantid::coord_t> minVector,
std::vector<std::string> pBinStrVector;
for (size_t iter = 0; iter < numDims; iter++) {
// creating pbin string using Min and Max Centre positions
if (minVector[iter] > maxVector[iter]) {
throw std::invalid_argument(
"Minimum extents MUST be less than Maximum extents");
}
auto pBinStr = boost::lexical_cast<std::string>(
minVector[iter] -
(inputWs->getDimension(iter)->getBinWidth() * 0.5)) +
......@@ -39,7 +43,7 @@ void CompactMD::findFirstNonZeroMinMaxExtents(
IMDHistoWorkspace_sptr inputWs, std::vector<Mantid::coord_t> &minVec,
std::vector<Mantid::coord_t> &maxVec) {
auto ws_iter = inputWs->createIterator();
while (ws_iter->next()) {
do {
if (ws_iter->getSignal() == 0) {
// if signal is 0 then go to next index
continue;
......@@ -59,7 +63,7 @@ void CompactMD::findFirstNonZeroMinMaxExtents(
}
}
}
}
} while (ws_iter->next());
}
void CompactMD::init() {
......
......@@ -171,7 +171,7 @@ public:
* Input structure:
*------------------
* -------------
* | | |///|
* |///| | |
* -------------
* -3-2-1 0 1 2 3
*---------------------------
......@@ -194,22 +194,22 @@ public:
const std::string name("test");
auto inWS = MDEventsTestHelper::makeFakeMDHistoWorkspaceGeneral(
numDims, signal, errorSquared, numBins, min, max, name);
inWS->setSignalAt(2, 1.0); // set right-most bin signal to one
inWS->setSignalAt(0, 1.0); // set right-most bin signal to one
CompactMD alg;
alg.setChild(true);
alg.setRethrows(true);
alg.initialize();
alg.setProperty("InputWorkspace", inWS);
alg.setProperty("OutputWorkspace", "out");
alg.execute();
TS_ASSERT_THROWS_NOTHING(alg.execute());
IMDHistoWorkspace_sptr outputWorkspace = alg.getProperty("OutputWorkspace");
TS_ASSERT(outputWorkspace);
TSM_ASSERT_EQUALS("Should have a signal of 1.0: ",
outputWorkspace->getSignalAt(0), 1);
TSM_ASSERT_EQUALS("Minimum should be cut to 1: ",
outputWorkspace->getDimension(0)->getMinimum(), 1.0);
outputWorkspace->getDimension(0)->getMinimum(), -3.0);
TSM_ASSERT_EQUALS("Maximum should still be 3: ",
outputWorkspace->getDimension(0)->getMaximum(), 3.0);
outputWorkspace->getDimension(0)->getMaximum(),-1.0);
TSM_ASSERT_EQUALS("Number of Bins should be 1 : ",
outputWorkspace->getDimension(0)->getNBins(), 1);
TSM_ASSERT_EQUALS("Bin width should be consistent: ",
......
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