Skip to content

Commit

Permalink
Refs #9170 Merge master in to add other recent features
Browse files Browse the repository at this point in the history
Merges changes from #9039 and #9043, tehy still need refactored for the new gui style though.

Merge remote-tracking branch 'origin/master' into bugfix/9170_Refl_stopped_working_error

Conflicts:
	Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
  • Loading branch information
keithnbrown committed Mar 20, 2014
2 parents 0faba51 + d1d8cd5 commit 784cd5e
Show file tree
Hide file tree
Showing 168 changed files with 5,842 additions and 1,703 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ set ( SRC_FILES
src/ImmutableCompositeFunction.cpp
src/ImplicitFunctionParameterParserFactory.cpp
src/ImplicitFunctionParserFactory.cpp
src/ImplictFunctionFactory.cpp
src/ImplicitFunctionFactory.cpp
src/InstrumentDataService.cpp
src/JointDomain.cpp
src/LinearScale.cpp
Expand Down
28 changes: 21 additions & 7 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
@@ -1,20 +1,34 @@
#ifndef IMD_NODE_H_
#define IMD_NODE_H_

#include <vector>
#include <algorithm>
#include "MantidKernel/ThreadScheduler.h"
#include "MantidAPI/IBoxControllerIO.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidGeometry/MDGeometry/MDDimensionExtents.h"
#include "MantidAPI/BoxController.h"
#include "MantidAPI/CoordTransform.h"
#include <string>
#include <vector>
#include "MantidKernel/VMD.h"
#include "MantidGeometry/MDGeometry/MDTypes.h"

namespace Mantid
{
namespace Kernel
{
class ISaveable;
class ThreadScheduler;
}

namespace Geometry
{
template <typename T>
class MDDimensionExtents;
class MDImplicitFunction;
}

namespace API
{

class BoxController;
class IBoxControllerIO;
class CoordTransform;

class IMDNode
{
/** This is an interface to MDBox or MDGridBox of an MDWorkspace
Expand Down
Expand Up @@ -70,16 +70,16 @@ namespace Mantid
{
using namespace Poco::XML;
AutoPtr<Document> pDoc = new Document;
Element* paramElement = pDoc->createElement("Parameter");
AutoPtr<Element> paramElement = pDoc->createElement("Parameter");

pDoc->appendChild(paramElement);
Element* typeElement = pDoc->createElement("Type");
Text* typeText = pDoc->createTextNode(this->getName());
AutoPtr<Element> typeElement = pDoc->createElement("Type");
AutoPtr<Text> typeText = pDoc->createTextNode(this->getName());
typeElement->appendChild(typeText);
paramElement->appendChild(typeElement);

Element* valueElement = pDoc->createElement("Value");
Text* valueText = pDoc->createTextNode(valueXMLtext);
AutoPtr<Element> valueElement = pDoc->createElement("Value");
AutoPtr<Text> valueText = pDoc->createTextNode(valueXMLtext);
valueElement->appendChild(valueText);
paramElement->appendChild(valueElement);

Expand Down
9 changes: 3 additions & 6 deletions Code/Mantid/Framework/API/inc/MantidAPI/MDGeometry.h
@@ -1,20 +1,17 @@
#ifndef MANTID_API_MDGEOMETRY_H_
#define MANTID_API_MDGEOMETRY_H_

#include "MantidAPI/CoordTransform.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidKernel/Exception.h"

#include "MantidKernel/System.h"
#include "MantidKernel/VMD.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidAPI/AnalysisDataService.h"
#include <Poco/NObserver.h>


namespace Mantid
{
namespace API
{

class CoordTransform;
class IMDWorkspace;

/** Describes the geometry (i.e. dimensions) of an IMDWorkspace.
Expand Down
15 changes: 13 additions & 2 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -1247,6 +1247,8 @@ namespace Mantid
// Don't make the new algorithm a child so that it's workspaces are stored correctly
alg_sptr->setChild(false);

alg_sptr->setRethrows(true);

IAlgorithm* alg = alg_sptr.get();
// Set all non-workspace properties
this->copyNonWorkspaceProperties(alg, int(entry)+1);
Expand Down Expand Up @@ -1298,8 +1300,17 @@ namespace Mantid
} // for each OutputWorkspace property

// ------------ Execute the algo --------------
if (!alg->execute())
throw std::runtime_error("Execution of " + this->name() + " for group entry " + Strings::toString(entry+1) + " failed.");
try
{
alg->execute();
}
catch(std::exception& e)
{
std::ostringstream msg;
msg << "Execution of " << this->name() << " for group entry " << (entry+1) << " failed: ";
msg << e.what(); // Add original message
throw std::runtime_error(msg.str());
}

// ------------ Fill in the output workspace group ------------------
// this has to be done after execute() because a workspace must exist
Expand Down
23 changes: 15 additions & 8 deletions Code/Mantid/Framework/API/src/BoxController.cpp
Expand Up @@ -117,34 +117,41 @@ namespace API
std::string vecStr;

element = pDoc->createElement("NumDims");
element->appendChild( pDoc->createTextNode(boost::str(boost::format("%d") % this->getNDims())) );
text = pDoc->createTextNode(boost::str(boost::format("%d") % this->getNDims()));
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("MaxId");
element->appendChild( pDoc->createTextNode(boost::str(boost::format("%d") % this->getMaxId())) );
text = pDoc->createTextNode(boost::str(boost::format("%d") % this->getMaxId()));
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("SplitThreshold");
element->appendChild( pDoc->createTextNode(boost::str(boost::format("%d") % this->getSplitThreshold())) );
text = pDoc->createTextNode(boost::str(boost::format("%d") % this->getSplitThreshold()));
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("MaxDepth");
element->appendChild( pDoc->createTextNode(boost::str(boost::format("%d") % this->getMaxDepth())) );
text = pDoc->createTextNode(boost::str(boost::format("%d") % this->getMaxDepth()));
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("SplitInto");
vecStr = Kernel::Strings::join( this->m_splitInto.begin(), this->m_splitInto.end(), ",");
element->appendChild( pDoc->createTextNode( vecStr ) );
text = pDoc->createTextNode( vecStr );
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("NumMDBoxes");
vecStr = Kernel::Strings::join( this->m_numMDBoxes.begin(), this->m_numMDBoxes.end(), ",");
element->appendChild( pDoc->createTextNode( vecStr ) );
text = pDoc->createTextNode( vecStr );
element->appendChild( text );
pBoxElement->appendChild(element);

element = pDoc->createElement("NumMDGridBoxes");
vecStr = Kernel::Strings::join( this->m_numMDGridBoxes.begin(), this->m_numMDGridBoxes.end(), ",");
element->appendChild( pDoc->createTextNode( vecStr ) );
text = pDoc->createTextNode( vecStr );
element->appendChild( text );
pBoxElement->appendChild(element);

//Create a string representation of the DOM tree.
Expand Down Expand Up @@ -182,7 +189,7 @@ namespace API
{
using namespace Poco::XML;
Poco::XML::DOMParser pParser;
Poco::XML::Document* pDoc = pParser.parseString(xml);
Poco::AutoPtr<Poco::XML::Document> pDoc = pParser.parseString(xml);
Poco::XML::Element* pBoxElement = pDoc->documentElement();

std::string s;
Expand Down
Expand Up @@ -42,7 +42,7 @@ namespace Mantid
{
using namespace Poco::XML;
DOMParser pParser;
Document* pDoc = pParser.parseString(processXML);
Poco::AutoPtr<Document> pDoc = pParser.parseString(processXML);
Element* pInstructionsXML = pDoc->documentElement();

ImplicitFunctionParser* funcParser = Mantid::API::ImplicitFunctionParserFactory::Instance().createImplicitFunctionParserFromXML(processXML);
Expand Down
Expand Up @@ -32,7 +32,7 @@ namespace Mantid
{
throw std::runtime_error("Expected passed element to be ParameterList.");
}
Poco::XML::NodeList* parameters = parametersElement->getElementsByTagName("Parameter");
Poco::AutoPtr<Poco::XML::NodeList> parameters = parametersElement->getElementsByTagName("Parameter");
ImplicitFunctionParameterParser* paramParser = NULL;
ImplicitFunctionParameterParser* nextParser = NULL;
for(unsigned long i = 0 ; i < parameters->length(); i++)
Expand Down
Expand Up @@ -44,7 +44,7 @@ namespace Mantid
ImplicitFunctionParameterParser* paramParser = Mantid::API::ImplicitFunctionParameterParserFactory::Instance().createImplicitFunctionParameterParserFromXML(parametersElement);
functionParser->setParameterParser(paramParser);

Poco::XML::NodeList* childFunctions = functionElement->getElementsByTagName("Function");
Poco::AutoPtr<Poco::XML::NodeList> childFunctions = functionElement->getElementsByTagName("Function");
ImplicitFunctionParser* childParser = NULL;
for(unsigned long i = 0; i < childFunctions->length(); i++)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace Mantid
{
using namespace Poco::XML;
DOMParser pParser;
Document* pDoc = pParser.parseString(functionXML);
AutoPtr<Document> pDoc = pParser.parseString(functionXML);
Element* pRootElem = pDoc->documentElement();

return createImplicitFunctionParserFromXML(pRootElem);
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/src/MDGeometry.cpp
@@ -1,5 +1,6 @@
#include "MantidAPI/MDGeometry.h"
#include "MantidKernel/System.h"
#include "MantidAPI/CoordTransform.h"
#include "MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
Expand Down
57 changes: 57 additions & 0 deletions Code/Mantid/Framework/API/test/AlgorithmTest.h
Expand Up @@ -109,6 +109,40 @@ class AlgorithmWithValidateInputs : public Algorithm
};
DECLARE_ALGORITHM(AlgorithmWithValidateInputs)

/**
* Algorithm which fails on specified workspace
*/
class FailingAlgorithm : public Algorithm
{
public:
FailingAlgorithm() : Algorithm() {}
virtual ~FailingAlgorithm() {}
const std::string name() const { return "FailingAlgorithm"; }
int version() const { return 1; }

static const std::string FAIL_MSG;

void init()
{
declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input));
declareProperty("WsNameToFail", "");
}

void exec()
{
std::string wsNameToFail = getPropertyValue("WsNameToFail");
std::string wsName = getPropertyValue("InputWorkspace");

if ( wsName == wsNameToFail )
{
throw std::runtime_error(FAIL_MSG);
}
}
};

const std::string FailingAlgorithm::FAIL_MSG("Algorithm failed as requested");

DECLARE_ALGORITHM(FailingAlgorithm)

class AlgorithmTest : public CxxTest::TestSuite
{
Expand Down Expand Up @@ -699,7 +733,30 @@ class AlgorithmTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( ws1->readY(0)[0], 234 );
}

void test_processGroups_failOnGroupMemberErrorMessage()
{
makeWorkspaceGroup("A", "A_1,A_2,A_3");

FailingAlgorithm alg;
alg.initialize();
alg.setRethrows(true);
alg.setLogging(false);
alg.setPropertyValue("InputWorkspace", "A");
alg.setPropertyValue("WsNameToFail", "A_2");

try
{
alg.execute();
TS_FAIL("Exception wasn't thrown");
}
catch(std::runtime_error& e)
{
std::string msg(e.what());

TSM_ASSERT("Error message should contain original error",
msg.find(FailingAlgorithm::FAIL_MSG) != std::string::npos);
}
}

private:
IAlgorithm_sptr runFromString(const std::string & input)
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/Framework/API/test/VectorParameterParserTest.h
Expand Up @@ -64,7 +64,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite
{
DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>ConcreteVectorDblParam</Type><Value>1, 2, 3</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorDblParamParser parser;
Expand All @@ -87,7 +87,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite
{
DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>SucessorVectorParameter</Type><Value>1, 2, 3</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorDblParamParser parser;
Expand All @@ -103,7 +103,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite

DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>SucessorVectorParameter</Type><Value>1, 2, 3</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorDblParamParser parser;
Expand All @@ -119,7 +119,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite
{
DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>ConcreteVectorBoolParam</Type><Value>1, 0, 1, 0</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorBoolParamParser parser;
Expand All @@ -145,7 +145,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite
{
DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>OTHER</Type><Value>1, 0, 1, 0</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorBoolParamParser parser;
Expand All @@ -156,7 +156,7 @@ class VectorParameterParserTest : public CxxTest::TestSuite
{
DOMParser pParser;
std::string xmlToParse = "<Parameter><Type>ConcreteVectorDblParam</Type><Value>1, 0, 1, 0</Value></Parameter>";
Document* pDoc = pParser.parseString(xmlToParse);
Poco::AutoPtr<Document> pDoc = pParser.parseString(xmlToParse);
Element* pRootElem = pDoc->documentElement();

ConcreteVectorDblParamParser parser;
Expand Down
Expand Up @@ -95,7 +95,7 @@ class DLLExport CheckWorkspacesMatch : public API::Algorithm
void doPeaksComparison(API::IPeaksWorkspace_sptr tws1, API::IPeaksWorkspace_sptr tws2);
void doTableComparison(API::ITableWorkspace_const_sptr tws1, API::ITableWorkspace_const_sptr tws2);
void doMDComparison(API::Workspace_sptr w1, API::Workspace_sptr w2);
bool checkEventLists(DataObjects::EventWorkspace_const_sptr ews1, DataObjects::EventWorkspace_const_sptr ews2);
bool compareEventWorkspaces(DataObjects::EventWorkspace_const_sptr ews1, DataObjects::EventWorkspace_const_sptr ews2);
bool checkData(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
bool checkAxes(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
bool checkSpectraMap(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
Expand All @@ -104,6 +104,11 @@ class DLLExport CheckWorkspacesMatch : public API::Algorithm
bool checkSample(const API::Sample& sample1, const API::Sample& sample2);
bool checkRunProperties(const API::Run& run1, const API::Run& run2);

/// Compare 2 EventsList
int compareEventsListInDetails(const DataObjects::EventList &el1, const DataObjects::EventList &el2,
double tolTof, double tolWeight, int64_t tolPulse, bool printdetails,
size_t& numdiffpulse, size_t& numdifftof, size_t& numdiffboth) const;

std::string result; ///< the result string

API::Progress * prog;
Expand Down
Expand Up @@ -96,7 +96,7 @@ namespace Algorithms
/// Conversion factor between time and energy
double m_t_to_mev;
/// The percentage deviation from the estimated peak time that defines the peak region
const double m_tof_window;
double m_tof_window;
/// Number of std deviations to consider a peak
const double m_peak_signif;
/// Number of std deviations to consider a peak for the derivative
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/ApplyDeadTimeCorr.cpp
Expand Up @@ -77,6 +77,11 @@ void ApplyDeadTimeCorr::exec()
{
double numGoodFrames = boost::lexical_cast<double>(run.getProperty("goodfrm")->value());

if (numGoodFrames == 0)
{
throw std::runtime_error("Number of good frames in the workspace is zero");
}

// Duplicate the input workspace. Only need to change Y values based on dead time corrections
IAlgorithm_sptr duplicate = createChildAlgorithm("CloneWorkspace");
duplicate->initialize();
Expand Down

0 comments on commit 784cd5e

Please sign in to comment.