Commit 8acad618 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Apply changes from clang-tidy readability-container-size-empty.

parent 9f49657e
......@@ -72,7 +72,7 @@ public:
MatrixWorkspace_sptr execute(MatrixWorkspace_sptr inputWS) const override {
MatrixWorkspace_sptr outWS;
if (m_indexes.size() > 0) {
if (!m_indexes.empty()) {
Mantid::API::AlgorithmManagerImpl &factory =
Mantid::API::AlgorithmManager::Instance();
auto sumSpectraAlg = factory.create("SumSpectra");
......
......@@ -174,7 +174,7 @@ void PlotAsymmetryByLogValue::exec() {
}
// Create the 2D workspace for the output
int nplots = m_greenY.size() ? 4 : 1;
int nplots = !m_greenY.empty() ? 4 : 1;
size_t npoints = m_logValue.size();
MatrixWorkspace_sptr outWS = WorkspaceFactory::Instance().create(
"Workspace2D",
......
......@@ -501,7 +501,7 @@ double ReflectometryReductionOneAuto::checkForDefault(
auto algProperty = this->getPointerToProperty(propName);
if (algProperty->isDefault()) {
auto defaults = instrument->getNumberParameter(idf_name);
if (defaults.size() == 0) {
if (defaults.empty()) {
throw std::runtime_error("No data could be retrieved from the parameters "
"and argument wasn't provided: " +
propName);
......
......@@ -53,11 +53,11 @@ void RenameWorkspaces::exec() {
std::string suffix = getPropertyValue("Suffix");
// Check properties
if (newWsName.size() == 0 && prefix == "" && suffix == "") {
if (newWsName.empty() && prefix == "" && suffix == "") {
throw std::invalid_argument(
"No list of Workspace names, prefix or suffix has been supplied.");
}
if (newWsName.size() > 0 && (prefix != "" || suffix != "")) {
if (!newWsName.empty() && (prefix != "" || suffix != "")) {
throw std::invalid_argument("Both a list of workspace names and a prefix "
"or suffix has been supplied.");
}
......@@ -73,7 +73,7 @@ void RenameWorkspaces::exec() {
}
size_t nWs = inputWsName.size();
if (newWsName.size() > 0) {
if (!newWsName.empty()) {
// We are using a list of new names
if (nWs > newWsName.size()) {
nWs = newWsName.size();
......
......@@ -106,7 +106,7 @@ void SetInstrumentParameter::exec() {
addParameter(paramMap, det.get(), paramName, paramType, paramValue);
}
} else {
if (cmptList.size() > 0) {
if (!cmptList.empty()) {
for (auto &cmpt : cmptList) {
addParameter(paramMap, cmpt.get(), paramName, paramType, paramValue);
}
......
......@@ -135,7 +135,7 @@ void SpatialGrouping::exec() {
m_groups.push_back(group);
}
if (m_groups.size() == 0) {
if (m_groups.empty()) {
g_log.warning() << "No groups generated." << std::endl;
return;
}
......
......@@ -85,7 +85,7 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() {
}
// Check that all the workspaces are of the same type
if (m_inputWorkspaces.size() > 0) {
if (!m_inputWorkspaces.empty()) {
const std::string id = m_inputWorkspaces[0]->id();
for (auto &inputWorkspace : m_inputWorkspaces) {
if (inputWorkspace->id() != id) {
......@@ -118,8 +118,7 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() {
m_startOverlaps = this->getProperty("StartOverlaps");
m_endOverlaps = this->getProperty("EndOverlaps");
if (m_startOverlaps.size() > 0 &&
m_startOverlaps.size() != m_numWorkspaces - 1)
if (!m_startOverlaps.empty() && m_startOverlaps.size() != m_numWorkspaces - 1)
errors["StartOverlaps"] = "If given, StartOverlaps must have one fewer "
"entries than the number of input workspaces.";
......@@ -132,7 +131,7 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() {
m_manualScaleFactor = this->getProperty("ManualScaleFactor");
m_params = this->getProperty("Params");
if (m_params.size() < 1)
if (m_params.empty())
errors["Params"] = "At least one parameter must be given.";
if (!m_scaleRHSWorkspace) {
......
......@@ -54,7 +54,7 @@ void UpdateScriptRepository::exec() {
return; // it means that the ScriptRepository was not installed.
std::vector<std::string> f_list = repo_ptr->check4Update();
if (f_list.size() > 0) {
if (!f_list.empty()) {
std::stringstream info;
info << "Information about ScriptRepository:\n"
<< " A more recent version of the following files was installed:\n";
......
......@@ -33,7 +33,7 @@ public:
if (intensity < 0) {
throw std::invalid_argument("SXPeak: Cannot have an intensity < 0");
}
if (spectral.size() == 0) {
if (spectral.empty()) {
throw std::invalid_argument(
"SXPeak: Cannot have zero sized spectral list");
}
......
......@@ -101,7 +101,7 @@ public:
_hkls = s;
}
void setFirst() {
if (_hkls.size() > 0) {
if (!_hkls.empty()) {
auto it = _hkls.begin(); // Take the first possiblity
it++;
_hkls.erase(it, _hkls.end()); // Erase all others!
......
......@@ -553,8 +553,8 @@ void AnvredCorrection::BuildLamdaWeights() {
// GetSpectrumWeights( spectrum_file_name, m_lamda_weight);
if (m_lamda_weight.size() == 0) // loading spectrum failed so use
{ // array of 1's
if (m_lamda_weight.empty()) // loading spectrum failed so use
{ // array of 1's
// power = power_ns; // This is commented out, so we
// don't override user specified
// value.
......
......@@ -84,7 +84,7 @@ Cluster::integrate(Mantid::API::IMDHistoWorkspace_const_sptr ws) const {
* @param disjointSet
*/
void Cluster::toUniformMinimum(VecElements &disjointSet) {
if (m_indexes.size() > 0) {
if (!m_indexes.empty()) {
size_t parentIndex = m_rootCluster->getRepresentitiveIndex();
for (size_t i = 1; i < m_indexes.size(); ++i) {
......
......@@ -494,7 +494,7 @@ void IntegratePeakTimeSlices::exec() {
auto XXX =
boost::make_shared<DataModeHandler>(*m_AttributeValues);
m_AttributeValues = XXX;
if (X.size() > 0)
if (!X.empty())
m_AttributeValues->setTime((X[chanMax] + X[chanMin]) / 2.0);
} else // lastAttributeList exists
......@@ -2391,7 +2391,7 @@ bool DataModeHandler::IsEnoughData(const double *ParameterValues,
// Check if flat
double Varx, Vary, Cov;
if (StatBase.size() <= 0)
if (StatBase.empty())
return false;
double ncells = static_cast<int>(StatBase[IIntensities]);
......
......@@ -82,7 +82,7 @@ void SortHKL::exec() {
const std::vector<Peak> &inputPeaks = inputPeaksWorkspace->getPeaks();
std::vector<Peak> peaks = getNonZeroPeaks(inputPeaks);
if (peaks.size() == 0) {
if (peaks.empty()) {
g_log.error() << "Number of peaks should not be 0 for SortHKL.\n";
return;
}
......@@ -329,7 +329,7 @@ double PeaksStatistics::getRMS(const std::vector<double> &data) const {
/// Returns the lowest and hights wavelength in the peak list.
std::pair<double, double>
PeaksStatistics::getLambdaLimits(const std::vector<Peak> &peaks) const {
if (peaks.size() == 0) {
if (peaks.empty()) {
return std::make_pair(0.0, 0.0);
}
......@@ -502,7 +502,7 @@ void UniqueReflection::removeOutliers(double sigmaCritical) {
}
}
if (outlierIndices.size() > 0) {
if (!outlierIndices.empty()) {
for (auto it = outlierIndices.rbegin(); it != outlierIndices.rend();
++it) {
m_peaks.erase(m_peaks.begin() + (*it));
......
......@@ -339,8 +339,7 @@ void FitPowderDiffPeaks::processInputProperties() {
m_rightmostPeakRightBound = getProperty("RightMostPeakRightBound");
if (m_fitMode == ROBUSTFIT) {
if (m_rightmostPeakHKL.size() == 0 ||
m_rightmostPeakLeftBound == EMPTY_DBL() ||
if (m_rightmostPeakHKL.empty() || m_rightmostPeakLeftBound == EMPTY_DBL() ||
m_rightmostPeakRightBound == EMPTY_DBL()) {
stringstream errss;
errss << "If fit mode is 'RobustFit', then user must specify all 3 "
......@@ -758,7 +757,7 @@ bool FitPowderDiffPeaks::fitSinglePeakRobust(
<< peakinfob1 << endl;
// c) Fit peak parameters by the value from right peak
if (rightpeakparammap.size() > 0) {
if (!rightpeakparammap.empty()) {
restoreFunctionParameters(peak, rightpeakparammap);
peak->setParameter("X0", tof_h);
peak->setParameter("I", height * fwhm);
......
......@@ -748,7 +748,7 @@ void LeBailFit::createLeBailFunction() {
boost::make_shared<LeBailFunction>(LeBailFunction(m_peakType));
// Set up profile parameters
if (m_funcParameters.size() == 0)
if (m_funcParameters.empty())
throw runtime_error("Function parameters must be set up by this point.");
map<string, double> pardblmap = convertToDoubleMap(m_funcParameters);
......@@ -2094,7 +2094,7 @@ bool LeBailFit::calculateDiffractionPattern(const MantidVec &vecX,
::transform(values.begin(), values.end(), vecBkgd.begin(), values.begin(),
::plus<double>());
} else {
if (veccalbkgd.size() == 0)
if (veccalbkgd.empty())
throw runtime_error("Programming logic error.");
::transform(values.begin(), values.end(), veccalbkgd.begin(),
values.begin(), ::plus<double>());
......@@ -2113,7 +2113,7 @@ bool LeBailFit::calculateDiffractionPattern(const MantidVec &vecX,
caldata.begin(), std::plus<double>());
} else {
// Re-calculate background
if (veccalbkgd.size() == 0)
if (veccalbkgd.empty())
throw runtime_error("Programming logic error (2). ");
std::transform(values.begin(), values.end(), veccalbkgd.begin(),
caldata.begin(), std::plus<double>());
......@@ -2401,7 +2401,7 @@ void LeBailFit::bookKeepBestMCResult(map<string, Parameter> parammap,
m_bestMCStep = istep;
// b) Record parameters
if (m_bestParameters.size() == 0) {
if (m_bestParameters.empty()) {
// If not be initialized, initialize it!
m_bestParameters = parammap;
} else {
......
......@@ -835,7 +835,7 @@ void LeBailFunction::groupPeaks(
<< " causes grouping "
<< "peak over at maximum TOF = " << xmax << ".\n";
if (peakgroup.size() > 0) {
if (!peakgroup.empty()) {
vector<pair<double, IPowderDiffPeakFunction_sptr>> peakgroupcopy =
peakgroup;
peakgroupvec.push_back(peakgroupcopy);
......
......@@ -662,7 +662,7 @@ void RefinePowderInstrumentParameters3::bookKeepMCResult(
}
// 2. Record for the best parameters
if (bestparammap.size() == 0) {
if (bestparammap.empty()) {
// No record yet
duplicateParameters(parammap, bestparammap);
} else if (recordparameter) {
......@@ -796,7 +796,7 @@ void RefinePowderInstrumentParameters3::addParameterToMCMinimize(
double RefinePowderInstrumentParameters3::calculateFunction(
map<string, Parameter> parammap, vector<double> &vecY) {
// 1. Implement parameter values to m_positionFunc
if (parammap.size() > 0)
if (!parammap.empty())
setFunctionParameterValues(m_positionFunc, parammap);
// 2. Calculate
......
......@@ -105,7 +105,7 @@ void InelasticDiffRotDiscreteCircle::function1D(double *out,
double Q;
if (getAttribute("Q").asDouble() == EMPTY_DBL()) {
if (m_qValueCache.size() == 0) {
if (m_qValueCache.empty()) {
throw std::runtime_error(
"No Q attribute provided and cannot retrieve from worksapce.");
}
......
......@@ -216,7 +216,7 @@ void InelasticDiffSphere::function1D(double *out, const double *xValues,
double Q;
if (getAttribute("Q").asDouble() == EMPTY_DBL()) {
if (m_qValueCache.size() == 0) {
if (m_qValueCache.empty()) {
throw std::runtime_error(
"No Q attribute provided and cannot retrieve from worksapce.");
}
......
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