run clang-tidy with readability-braces-around-statements (#2899)

* run clang-tidy with readability-braces-around-statements
clang-format the results
clean up all the parts that clang-tidy-8 broke

* fix problem on windows
This commit is contained in:
Greg Landrum
2020-01-25 14:19:32 +01:00
committed by GitHub
parent fb3cad523e
commit d41752d558
261 changed files with 7449 additions and 3545 deletions

View File

@@ -172,7 +172,9 @@ unsigned int jacobi(double quad[4][4], double eigenVals[4],
// initialize the eigen vector to Identity
for (j = 0; j <= 3; j++) {
for (i = 0; i <= 3; i++) eigenVecs[i][j] = 0.0;
for (i = 0; i <= 3; i++) {
eigenVecs[i][j] = 0.0;
}
eigenVecs[j][j] = 1.0;
eigenVals[j] = quad[j][j];
}
@@ -186,7 +188,9 @@ unsigned int jacobi(double quad[4][4], double eigenVals[4],
offDiagNorm += fabs(quad[i][j]);
}
}
if ((offDiagNorm / diagNorm) <= TOLERANCE) goto Exit_now;
if ((offDiagNorm / diagNorm) <= TOLERANCE) {
goto Exit_now;
}
for (j = 1; j <= 3; j++) {
for (i = 0; i <= j - 1; i++) {
b = quad[i][j];

View File

@@ -30,11 +30,13 @@ void GetPointsFromPythonSequence(python::object &points,
double *data;
if (PyArray_Check(pyObj)) {
// get the dimensions of the array
PyArrayObject *ptsMat = reinterpret_cast<PyArrayObject *>(pyObj);
auto *ptsMat = reinterpret_cast<PyArrayObject *>(pyObj);
nrows = PyArray_DIM(ptsMat, 0);
ncols = PyArray_DIM(ptsMat, 1);
if (ncols != 3) throw_value_error("Wrong dimension for the points array");
if (ncols != 3) {
throw_value_error("Wrong dimension for the points array");
}
data = reinterpret_cast<double *>(PyArray_DATA(ptsMat));
@@ -45,13 +47,16 @@ void GetPointsFromPythonSequence(python::object &points,
}
} else if (PySequence_Check(pyObj)) {
nrows = PySequence_Size(pyObj);
if (nrows <= 0) throw_value_error("Empty sequence passed in");
if (nrows <= 0) {
throw_value_error("Empty sequence passed in");
}
python::extract<RDGeom::Point3D> ptOk(points[0]);
if (!ptOk.check()) {
for (unsigned int i = 0; i < nrows; i++) {
PySequenceHolder<double> row(points[i]);
if (row.size() != 3)
if (row.size() != 3) {
throw_value_error("Wrong number of entries in the list of lists");
}
auto *rpt = new RDGeom::Point3D(row[0], row[1], row[2]);
pts.push_back(rpt);
}
@@ -90,19 +95,21 @@ PyObject *AlignPointPairs(python::object refPoints, python::object probePoints,
GetPointsFromPythonSequence(probePoints, probePts);
unsigned int npt = refPts.size();
if (npt != probePts.size())
if (npt != probePts.size()) {
throw_value_error("Mis-match in number of points");
}
PyObject *weightsObj = weights.ptr();
RDNumeric::DoubleVector *wtsVec;
wtsVec = nullptr;
double *data;
if (PyArray_Check(weightsObj)) {
PyArrayObject *wtsMat = reinterpret_cast<PyArrayObject *>(weightsObj);
auto *wtsMat = reinterpret_cast<PyArrayObject *>(weightsObj);
unsigned int nwts = PyArray_DIM(wtsMat, 0);
if (nwts != npt)
if (nwts != npt) {
throw_value_error(
"Number of weights supplied do not match the number of points");
}
wtsVec = new RDNumeric::DoubleVector(nwts);
data = reinterpret_cast<double *>(PyArray_DATA(wtsMat));
for (unsigned int i = 0; i < nwts; i++) {
@@ -113,9 +120,10 @@ PyObject *AlignPointPairs(python::object refPoints, python::object probePoints,
unsigned int nwts = wts.size();
if (nwts > 0) {
if (nwts != npt)
if (nwts != npt) {
throw_value_error(
"Number of weights supplied do not match the number of points");
}
wtsVec = new RDNumeric::DoubleVector(nwts);
for (unsigned int i = 0; i < npt; i++) {
wtsVec->setVal(i, wts[i]);
@@ -130,8 +138,8 @@ PyObject *AlignPointPairs(python::object refPoints, python::object probePoints,
npy_intp dims[2];
dims[0] = 4;
dims[1] = 4;
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
double *resData = reinterpret_cast<double *>(PyArray_DATA(res));
auto *res = (PyArrayObject *)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
auto *resData = reinterpret_cast<double *>(PyArray_DATA(res));
const double *tdata = trans.getData();
for (unsigned int i = 0; i < trans.numRows(); ++i) {
unsigned int itab = i * 4;

View File

@@ -43,7 +43,9 @@ bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
unsigned int i, j, id, iter, evalId;
DoubleVector v(N), z(N);
if (seed <= 0) seed = clock();
if (seed <= 0) {
seed = clock();
}
for (ei = 0; ei < numEig; ei++) {
eigVal = -HUGE_EIGVAL;
seed += ei;

View File

@@ -24,7 +24,7 @@ TEST_CASE("Conrec basics", "[conrec]") {
SECTION("basics") {
std::vector<RDGeom::Point2D> pts = {{0., 0.}, {1., 0.}, {1., 1.}, {0., 1.}};
const size_t gridSz = 100;
double *grid = new double[gridSz * gridSz];
auto *grid = new double[gridSz * gridSz];
double xps[gridSz];
double yps[gridSz];
double x1 = -4, y1 = -4, x2 = 6, y2 = 6;
@@ -35,13 +35,17 @@ TEST_CASE("Conrec basics", "[conrec]") {
xps[ix] = px;
for (size_t iy = 0; iy < gridSz; ++iy) {
auto py = y1 + iy * dy;
if (ix == 0) yps[iy] = py;
if (ix == 0) {
yps[iy] = py;
}
RDGeom::Point2D loc(px, py);
double val = 0.0;
for (const auto &pt : pts) {
auto dv = loc - pt;
auto r = dv.length();
if (r > 0) val += 1 / r;
if (r > 0) {
val += 1 / r;
}
}
maxV = std::max(val, maxV);
grid[ix * gridSz + iy] = val;