Skip to content
Snippets Groups Projects
Commit c5e77ee7 authored by Simon Heybrock's avatar Simon Heybrock Committed by GitHub
Browse files

Merge pull request #17387 from mantidproject/17082_compactMD_out_of_bounds

Fix CompactMD out of bounds bug
parents e10bd970 4a63f5a7
No related branches found
No related tags found
No related merge requests found
...@@ -147,13 +147,18 @@ void setMinMaxBins(Mantid::coord_t &pMin, Mantid::coord_t &pMax, ...@@ -147,13 +147,18 @@ void setMinMaxBins(Mantid::coord_t &pMin, Mantid::coord_t &pMax,
snappedPMax += offset; snappedPMax += offset;
snappedPMin += offset; snappedPMin += offset;
if (pMin != snappedPMin) { if (snappedPMin < dimension->getMinimum()) {
snappedPMin = dimension->getMinimum();
} else if (pMin != snappedPMin) {
std::stringstream buffer; std::stringstream buffer;
buffer << "Rounding min from: " << pMin buffer << "Rounding min from: " << pMin
<< " to the nearest whole width at: " << snappedPMin; << " to the nearest whole width at: " << snappedPMin;
logger.warning(buffer.str()); logger.warning(buffer.str());
} }
if (pMax != snappedPMax) {
if (snappedPMax > dimension->getMaximum()) {
snappedPMax = dimension->getMaximum();
} else if (pMax != snappedPMax) {
std::stringstream buffer; std::stringstream buffer;
buffer << "Rounding max from: " << pMax buffer << "Rounding max from: " << pMax
<< " to the nearest whole width at: " << snappedPMax; << " to the nearest whole width at: " << snappedPMax;
......
...@@ -216,7 +216,8 @@ public: ...@@ -216,7 +216,8 @@ public:
outputWorkspace->getDimension(0)->getBinWidth(), outputWorkspace->getDimension(0)->getBinWidth(),
inWS->getDimension(0)->getBinWidth()); inWS->getDimension(0)->getBinWidth());
} }
void test_compact_md_throws_when_loading_empty_workspace() {
void test_compact_md_does_not_throw_when_loading_empty_workspace() {
using namespace Mantid::DataObjects; using namespace Mantid::DataObjects;
const size_t numDims = 1; const size_t numDims = 1;
const double signal = 0.0; const double signal = 0.0;
......
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