Skip to content

Commit

Permalink
Re #8023. Adding checks for MinValues and Maxvalues.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Oct 10, 2013
1 parent 4a324a2 commit 907bdd4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace MDAlgorithms

private:
void init();
std::map<std::string, std::string> validateInputs();
void exec();
/// Sets documentation strings for this algorithm
virtual void initDocs();
Expand Down
42 changes: 42 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,48 @@ ConvertToMD::init()

}

std::map<std::string, std::string> ConvertToMD::validateInputs()
{
std::map<std::string, std::string> result;

std::vector<double> minVals = this->getProperty("MinValues");
std::vector<double> maxVals = this->getProperty("MaxValues");

if (minVals.size() != maxVals.size())
{
std::stringstream msg;
msg << "Rank of MinValues != MaxValues (" << minVals.size() << "!=" << maxVals.size() << ")";
result["MinValues"] = msg.str();
result["MaxValues"] = msg.str();
}
else
{
std::stringstream msg;

size_t rank = minVals.size();
for (size_t i = 0; i < rank; ++i)
{
if (minVals[i] >= maxVals[i])
{
if (msg.str().empty())
msg << "max not bigger than min ";
else
msg << ", ";
msg << "at index=" << (i+1) << " ("
<< minVals[i] << ">=" << maxVals[i] << ")";
}
}

if (!msg.str().empty())
{
result["MinValues"] = msg.str();
result["MaxValues"] = msg.str();
}
}

return result;
}

//----------------------------------------------------------------------------------------------
/* Execute the algorithm. */
void ConvertToMD::exec()
Expand Down

0 comments on commit 907bdd4

Please sign in to comment.