Commit 2627d3e6 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #18518. Apply clang format patch.

parent f387b4a4
......@@ -256,7 +256,7 @@ public:
explicit Attribute(const std::vector<double> &v)
: m_data(v), m_quoteValue(false) {}
/// Copy assignment
Attribute& operator=(const Attribute &attr);
Attribute &operator=(const Attribute &attr);
/// Apply an attribute visitor
template <typename T> T apply(AttributeVisitor<T> &v) {
......
......@@ -54,6 +54,7 @@ public:
protected:
void reset(IFunction *fun, std::size_t index, bool isDefault = false);
private:
/// Function-owner of this reference. parameterName() and parameterIndex()
/// return values relative to this function.
......
......@@ -326,13 +326,15 @@ std::string CompositeFunction::descriptionOfActive(size_t i) const {
}
/// Change status of parameter
void CompositeFunction::setParameterStatus(size_t i, IFunction::ParameterStatus status) {
void CompositeFunction::setParameterStatus(size_t i,
IFunction::ParameterStatus status) {
size_t iFun = functionIndex(i);
m_functions[iFun]->setParameterStatus(i - m_paramOffsets[iFun], status);
}
/// Get status of parameter
IFunction::ParameterStatus CompositeFunction::getParameterStatus(size_t i) const {
IFunction::ParameterStatus
CompositeFunction::getParameterStatus(size_t i) const {
size_t iFun = functionIndex(i);
return m_functions[iFun]->getParameterStatus(i - m_paramOffsets[iFun]);
}
......@@ -409,7 +411,7 @@ void CompositeFunction::removeFunction(size_t i) {
// Number of parameters in functions preceding the removed one.
// Indices of those parameters won't change
size_t nParamsBeforeRemoved = m_paramOffsets[i];
//
//
// Shift down the function indeces for parameters
for (auto it = m_IFunction.begin(); it != m_IFunction.end();) {
......
......@@ -124,7 +124,8 @@ void FunctionGenerator::setError(size_t i, double err) {
}
/// Change status of parameter
void FunctionGenerator::setParameterStatus(size_t i, IFunction::ParameterStatus status) {
void FunctionGenerator::setParameterStatus(size_t i,
IFunction::ParameterStatus status) {
if (i < m_nOwnParams) {
m_source->setParameterStatus(i, status);
} else {
......@@ -134,7 +135,8 @@ void FunctionGenerator::setParameterStatus(size_t i, IFunction::ParameterStatus
}
/// Get status of parameter
IFunction::ParameterStatus FunctionGenerator::getParameterStatus(size_t i) const {
IFunction::ParameterStatus
FunctionGenerator::getParameterStatus(size_t i) const {
if (i < m_nOwnParams) {
return m_source->getParameterStatus(i);
} else {
......@@ -291,7 +293,5 @@ IConstraint *FunctionGenerator::getConstraint(size_t i) const {
return constraint;
}
} // namespace API
} // namespace Mantid
......@@ -212,8 +212,9 @@ void IFunction::removeTie(const std::string &parName) {
std::string IFunction::writeTies() const {
std::ostringstream tieStream;
bool first = true;
for(auto &tie: m_ties) {
if (tie->isDefault()) continue;
for (auto &tie : m_ties) {
if (tie->isDefault())
continue;
if (!first) {
tieStream << ',';
} else {
......@@ -267,7 +268,8 @@ class ReferenceEqual {
public:
/// Constructor
explicit ReferenceEqual(const IFunction &fun, size_t i) : m_fun(fun), m_i(i) {}
explicit ReferenceEqual(const IFunction &fun, size_t i)
: m_fun(fun), m_i(i) {}
/// Bracket operator
/// @param p :: the element you are looking for
/// @return True if found
......@@ -284,7 +286,8 @@ bool IFunction::removeTie(size_t i) {
if (i >= nParams()) {
throw std::out_of_range("Function parameter index out of range.");
}
auto it = std::find_if(m_ties.begin(), m_ties.end(), ReferenceEqual(*this, i));
auto it =
std::find_if(m_ties.begin(), m_ties.end(), ReferenceEqual(*this, i));
if (it != m_ties.end()) {
m_ties.erase(it);
setParameterStatus(i, Active);
......@@ -302,7 +305,8 @@ ParameterTie *IFunction::getTie(size_t i) const {
if (i >= nParams()) {
throw std::out_of_range("Function parameter index out of range.");
}
auto it = std::find_if(m_ties.cbegin(), m_ties.cend(), ReferenceEqual(*this, i));
auto it =
std::find_if(m_ties.cbegin(), m_ties.cend(), ReferenceEqual(*this, i));
if (it != m_ties.cend()) {
return it->get();
}
......@@ -366,10 +370,7 @@ void IFunction::removeConstraint(const std::string &parName) {
}
/// Remove all constraints.
void IFunction::clearConstraints() {
m_constraints.clear();
}
void IFunction::clearConstraints() { m_constraints.clear(); }
void IFunction::setUpForFit() {
for (auto &constraint : m_constraints) {
......@@ -382,8 +383,9 @@ void IFunction::setUpForFit() {
std::string IFunction::writeConstraints() const {
std::ostringstream stream;
bool first = true;
for(auto &constrint: m_constraints) {
if (constrint->isDefault()) continue;
for (auto &constrint : m_constraints) {
if (constrint->isDefault())
continue;
if (!first) {
stream << ',';
} else {
......@@ -574,7 +576,7 @@ private:
/// Copy assignment. Do not copy m_quoteValue flag.
/// @param attr :: The attribute to copy from.
IFunction::Attribute& IFunction::Attribute::operator=(const Attribute &attr) {
IFunction::Attribute &IFunction::Attribute::operator=(const Attribute &attr) {
m_data = attr.m_data;
return *this;
}
......@@ -836,7 +838,8 @@ void IFunction::Attribute::fromString(const std::string &str) {
/// Value of i-th active parameter. Override this method to make fitted
/// parameters different from the declared
double IFunction::activeParameter(size_t i) const {
if (!isActive(i)) { throw std::runtime_error("Attempt to use an inactive parameter " +
if (!isActive(i)) {
throw std::runtime_error("Attempt to use an inactive parameter " +
parameterName(i));
}
return getParameter(i);
......
......@@ -26,12 +26,10 @@ ParameterReference::ParameterReference(IFunction *fun, std::size_t index,
IFunction *ParameterReference::getLocalFunction() const { return m_function; }
/// Return parameter index in the local function
std::size_t ParameterReference::getLocalIndex() const {
return m_index;
}
std::size_t ParameterReference::getLocalIndex() const { return m_index; }
/// Return parameter index in the owning function
std::size_t ParameterReference::parameterIndex() const {
std::size_t ParameterReference::parameterIndex() const {
return m_owner->getParameterIndex(*this);
}
......@@ -71,7 +69,8 @@ void ParameterReference::reset(IFunction *fun, std::size_t index,
* Set the parameter
* @param value :: A value to set.
*/
void ParameterReference::setParameter(const double &value, bool isExplicitlySet) {
void ParameterReference::setParameter(const double &value,
bool isExplicitlySet) {
m_function->setParameter(m_index, value, isExplicitlySet);
}
......
......@@ -115,7 +115,7 @@ double ParameterTie::eval() {
*(it->first) = it->second.getParameter();
}
res = m_parser->Eval();
} catch (mu::ParserError& e) {
} catch (mu::ParserError &e) {
throw std::runtime_error("Error in expresseion: " + e.GetMsg());
}
......
......@@ -280,10 +280,9 @@ public:
icf.applyTies();
auto icfString = icf.asString();
TS_ASSERT_EQUALS(
icfString.substr(0, 91),
"name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,a2=2.2,b2=12,ties=(");
TS_ASSERT_EQUALS(icfString.substr(0, 91),
"name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,a2=2.2,b2=12,ties=(");
auto icfTies = icfString.substr(91);
TS_ASSERT(icfTies.find("a2=a1/5") != std::string::npos)
TS_ASSERT(icfTies.find("b2=b1") != std::string::npos)
......
......@@ -109,7 +109,7 @@ public:
}
/// Get parameter name
// std::string getParameterName() const { return m_parameterName; }
// std::string getParameterName() const { return m_parameterName; }
/// overwrite IConstraint base class methods
double check() override;
......@@ -123,7 +123,7 @@ private:
double m_penaltyFactor;
/// name of parameter you want to constraint
//std::string m_parameterName;
// std::string m_parameterName;
/// has a lower bound set true/false
bool m_hasLowerBound;
......
......@@ -28,9 +28,9 @@ DECLARE_ALGORITHM(Fit)
void Fit::initConcrete() {
declareProperty("Ties", "", Kernel::Direction::Input);
getPointerToProperty("Ties")->setDocumentation(
"Math expressions defining ties between parameters of "
"the fitting function.");
getPointerToProperty("Ties")
->setDocumentation("Math expressions defining ties between parameters of "
"the fitting function.");
declareProperty("Constraints", "", Kernel::Direction::Input);
getPointerToProperty("Constraints")->setDocumentation("List of constraints");
auto mustBePositive = boost::make_shared<Kernel::BoundedValidator<int>>();
......
......@@ -25,15 +25,14 @@ using namespace API;
/// Default constructor
BoundaryConstraint::BoundaryConstraint()
: API::IConstraint(), m_penaltyFactor(1000.0),
m_hasLowerBound(false), m_hasUpperBound(false), m_lowerBound(DBL_MAX),
m_upperBound(-DBL_MAX) {}
: API::IConstraint(), m_penaltyFactor(1000.0), m_hasLowerBound(false),
m_hasUpperBound(false), m_lowerBound(DBL_MAX), m_upperBound(-DBL_MAX) {}
/// Constructor with no boundary arguments
/// @param paramName :: The parameter name
BoundaryConstraint::BoundaryConstraint(const std::string &paramName)
: API::IConstraint(), m_penaltyFactor(1000.0),
m_hasLowerBound(false), m_hasUpperBound(false) {}
: API::IConstraint(), m_penaltyFactor(1000.0), m_hasLowerBound(false),
m_hasUpperBound(false) {}
/** Constructor with boundary arguments
* @param fun :: The function
......@@ -48,18 +47,16 @@ BoundaryConstraint::BoundaryConstraint(API::IFunction *fun,
const std::string paramName,
const double lowerBound,
const double upperBound, bool isDefault)
: m_penaltyFactor(1000.0),
m_hasLowerBound(true), m_hasUpperBound(true), m_lowerBound(lowerBound),
m_upperBound(upperBound) {
: m_penaltyFactor(1000.0), m_hasLowerBound(true), m_hasUpperBound(true),
m_lowerBound(lowerBound), m_upperBound(upperBound) {
reset(fun, fun->parameterIndex(paramName), isDefault);
}
BoundaryConstraint::BoundaryConstraint(API::IFunction *fun,
const std::string paramName,
const double lowerBound, bool isDefault)
: m_penaltyFactor(1000.0),
m_hasLowerBound(true), m_hasUpperBound(false), m_lowerBound(lowerBound),
m_upperBound(-DBL_MAX) {
: m_penaltyFactor(1000.0), m_hasLowerBound(true), m_hasUpperBound(false),
m_lowerBound(lowerBound), m_upperBound(-DBL_MAX) {
reset(fun, fun->parameterIndex(paramName), isDefault);
}
......
......@@ -382,7 +382,8 @@ void CrystalFieldMultiSpectrum::updateTargetFunction() const {
auto &fun = dynamic_cast<MultiDomainFunction &>(*m_target);
try {
for (size_t i = 0; i < temperatures.size(); ++i) {
updateSpectrum(*fun.getFunction(i), nre, en, wf, ham, temperatures[i], fwhms[i], i);
updateSpectrum(*fun.getFunction(i), nre, en, wf, ham, temperatures[i],
fwhms[i], i);
}
} catch (std::out_of_range &) {
buildTargetFunction();
......@@ -427,8 +428,8 @@ void CrystalFieldMultiSpectrum::updateSpectrum(
calcExcitations(nre, en, wf, temperature, values, iSpec);
auto &composite = dynamic_cast<API::CompositeFunction &>(spectrum);
m_nPeaks[iSpec] = CrystalFieldUtils::updateSpectrumFunction(
composite, peakShape, values, m_nPeaks[iSpec], 1, m_fwhmX[iSpec], m_fwhmY[iSpec],
fwhmVariation, fwhm, fixAllPeaks);
composite, peakShape, values, m_nPeaks[iSpec], 1, m_fwhmX[iSpec],
m_fwhmY[iSpec], fwhmVariation, fwhm, fixAllPeaks);
}
}
......
......@@ -2032,7 +2032,8 @@ public:
void test_fit_size_change() {
auto ws = WorkspaceCreationHelper::create2DWorkspaceFromFunction(
[](double x, int) { return 2*exp(-(5*x + x*x - 3*x*x*x)); }, 1, 0, 1, 0.1);
[](double x, int) { return 2 * exp(-(5 * x + x * x - 3 * x * x * x)); },
1, 0, 1, 0.1);
{
API::IFunction_sptr fun =
boost::make_shared<TestHelpers::FunctionChangesNParams>();
......@@ -2080,7 +2081,7 @@ public:
void test_fit_size_change_1() {
auto ws = WorkspaceCreationHelper::create2DWorkspaceFromFunction(
[](double x, int) { return 2 + x - 0.1*x*x; }, 1, 0, 1, 0.1);
[](double x, int) { return 2 + x - 0.1 * x * x; }, 1, 0, 1, 0.1);
{
API::IFunction_sptr fun =
boost::make_shared<TestHelpers::FunctionChangesNParams>();
......
......@@ -434,7 +434,6 @@ public:
"name=Gaussian,Height=0,PeakCentre=0,Sigma=0,constraints=("
"0<Height);name=LinearBackground,A0=0,A1=0,constraints=("
"A0<0);constraints=(f0.Sigma<0,10<f1.A1)");
}
void test_ties_str() {
......
......@@ -22,7 +22,7 @@ using namespace Mantid::CurveFitting::Constraints;
class BoundaryConstraintTest : public CxxTest::TestSuite {
public:
//void test1() {
// void test1() {
// // set up fitting function
// Gaussian gaus;
// gaus.initialize();
......
......@@ -351,6 +351,7 @@ public:
/// during fit.
class MANTID_KERNEL_DLL FitSizeWarning final : public std::exception {
std::string m_message;
public:
explicit FitSizeWarning(size_t oldSize);
FitSizeWarning(size_t oldSize, size_t newSize);
......
......@@ -57,9 +57,8 @@ public:
static PyObject *getAttributeValue(IFunction &self,
const API::IFunction::Attribute &attr);
/// Set the attribute's value
static void setAttributePythonValue(IFunction &self,
const std::string &name,
const boost::python::object &value);
static void setAttributePythonValue(IFunction &self, const std::string &name,
const boost::python::object &value);
/// Called by the framework when an attribute has been set
void setAttribute(const std::string &attName,
const API::IFunction::Attribute &attr) override;
......
......@@ -50,8 +50,10 @@ typedef void (IFunction::*setParameterType2)(const std::string &,
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setParameterType2_Overloads,
setParameter, 2, 3)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(tie_Overloads, tie, 2, 3)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addConstraints_Overloads, addConstraints, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(fixParameter_Overloads, fixParameter, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addConstraints_Overloads, addConstraints,
1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(fixParameter_Overloads, fixParameter, 1,
2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(fix_Overloads, fix, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(fixAll_Overloads, fixAll, 0, 1)
#ifdef __clang__
......@@ -144,8 +146,9 @@ void export_IFunction() {
(arg("self"), arg("name")),
"Declare a fitting parameter settings its default value to 0.0")
.def("fixParameter", &IFunction::fix, fix_Overloads(
(arg("self"), arg("i"), arg("isDefault")), "Fix the ith parameter"))
.def("fixParameter", &IFunction::fix,
fix_Overloads((arg("self"), arg("i"), arg("isDefault")),
"Fix the ith parameter"))
.def("fixParameter", &IFunction::fixParameter,
fixParameter_Overloads((arg("self"), arg("name"), arg("isDefault")),
......@@ -160,8 +163,9 @@ void export_IFunction() {
.def("isFixed", &IFunction::isFixed, (arg("self"), arg("i")),
"Return whether the ith parameter is fixed or tied")
.def("fixAll", &IFunction::fixAll, fixAll_Overloads((arg("self"), arg("isDefault")),
"Fix all parameters"))
.def("fixAll", &IFunction::fixAll,
fixAll_Overloads((arg("self"), arg("isDefault")),
"Fix all parameters"))
.def("freeAll", &IFunction::unfixAll, (arg("self")),
"Free all parameters")
......
......@@ -45,7 +45,7 @@ IFunction::Attribute createAttributeFromPythonValue(const object &value) {
} else if (PyList_Check(rawptr) == 1) {
auto n = PyList_Size(rawptr);
std::vector<double> vec;
for(Py_ssize_t i = 0; i < n; ++i) {
for (Py_ssize_t i = 0; i < n; ++i) {
auto v = extract<double>(PyList_GetItem(rawptr, i))();
vec.push_back(v);
}
......@@ -149,8 +149,8 @@ IFunctionAdapter::getAttributeValue(IFunction &self,
* @param value :: The value to set
*/
void IFunctionAdapter::setAttributePythonValue(IFunction &self,
const std::string &name,
const object &value) {
const std::string &name,
const object &value) {
auto attr = createAttributeFromPythonValue(value);
self.setAttribute(name, attr);
}
......@@ -178,16 +178,16 @@ void IFunctionAdapter::setAttribute(const std::string &attName,
* For a single domain function it should have a single element (self).
* @return A python list of IFunction_sprs.
*/
boost::python::object IFunctionAdapter::createEquivalentFunctions(IFunction &self) {
boost::python::object
IFunctionAdapter::createEquivalentFunctions(IFunction &self) {
auto functions = self.createEquivalentFunctions();
boost::python::list list;
for(auto fun : functions) {
for (auto fun : functions) {
list.append(fun);
}
return list;
}
/**
* Value of i-th active parameter. If this functions is overridden
* in Python then it returns the value of the ith active Parameter
......
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