Commit e6e520f8 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Use to_string instead of lexical_cast.

parent 085529ef
......@@ -180,7 +180,7 @@ SplineSmoothing::setupOutputWorkspace(API::MatrixWorkspace_const_sptr inws,
// create labels for output workspace
auto tAxis = new API::TextAxis(size);
for (int i = 0; i < size; ++i) {
std::string index = boost::lexical_cast<std::string>(i);
std::string index = std::to_string(i);
tAxis->setLabel(i, "Y" + index);
}
outputWorkspace->replaceAxis(1, tAxis);
......
......@@ -126,8 +126,7 @@ void VesuvioCalculateGammaBackground::exec() {
if (!calculateBackground(inputIndex, outputIndex)) {
g_log.information("No detector defined for index=" +
boost::lexical_cast<std::string>(inputIndex) +
". Skipping correction.");
std::to_string(inputIndex) + ". Skipping correction.");
}
PARALLEL_END_INTERUPT_REGION
......@@ -164,8 +163,7 @@ bool VesuvioCalculateGammaBackground::calculateBackground(
spectrumNo <= FORWARD_SCATTER_SPECMAX) {
applyCorrection(inputIndex, outputIndex);
} else {
g_log.information("Spectrum " +
boost::lexical_cast<std::string>(spectrumNo) +
g_log.information("Spectrum " + std::to_string(spectrumNo) +
" not in forward scatter range. Skipping correction.");
// Leave background at 0 and just copy data to corrected
m_correctedWS->dataY(outputIndex) = m_inputWS->readY(inputIndex);
......
......@@ -334,16 +334,14 @@ void VesuvioCalculateMS::calculateMS(const size_t wsIndex,
// Final counts averaged over all simulations
CurveFitting::MSVesuvioHelper::SimulationAggregator accumulator(m_nruns);
for (size_t i = 0; i < m_nruns; ++i) {
m_progress->report("MS calculation: idx=" +
boost::lexical_cast<std::string>(wsIndex) + ", run=" +
boost::lexical_cast<std::string>(i));
m_progress->report("MS calculation: idx=" + std::to_string(wsIndex) +
", run=" + std::to_string(i));
simulate(detpar, respar,
accumulator.newSimulation(m_nscatters, m_inputWS->blocksize()));
m_progress->report("MS calculation: idx=" +
boost::lexical_cast<std::string>(wsIndex) + ", run=" +
boost::lexical_cast<std::string>(i));
m_progress->report("MS calculation: idx=" + std::to_string(wsIndex) +
", run=" + std::to_string(i));
}
// Average over all runs and assign to output workspaces
......
......@@ -369,8 +369,7 @@ bool FABADAMinimizer::iterate(size_t) {
}
failed.replace(failed.end() - 2, failed.end(), ".");
throw std::runtime_error(
"Convegence NOT reached after " +
boost::lexical_cast<std::string>(m_max_iter) +
"Convegence NOT reached after " + std::to_string(m_max_iter) +
" iterations.\n Try to set better initial values for parameters: " +
failed);
}
......
......@@ -67,8 +67,8 @@ void LevenbergMarquardtMinimizer::initialize(
if (!m_gslSolver) {
throw std::runtime_error(
"Levenberg-Marquardt minimizer failed to initialize. \n" +
boost::lexical_cast<std::string>(m_data->n) + " data points, " +
boost::lexical_cast<std::string>(m_data->p) + " fitting parameters. ");
std::to_string(m_data->n) + " data points, " +
std::to_string(m_data->p) + " fitting parameters. ");
}
gsl_multifit_fdfsolver_set(m_gslSolver, &gslContainer,
m_data->initFuncParams);
......
......@@ -192,7 +192,7 @@ void BSpline::resetParameters() {
}
size_t np = gsl_bspline_ncoeffs(m_bsplineWorkspace.get());
for (size_t i = 0; i < np; ++i) {
std::string pname = "A" + boost::lexical_cast<std::string>(i);
std::string pname = "A" + std::to_string(i);
declareParameter(pname);
}
}
......
......@@ -93,7 +93,7 @@ void Chebyshev::setAttribute(const std::string &attName,
"Chebyshev: polynomial order cannot be negative.");
}
for (int i = 0; i <= m_n; ++i) {
std::string parName = "A" + boost::lexical_cast<std::string>(i);
std::string parName = "A" + std::to_string(i);
declareParameter(parName);
}
} else if (attName == "StartX") {
......
......@@ -98,7 +98,7 @@ void ComptonProfile::buildCaches() {
} catch (Kernel::Exception::NotFoundError &) {
throw std::invalid_argument("ComptonProfile - Workspace has no detector "
"attached to histogram at index " +
boost::lexical_cast<std::string>(m_wsIndex));
std::to_string(m_wsIndex));
}
m_resolutionFunction->setAttributeValue("Mass", m_mass);
......
......@@ -79,7 +79,7 @@ void CubicSpline::setupInput(boost::scoped_array<double> &x,
bool xSortFlag = false;
for (int i = 0; i < n; ++i) {
std::string num = boost::lexical_cast<std::string>(i);
std::string num = std::to_string(i);
std::string xName = "x" + num;
std::string yName = "y" + num;
......@@ -270,7 +270,7 @@ void CubicSpline::setAttribute(const std::string &attName,
// check that the number of data points is in a valid range
if (n > oldN) {
// get the name of the last x data point
std::string oldXName = "x" + boost::lexical_cast<std::string>(oldN - 1);
std::string oldXName = "x" + std::to_string(oldN - 1);
double oldX = getAttribute(oldXName).asDouble();
// reallocate gsl object to new size
......@@ -278,7 +278,7 @@ void CubicSpline::setAttribute(const std::string &attName,
// create blank a number of new blank parameters and attributes
for (int i = oldN; i < n; ++i) {
std::string num = boost::lexical_cast<std::string>(i);
std::string num = std::to_string(i);
std::string newXName = "x" + num;
std::string newYName = "y" + num;
......@@ -309,7 +309,7 @@ void CubicSpline::setXAttribute(const size_t index, double x) {
// check that setting the x attribute is within our range
if (index < n) {
std::string xName = "x" + boost::lexical_cast<std::string>(index);
std::string xName = "x" + std::to_string(index);
setAttributeValue(xName, x);
// attributes updated, flag for recalculation
......
......@@ -16,7 +16,7 @@ DECLARE_FUNCTION(FullprofPolynomial)
FullprofPolynomial::FullprofPolynomial() : m_n(6), m_bkpos(1.) {
// Declare first 6th order polynomial as default
for (int i = 0; i < m_n; ++i) {
std::string parName = "A" + boost::lexical_cast<std::string>(i);
std::string parName = "A" + std::to_string(i);
declareParameter(parName);
}
}
......@@ -130,7 +130,7 @@ void FullprofPolynomial::setAttribute(const std::string &attName,
m_n = attint;
for (int i = 0; i < m_n; ++i) {
std::string parName = "A" + boost::lexical_cast<std::string>(i);
std::string parName = "A" + std::to_string(i);
declareParameter(parName);
}
}
......
......@@ -136,7 +136,7 @@ void Polynomial::setAttribute(const std::string &attName,
"Polynomial: polynomial order cannot be negative.");
}
for (int i = 0; i <= m_n; ++i) {
std::string parName = "A" + boost::lexical_cast<std::string>(i);
std::string parName = "A" + std::to_string(i);
declareParameter(parName);
}
}
......
......@@ -286,11 +286,11 @@ void ReflectivityMulf::setAttribute(const std::string &attName,
declareParameter("Resolution", coeff[6]);
for (int i = 0; i < m_nlayer; ++i) {
std::string parName = "SLD_Layer" + boost::lexical_cast<std::string>(i);
std::string parName = "SLD_Layer" + std::to_string(i);
declareParameter(parName, coeff[7 + i * 3]);
parName = "d_Layer" + boost::lexical_cast<std::string>(i);
parName = "d_Layer" + std::to_string(i);
declareParameter(parName, coeff[8 + i * 3]);
parName = "Rough_Layer" + boost::lexical_cast<std::string>(i);
parName = "Rough_Layer" + std::to_string(i);
declareParameter(parName, coeff[9 + i * 3]);
}
}
......
......@@ -44,7 +44,7 @@ ResolutionParams VesuvioResolution::getResolutionParameters(
} catch (Kernel::Exception::NotFoundError &) {
throw std::invalid_argument("VesuvioResolution - Workspace has no detector "
"attached to histogram at index " +
boost::lexical_cast<std::string>(index));
std::to_string(index));
}
ResolutionParams respar;
......
......@@ -35,7 +35,7 @@ GeneralDomainCreator::GeneralDomainCreator(
m_domainColumnNames.push_back("ArgumentColumn");
for (size_t i = 1; i < nDomainColumns; ++i) {
m_domainColumnNames.push_back(m_domainColumnNames.front() + "_" +
boost::lexical_cast<std::string>(i));
std::to_string(i));
}
}
......@@ -44,7 +44,7 @@ GeneralDomainCreator::GeneralDomainCreator(
m_dataColumnNames.push_back("DataColumn");
m_weightsColumnNames.push_back("WeightsColumn");
for (size_t i = 1; i < nDataColumns; ++i) {
auto si = "_" + boost::lexical_cast<std::string>(i);
auto si = "_" + std::to_string(i);
m_dataColumnNames.push_back(m_dataColumnNames.front() + si);
m_weightsColumnNames.push_back(m_weightsColumnNames.front() + si);
}
......
......@@ -144,8 +144,7 @@ void IFittingAlgorithm::setFunction() {
m_workspacePropertyNames.resize(ndom);
m_workspacePropertyNames[0] = "InputWorkspace";
for (size_t i = 1; i < ndom; ++i) {
std::string workspacePropertyName =
"InputWorkspace_" + boost::lexical_cast<std::string>(i);
std::string workspacePropertyName = "InputWorkspace_" + std::to_string(i);
m_workspacePropertyNames[i] = workspacePropertyName;
if (!existsProperty(workspacePropertyName)) {
declareProperty(
......
......@@ -136,8 +136,7 @@ boost::shared_ptr<API::Workspace> MultiDomainCreator::createOutputWorkspace(
API::WorkspaceGroup_sptr(new API::WorkspaceGroup());
for (size_t i = 0; i < functions.size(); ++i) {
std::string localName =
baseName + "Workspace_" + boost::lexical_cast<std::string>(i);
std::string localName = baseName + "Workspace_" + std::to_string(i);
auto fun = functions[i];
auto creator = m_creators[i];
boost::shared_ptr<API::FunctionDomain> localDomain;
......
......@@ -484,7 +484,7 @@ void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS,
std::vector<int> value;
file.getData(value);
if (!value.empty())
run = boost::lexical_cast<std::string>(value[0]);
run = std::to_string(value[0]);
}
if (!run.empty()) {
WS->mutableRun().addProperty("run_number", run);
......
......@@ -342,7 +342,7 @@ MantidVecPtr CreateSimulationWorkspace::createBinBoundaries() const {
if (numBoundaries <= 2) {
throw std::invalid_argument(
"Error in BinParams - Gave invalid number of bin boundaries: " +
boost::lexical_cast<std::string>(numBoundaries));
std::to_string(numBoundaries));
}
return binsPtr;
}
......
......@@ -457,7 +457,7 @@ void GroupDetectors2::processFile(std::string fname,
g_log.debug() << "Exception thrown: " << e.what() << std::endl;
File.close();
std::string error(e.what() + std::string(" near line number ") +
boost::lexical_cast<std::string>(lineNum));
std::to_string(lineNum));
if (File.fail()) {
error = "Input output error while reading file ";
}
......@@ -467,7 +467,7 @@ void GroupDetectors2::processFile(std::string fname,
File.close();
std::string error(std::string("Problem reading integer value \"") +
e.what() + std::string("\" near line number ") +
boost::lexical_cast<std::string>(lineNum));
std::to_string(lineNum));
if (File.fail()) {
error = "Input output error while reading file ";
}
......@@ -816,10 +816,11 @@ void GroupDetectors2::readFile(spec2index_map &specs2index, std::istream &File,
if (static_cast<int>(m_GroupWsInds[spectrumNo].size()) !=
numberOfSpectra) { // it makes no sense to continue reading the file,
// we'll stop here
throw std::invalid_argument(
std::string("Bad number of spectra specification or spectra list "
"near line number ") +
boost::lexical_cast<std::string>(lineNum));
throw std::invalid_argument(
std::string("Bad number of spectra "
"specification or spectra list "
"near line number ") +
std::to_string(lineNum));
}
// make regular progress reports and check for a cancellation notification
if ((m_GroupWsInds.size() % INTERVAL) == 1) {
......@@ -861,9 +862,8 @@ void GroupDetectors2::readSpectraIndexes(std::string line,
g_log.debug() << name() << ": spectrum number " << spectrumNum
<< " refered to in the input file was not found in the "
"input workspace\n";
throw std::invalid_argument(
"Spectrum number " + boost::lexical_cast<std::string>(spectrumNum) +
" not found");
throw std::invalid_argument("Spectrum number " +
std::to_string(spectrumNum) + " not found");
}
if (unUsedSpec[ind->second] != USED) { // this array is used when the user
// sets KeepUngroupedSpectra, as
......
......@@ -414,7 +414,7 @@ void Load::loadMultipleFiles() {
for (; childWsName != childWsNames.end(); ++childWsName, ++count) {
Workspace_sptr childWs = group->getItem(*childWsName);
const std::string childName =
group->getName() + "_" + boost::lexical_cast<std::string>(count);
group->getName() + "_" + std::to_string(count);
API::AnalysisDataService::Instance().addOrReplace(childName, childWs);
// childWs->setName(group->getName() + "_" +
// boost::lexical_cast<std::string>(count));
......@@ -444,7 +444,7 @@ void Load::loadMultipleFiles() {
// child->setName(child->getName() + "_" +
// boost::lexical_cast<std::string>(count));
const std::string childName =
child->getName() + "_" + boost::lexical_cast<std::string>(count);
child->getName() + "_" + std::to_string(count);
API::AnalysisDataService::Instance().addOrReplace(childName, child);
count++;
}
......@@ -454,8 +454,7 @@ void Load::loadMultipleFiles() {
count = 1;
for (auto &childWsName : childWsNames) {
Workspace_sptr childWs = group->getItem(childWsName);
std::string outWsPropName =
"OutputWorkspace_" + boost::lexical_cast<std::string>(count);
std::string outWsPropName = "OutputWorkspace_" + std::to_string(count);
++count;
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
outWsPropName, childWsName, Direction::Output));
......
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