Skip to content

Commit

Permalink
refs #7664. Remove HasUB aspects from ClearUB alg.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Aug 22, 2013
1 parent fbeff8d commit 0066f8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 69 deletions.
7 changes: 2 additions & 5 deletions Code/Mantid/Framework/Crystal/src/ClearUB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ namespace Mantid
{
declareProperty(new WorkspaceProperty<Workspace>("Workspace", "", Direction::InOut),
"Workspace to clear the UB from.");
declareProperty(new PropertyWithValue<bool>("DryRun", false, Direction::Input),
"Dry run mode, will complete processing without error, and without removing any UB. Use in conjunction with DoesClear output property.");
declareProperty(new PropertyWithValue<bool>("DoesClear", "", Direction::Output),
"Indicates action performed, or predicted to perform if DryRun.");
"Indicates action performed. DoesClear returns true only if one or more OrientedLattices have been removed.");
}

/**
Expand Down Expand Up @@ -146,8 +144,7 @@ namespace Mantid
void ClearUB::exec()
{
Workspace_sptr ws = getProperty("Workspace");
const bool dryRun = getProperty("DryRun");
bool doesClear = doExecute(ws.get(), dryRun);
bool doesClear = doExecute(ws.get(), false /* Not a dry run*/);
this->setProperty("DoesClear", doesClear);
}

Expand Down
66 changes: 2 additions & 64 deletions Code/Mantid/Framework/Crystal/test/ClearUBTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class ClearUBTest : public CxxTest::TestSuite

private:

const static bool DRY_RUN = true;

// Single return type
struct SingleReturnType
{
Expand Down Expand Up @@ -69,15 +67,14 @@ class ClearUBTest : public CxxTest::TestSuite
}

// Execute the algorithm
SingleReturnType doExecute(const std::string& wsName, bool dryRun = !DRY_RUN)
SingleReturnType doExecute(const std::string& wsName)
{
// Create and run the algorithm
ClearUB alg;
alg.setRethrows(true);
TS_ASSERT_THROWS_NOTHING( alg.initialize())
TS_ASSERT( alg.isInitialized())
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Workspace", wsName));
TS_ASSERT_THROWS_NOTHING( alg.setProperty("DryRun", dryRun));
alg.execute();
TS_ASSERT( alg.isExecuted());

Expand All @@ -90,15 +87,14 @@ class ClearUBTest : public CxxTest::TestSuite
}

// Execute the algorithm
MultipleReturnType doExecuteMultiInfo(const std::string& wsName, bool dryRun = !DRY_RUN)
MultipleReturnType doExecuteMultiInfo(const std::string& wsName)
{
// Create and run the algorithm
ClearUB alg;
alg.setRethrows(true);
TS_ASSERT_THROWS_NOTHING( alg.initialize())
TS_ASSERT( alg.isInitialized())
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Workspace", wsName));
TS_ASSERT_THROWS_NOTHING( alg.setProperty("DryRun", dryRun));
alg.execute();
TS_ASSERT( alg.isExecuted());

Expand Down Expand Up @@ -192,64 +188,6 @@ class ClearUBTest : public CxxTest::TestSuite
AnalysisDataService::Instance().remove(wsName);
}

void test_dry_run_with_intput_workspace_not_expeirmentinfo()
{
using Mantid::DataObjects::TableWorkspace;
Workspace_sptr inws = boost::make_shared<TableWorkspace>();
const std::string wsName = "tablews";
AnalysisDataService::Instance().addOrReplace(wsName, inws);

const bool dryRun = true;

SingleReturnType output;
TSM_ASSERT_THROWS_NOTHING("Input workspace type is not derived from ExperimentInfo or MultipleExperimentInfo, so should throw.", output = doExecute(wsName, dryRun));
TSM_ASSERT("Should indicate that it could not clear a workspace, this is because it is a table workspace (no experiment info)", !output.DidClear);

AnalysisDataService::Instance().remove(wsName);
}

void test_removeOrientedLattice_dry_run()
{
// Name of the output workspace.
const std::string wsName = createMatrixWorkspace();
auto ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName);
TSM_ASSERT("OrientedLattice should be present to begin with", ws->sample().hasOrientedLattice());

const bool dryRun = true;
auto output = doExecute(wsName, DRY_RUN);
auto expInfo = output.ExperimentInfo;

TS_ASSERT( expInfo)
TSM_ASSERT("OrientedLattice should NOT be gone as is dry run", expInfo->sample().hasOrientedLattice());
TSM_ASSERT("OutputFlag should indicate possible removal", output.DidClear);

// Clean up.
AnalysisDataService::Instance().remove(wsName);
}

void test_removeOrientedLatticeMDHW_dry_run()
{
// Name of the output workspace.
const std::string wsName = createMDHistoWorkspace();

auto output = doExecuteMultiInfo(wsName, DRY_RUN);
auto expInfo = output.ExperimentInfos;

TS_ASSERT( expInfo)

// Check that every experiment info has been cleared.
const uint16_t nInfos = expInfo->getNumExperimentInfo();
for (uint16_t i = 0; i < nInfos; ++i)
{
TSM_ASSERT("OrientedLattice should NOT be gone as this is a dry run", expInfo->getExperimentInfo(i)->sample().hasOrientedLattice() )
}
TSM_ASSERT("OutputFlag should indicate potential removal", output.DidClear);
// Clean up.
AnalysisDataService::Instance().remove(wsName);
}



};


Expand Down

0 comments on commit 0066f8c

Please sign in to comment.