Skip to content

Commit

Permalink
Modify and test renamed LoadMask. Refs #4601.
Browse files Browse the repository at this point in the history
SaveMaskTest uses LoadMask. Thus it is changed too.
  • Loading branch information
wdzhou committed Feb 14, 2012
1 parent 72b656a commit 8e10b35
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set ( SRC_FILES
src/LoadLogsForSNSPulsedMagnet.cpp
src/LoadLogsFromSNSNexus.cpp
src/LoadMappingTable.cpp
src/LoadMaskingFile.cpp
src/LoadMask.cpp
src/LoadMuonLog.cpp
src/LoadMuonNexus.cpp
src/LoadMuonNexus2.cpp
Expand Down Expand Up @@ -148,7 +148,7 @@ set ( INC_FILES
inc/MantidDataHandling/LoadLogsForSNSPulsedMagnet.h
inc/MantidDataHandling/LoadLogsFromSNSNexus.h
inc/MantidDataHandling/LoadMappingTable.h
inc/MantidDataHandling/LoadMaskingFile.h
inc/MantidDataHandling/LoadMask.h
inc/MantidDataHandling/LoadMuonLog.h
inc/MantidDataHandling/LoadMuonNexus.h
inc/MantidDataHandling/LoadMuonNexus2.h
Expand Down Expand Up @@ -250,7 +250,7 @@ set ( TEST_FILES
test/LoadLogTest.h
test/LoadLogsFromSNSNexusTest.h
test/LoadMappingTableTest.h
test/LoadMaskingFileTest.h
test/LoadMaskTest.h
test/LoadMuonLogTest.h
test/LoadMuonNexus2Test.h
test/LoadMuonNexusTest.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MANTID_DATAHANDLING_LOADMASKINGFILE_H_
#define MANTID_DATAHANDLING_LOADMASKINGFILE_H_
#ifndef MANTID_DATAHANDLING_LOADMASK_H_
#define MANTID_DATAHANDLING_LOADMASK_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
Expand All @@ -11,7 +11,7 @@ namespace Mantid
namespace DataHandling
{

/** LoadMaskingFile : TODO: DESCRIPTION
/** LoadMask : TODO: DESCRIPTION
@author
@date 2011-11-02
Expand All @@ -36,14 +36,14 @@ namespace DataHandling
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadMaskingFile : public API::Algorithm
class DLLExport LoadMask : public API::Algorithm
{
public:
LoadMaskingFile();
~LoadMaskingFile();
LoadMask();
~LoadMask();

/// Algorithm's name for identification
virtual const std::string name() const { return "LoadMaskingFile";};
virtual const std::string name() const { return "LoadMask";};
/// Algorithm's version for identification
virtual int version() const { return 1;};
/// Algorithm's category for identification
Expand Down Expand Up @@ -121,4 +121,4 @@ namespace DataHandling
} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_LOADMASKINGFILE_H_ */
#endif /* MANTID_DATAHANDLING_LOADMASK_H_ */
44 changes: 22 additions & 22 deletions Code/Mantid/Framework/DataHandling/src/LoadMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The format can be
*WIKI*/

#include "MantidDataHandling/LoadMaskingFile.h"
#include "MantidDataHandling/LoadMask.h"
#include "MantidKernel/System.h"
#include "MantidAPI/FileProperty.h"
#include "MantidKernel/ListValidator.h"
Expand Down Expand Up @@ -55,12 +55,12 @@ namespace Mantid
namespace DataHandling
{

DECLARE_ALGORITHM(LoadMaskingFile)
DECLARE_ALGORITHM(LoadMask)

//----------------------------------------------------------------------------------------------
/** Constructor
*/
LoadMaskingFile::LoadMaskingFile()
LoadMask::LoadMask()
{
// mMaskWS = NULL;
// mInstrumentName = "";
Expand All @@ -73,19 +73,19 @@ namespace DataHandling
//----------------------------------------------------------------------------------------------
/** Destructor
*/
LoadMaskingFile::~LoadMaskingFile()
LoadMask::~LoadMask()
{
// Auto-generated destructor stub
}

/// Sets documentation strings for this algorithm
void LoadMaskingFile::initDocs(){
void LoadMask::initDocs(){
this->setWikiSummary("Loads an XML file or calibration file to generate MaskWorkspace.");
this->setOptionalMessage("");
}

/// Initialise the properties
void LoadMaskingFile::init(){
void LoadMask::init(){

// 1. Declare property
declareProperty("Instrument", "", "Name of instrument to mask.");
Expand All @@ -100,7 +100,7 @@ namespace DataHandling


/// Run the algorithm
void LoadMaskingFile::exec(){
void LoadMask::exec(){

// 1. Load Instrument and create output Mask workspace
const std::string instrumentname = getProperty("Instrument");
Expand Down Expand Up @@ -143,7 +143,7 @@ namespace DataHandling
return;
}

void LoadMaskingFile::initDetectors(){
void LoadMask::initDetectors(){

// 1. Initialize
if (mDefaultToUse){
Expand All @@ -166,7 +166,7 @@ namespace DataHandling
* params:
* @ tomask: true to mask, false to unmask
*/
void LoadMaskingFile::processMaskOnDetectors(bool tomask, std::vector<int32_t> singledetids, std::vector<int32_t> pairdetids_low,
void LoadMask::processMaskOnDetectors(bool tomask, std::vector<int32_t> singledetids, std::vector<int32_t> pairdetids_low,
std::vector<int32_t> pairdetids_up){

// 1. Get index map
Expand Down Expand Up @@ -207,7 +207,7 @@ namespace DataHandling
* @params
* -
*/
void LoadMaskingFile::componentToDetectors(std::vector<std::string> componentnames,
void LoadMask::componentToDetectors(std::vector<std::string> componentnames,
std::vector<int32_t>& detectors){

Geometry::Instrument_const_sptr minstrument = mMaskWS->getInstrument();
Expand Down Expand Up @@ -256,7 +256,7 @@ namespace DataHandling
/*
* Convert bank to detectors
*/
void LoadMaskingFile::bankToDetectors(std::vector<std::string> singlebanks,
void LoadMask::bankToDetectors(std::vector<std::string> singlebanks,
std::vector<int32_t>& detectors,
std::vector<int32_t>& detectorpairslow, std::vector<int32_t>& detectorpairsup){

Expand Down Expand Up @@ -304,7 +304,7 @@ namespace DataHandling
/*
* Convert spectrum to detectors
*/
void LoadMaskingFile::spectrumToDetectors(std::vector<int32_t> singles, std::vector<int32_t> pairslow, std::vector<int32_t> pairsup,
void LoadMask::spectrumToDetectors(std::vector<int32_t> singles, std::vector<int32_t> pairslow, std::vector<int32_t> pairsup,
std::vector<int32_t>& detectors,
std::vector<int32_t>& detectorpairslow, std::vector<int32_t>& detectorpairsup){

Expand All @@ -329,7 +329,7 @@ namespace DataHandling
/*
* Convert spectrum to detectors
*/
void LoadMaskingFile::detectorToDetectors(std::vector<int32_t> singles, std::vector<int32_t> pairslow, std::vector<int32_t> pairsup,
void LoadMask::detectorToDetectors(std::vector<int32_t> singles, std::vector<int32_t> pairslow, std::vector<int32_t> pairsup,
std::vector<int32_t>& detectors,
std::vector<int32_t>& detectorpairslow, std::vector<int32_t>& detectorpairsup){
UNUSED_ARG(detectorpairslow)
Expand Down Expand Up @@ -363,7 +363,7 @@ namespace DataHandling
/*
* Initalize Poco XML Parser
*/
void LoadMaskingFile::initializeXMLParser(const std::string & filename)
void LoadMask::initializeXMLParser(const std::string & filename)
{
// const std::string instName
std::cout << "Load File " << filename << std::endl;
Expand Down Expand Up @@ -396,11 +396,11 @@ namespace DataHandling
/*
* Parse XML file
*/
void LoadMaskingFile::parseXML()
void LoadMask::parseXML()
{
// 0. Check
if (!pDoc)
throw std::runtime_error("Call LoadMaskingFile::initialize() before parseXML.");
throw std::runtime_error("Call LoadMask::initialize() before parseXML.");

// 1. Parse and create a structure
NodeList* pNL_type = pRootElem->getElementsByTagName("type");
Expand Down Expand Up @@ -490,7 +490,7 @@ namespace DataHandling
* params:
* @valutext: must be bank name
*/
void LoadMaskingFile::parseComponent(std::string valuetext, bool tomask){
void LoadMask::parseComponent(std::string valuetext, bool tomask){

// 1. Parse bank out
/*
Expand Down Expand Up @@ -523,7 +523,7 @@ namespace DataHandling
/*
* Parse input string for spectrum ID
*/
void LoadMaskingFile::parseSpectrumIDs(std::string inputstr, bool tomask){
void LoadMask::parseSpectrumIDs(std::string inputstr, bool tomask){

g_log.error() << "SpectrumID in XML File (ids) Is Not Supported! Spectrum IDs: " << inputstr << std::endl;

Expand Down Expand Up @@ -557,7 +557,7 @@ namespace DataHandling
/*
* Parse input string for spectrum ID
*/
void LoadMaskingFile::parseDetectorIDs(std::string inputstr, bool tomask){
void LoadMask::parseDetectorIDs(std::string inputstr, bool tomask){

// g_log.information() << "Detector IDs: " << inputstr << std::endl;

Expand Down Expand Up @@ -592,7 +592,7 @@ namespace DataHandling
* Parse index range text to singles and pairs
* Example: 3,4,9-10,33
*/
void LoadMaskingFile::parseRangeText(std::string inputstr, std::vector<int32_t>& singles, std::vector<int32_t>& pairs){
void LoadMask::parseRangeText(std::string inputstr, std::vector<int32_t>& singles, std::vector<int32_t>& pairs){
// 1. Split ','
std::vector<std::string> rawstrings;
this->splitString(inputstr, rawstrings, ",");
Expand Down Expand Up @@ -646,7 +646,7 @@ namespace DataHandling
return;
}

void LoadMaskingFile::splitString(std::string inputstr, std::vector<std::string>& strings, std::string sep){
void LoadMask::splitString(std::string inputstr, std::vector<std::string>& strings, std::string sep){

// std::vector<std::string> SplitVec;
boost::split(strings, inputstr, boost::is_any_of(sep), boost::token_compress_on);
Expand All @@ -660,7 +660,7 @@ namespace DataHandling
/*
* Initialize the Mask Workspace with instrument
*/
void LoadMaskingFile::intializeMaskWorkspace(){
void LoadMask::intializeMaskWorkspace(){

// 1. Execute algorithm LoadInstrument() to a temporary Workspace
API::Algorithm_sptr childAlg = createSubAlgorithm("LoadInstrument");
Expand Down
22 changes: 11 additions & 11 deletions Code/Mantid/Framework/DataHandling/test/LoadMaskTest.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MANTID_DATAHANDLING_LOADMASKINGFILETEST_H_
#define MANTID_DATAHANDLING_LOADMASKINGFILETEST_H_
#ifndef MANTID_DATAHANDLING_LOADMASKTEST_H_
#define MANTID_DATAHANDLING_LOADMASKTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
Expand All @@ -9,25 +9,25 @@
#include <fstream>
#include "Poco/File.h"

#include "MantidDataHandling/LoadMaskingFile.h"
#include "MantidDataHandling/LoadMask.h"
#include "MantidDataObjects/SpecialWorkspace2D.h"

using namespace Mantid;
using namespace Mantid::DataHandling;
using namespace Mantid::API;

class LoadMaskingFileTest : public CxxTest::TestSuite
class LoadMaskTest : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static LoadMaskingFileTest *createSuite() { return new LoadMaskingFileTest(); }
static void destroySuite( LoadMaskingFileTest *suite ) { delete suite; }
static LoadMaskTest *createSuite() { return new LoadMaskTest(); }
static void destroySuite( LoadMaskTest *suite ) { delete suite; }


void test_LoadXML()
{
LoadMaskingFile loadfile;
LoadMask loadfile;
loadfile.initialize();

loadfile.setProperty("Instrument", "POWGEN");
Expand All @@ -51,7 +51,7 @@ class LoadMaskingFileTest : public CxxTest::TestSuite
*/
void test_LoadXMLThrow()
{
LoadMaskingFile loadfile;
LoadMask loadfile;
loadfile.initialize();

loadfile.setProperty("Instrument", "WhatEver");
Expand Down Expand Up @@ -89,7 +89,7 @@ class LoadMaskingFileTest : public CxxTest::TestSuite
genMaskingFile(maskfname1, detids, banks1);

// 2. Run
LoadMaskingFile loadfile;
LoadMask loadfile;
loadfile.initialize();

loadfile.setProperty("Instrument", "VULCAN");
Expand Down Expand Up @@ -151,7 +151,7 @@ class LoadMaskingFileTest : public CxxTest::TestSuite
genMaskingFile(maskfname2, detids, banks2);

// 1. Generate Mask Workspace
LoadMaskingFile loadfile;
LoadMask loadfile;
loadfile.initialize();

loadfile.setProperty("Instrument", "VULCAN");
Expand All @@ -163,7 +163,7 @@ class LoadMaskingFileTest : public CxxTest::TestSuite
boost::dynamic_pointer_cast<DataObjects::SpecialWorkspace2D>(AnalysisDataService::Instance().retrieve("VULCAN_Mask1"));

// 2. Generate Region of Interest Workspace
LoadMaskingFile loadfile2;
LoadMask loadfile2;
loadfile2.initialize();

loadfile2.setProperty("Instrument", "VULCAN");
Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/DataHandling/test/SaveMaskTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <iomanip>

#include "MantidDataHandling/SaveMask.h"
#include "MantidDataHandling/LoadMaskingFile.h"
#include "MantidDataHandling/LoadMask.h"
#include "MantidDataObjects/SpecialWorkspace2D.h"

#include "Poco/File.h"
Expand Down Expand Up @@ -39,16 +39,16 @@ class SaveMaskTest : public CxxTest::TestSuite
* (1) Load an existing masking file.
* (2) Save masking workspace to file.
* (3) Load the newly saved file, and compare with original masking workspace
* Notice: the prerequisit is that LoadMaskingFile() is correct.
* Notice: the prerequisit is that LoadMask() is correct.
*/
void test_SaveFile()
{
// 1. Init SaveDetectorMasking
SaveMask savealg;
savealg.initialize();

// 2. Run LoadMaskingFile
LoadMaskingFile loadfile;
// 2. Run LoadMask
LoadMask loadfile;
loadfile.initialize();

loadfile.setProperty("Instrument", "POWGEN");
Expand All @@ -70,7 +70,7 @@ class SaveMaskTest : public CxxTest::TestSuite
std::string file1 = savealg.getPropertyValue("OutputFile");

// 4. Load the new XML file
LoadMaskingFile loadfile2;
LoadMask loadfile2;
loadfile2.initialize();

loadfile2.setProperty("Instrument", "POWGEN");
Expand Down

0 comments on commit 8e10b35

Please sign in to comment.