Skip to content
Snippets Groups Projects
Commit 04f98750 authored by Alex Buts's avatar Alex Buts
Browse files

refs #1637 Additional test to check if the load_MDWorkspace algorithm loads MD image correctly

parent 2de6fff0
No related merge requests found
......@@ -18,6 +18,7 @@ class Load_MDWorkspaceTest : public CxxTest::TestSuite
{
Load_MDWorkspace loader;
std::string targetWorkspaceName;
MDWorkspace *pLoadedWS;
public:
void testLoadMDWSInit(){
TSM_ASSERT_THROWS_NOTHING("loader should initialize without throwing",loader.initialize());
......@@ -31,6 +32,7 @@ class Load_MDWorkspaceTest : public CxxTest::TestSuite
TSM_ASSERT_THROWS("This file should not exist",loader.setPropertyValue("inFilename","../Test/AutoTestData/test_horace_reader.sqw"),std::invalid_argument);
// and so this
TSM_ASSERT_THROWS_NOTHING("The test file should exist",loader.setPropertyValue("inFilename","test_horace_reader.sqw"));
// TSM_ASSERT_THROWS_NOTHING("The test file should exist",loader.setPropertyValue("inFilename","fe_demo.sqw"));
}
void testMDWSExec(){
// does it add it to analysis data service? -- no
......@@ -44,14 +46,50 @@ class Load_MDWorkspaceTest : public CxxTest::TestSuite
Workspace_sptr result;
TSM_ASSERT_THROWS_NOTHING("We should retrieve loaded workspace without throwing",result=AnalysisDataService::Instance().retrieve(targetWorkspaceName));
MDWorkspace_sptr loadedWS=boost::dynamic_pointer_cast<MDWorkspace>(result);
TSM_ASSERT("MD workspace has not been casted coorectly",loadedWS.get()!=0);
MDWorkspace_sptr sp_loadedWS=boost::dynamic_pointer_cast<MDWorkspace>(result);
TSM_ASSERT("MD workspace has not been casted coorectly",sp_loadedWS.get()!=0);
pLoadedWS = sp_loadedWS.get();
//
TSM_ASSERT_EQUALS("The workspace should be 4D",4,loadedWS->getNumDims());
TSM_ASSERT_EQUALS("The workspace should be 4D",4,pLoadedWS->getNumDims());
TSM_ASSERT_EQUALS("The number of pixels contributed into this workspace should be 1523850",1523850,pLoadedWS->getNPoints());
TSM_ASSERT_EQUALS("The MD image in this workspace has to had 64 data cells",64,pLoadedWS->get_const_MDImage().getDataSize());
}
void testMDImageCorrect(){
// if the image we've loaded is correct image (the same as we've put there)
MDImage &IMG = pLoadedWS->get_const_MDImage();
std::vector<point3D> img_data;
std::vector<unsigned int> selection(2,0);
IMG.getPointData(selection,img_data);
double sum(0);
for(size_t i=0;i<img_data.size();i++){
sum+=img_data[i].S();
}
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0.65789,img_data[0 ].S(),1.e-4);
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0.37786,img_data[10].S(),1.e-4);
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0.0, img_data[15].S(),1.e-4);
TSM_ASSERT_DELTA("The sum of all signals in the signals selection should be specific value",7.3273, sum,1.e-4);
selection[0]=1;
selection[1]=1;
IMG.getPointData(selection,img_data);
sum = 0;
for(size_t i=0;i<img_data.size();i++){
sum+=img_data[i].S();
}
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0, img_data[ 0].S(),1.e-4);
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0.25612,img_data[ 1].S(),1.e-4);
TSM_ASSERT_DELTA("The signal in this cell should be specified value",0.15172,img_data[15].S(),1.e-4);
TSM_ASSERT_EQUALS("The number of pixels contributed into this workspace should be 1523850",1523850,loadedWS->getNPoints());
TSM_ASSERT_DELTA("The sum of all signals in the signals selection should be specific value",2.52227, sum,1.e-4);
TSM_ASSERT_EQUALS("The MD image in this workspace has to had 64 data cells",64,loadedWS->get_const_MDImage().getDataSize());
}
};
......
......@@ -2,21 +2,65 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_MDAlgorithms", "test_MDAlgorithms.vcxproj", "{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}"
ProjectSection(ProjectDependencies) = postProject
{75061EAA-4AB1-4969-99EA-103E4F74B70E} = {75061EAA-4AB1-4969-99EA-103E4F74B70E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MDAlgorithms", "..\..\..\Win32\Framework\MDAlgorithms\MDAlgorithms.vcxproj", "{75061EAA-4AB1-4969-99EA-103E4F74B70E}"
ProjectSection(ProjectDependencies) = postProject
{44C42D5C-37D6-4D66-AFC3-447E93F731BA} = {44C42D5C-37D6-4D66-AFC3-447E93F731BA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MDDataObjects", "..\..\..\Win32\Framework\MDDataObjects\MDDataObjects.vcxproj", "{44C42D5C-37D6-4D66-AFC3-447E93F731BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
MinSizeRel|Win32 = MinSizeRel|Win32
MinSizeRel|x64 = MinSizeRel|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
RelWithDebInfo|Win32 = RelWithDebInfo|Win32
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Debug|Win32.ActiveCfg = Debug|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Debug|Win32.Build.0 = Debug|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Debug|x64.ActiveCfg = Debug|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.MinSizeRel|Win32.ActiveCfg = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.MinSizeRel|Win32.Build.0 = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.MinSizeRel|x64.ActiveCfg = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Release|Win32.ActiveCfg = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Release|Win32.Build.0 = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.Release|x64.ActiveCfg = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.RelWithDebInfo|Win32.Build.0 = Release|Win32
{4C8D2E1C-650A-4CB4-8209-EC18AFB550C2}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Debug|Win32.ActiveCfg = Debug|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Debug|Win32.Build.0 = Debug|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Debug|x64.ActiveCfg = Debug|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Release|Win32.ActiveCfg = Release|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Release|Win32.Build.0 = Release|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.Release|x64.ActiveCfg = Release|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
{75061EAA-4AB1-4969-99EA-103E4F74B70E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|Win32.ActiveCfg = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|Win32.Build.0 = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|x64.ActiveCfg = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|x64.ActiveCfg = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|Win32.ActiveCfg = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|Win32.Build.0 = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|x64.ActiveCfg = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -52,7 +52,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir);..\..\..\Win32\bin\Debug;..\..\..\..\Third_Party\lib\win32</AdditionalLibraryDirectories>
<AdditionalDependencies>MDAlgorithms.lib;MDDataObjects.lib;MantidGeometry.lib;MantidAPI.lib;MantidKernel.lib</AdditionalDependencies>
<AdditionalDependencies>MantidMDAlgorithms.lib;MantidMDDataObjects.lib;MantidGeometry.lib;MantidAPI.lib;MantidKernel.lib</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
</Link>
<PreBuildEvent>
......
#ifndef FILE_TEST_DATA_GENERATOR_H
#define FILE_TEST_DATA_GENERATOR_H
//
......
......@@ -110,6 +110,7 @@ MD_FileTestDataGenerator::read_pix(MDDataPoints & sqw)
size_t
MD_FileTestDataGenerator::read_pix_subset(const MDImage &dnd,const std::vector<size_t> &selected_cells,size_t starting_cell,std::vector<char> &pix_buf, size_t &n_pix_in_buffer)
{
// pixels data generated assiuming 50^nDim lattice;
size_t ic(starting_cell),j;
unsigned int idim;
unsigned long max_data_size;
......@@ -117,17 +118,26 @@ MD_FileTestDataGenerator::read_pix_subset(const MDImage &dnd,const std::vector<s
const Geometry::MDGeometry *pCurrentGeom = dnd.getGeometry();
std::vector<std::string> dimID = pCurrentGeom->getBasisTags();
std::vector<std::vector<double> > dimPoints(this->nDims);
// data points;
std::vector<std::vector<float> > dimPoints(this->nDims);
// obtain dimensions and dimensions coordinates;
for(idim=0;idim<this->nDims;idim++){
const Geometry::IMDDimension *pDim = pCurrentGeom->get_constDimension(dimID[idim]).get();
pDim->getAxisPoints(dimPoints[idim]);
dimPoints[idim].resize(50);
double min = pDim->getMinimum();
double step = (pDim->getMaximum()-min)/50;
min+=0.5*step;
for(j=0;j<50;j++){
dimPoints[idim][j]=(float)(min+j*step);
}
}
// if data buffer is unsufficient even for one block of pixels, increase it (very inefficient)
if(pix_buf.size()<sizeof_pixel*(starting_cell+1)){
pix_buf.resize(sizeof_pixel*(starting_cell+1));
max_data_size = starting_cell+1;
// number of pixels in test data cell equal the cell number (+1 ?)
size_t n_pix_in_block = selected_cells[starting_cell]+1;
if(pix_buf.size()<sizeof_pixel*n_pix_in_block){
pix_buf.resize(sizeof_pixel*n_pix_in_block);
max_data_size = n_pix_in_block;
}else{
max_data_size = pix_buf.size()/sizeof_pixel;
}
......
......@@ -5,6 +5,7 @@
#include "MDDataObjects/MD_FileFormatFactory.h"
#include "Poco/Path.h"
#include "MantidKernel/System.h"
#include "MantidKernel/ConfigService.h"
#include "MDDataObjects/MD_FileHoraceReader.h"
#include "MDDataObjects/MDImage.h"
......@@ -73,6 +74,7 @@ class HoraceReaderTest : public CxxTest::TestSuite
{
public:
void testConstructor(){
std::string instrumentPath = Kernel::ConfigService::Instance().getString("instrumentDefinition.directory");
std::string test_file;
std::string testFile = findTestFileLocation("../../../../Test/AutoTestData/test_horace_reader.sqw");
......
......@@ -3,22 +3,46 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_MDD", "test_MDD.vcxproj", "{35BD3896-7AB3-4781-A28A-279CBBE6AD68}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MDDataObjects", "..\..\..\Win32\Framework\MDDataObjects\MDDataObjects.vcxproj", "{44C42D5C-37D6-4D66-AFC3-447E93F731BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
MinSizeRel|Win32 = MinSizeRel|Win32
MinSizeRel|x64 = MinSizeRel|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
RelWithDebInfo|Win32 = RelWithDebInfo|Win32
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Debug|Win32.ActiveCfg = Debug|Win32
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Debug|Win32.Build.0 = Debug|Win32
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Debug|x64.ActiveCfg = Debug|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Debug|x64.Build.0 = Debug|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.MinSizeRel|Win32.ActiveCfg = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.MinSizeRel|x64.ActiveCfg = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.MinSizeRel|x64.Build.0 = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Release|Win32.ActiveCfg = Release|Win32
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Release|Win32.Build.0 = Release|Win32
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Release|x64.ActiveCfg = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.Release|x64.Build.0 = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.RelWithDebInfo|Win32.ActiveCfg = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{35BD3896-7AB3-4781-A28A-279CBBE6AD68}.RelWithDebInfo|x64.Build.0 = Release|x64
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|Win32.ActiveCfg = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|Win32.Build.0 = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Debug|x64.ActiveCfg = Debug|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.MinSizeRel|x64.ActiveCfg = MinSizeRel|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|Win32.ActiveCfg = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|Win32.Build.0 = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.Release|x64.ActiveCfg = Release|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
{44C42D5C-37D6-4D66-AFC3-447E93F731BA}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment