Commit b6768c92 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #14642. Apply clang-format patch.

parent c5297e6a
......@@ -432,7 +432,8 @@ void Expression::setFunct(const std::string &name) {
std::string f = name.substr(0, i);
Expression tmp(this);
tmp.parse(args);
if (tmp.name() != EMPTY_EXPRESSION_NAME && (!tmp.isFunct() || tmp.name() != ",")) {
if (tmp.name() != EMPTY_EXPRESSION_NAME &&
(!tmp.isFunct() || tmp.name() != ",")) {
m_terms.push_back(tmp);
} else {
std::string my_op = m_op;
......
......@@ -32,7 +32,8 @@ DECLARE_FUNCTION(TabulatedFunction)
const int TabulatedFunction::defaultIndexValue = 0;
/// Constructor
TabulatedFunction::TabulatedFunction() : m_setupFinished(false), m_explicitXY(false) {
TabulatedFunction::TabulatedFunction()
: m_setupFinished(false), m_explicitXY(false) {
declareParameter("Scaling", 1.0, "A scaling factor");
declareParameter("Shift", 0.0, "Shift in the abscissa");
declareParameter("XScaling", 1.0, "Scaling factor in X");
......@@ -193,39 +194,39 @@ void TabulatedFunction::setAttribute(const std::string &attName,
m_explicitXY = false;
}
} else if (attName == "X") {
m_xData = value.asVector();
if (m_xData.empty()) {
m_setupFinished = false;
m_explicitXY = false;
if (!m_yData.empty()) {
m_yData.clear();
}
return;
}
if (m_xData.size() != m_yData.size()) {
m_yData.resize(m_xData.size());
m_xData = value.asVector();
if (m_xData.empty()) {
m_setupFinished = false;
m_explicitXY = false;
if (!m_yData.empty()) {
m_yData.clear();
}
storeAttributeValue("FileName", Attribute("", true));
storeAttributeValue("Workspace", Attribute(""));
m_setupFinished = true;
m_explicitXY = true;
return;
}
if (m_xData.size() != m_yData.size()) {
m_yData.resize(m_xData.size());
}
storeAttributeValue("FileName", Attribute("", true));
storeAttributeValue("Workspace", Attribute(""));
m_setupFinished = true;
m_explicitXY = true;
} else if (attName == "Y") {
m_yData = value.asVector();
if (m_yData.empty()) {
m_setupFinished = false;
m_explicitXY = false;
if (!m_xData.empty()) {
m_xData.clear();
}
return;
}
if (m_xData.size() != m_yData.size()) {
m_xData.resize(m_yData.size());
m_yData = value.asVector();
if (m_yData.empty()) {
m_setupFinished = false;
m_explicitXY = false;
if (!m_xData.empty()) {
m_xData.clear();
}
storeAttributeValue("FileName", Attribute("", true));
storeAttributeValue("Workspace", Attribute(""));
m_setupFinished = true;
m_explicitXY = true;
return;
}
if (m_xData.size() != m_yData.size()) {
m_xData.resize(m_yData.size());
}
storeAttributeValue("FileName", Attribute("", true));
storeAttributeValue("Workspace", Attribute(""));
m_setupFinished = true;
m_explicitXY = true;
} else {
IFunction::setAttribute(attName, value);
m_setupFinished = false;
......@@ -233,13 +234,13 @@ void TabulatedFunction::setAttribute(const std::string &attName,
}
/// Returns the number of attributes associated with the function
size_t TabulatedFunction::nAttributes() const{
size_t TabulatedFunction::nAttributes() const {
// additional X and Y attributes
return IFunction::nAttributes() + 2;
}
/// Returns a list of attribute names
std::vector<std::string> TabulatedFunction::getAttributeNames() const{
std::vector<std::string> TabulatedFunction::getAttributeNames() const {
std::vector<std::string> attNames = IFunction::getAttributeNames();
attNames.push_back("X");
attNames.push_back("Y");
......@@ -248,7 +249,8 @@ std::vector<std::string> TabulatedFunction::getAttributeNames() const{
/// Return a value of attribute attName
/// @param attName :: The attribute name
IFunction::Attribute TabulatedFunction::getAttribute(const std::string &attName) const{
IFunction::Attribute
TabulatedFunction::getAttribute(const std::string &attName) const {
if (attName == "X") {
return m_explicitXY ? Attribute(m_xData) : Attribute(std::vector<double>());
} else if (attName == "Y") {
......@@ -259,14 +261,13 @@ IFunction::Attribute TabulatedFunction::getAttribute(const std::string &attName)
/// Check if attribute attName exists
/// @param attName :: The attribute name
bool TabulatedFunction::hasAttribute(const std::string &attName) const{
bool TabulatedFunction::hasAttribute(const std::string &attName) const {
if (attName == "X" || attName == "Y") {
return true;
}
return IFunction::hasAttribute(attName);
}
/**
* Load input file as a Nexus file.
* @param fname :: The file name
......@@ -318,7 +319,8 @@ void TabulatedFunction::loadWorkspace(
void TabulatedFunction::setupData() const {
if (m_setupFinished) {
if (m_xData.size() != m_yData.size()) {
throw std::invalid_argument(this->name() + ": X and Y vectors have different sizes.");
throw std::invalid_argument(this->name() +
": X and Y vectors have different sizes.");
}
g_log.debug() << "Re-setting isn't required.";
return;
......
......@@ -276,7 +276,7 @@ public:
const size_t n = 10;
std::vector<double> X(n);
std::vector<double> Y(n);
for(size_t i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
X[i] = double(i);
Y[i] = X[i] * X[i];
}
......@@ -287,9 +287,9 @@ public:
FunctionValues y(x);
fun.function(x, y);
for(size_t i = 0; i < x.size(); ++i) {
for (size_t i = 0; i < x.size(); ++i) {
double xx = x[i];
TS_ASSERT_DELTA(y[i], xx*xx, 0.5);
TS_ASSERT_DELTA(y[i], xx * xx, 0.5);
}
}
......@@ -297,7 +297,7 @@ public:
TabulatedFunction fun;
const size_t n = 10;
std::vector<double> X(n);
std::vector<double> Y(n-1);
std::vector<double> Y(n - 1);
fun.setAttributeValue("X", X);
fun.setAttributeValue("Y", Y);
......@@ -307,7 +307,6 @@ public:
TS_ASSERT_EQUALS(x.size(), y.size());
TS_ASSERT_EQUALS(x.size(), Y.size());
}
void test_set_X_Y_attributes_string() {
......
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