Skip to content
Snippets Groups Projects
Commit 3b3ed019 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #20714 clang format

parent cd25aa64
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,8 @@ private: ...@@ -63,7 +63,8 @@ private:
API::MatrixWorkspace_sptr squash(const API::MatrixWorkspace_sptr &ws, API::MatrixWorkspace_sptr squash(const API::MatrixWorkspace_sptr &ws,
const API::ITableWorkspace_sptr &phase, const API::ITableWorkspace_sptr &phase,
const std::vector<double> &n0); const std::vector<double> &n0);
int findName(const std::string pattern, const std::vector<std::string> &names); int findName(const std::string pattern,
const std::vector<std::string> &names);
}; };
} // namespace Algorithms } // namespace Algorithms
......
...@@ -66,59 +66,62 @@ void PhaseQuadMuon::exec() { ...@@ -66,59 +66,62 @@ void PhaseQuadMuon::exec() {
*/ */
std::map<std::string, std::string> PhaseQuadMuon::validateInputs() { std::map<std::string, std::string> PhaseQuadMuon::validateInputs() {
std::map<std::string, std::string> result; std::map<std::string, std::string> result;
// Check that input ws and table ws have compatible dimensions // Check that input ws and table ws have compatible dimensions
API::MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace"); API::MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace");
API::ITableWorkspace_const_sptr tabWS = getProperty("PhaseTable"); API::ITableWorkspace_const_sptr tabWS = getProperty("PhaseTable");
if (!inputWS) { if (!inputWS) {
result["InputWorkspace"] = "InputWorkspace is of Incorrect type. Please " result["InputWorkspace"] = "InputWorkspace is of Incorrect type. Please "
"provide a MatrixWorkspace as the " "provide a MatrixWorkspace as the "
"InputWorkspace"; "InputWorkspace";
return result; return result;
} }
size_t nspec = inputWS->getNumberHistograms(); size_t nspec = inputWS->getNumberHistograms();
size_t ndet = tabWS->rowCount(); size_t ndet = tabWS->rowCount();
if (tabWS->columnCount() == 0) { if (tabWS->columnCount() == 0) {
result["PhaseTable"] = "Please provide a non-empty PhaseTable."; result["PhaseTable"] = "Please provide a non-empty PhaseTable.";
} }
if (nspec != ndet) { if (nspec != ndet) {
result["PhaseTable"] = "PhaseTable must have one row per spectrum"; result["PhaseTable"] = "PhaseTable must have one row per spectrum";
} }
// PhaseTable should have three columns: (detector, asymmetry, phase) // PhaseTable should have three columns: (detector, asymmetry, phase)
if (tabWS->columnCount() != 3) { if (tabWS->columnCount() != 3) {
result["PhaseTable"] = "PhaseTable must have three columns"; result["PhaseTable"] = "PhaseTable must have three columns";
} }
auto names = tabWS->getColumnNames(); auto names = tabWS->getColumnNames();
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
std::transform(names[j].begin(), names[j].end(), names[j].begin(), ::tolower); std::transform(names[j].begin(), names[j].end(), names[j].begin(),
} ::tolower);
std::vector<std::string> goodNames = {"phase", "asym", "asymm", "asymmetry"}; }
int phaseCount = 0; std::vector<std::string> goodNames = {"phase", "asym", "asymm", "asymmetry"};
int asymmetryCount = 0; int phaseCount = 0;
for (std::string name : names) { int asymmetryCount = 0;
if (name == goodNames[0]) { for (std::string name : names) {
phaseCount += 1; if (name == goodNames[0]) {
} phaseCount += 1;
if (name == goodNames[1] || name == goodNames[2] || name == goodNames[3]) { }
asymmetryCount += 1; if (name == goodNames[1] || name == goodNames[2] || name == goodNames[3]) {
} asymmetryCount += 1;
} }
if (phaseCount == 0) { }
result["PhaseTable"] = "PhaseTable needs phases column"; if (phaseCount == 0) {
} result["PhaseTable"] = "PhaseTable needs phases column";
if (asymmetryCount == 0) { }
result["PhaseTable"] = "PhaseTable needs a asymmetry/asymm/asym column"; if (asymmetryCount == 0) {
} result["PhaseTable"] = "PhaseTable needs a asymmetry/asymm/asym column";
if (phaseCount >1) { }
result["PhaseTable"] = "PhaseTable has "+std::to_string(phaseCount)+ " phase columns"; if (phaseCount > 1) {
} result["PhaseTable"] =
if (asymmetryCount > 1) { "PhaseTable has " + std::to_string(phaseCount) + " phase columns";
result["PhaseTable"] = "PhaseTable has "+std::to_string(asymmetryCount)+" asymmetry/asymm/asym columns"; }
} if (asymmetryCount > 1) {
result["PhaseTable"] = "PhaseTable has " + std::to_string(asymmetryCount) +
" asymmetry/asymm/asym columns";
}
// Check units, should be microseconds // Check units, should be microseconds
Unit_const_sptr unit = inputWS->getAxis(0)->unit(); Unit_const_sptr unit = inputWS->getAxis(0)->unit();
if ((unit->caption() != "Time") || (unit->label().ascii() != "microsecond")) { if ((unit->caption() != "Time") || (unit->label().ascii() != "microsecond")) {
...@@ -128,17 +131,22 @@ std::map<std::string, std::string> PhaseQuadMuon::validateInputs() { ...@@ -128,17 +131,22 @@ std::map<std::string, std::string> PhaseQuadMuon::validateInputs() {
return result; return result;
} }
int PhaseQuadMuon::findName(const std::string pattern, const std::vector<std::string> &names) { int PhaseQuadMuon::findName(const std::string pattern,
auto it = std::find_if(names.begin(), names.end(), [pattern](const std::string& s) { const std::vector<std::string> &names) {
if (s == pattern) { return true; } auto it =
else { return false; } }); std::find_if(names.begin(), names.end(), [pattern](const std::string &s) {
if (it == names.end()) { if (s == pattern) {
return -1; return true;
} } else {
return static_cast<int>(std::distance(names.begin(), it)); return false;
}
});
if (it == names.end()) {
return -1;
}
return static_cast<int>(std::distance(names.begin(), it));
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
/** Calculates the normalization constant for the exponential decay /** Calculates the normalization constant for the exponential decay
* @param ws :: [input] Workspace containing the spectra to remove exponential * @param ws :: [input] Workspace containing the spectra to remove exponential
...@@ -208,15 +216,16 @@ PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws, ...@@ -208,15 +216,16 @@ PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws,
auto names = phase->getColumnNames(); auto names = phase->getColumnNames();
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
std::transform(names[j].begin(), names[j].end(), names[j].begin(), ::tolower); std::transform(names[j].begin(), names[j].end(), names[j].begin(),
::tolower);
} }
auto phaseIndex = findName("phase", names); auto phaseIndex = findName("phase", names);
auto asymmetryIndex = findName("asymmetry", names); auto asymmetryIndex = findName("asymmetry", names);
if (asymmetryIndex == -1) { if (asymmetryIndex == -1) {
asymmetryIndex = findName("asymm", names); asymmetryIndex = findName("asymm", names);
if (asymmetryIndex == -1) { if (asymmetryIndex == -1) {
asymmetryIndex = findName("asym", names); asymmetryIndex = findName("asym", names);
} }
} }
// Get the maximum asymmetry // Get the maximum asymmetry
......
...@@ -13,10 +13,11 @@ using namespace Mantid::DataObjects; ...@@ -13,10 +13,11 @@ using namespace Mantid::DataObjects;
using namespace Mantid::API; using namespace Mantid::API;
namespace { namespace {
void populatePhaseTable(ITableWorkspace_sptr phaseTable, std::vector<std::string> names) { void populatePhaseTable(ITableWorkspace_sptr phaseTable,
std::vector<std::string> names) {
phaseTable->addColumn("int", names[0]); phaseTable->addColumn("int", names[0]);
phaseTable->addColumn("double", names[1]); phaseTable->addColumn("double", names[1]);
phaseTable->addColumn("double",names[2]); phaseTable->addColumn("double", names[2]);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
TableRow phaseRow1 = phaseTable->appendRow(); TableRow phaseRow1 = phaseTable->appendRow();
phaseRow1 << i << 1. << 0.; phaseRow1 << i << 1. << 0.;
...@@ -25,7 +26,7 @@ void populatePhaseTable(ITableWorkspace_sptr phaseTable, std::vector<std::string ...@@ -25,7 +26,7 @@ void populatePhaseTable(ITableWorkspace_sptr phaseTable, std::vector<std::string
} }
} }
void populatePhaseTable(ITableWorkspace_sptr phaseTable) { void populatePhaseTable(ITableWorkspace_sptr phaseTable) {
populatePhaseTable(phaseTable,{"DetectorID", "Asymmetry", "Phase"}); populatePhaseTable(phaseTable, {"DetectorID", "Asymmetry", "Phase"});
} }
IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr inputWs, bool isChildAlg) { IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr inputWs, bool isChildAlg) {
// Create and populate a detector table // Create and populate a detector table
...@@ -107,15 +108,13 @@ public: ...@@ -107,15 +108,13 @@ public:
} }
// add test for no phase // add test for no phase
// add test for no asymm // add test for no asymm
// add test for two phase // add test for two phase
// add test for two asymm
// add test for different order
// add test for two asymm
// add test for different order
}; };
class PhaseQuadMuonTestPerformance : public CxxTest::TestSuite { class PhaseQuadMuonTestPerformance : public CxxTest::TestSuite {
......
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