Skip to content

Commit

Permalink
Refs #4459 fix test build
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Feb 10, 2012
1 parent 98d8c2a commit da0f6f6
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 44 deletions.
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/API/src/IMDWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ namespace Mantid
*/
IMDIterator* IMDWorkspace::createIterator(Mantid::Geometry::MDImplicitFunction * function) const
{
return this->createIterators(1, function)[0];
std::vector<IMDIterator*> iterators = this->createIterators(1, function);
if (iterators.size() == 0)
throw std::runtime_error("IMDWorkspace::createIterator(): iterator creation was not successful. No iterators returned by " + this->id() );
return iterators[0];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,10 +1496,10 @@ namespace Mantid
{
// Find the right number of cores to use
size_t numCores = suggestedNumCores;
if (numCores < 1) numCores = 1;
if (!this->threadSafe()) numCores = 1;
size_t numElements = this->getNumberHistograms();
if (numCores > numElements) numCores = numElements;
if (numCores < 1) numCores = 1;

// Create one iterator per core, splitting evenly amongst spectra
std::vector<IMDIterator*> out;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDAlgorithms/test/TransformMDTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class TransformMDTest : public CxxTest::TestSuite

TS_ASSERT_DELTA( ws2->getInverseVolume(), 1./16., 1e-6);
coord_t point[2] = {21.1, 21.1};
TS_ASSERT_DELTA( ws2->getSignalAtCoord(point), 1.23 * ws2->getInverseVolume(), 1e-6);
TS_ASSERT_DELTA( ws2->getSignalAtCoord(point, Mantid::API::NoNormalization), 1.23, 1e-6);


// Remove workspace from the data service.
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ namespace MDEvents

// Calculate the right number of cores
size_t numCores = suggestedNumCores;
if (numCores < 1) numCores = 1;
if (!this->threadSafe()) numCores = 1;
size_t numElements = this->getNPoints();
size_t numElements = boxes.size();
if (numCores > numElements) numCores = numElements;
if (numCores < 1) numCores = 1;

// Create one iterator per core, splitting evenly amongst spectra
std::vector<IMDIterator*> out;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ namespace MDEvents
Mantid::Geometry::MDImplicitFunction * function) const
{
size_t numCores = suggestedNumCores;
if (numCores < 1) numCores = 1;
if (!this->threadSafe()) numCores = 1;
size_t numElements = this->getNPoints();
if (numCores > numElements) numCores = numElements;
if (numCores < 1) numCores = 1;

// Create one iterator per core, splitting evenly amongst spectra
std::vector<IMDIterator*> out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public slots:
void updateDimensionSliceWidgets();
void resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr dim);
QwtDoubleInterval getRange(Mantid::API::IMDIterator * it);
QwtDoubleInterval getRange(std::vector<Mantid::API::IMDIterator *> & iterators);

void findRangeFull();
void findRangeSlice();
Expand Down
17 changes: 17 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ QwtDoubleInterval SliceViewer::getRange(IMDIterator * it)
return QwtDoubleInterval(0., 1.0);
if (!it->valid())
return QwtDoubleInterval(0., 1.0);
// Use the current normalization
it->setNormalization(m_data->getNormalization());

double minSignal = DBL_MAX;
double maxSignal = -DBL_MAX;
Expand Down Expand Up @@ -961,6 +963,21 @@ QwtDoubleInterval SliceViewer::getRange(IMDIterator * it)
}
}

//------------------------------------------------------------------------------------
/** Get the range of signal, in parallel, given an iterator
*
* @param iterators :: vector of IMDIterator of what to find
* @return the min/max range, or 0-1.0 if not found
*/
QwtDoubleInterval SliceViewer::getRange(std::vector<IMDIterator *> & iterators)
{
// PRAGMA_OMP( parallel for )
// for (int i=0; i < int(iterators.size(); i++)
// {
//
// }
}

//------------------------------------------------------------------------------------
/// Find the full range of values in the workspace
void SliceViewer::findRangeFull()
Expand Down
23 changes: 21 additions & 2 deletions Code/Mantid/Vates/VatesAPI/test/MockObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,27 @@ class MockIMDWorkspace: public Mantid::API::IMDWorkspace
Mantid::API::MDNormalization , std::vector<Mantid::coord_t> & , std::vector<Mantid::signal_t> & , std::vector<Mantid::signal_t> & ) const
{}

virtual Mantid::API::IMDIterator* createIterator(Mantid::Geometry::MDImplicitFunction * /*function*/ = NULL) const
{ throw std::runtime_error("Mock createIterator() Not implemented.");
virtual std::vector<Mantid::API::IMDIterator*> createIterators(size_t = 1,
Mantid::Geometry::MDImplicitFunction * = NULL) const
{
throw std::runtime_error("Not Implemented");
}

virtual Mantid::signal_t getSignalAtCoord(const Mantid::coord_t * , const Mantid::API::MDNormalization & ) const
{
return 0;
}

//constructor allows a workspace name to be provide.
MockIMDWorkspace(std::string name)
: IMDWorkspace()
{
setName(name);
}

MockIMDWorkspace()
: IMDWorkspace()
{
}

virtual ~MockIMDWorkspace() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidKernel/System.h"
#include <boost/shared_ptr.hpp>
#include "MockObjects.h"

using namespace Mantid::VATES;

Expand All @@ -31,42 +32,6 @@ class RebinningKnowledgeSerializerTest: public CxxTest::TestSuite
}
};

//Helper class. Not all methods can be mocked.

class MockIMDWorkspace: public Mantid::API::IMDWorkspace
{
public:

MOCK_CONST_METHOD0(id, const std::string());
MOCK_CONST_METHOD0(getMemorySize, size_t());
MOCK_CONST_METHOD0(getNonIntegratedDimensions, Mantid::Geometry::VecIMDDimension_const_sptr());
MOCK_CONST_METHOD0(getGeometryXML,std::string());

virtual void getLinePlot(const Mantid::Kernel::VMD & , const Mantid::Kernel::VMD & ,
Mantid::API::MDNormalization , std::vector<Mantid::coord_t> & , std::vector<Mantid::signal_t> & , std::vector<Mantid::signal_t> & ) const
{}

virtual uint64_t getNPoints() const
{
throw std::runtime_error("Not Implemented");
}

virtual signal_t getSignalAtCoord(const coord_t * , const Mantid::API::MDNormalization & ) const
{
return 0;
}

//constructor allows a workspace name to be provide.
MockIMDWorkspace(std::string name)
{
setName(name);
}

MockIMDWorkspace()
{
}
};

//Test methods

public:
Expand Down

0 comments on commit da0f6f6

Please sign in to comment.