Skip to content

Commit

Permalink
Fixed the inconsistency in unit test. Refs #7506.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Jul 29, 2013
1 parent 567c58d commit 4cd8c6d
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions Code/Mantid/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,7 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite

void testExec()
{
// ---- Create the simple workspace -------
MatrixWorkspace_sptr WS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(1,200);
AnalysisDataService::Instance().addOrReplace("temp_event_ws", WS);
WS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("dSpacing");
const Mantid::MantidVec &X = WS->readX(0);
Mantid::MantidVec &Y = WS->dataY(0);
Mantid::MantidVec &E = WS->dataE(0);
for (size_t i = 0; i < Y.size(); ++i)
{
const double x = (X[i]+X[i+1])/2;
Y[i] = 5.1*exp(-0.5*pow((x-10)/1.0,2));
E[i] = 0.001;
}
setupTestWorkspace();

// ---- Run algo -----
if ( !offsets.isInitialized() ) offsets.initialize();
Expand All @@ -69,7 +57,7 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite
TS_ASSERT_THROWS_NOTHING( output = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputWS) );
if (!output) return;

TS_ASSERT_DELTA( output->dataY(0)[0], 0.0506, 0.0002);
TS_ASSERT_DELTA( output->dataY(0)[0], -0.002, 0.0002);

AnalysisDataService::Instance().remove(outputWS);

Expand All @@ -82,6 +70,8 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite

void testExecWithGroup()
{
setupTestWorkspace();

// --------- Workspace with summed spectra -------
MatrixWorkspace_sptr WS = WorkspaceCreationHelper::CreateGroupedWorkspace2D(3, 200, 1.0);
WS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("dSpacing");
Expand Down Expand Up @@ -123,6 +113,23 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite

}

void setupTestWorkspace()
{
// ---- Create the simple workspace -------
MatrixWorkspace_sptr WS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(1,200);
AnalysisDataService::Instance().addOrReplace("temp_event_ws", WS);
WS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("dSpacing");
const Mantid::MantidVec &X = WS->readX(0);
Mantid::MantidVec &Y = WS->dataY(0);
Mantid::MantidVec &E = WS->dataE(0);
for (size_t i = 0; i < Y.size(); ++i)
{
const double x = (X[i]+X[i+1])/2;
Y[i] = 5.1*exp(-0.5*pow((x-10)/1.0,2));
E[i] = 0.001;
}
}



private:
Expand Down

0 comments on commit 4cd8c6d

Please sign in to comment.