Commit 0893c3cb authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #3023: Removed MAKE_MDEVENTS flag from CMAKE. Made a test helper for...

Refs #3023: Removed MAKE_MDEVENTS flag from CMAKE. Made a test helper for MDEvents to reduce code duplication. Refs #2897: No warnings in MDEvents.
parent 824132d4
......@@ -82,7 +82,6 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( MAKE_VATES OFF CACHE BOOL "Switch for compiling the Vates project")
set ( MAKE_MULTIDIMENSIONAL OFF CACHE BOOL "Switch for compiling the MD framework projects")
set ( REDUCER_TEST OFF CACHE BOOL "Switch for running flaky Reducer test")
set ( MAKE_MDEVENTS ON CACHE BOOL "Switch for compiling the MDEvents project")
set ( CXXTEST_SINGLE_LOGFILE CACHE BOOL "Switch to have the tests for each package run together")
set ( CXXTEST_ADD_PERFORMANCE OFF CACHE BOOL "Switch to add Performance tests to the list of tests run by ctest?")
......@@ -90,9 +89,6 @@ if ( MAKE_VATES )
if( NOT MAKE_MULTIDIMENSIONAL )
message(SEND_ERROR "Cannot Make VATES visualisation without MAKE_MULTIDIMENSIONAL framework code.")
endif( NOT MAKE_MULTIDIMENSIONAL )
if( NOT MAKE_MDEVENTS )
message(SEND_ERROR "Cannot Make VATES visualisation without MAKE_MDEVENTS framework code.")
endif( NOT MAKE_MDEVENTS )
add_subdirectory ( Vates )
endif ( MAKE_VATES )
......
......@@ -98,18 +98,17 @@ if( MAKE_MULTIDIMENSIONAL )
include_directories(MDAlgorithms/inc)
endif ()
if ( MAKE_MDEVENTS )
add_subdirectory (MDEvents)
set(MANTIDLIBS ${MANTIDLIBS} MDEvents)
include_directories(MDEvents/inc)
endif ()
# As of May 15, 2011, MDEvents is not an optional flag and is included in the main build.
add_subdirectory (MDEvents)
set(MANTIDLIBS ${MANTIDLIBS} MDEvents)
include_directories(MDEvents/inc)
###########################################################################
# Add a custom target to build all of the Framework
###########################################################################
set ( FRAMEWORK_LIBS Kernel Geometry API PythonAPI DataObjects
DataHandling Nexus Algorithms CurveFitting ICat
DataHandling Nexus Algorithms CurveFitting ICat MDEvents
)
if ( MAKE_VATES )
......
#ifndef MANTID_DATAHANDLING_MaskPeaksWorkspaceTEST_H_
#define MANTID_DATAHANDLING_MaskPeaksWorkspaceTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include <iostream>
#include <iomanip>
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/MaskPeaksWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidKernel/System.h"
#include "MantidKernel/Timer.h"
#include "MantidTestHelpers/AlgorithmHelper.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MDEventsTestHelper.hh"
#include <cxxtest/TestSuite.h>
#include <iomanip>
#include <iostream>
using namespace Mantid;
using namespace Mantid::Kernel;
......@@ -24,68 +24,6 @@ using namespace Mantid::DataHandling;
class MaskPeaksWorkspaceTest : public CxxTest::TestSuite
{
public:
/** Create an EventWorkspace containing fake data
* of single-crystal diffraction.
*
* @return EventWorkspace_sptr
*/
EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents)
{
int numPixels = 10000;
int numBins = 1600;
double binDelta = 10.0;
EventWorkspace_sptr retVal(new EventWorkspace);
retVal->initialize(numPixels,1,1);
// --------- Load the instrument -----------
LoadInstrument * loadInst = new LoadInstrument();
loadInst->initialize();
loadInst->setPropertyValue("Filename", "IDFs_for_UNIT_TESTING/MINITOPAZ_Definition.xml");
loadInst->setProperty<MatrixWorkspace_sptr> ("Workspace", retVal);
loadInst->execute();
delete loadInst;
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();
DateAndTime run_start("2010-01-01");
for (int pix = 0; pix < numPixels; pix++)
{
for (int i=0; i<numEvents; i++)
{
retVal->getEventListAtPixelID(pix) += TofEvent((i+0.5)*binDelta, run_start+double(i));
}
}
retVal->doneLoadingData();
//Create the x-axis for histogramming.
MantidVecPtr x1;
MantidVec& xRef = x1.access();
xRef.resize(numBins);
for (int i = 0; i < numBins; ++i)
{
xRef[i] = i*binDelta;
}
//Set all the histograms at once.
retVal->setAllX(x1);
// Some sanity checks
TS_ASSERT_EQUALS( retVal->getInstrument()->getName(), "MINITOPAZ");
detid2det_map dets;
retVal->getInstrument()->getDetectors(dets);
TS_ASSERT_EQUALS( dets.size(), 100*100);
return retVal;
}
void setUp()
{
Mantid::Kernel::ConfigService::Instance().setString("default.facility", "TEST");
}
void test_Init()
{
......@@ -100,7 +38,7 @@ public:
{
int numEventsPer = 100;
MatrixWorkspace_sptr inputW = createDiffractionEventWorkspace(numEventsPer);
MatrixWorkspace_sptr inputW = MDEventsTestHelper::createDiffractionEventWorkspace(numEventsPer);
EventWorkspace_sptr in_ws = boost::dynamic_pointer_cast<EventWorkspace>( inputW );
AnalysisDataService::Instance().addOrReplace("testInEW", in_ws);
if (type == WEIGHTED)
......
......@@ -346,7 +346,7 @@ namespace MDEvents
size_t lastNumBoxes = ws->getBoxController()->getTotalNumMDBoxes();
if (DODEBUG) std::cout << cputim << ": initial setup. There are " << lastNumBoxes << " MDBoxes.\n";
for (int wi=0; wi < in_ws->getNumberHistograms(); wi++)
for (size_t wi=0; wi < in_ws->getNumberHistograms(); wi++)
{
// Equivalent of: this->convertEventList(wi);
EventList & el = in_ws->getEventList(wi);
......
#ifndef MANTID_MDEVENTS_BINTOMDHISTOWORKSPACETEST_H_
#define MANTID_MDEVENTS_BINTOMDHISTOWORKSPACETEST_H_
#include <cxxtest/TestSuite.h>
#include <iostream>
#include <iomanip>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <boost/math/special_functions/fpclassify.hpp>
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/ImplicitFunction.h"
#include "MantidAPI/ImplicitFunctionFactory.h"
......@@ -21,7 +14,13 @@
#include "MantidKernel/Timer.h"
#include "MantidMDEvents/BinToMDHistoWorkspace.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MDEventsTestHelper.hh"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include <boost/math/special_functions/fpclassify.hpp>
#include <cxxtest/TestSuite.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <iomanip>
#include <iostream>
using namespace Mantid::MDEvents;
using namespace Mantid::API;
......@@ -94,7 +93,7 @@ public:
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
IMDEventWorkspace_sptr in_ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
IMDEventWorkspace_sptr in_ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
AnalysisDataService::Instance().addOrReplace("BinToMDHistoWorkspaceTest_ws", in_ws);
// 1000 boxes with 1 event each
TS_ASSERT_EQUALS( in_ws->getNPoints(), 1000);
......@@ -142,7 +141,7 @@ public:
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
IMDEventWorkspace_sptr in_ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
IMDEventWorkspace_sptr in_ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
AnalysisDataService::Instance().addOrReplace("BinToMDHistoWorkspaceTest_ws", in_ws);
// 1000 boxes with 1 event each
TS_ASSERT_EQUALS( in_ws->getNPoints(), 1000);
......@@ -184,7 +183,7 @@ public:
void setUp()
{
Mantid::Kernel::CPUTimer tim;
in_ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1000);
in_ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1000);
// 1000 boxes with 1000 event each
TS_ASSERT_EQUALS( in_ws->getNPoints(), 1000*1000);
in_ws->splitAllIfNeeded(NULL);
......
#ifndef MANTID_MDEVENTS_FAKEMDEVENTDATATEST_H_
#define MANTID_MDEVENTS_FAKEMDEVENTDATATEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include "MantidKernel/Timer.h"
#include "MantidMDEvents/FakeMDEventData.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MDEventsTestHelper.hh"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include <cxxtest/TestSuite.h>
#include <iomanip>
#include <iostream>
using namespace Mantid::MDEvents;
using namespace Mantid::API;
......@@ -35,7 +34,7 @@ public:
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
IMDEventWorkspace_sptr in_ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
IMDEventWorkspace_sptr in_ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1);
AnalysisDataService::Instance().addOrReplace("FakeMDEventDataTest_ws", in_ws);
// 1000 boxes with 1 event each
......
#ifndef MDEVENTWORKSPACETEST_H
#define MDEVENTWORKSPACETEST_H
#include <cxxtest/TestSuite.h>
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
#include "MantidKernel/ProgressText.h"
#include "MantidKernel/Timer.h"
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
#include "MantidMDEvents/BoxController.h"
#include "MantidMDEvents/CoordTransformDistance.h"
#include "MantidMDEvents/MDBox.h"
......@@ -13,15 +11,16 @@
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidMDEvents/MDGridBox.h"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include <boost/random/linear_congruential.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/variate_generator.hpp>
#include <cxxtest/TestSuite.h>
#include <map>
#include <memory>
#include <vector>
#include "MDEventsTestHelper.hh"
using namespace Mantid;
using namespace Mantid::Kernel;
......@@ -116,7 +115,7 @@ public:
if (DODEBUG) prog = new ProgressText(0.0, 1.0, 10, false);
typedef MDGridBox<MDEvent<2>,2> box_t;
MDEventWorkspace2::sptr b = MDEventsHelper::makeMDEW<2>(10, 0.0, 10.0);
MDEventWorkspace2::sptr b = MDEventsTestHelper::makeMDEW<2>(10, 0.0, 10.0);
box_t * subbox;
// Manually set some of the tasking parameters
......@@ -240,7 +239,7 @@ public:
size_t binlen = 5; // And bin more coarsely
// 10x10x10 eventWorkspace
MDEventWorkspace3::sptr ws = MDEventsHelper::makeMDEW<3>(len, 0.0, size);
MDEventWorkspace3::sptr ws = MDEventsTestHelper::makeMDEW<3>(len, 0.0, size);
// Put one event per bin
for (double x=0; x<len; x++)
......@@ -322,7 +321,7 @@ public:
void test_integrateSphere()
{
// 10x10x10 eventWorkspace
MDEventWorkspace3::sptr ws = MDEventsHelper::makeMDEW<3>(10, 0.0, 10.0, 1 /*event per box*/);
MDEventWorkspace3::sptr ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1 /*event per box*/);
TS_ASSERT_EQUALS( ws->getNPoints(), 1000);
// The sphere transformation
......
#ifndef MANTID_MDEVENTS_MAKEDIFFRACTIONMDEVENTWORKSPACETEST_H_
#define MANTID_MDEVENTS_MAKEDIFFRACTIONMDEVENTWORKSPACETEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidKernel/System.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include <iostream>
#include <iomanip>
#include "MantidKernel/Timer.h"
#include "MantidMDEvents/MakeDiffractionMDEventWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidTestHelpers/AlgorithmHelper.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include <cxxtest/TestSuite.h>
#include <iomanip>
#include <iostream>
using namespace Mantid;
using namespace Mantid::Kernel;
......@@ -24,68 +24,6 @@ using namespace Mantid::MDEvents;
class MakeDiffractionMDEventWorkspaceTest : public CxxTest::TestSuite
{
public:
/** Create an EventWorkspace containing fake data
* of single-crystal diffraction.
*
* @return EventWorkspace_sptr
*/
EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents)
{
int numPixels = 10000;
int numBins = 1600;
double binDelta = 10.0;
EventWorkspace_sptr retVal(new EventWorkspace);
retVal->initialize(numPixels,1,1);
// --------- Load the instrument -----------
LoadInstrument * loadInst = new LoadInstrument();
loadInst->initialize();
loadInst->setPropertyValue("Filename", "IDFs_for_UNIT_TESTING/MINITOPAZ_Definition.xml");
loadInst->setProperty<MatrixWorkspace_sptr> ("Workspace", retVal);
loadInst->execute();
delete loadInst;
// Populate the instrument parameters in this workspace - this works around a bug
retVal->populateInstrumentParameters();
DateAndTime run_start("2010-01-01");
for (int pix = 0; pix < numPixels; pix++)
{
for (int i=0; i<numEvents; i++)
{
retVal->getEventListAtPixelID(pix) += TofEvent((i+0.5)*binDelta, run_start+double(i));
}
}
retVal->doneLoadingData();
//Create the x-axis for histogramming.
MantidVecPtr x1;
MantidVec& xRef = x1.access();
xRef.resize(numBins);
for (int i = 0; i < numBins; ++i)
{
xRef[i] = i*binDelta;
}
//Set all the histograms at once.
retVal->setAllX(x1);
// Some sanity checks
TS_ASSERT_EQUALS( retVal->getInstrument()->getName(), "MINITOPAZ");
detid2det_map dets;
retVal->getInstrument()->getDetectors(dets);
TS_ASSERT_EQUALS( dets.size(), 100*100);
return retVal;
}
void setUp()
{
Mantid::Kernel::ConfigService::Instance().setString("default.facility", "TEST");
}
void test_Init()
{
......@@ -99,7 +37,7 @@ public:
/** Test various combinations of OutputDimensions parameter */
void test_OutputDimensions_Parameter()
{
EventWorkspace_sptr in_ws = createDiffractionEventWorkspace(10);
EventWorkspace_sptr in_ws = MDEventsTestHelper::createDiffractionEventWorkspace(10);
AnalysisDataService::Instance().addOrReplace("testInEW", in_ws);
Algorithm_sptr alg;
......@@ -143,12 +81,12 @@ public:
{
int numEventsPer = 100;
EventWorkspace_sptr in_ws = createDiffractionEventWorkspace(numEventsPer);
EventWorkspace_sptr in_ws = MDEventsTestHelper::createDiffractionEventWorkspace(numEventsPer);
if (type == WEIGHTED)
in_ws *= 2.0;
if (type == WEIGHTED_NOTIME)
{
for (int i =0; i<in_ws->getNumberHistograms(); i++)
for (size_t i =0; i<in_ws->getNumberHistograms(); i++)
{
EventList & el = in_ws->getEventList(i);
el.compressEvents(0.0, &el);
......
......@@ -2,6 +2,7 @@ set ( SRC_FILES
src/AlgorithmHelper.cpp
src/WorkspaceCreationHelper.cpp
src/ComponentCreationHelper.cpp
src/MDEventsTestHelper.cpp
)
set ( INC_FILES
......@@ -9,10 +10,11 @@ set ( INC_FILES
inc/MantidTestHelpers/AlgorithmHelper.h
inc/MantidTestHelpers/WorkspaceCreationHelper.h
inc/MantidTestHelpers/ComponentCreationHelper.h
inc/MantidTestHelpers/MDEventsTestHelper.h
)
# Requires DataHandling for a load call
include_directories (../DataHandling/inc)
include_directories (../DataHandling/inc ../MDEvents/inc)
include_directories ( inc )
# For Windows:
......@@ -39,4 +41,4 @@ set ( TMP_MANTIDLIBS )
#add_executable(WikiMaker EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/src/WikiMaker.cpp )
add_executable(WikiMaker ${CMAKE_CURRENT_SOURCE_DIR}/src/WikiMaker.cpp )
target_link_libraries ( WikiMaker ${MANTIDLIBS} Algorithms DataHandling DataObjects Geometry )
target_link_libraries ( WikiMaker ${MANTIDLIBS} Algorithms DataHandling DataObjects Geometry MDEvents)
#ifndef MDEVENTSTEST_HELPER_H
#define MDEVENTSTEST_HELPER_H
//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include "MantidTestHelpers/DLLExport.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidMDEvents/BoxController.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/Utils.h"
#include "MantidMDEvents/BoxController.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidTestHelpers/DLLExport.h"
/** Set of helper methods for testing MDEventWorkspace things
*
* @author Janik Zikovsky
* @date March 29, 2011
* */
namespace MDEventsHelper
namespace MDEventsTestHelper
{
/** Create an EventWorkspace containing fake data
* of single-crystal diffraction.
* Instrument is MINITOPAZ
*
* @return EventWorkspace_sptr
*/
DLL_TESTHELPERS Mantid::DataObjects::EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents);
/** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc.
*
......@@ -72,7 +82,6 @@ namespace MDEventsHelper
}
} // namespace
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment