Commit 8de22e32 authored by Matthew Bowles's avatar Matthew Bowles
Browse files

initial fit for single/multi ion/spectra Re #20358

parent c3d1dd66
......@@ -88,7 +88,7 @@ void LoadIDFFromNexus::exec() {
// Look for parameter correction file
std::string parameterCorrectionFile =
getPropertyValue("ParameterCorrectionFilePath");
if (parameterCorrectionFile == "") {
if (parameterCorrectionFile.empty()) {
parameterCorrectionFile =
getParameterCorrectionFile(localWorkspace->getInstrument()->getName());
}
......@@ -98,7 +98,7 @@ void LoadIDFFromNexus::exec() {
// Read parameter correction file, if found
std::string correctionParameterFile;
bool append = false;
if (parameterCorrectionFile != "") {
if (!parameterCorrectionFile.empty()) {
// Read parameter correction file
// to find out which parameter file to use
// and whether it is appended to default parameters.
......@@ -112,7 +112,7 @@ void LoadIDFFromNexus::exec() {
// Load default parameters if either there is no correction parameter file or
// it is to be appended.
if (correctionParameterFile == "" || append) {
if (correctionParameterFile.empty() || append) {
LoadParameters(&nxfile, localWorkspace);
} else { // Else clear the parameters
g_log.notice() << "Parameters to be replaced are cleared.\n";
......@@ -120,7 +120,7 @@ void LoadIDFFromNexus::exec() {
}
// Load parameters from correction parameter file, if it exists
if (correctionParameterFile != "") {
if (!correctionParameterFile.empty()) {
Poco::Path corrFilePath(parameterCorrectionFile);
g_log.debug() << "Correction file path: " << corrFilePath.toString()
<< "\n";
......@@ -200,7 +200,7 @@ void LoadIDFFromNexus::readParameterCorrectionFile(
append = false;
// Check the date.
if (date == "") {
if (date.empty()) {
g_log.notice() << "No date is supplied for parameter correction file "
<< correction_file << ". Correction file is ignored.\n";
return;
......
......@@ -480,7 +480,7 @@ std::vector<double> LoadILLDiffraction::getScannedVaribleByPropertyName(
}
}
if (scannedVariable.size() == 0)
if (scannedVariable.empty())
throw std::runtime_error(
"Can not load file because scanned variable with property name " +
propertyName + " was not found");
......
......@@ -130,7 +130,7 @@ void LoadILLIndirect2::exec() {
void LoadILLIndirect2::setInstrumentName(
const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath) {
if (instrumentNamePath == "") {
if (instrumentNamePath.empty()) {
std::string message("Cannot set the instrument name from the Nexus file!");
g_log.error(message);
throw std::runtime_error(message);
......
......@@ -176,7 +176,7 @@ void LoadILLReflectometry::exec() {
void LoadILLReflectometry::setInstrumentName(
const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath) {
if (instrumentNamePath == "") {
if (instrumentNamePath.empty()) {
std::string message("Cannot set the instrument name from the Nexus file!");
g_log.error(message);
throw std::runtime_error(message);
......
......@@ -107,7 +107,7 @@ void LoadILLSANS::exec() {
void LoadILLSANS::setInstrumentName(const NeXus::NXEntry &firstEntry,
const std::string &instrumentNamePath) {
if (instrumentNamePath == "") {
if (instrumentNamePath.empty()) {
std::string message("Cannot set the instrument name from the Nexus file!");
g_log.error(message);
throw std::runtime_error(message);
......
......@@ -144,7 +144,7 @@ void LoadILLTOF2::loadInstrumentDetails(NeXus::NXEntry &firstEntry) {
m_instrumentPath = m_loader.findInstrumentNexusPath(firstEntry);
if (m_instrumentPath == "") {
if (m_instrumentPath.empty()) {
throw std::runtime_error(
"Cannot set the instrument name from the Nexus file!");
}
......
......@@ -92,7 +92,7 @@ std::map<std::string, std::string> LoadIsawDetCal::validateInputs() {
// two detcal files is only valid for snap
std::vector<std::string> filenames = getFilenames();
if (filenames.size() == 0) {
if (filenames.empty()) {
result["Filename"] = "Must supply .detcal file";
} else if (filenames.size() == 2) {
Workspace_const_sptr wksp = getProperty("InputWorkspace");
......
......@@ -104,7 +104,7 @@ void LoadLLB::setInstrumentName(NeXus::NXEntry &entry) {
m_instrumentName =
m_loader.getStringFromNexusPath(entry, m_instrumentPath + "/name");
if (m_instrumentName == "") {
if (m_instrumentName.empty()) {
throw std::runtime_error(
"Cannot read the instrument name from the Nexus file!");
}
......
......@@ -149,7 +149,7 @@ void LoadMLZ::loadInstrumentDetails(NeXus::NXEntry &firstEntry) {
m_instrumentPath = m_mlzloader.findInstrumentNexusPath(firstEntry);
if (m_instrumentPath == "") {
if (m_instrumentPath.empty()) {
throw std::runtime_error(
"Cannot set the instrument name from the Nexus file!");
}
......
......@@ -112,7 +112,7 @@ void LoadSINQFocus::setInstrumentName(NeXus::NXEntry &entry) {
m_instrumentPath = m_loader.findInstrumentNexusPath(entry);
if (m_instrumentPath == "") {
if (m_instrumentPath.empty()) {
throw std::runtime_error(
"Cannot set the instrument name from the Nexus file!");
}
......
......@@ -136,6 +136,7 @@ LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws,
if (getProperty("SortByQVectors")) {
std::vector<mypair> qvmodpair;
qvmodpair.reserve(nq);
for (int iq = 0; iq < nq; iq++)
qvmodpair.emplace_back(qvmod[iq], iq);
std::sort(qvmodpair.begin(), qvmodpair.end(), compare);
......
......@@ -468,6 +468,7 @@ void LoadSpice2D::setBeamTrapRunProperty(
// store trap diameters in use
std::vector<double> trapDiametersInUse;
trapDiametersInUse.reserve(trapIndexInUse.size());
for (auto index : trapIndexInUse) {
trapDiametersInUse.push_back(trapDiameters[index]);
}
......
......@@ -231,7 +231,7 @@ void LoadSpiceXML2DDet::processInputs() {
if (vec_pixelgeom.size() == 2) {
m_numPixelX = vec_pixelgeom[0];
m_numPixelY = vec_pixelgeom[1];
} else if (vec_pixelgeom.size() == 0) {
} else if (vec_pixelgeom.empty()) {
m_numPixelX = 0;
m_numPixelY = 0;
} else {
......@@ -714,7 +714,7 @@ LoadSpiceXML2DDet::parseDetectorNode(const std::string &detvaluestr,
size_t num_empty_line = 0;
size_t num_weird_line = 0;
for (size_t iline = 0; iline < vecLines.size(); ++iline) {
if (vecLines[iline].size() == 0)
if (vecLines[iline].empty())
++num_empty_line;
else if (vecLines[iline].size() < 100)
++num_weird_line;
......
......@@ -342,7 +342,7 @@ void LoadTBL::exec() {
std::string line;
int stitchID = 1;
while (Kernel::Strings::extractToEOL(file, line)) {
if (line == "" || line == ",,,,,,,,,,,,,,,,") {
if (line.empty() || line == ",,,,,,,,,,,,,,,,") {
continue;
}
getCells(line, rowVec, 16, isOld);
......@@ -351,8 +351,8 @@ void LoadTBL::exec() {
// check if the first run in the row has any data associated with it
// 0 = runs, 1 = theta, 2 = trans, 3 = qmin, 4 = qmax
if (rowVec[0] != "" || rowVec[1] != "" || rowVec[2] != "" ||
rowVec[3] != "" || rowVec[4] != "") {
if (!rowVec[0].empty() || !rowVec[1].empty() || !rowVec[2].empty() ||
!rowVec[3].empty() || !rowVec[4].empty()) {
TableRow row = ws->appendRow();
row << stitchStr;
for (int i = 0; i < 5; ++i) {
......@@ -364,8 +364,8 @@ void LoadTBL::exec() {
// check if the second run in the row has any data associated with it
// 5 = runs, 6 = theta, 7 = trans, 8 = qmin, 9 = qmax
if (rowVec[5] != "" || rowVec[6] != "" || rowVec[7] != "" ||
rowVec[8] != "" || rowVec[9] != "") {
if (!rowVec[5].empty() || !rowVec[6].empty() || !rowVec[7].empty() ||
!rowVec[8].empty() || !rowVec[9].empty()) {
TableRow row = ws->appendRow();
row << stitchStr;
for (int i = 5; i < 10; ++i) {
......@@ -377,8 +377,8 @@ void LoadTBL::exec() {
// check if the third run in the row has any data associated with it
// 10 = runs, 11 = theta, 12 = trans, 13 = qmin, 14 = qmax
if (rowVec[10] != "" || rowVec[11] != "" || rowVec[12] != "" ||
rowVec[13] != "" || rowVec[14] != "") {
if (!rowVec[10].empty() || !rowVec[11].empty() || !rowVec[12].empty() ||
!rowVec[13].empty() || !rowVec[14].empty()) {
TableRow row = ws->appendRow();
row << stitchStr;
for (int i = 10; i < 17; ++i) {
......@@ -413,7 +413,7 @@ void LoadTBL::exec() {
}
size_t expectedCommas = columnHeadings.size() - 1;
while (Kernel::Strings::extractToEOL(file, line)) {
if (line == "" || line == ",,,,,,,,,,,,,,,,") {
if (line.empty() || line == ",,,,,,,,,,,,,,,,") {
// skip over any empty lines
continue;
}
......
......@@ -62,6 +62,7 @@ void RemoveLogs::exec() {
localWorkspace->run().getLogData();
std::vector<std::string> keepLogs = getProperty("KeepLogs");
std::vector<std::string> logNames;
logNames.reserve(logData.size());
for (const auto property : logData) {
logNames.push_back(property->name());
}
......
......@@ -111,7 +111,7 @@ void SaveAscii::exec() {
std::string sep;
// If the custom separator property is not empty, then we use that under any
// circumstance.
if (custom != "") {
if (!custom.empty()) {
sep = custom;
}
// Else if the separator drop down choice is not UserDefined then we use that.
......
......@@ -166,7 +166,7 @@ void SaveAscii2::exec() {
const std::string custom = getPropertyValue("CustomSeparator");
// If the custom separator property is not empty, then we use that under any
// circumstance.
if (custom != "") {
if (!custom.empty()) {
m_sep = custom;
}
// Else if the separator drop down choice is not UserDefined then we use that.
......
......@@ -86,6 +86,7 @@ bool SaveDiffFittingAscii::processGroups() {
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(name);
std::vector<API::ITableWorkspace_sptr> input_ws;
input_ws.reserve(inputGroup->getNumberOfEntries());
for (int i = 0; i < inputGroup->getNumberOfEntries(); ++i) {
input_ws.push_back(
boost::dynamic_pointer_cast<ITableWorkspace>(inputGroup->getItem(i)));
......
......@@ -34,7 +34,7 @@ void SaveReflCustomAscii::extraHeaders(std::ofstream &file) {
std::string subtitleEntry;
std::string title = getProperty("Title");
if (title != "") // if is toggled
if (!title.empty()) // if is toggled
{
file << "#" << title << '\n';
}
......
......@@ -28,7 +28,7 @@ void SaveReflThreeColumnAscii::extraHeaders(std::ofstream &file) {
auto samp = m_ws->run();
std::string title = getProperty("Title");
if (title != "") // if is toggled
if (!title.empty()) // if is toggled
{
file << "#" << title << '\n';
}
......
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