Commit 47a7cf31 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #26878 clang format for ALF view tests

parent 586d1a31
......@@ -10,14 +10,14 @@
#include <gmock/gmock.h>
#include "ALFCustomInstrumentModel.h"
#include "ALFCustomInstrumentView.h"
#include "ALFCustomInstrumentPresenter.h"
#include "ALFCustomInstrumentView.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPanePresenter.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
......@@ -31,83 +31,92 @@ using namespace MantidQt::CustomInterfaces;
using Mantid::Geometry::Instrument;
using namespace MantidQt::MantidWidgets;
class mockALFData{
class mockALFData {
public:
mockALFData(const std::string &name, const std::string &instName, const int &run, const bool TOF):m_name(name){
std::set<long int> masks;
auto ws = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(1, 10, false, 0.1, 0.2, 0.01,0.3,masks);
//set instrument
mockALFData(const std::string &name, const std::string &instName,
const int &run, const bool TOF)
: m_name(name) {
std::set<long int> masks;
auto ws = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(
1, 10, false, 0.1, 0.2, 0.01, 0.3, masks);
// set instrument
boost::shared_ptr<Instrument> inst = boost::make_shared<Instrument>();
inst->setName(instName);
//set run
ws->mutableRun().addProperty("run_number", run,true);
// set units
// set run
ws->mutableRun().addProperty("run_number", run, true);
// set units
ws->setInstrument(inst);
auto axis = ws->getAxis(0);
if(TOF){axis->setUnit("TOF");}else{
axis->setUnit("dSpacing");}
AnalysisDataService::Instance().addOrReplace(m_name, ws);
}
~mockALFData(){
AnalysisDataService::Instance().remove(m_name);
}
if (TOF) {
axis->setUnit("TOF");
} else {
axis->setUnit("dSpacing");
}
AnalysisDataService::Instance().addOrReplace(m_name, ws);
}
~mockALFData() { AnalysisDataService::Instance().remove(m_name); }
private:
std::string m_name;
std::string m_name;
};
class MockALFCustomInstrumentModel : public IALFCustomInstrumentModel {
public:
MockALFCustomInstrumentModel(){};
~MockALFCustomInstrumentModel(){};
MockALFCustomInstrumentModel(){};
~MockALFCustomInstrumentModel(){};
MOCK_METHOD1(loadAlg, void(const std::string &name));
MOCK_METHOD0(transformData, void());
MOCK_METHOD0(isDataValid, std::map<std::string, bool>());
MOCK_METHOD1(storeSingleTube, void(const std::string &name));
MOCK_METHOD0(averageTube,void());
MOCK_METHOD1(hasTubeBeenExtracted, bool(const std::string &name));
MOCK_METHOD1(extractTubeCondition, bool(std::map<std::string, bool> tabBools));
MOCK_METHOD1(averageTubeCondition, bool(std::map<std::string, bool> tabBools));
MOCK_METHOD0(extractSingleTube, void());
MOCK_METHOD0(WSName, std::string());
MOCK_METHOD0(getDefaultFunction, Mantid::API::CompositeFunction_sptr());
MOCK_METHOD0(loadEmptyInstrument, void());
MOCK_METHOD1(loadData, std::pair<int, std::string>(const std::string &name));
MOCK_METHOD1(setCurrentRun, void(int &run));
MOCK_METHOD0(getCurrentRun, int());
MOCK_METHOD0(rename, void());
MOCK_METHOD0(remove, void());
MOCK_METHOD0(dataFileName, std::string());
MOCK_METHOD0(currentRun, int());
MOCK_METHOD1(isErrorCode, bool(const int run));
MOCK_METHOD0(getInstrument, const std::string());
MOCK_METHOD0(getTmpName, const std::string());
MOCK_METHOD0(getWSName, const std::string());
MOCK_METHOD1(loadAlg, void(const std::string &name));
MOCK_METHOD0(transformData, void());
MOCK_METHOD0(isDataValid, std::map<std::string, bool>());
MOCK_METHOD1(storeSingleTube, void(const std::string &name));
MOCK_METHOD0(averageTube, void());
MOCK_METHOD1(hasTubeBeenExtracted, bool(const std::string &name));
MOCK_METHOD1(extractTubeCondition,
bool(std::map<std::string, bool> tabBools));
MOCK_METHOD1(averageTubeCondition,
bool(std::map<std::string, bool> tabBools));
MOCK_METHOD0(extractSingleTube, void());
MOCK_METHOD0(WSName, std::string());
MOCK_METHOD0(getDefaultFunction, Mantid::API::CompositeFunction_sptr());
MOCK_METHOD0(loadEmptyInstrument, void());
MOCK_METHOD1(loadData, std::pair<int, std::string>(const std::string &name));
MOCK_METHOD1(setCurrentRun, void(int &run));
MOCK_METHOD0(getCurrentRun, int());
MOCK_METHOD0(rename, void());
MOCK_METHOD0(remove, void());
MOCK_METHOD0(dataFileName, std::string());
MOCK_METHOD0(currentRun, int());
MOCK_METHOD1(isErrorCode, bool(const int run));
MOCK_METHOD0(getInstrument, const std::string());
MOCK_METHOD0(getTmpName, const std::string());
MOCK_METHOD0(getWSName, const std::string());
};
class MockALFCustomInstrumentView : public IALFCustomInstrumentView {
public:
explicit MockALFCustomInstrumentView(const std::string &instrument,
explicit MockALFCustomInstrumentView(const std::string &instrument,
QWidget *parent = nullptr){};
~MockALFCustomInstrumentView(){};
~MockALFCustomInstrumentView(){};
MOCK_METHOD1(observeExtractSingleTube, void(Observer *listner));
MOCK_METHOD1(observeAverageTube, void(Observer *listner));
MOCK_METHOD1(addSpectrum, void(std::string name));
MOCK_METHOD1(setupAnalysisPane, void(IPlotFitAnalysisPaneView *analysis));
MOCK_METHOD0(getFile, std::string());
MOCK_METHOD1(setRunQuietly, void(const std::string &runNumber));
MOCK_METHOD1(observeLoadRun, void( Observer *listener));
MOCK_METHOD1(warningBox, void(const std::string &error));
MOCK_METHOD1(setInstrumentWidget, void(InstrumentWidget *instrument));
MOCK_METHOD0(getInstrumentView, InstrumentWidget*());
MOCK_METHOD2(setUpInstrument,void(const std::string &fileName, std::vector<std::function<bool(std::map<std::string,bool>)>> &binders));
MOCK_METHOD1(addObserver, void(std::tuple<std::string, Observer *> &listener));
MOCK_METHOD1(setupInstrumentAnalysisSplitters, void(QWidget *analysis));
MOCK_METHOD0(setupHelp, void());
MOCK_METHOD1(observeExtractSingleTube, void(Observer *listner));
MOCK_METHOD1(observeAverageTube, void(Observer *listner));
MOCK_METHOD1(addSpectrum, void(std::string name));
MOCK_METHOD1(setupAnalysisPane, void(IPlotFitAnalysisPaneView *analysis));
MOCK_METHOD0(getFile, std::string());
MOCK_METHOD1(setRunQuietly, void(const std::string &runNumber));
MOCK_METHOD1(observeLoadRun, void(Observer *listener));
MOCK_METHOD1(warningBox, void(const std::string &error));
MOCK_METHOD1(setInstrumentWidget, void(InstrumentWidget *instrument));
MOCK_METHOD0(getInstrumentView, InstrumentWidget *());
MOCK_METHOD2(
setUpInstrument,
void(const std::string &fileName,
std::vector<std::function<bool(std::map<std::string, bool>)>>
&binders));
MOCK_METHOD1(addObserver,
void(std::tuple<std::string, Observer *> &listener));
MOCK_METHOD1(setupInstrumentAnalysisSplitters, void(QWidget *analysis));
MOCK_METHOD0(setupHelp, void());
};
// want a partial mock of the model - removes the functions that just run algs.
......
......@@ -40,7 +40,7 @@ void ALFCustomInstrumentModel::loadAlg(const std::string &name) {
alg->setProperty("Filename", name);
alg->setProperty("OutputWorkspace", getTmpName()); // write to tmp ws
alg->execute();
}
}
/*
* Loads data for use in ALFView
......@@ -85,8 +85,8 @@ std::map<std::string, bool> ALFCustomInstrumentModel::isDataValid() {
auto axis = ws->getAxis(0);
auto unit = axis->unit()->unitID();
bool isItDSpace = true;
if (unit != "dSpacing"){
isItDSpace = false;
if (unit != "dSpacing") {
isItDSpace = false;
}
return {{"IsValidInstrument", isItALF}, {"IsItDSpace", isItDSpace}};
}
......
......@@ -21,22 +21,20 @@ class DLLExport IALFCustomInstrumentModel
public:
// virtual so we can patch them later
virtual void loadAlg(const std::string &name)=0;
virtual void transformData()=0;
virtual std::map<std::string, bool> isDataValid()=0;
virtual void storeSingleTube(const std::string &name)=0;
virtual void averageTube()=0;
virtual bool hasTubeBeenExtracted(const std::string &name)=0;
virtual bool extractTubeCondition(std::map<std::string, bool> tabBools)=0;
virtual bool averageTubeCondition(std::map<std::string, bool> tabBools)=0;
virtual void extractSingleTube()=0;
virtual std::string WSName()=0;
virtual Mantid::API::CompositeFunction_sptr getDefaultFunction()=0;
virtual void loadAlg(const std::string &name) = 0;
virtual void transformData() = 0;
virtual std::map<std::string, bool> isDataValid() = 0;
virtual void storeSingleTube(const std::string &name) = 0;
virtual void averageTube() = 0;
virtual bool hasTubeBeenExtracted(const std::string &name) = 0;
virtual bool extractTubeCondition(std::map<std::string, bool> tabBools) = 0;
virtual bool averageTubeCondition(std::map<std::string, bool> tabBools) = 0;
virtual void extractSingleTube() = 0;
virtual std::string WSName() = 0;
virtual Mantid::API::CompositeFunction_sptr getDefaultFunction() = 0;
};
class DLLExport ALFCustomInstrumentModel
: public IALFCustomInstrumentModel{
class DLLExport ALFCustomInstrumentModel : public IALFCustomInstrumentModel {
public:
ALFCustomInstrumentModel();
......@@ -55,20 +53,20 @@ public:
std::string WSName() override;
Mantid::API::CompositeFunction_sptr getDefaultFunction() override;
void loadEmptyInstrument() override { m_base->loadEmptyInstrument(); };
void setCurrentRun(int &run) override { m_base->setCurrentRun(run); };
int getCurrentRun() override { return m_base->getCurrentRun(); };
void rename() override { m_base->rename(); };
void remove() override { m_base->remove(); };
std::string dataFileName() override { return m_base->dataFileName(); };
int currentRun() override {return m_base->currentRun(); };
int currentRun() override { return m_base->currentRun(); };
bool isErrorCode(const int run) override { return m_base->isErrorCode(run); };
const std::string getInstrument() override { return m_base->getInstrument(); };
const std::string getInstrument() override {
return m_base->getInstrument();
};
const std::string getTmpName() override { return m_base->getTmpName(); };
const std::string getWSName() override { return m_base->getWSName(); };
private:
int m_numberOfTubesInAverage;
MantidWidgets::BaseCustomInstrumentModel *m_base;
......
......@@ -19,8 +19,8 @@ namespace CustomInterfaces {
ALFCustomInstrumentPresenter::ALFCustomInstrumentPresenter(
IALFCustomInstrumentView *view, IALFCustomInstrumentModel *model,
MantidWidgets::IPlotFitAnalysisPanePresenter *analysisPane)
: BaseCustomInstrumentPresenter(view, model, analysisPane),
m_view(view), m_model(model), m_analysisPane(analysisPane),
: BaseCustomInstrumentPresenter(view, model, analysisPane), m_view(view),
m_model(model), m_analysisPane(analysisPane),
m_extractSingleTubeObserver(nullptr), m_averageTubeObserver(nullptr) {
addInstrument();
}
......
......@@ -19,7 +19,7 @@
namespace MantidQt {
namespace CustomInterfaces {
class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
: public MantidWidgets::BaseCustomInstrumentPresenter {
Q_OBJECT
......@@ -38,6 +38,7 @@ public:
void loadSideEffects() override;
std::pair<instrumentSetUp, instrumentObserverOptions> setupALFInstrument();
public:
void setUpInstrumentAnalysisSplitter() override;
......
......@@ -88,7 +88,8 @@ void ALFCustomInstrumentView::setupAnalysisPane(
// keep a copy here so we can use a custom class
m_analysisPane = analysis;
// just adds it to the view
BaseCustomInstrumentView::setupInstrumentAnalysisSplitters(analysis->getQWidget());
BaseCustomInstrumentView::setupInstrumentAnalysisSplitters(
analysis->getQWidget());
}
void ALFCustomInstrumentView::addSpectrum(const std::string &wsName) {
......
......@@ -23,16 +23,17 @@ namespace CustomInterfaces {
class MANTIDQT_DIRECT_DLL IALFCustomInstrumentView
: public virtual MantidWidgets::IBaseCustomInstrumentView {
public:
virtual void observeExtractSingleTube(Observer *listner)=0;
virtual void observeAverageTube(Observer *listner)=0;
virtual void observeExtractSingleTube(Observer *listner) = 0;
virtual void observeAverageTube(Observer *listner) = 0;
virtual void addSpectrum(std::string wsName) = 0;
virtual void setupAnalysisPane(MantidWidgets::IPlotFitAnalysisPaneView *analysis) = 0;
virtual void
setupAnalysisPane(MantidWidgets::IPlotFitAnalysisPaneView *analysis) = 0;
};
class DLLExport ALFCustomInstrumentView
: public MantidWidgets::BaseCustomInstrumentView,
public IALFCustomInstrumentView
{Q_OBJECT
public IALFCustomInstrumentView {
Q_OBJECT
public:
explicit ALFCustomInstrumentView(const std::string &instrument,
......@@ -44,7 +45,8 @@ public:
std::vector<std::function<bool(std::map<std::string, bool>)>>
&binders) override final;
void addObserver(std::tuple<std::string, Observer *> &listener) override final;
void
addObserver(std::tuple<std::string, Observer *> &listener) override final;
void addSpectrum(std::string wsName) override final;
void setupAnalysisPane(
MantidWidgets::IPlotFitAnalysisPaneView *analysis) override final;
......
......@@ -15,8 +15,8 @@
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidGeometry/Instrument.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidGeometry/Instrument.h"
#include <string>
#include <utility>
......@@ -26,209 +26,220 @@ using namespace MantidQt::CustomInterfaces;
using namespace testing;
using Mantid::Geometry::Instrument;
namespace{
const std::string notALFFile = "ZOOM00006113.nxs";
namespace {
const std::string notALFFile = "ZOOM00006113.nxs";
}
class ALFCustomInstrumentModelTest : public CxxTest::TestSuite {
public:
ALFCustomInstrumentModelTest() { FrameworkManager::Instance(); }
static ALFCustomInstrumentModelTest *createSuite() { return new ALFCustomInstrumentModelTest(); }
static void destroySuite(ALFCustomInstrumentModelTest *suite) { delete suite; }
static ALFCustomInstrumentModelTest *createSuite() {
return new ALFCustomInstrumentModelTest();
}
void setUp() override { m_model = new PartMockALFCustomInstrumentModel();
static void destroySuite(ALFCustomInstrumentModelTest *suite) {
delete suite;
}
void setUp() override { m_model = new PartMockALFCustomInstrumentModel(); }
void tearDown() override {
AnalysisDataService::Instance().clear();
delete m_model;
}
void test_loadData() {
auto data = mockALFData("ALF_tmp","ALF",6113,true);
TS_ASSERT_EQUALS(m_model->getLoadCount(),0);
auto data = mockALFData("ALF_tmp", "ALF", 6113, true);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 0);
std::pair<int, std::string> loadResult = m_model->loadData(notALFFile);
TS_ASSERT_EQUALS(m_model->getLoadCount(),1);
TS_ASSERT_EQUALS(m_model->getTransformCount(),1);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 1);
TS_ASSERT_EQUALS(m_model->getTransformCount(), 1);
TS_ASSERT_EQUALS(loadResult.first, 6113);
TS_ASSERT_EQUALS(loadResult.second, "success");
}
void test_loadDataNotALF(){
void test_loadDataNotALF() {
auto data = mockALFData("ALF_tmp", "EMU", 6113, true);
TS_ASSERT_EQUALS(m_model->getLoadCount(),0);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 0);
std::pair<int, std::string> loadResult = m_model->loadData(notALFFile);
TS_ASSERT_EQUALS(m_model->getLoadCount(),1);
TS_ASSERT_EQUALS(m_model->getTransformCount(),0);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 1);
TS_ASSERT_EQUALS(m_model->getTransformCount(), 0);
TS_ASSERT_EQUALS(loadResult.first, 6113);
TS_ASSERT_EQUALS(loadResult.second, "Not the correct instrument, expected ALF");
TS_ASSERT_EQUALS(loadResult.second,
"Not the correct instrument, expected ALF");
}
void test_loadDataDSpace(){
void test_loadDataDSpace() {
auto data = mockALFData("ALF_tmp", "ALF", 6113, false);
TS_ASSERT_EQUALS(m_model->getLoadCount(),0);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 0);
std::pair<int, std::string> loadResult = m_model->loadData(notALFFile);
TS_ASSERT_EQUALS(m_model->getLoadCount(),1);
TS_ASSERT_EQUALS(m_model->getTransformCount(),0);
TS_ASSERT_EQUALS(m_model->getLoadCount(), 1);
TS_ASSERT_EQUALS(m_model->getTransformCount(), 0);
TS_ASSERT_EQUALS(loadResult.first, 6113);
TS_ASSERT_EQUALS(loadResult.second, "success");
}
void test_isDataValid(){
void test_isDataValid() {
auto data = mockALFData("ALF_tmp", "ALF", 6113, true);
std::map<std::string, bool> isDataValid = m_model->isDataValid();
TS_ASSERT(isDataValid["IsValidInstrument"])
TS_ASSERT(!isDataValid["IsItDSpace"])
}
}
void test_isDataValidNotALF(){
auto data = mockALFData("ALF_tmp", "EMU", 6113, true);
void test_isDataValidNotALF() {
auto data = mockALFData("ALF_tmp", "EMU", 6113, true);
std::map<std::string, bool> isDataValid = m_model->isDataValid();
TS_ASSERT(!isDataValid["IsValidInstrument"])
TS_ASSERT(!isDataValid["IsItDSpace"])
}
void test_isDataValidDSpace(){
void test_isDataValidDSpace() {
auto data = mockALFData("ALF_tmp", "ALF", 6113, false);
std::map<std::string, bool> isDataValid = m_model->isDataValid();
TS_ASSERT(isDataValid["IsValidInstrument"]);
TS_ASSERT(isDataValid["IsItDSpace"]);
}
void test_transformData(){
return;
}
void test_transformData() { return; }
void test_storeSingleTube(){
void test_storeSingleTube() {
auto data = mockALFData("CURVES", "ALF", 6113, false);
m_model->storeSingleTube("test");
auto outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("extractedTubes_test");
TS_ASSERT_DELTA(outputWS->readX(0)[0],-22.9, 0.1);
TS_ASSERT_EQUALS(outputWS->readY(0)[0],0.2);
TS_ASSERT_DELTA(outputWS->readX(0)[9],492.7, 0.1);
TS_ASSERT_EQUALS(outputWS->readY(0)[9],0.2);
auto outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
"extractedTubes_test");
TS_ASSERT_DELTA(outputWS->readX(0)[0], -22.9, 0.1);
TS_ASSERT_EQUALS(outputWS->readY(0)[0], 0.2);
TS_ASSERT_DELTA(outputWS->readX(0)[9], 492.7, 0.1);
TS_ASSERT_EQUALS(outputWS->readY(0)[9], 0.2);
AnalysisDataService::Instance().remove("extractedTubes_test");
}
void test_averageTube(){
void test_averageTube() {
int run = 6113;
auto data = mockALFData("CURVES", "ALF", run, false);
m_model->setCurrentRun(run);
m_model->extractSingleTube();
// check original y values
auto tmpWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("extractedTubes_ALF6113");
TS_ASSERT_EQUALS(tmpWS->readY(0)[1],0.2);
TS_ASSERT_EQUALS(tmpWS->readY(0)[9],0.2);
auto tmpWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
"extractedTubes_ALF6113");
TS_ASSERT_EQUALS(tmpWS->readY(0)[1], 0.2);
TS_ASSERT_EQUALS(tmpWS->readY(0)[9], 0.2);
// create another ws to add
auto ws = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(1, 10, false, 1.1, 2.2, 0.01,0.3);
auto ws = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(
1, 10, false, 1.1, 2.2, 0.01, 0.3);
boost::shared_ptr<Instrument> inst = boost::make_shared<Instrument>();
inst->setName("ALF");
ws->mutableRun().addProperty("run_number", run,true);
ws->mutableRun().addProperty("run_number", run, true);
ws->setInstrument(inst);
auto axis = ws->getAxis(0);
axis->setUnit("dSpacing");
AnalysisDataService::Instance().addOrReplace("CURVES", ws);
// check second WS y values
TS_ASSERT_DELTA(ws->readY(0)[1], 2.2, 0.001);
TS_ASSERT_DELTA(ws->readY(0)[9], 2.2, 0.001);
TS_ASSERT_DELTA(ws->readY(0)[1], 2.2, 0.001);
TS_ASSERT_DELTA(ws->readY(0)[9], 2.2, 0.001);
m_model->averageTube();
// check averages: (2.2+0.2)/2 = 2.4/2 = 1.2
auto outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("extractedTubes_ALF6113");
TS_ASSERT_DELTA(outputWS->readX(0)[1],34.4, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[1], 1.2, 0.01);
TS_ASSERT_DELTA(outputWS->readX(0)[9],492.7, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[9], 1.2, 0.01);
auto outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
"extractedTubes_ALF6113");
TS_ASSERT_DELTA(outputWS->readX(0)[1], 34.4, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[1], 1.2, 0.01);
TS_ASSERT_DELTA(outputWS->readX(0)[9], 492.7, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[9], 1.2, 0.01);
// create another ws to add
auto ws3 = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(1, 10, false, 1.1, 3.2, 0.01,0.3);
auto ws3 = WorkspaceCreationHelper::create2DWorkspaceWithValuesAndXerror(
1, 10, false, 1.1, 3.2, 0.01, 0.3);
inst = boost::make_shared<Instrument>();
inst->setName("ALF");
ws3->mutableRun().addProperty("run_number", run,true);
ws3->mutableRun().addProperty("run_number", run, true);
ws3->setInstrument(inst);
axis = ws3->getAxis(0);
axis->setUnit("dSpacing");
AnalysisDataService::Instance().addOrReplace("CURVES", ws3);
// check second WS y values
TS_ASSERT_DELTA(ws3->readY(0)[1], 3.2, 0.001);
TS_ASSERT_DELTA(ws3->readY(0)[9], 3.2, 0.001);
TS_ASSERT_DELTA(ws3->readY(0)[1], 3.2, 0.001);
TS_ASSERT_DELTA(ws3->readY(0)[9], 3.2, 0.001);
m_model->averageTube();
// check averages: (2.2+0.2+3.2)/2 = 5.6/3 = 1.8666
outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("extractedTubes_ALF6113");
TS_ASSERT_DELTA(outputWS->readX(0)[1],34.4, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[1], 1.86, 0.01);
TS_ASSERT_DELTA(outputWS->readX(0)[9],492.7, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[9], 1.86, 0.01);
outputWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
"extractedTubes_ALF6113");
TS_ASSERT_DELTA(outputWS->readX(0)[1], 34.4, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[1], 1.86, 0.01);
TS_ASSERT_DELTA(outputWS->readX(0)[9], 492.7, 0.1);
TS_ASSERT_DELTA(outputWS->readY(0)[9], 1.86, 0.01);
AnalysisDataService::Instance().remove("extractedTubes_ALF6113");
}
void test_hasTubeBeenExtracted(){