Skip to content

Commit

Permalink
Merge pull request #606 from lsst/tickets/DM-29511
Browse files Browse the repository at this point in the history
DM-29511: apply clang tidy cleanups
  • Loading branch information
mwittgen committed Sep 13, 2021
2 parents 197addc + f2ab5af commit 184b6e4
Show file tree
Hide file tree
Showing 191 changed files with 1,182 additions and 1,277 deletions.
2 changes: 1 addition & 1 deletion examples/analyticKernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Demonstrate an AnalyticKernel, both spatially invariant and spatially varying.
*/

typedef lsst::afw::math::Kernel::Pixel Pixel;
using Pixel = lsst::afw::math::Kernel::Pixel;

using namespace std;

Expand Down
6 changes: 3 additions & 3 deletions examples/chebyshev1Function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
using namespace std;

int main() {
typedef double funcType;
using funcType = double;
const unsigned int order = 3;
vector<double> params(order + 1);
lsst::afw::math::Chebyshev1Function1<funcType> chebyFunc(order);
Expand All @@ -41,8 +41,8 @@ int main() {
}
chebyFunc.setParameters(params);
cout << "Chebychev polynomial of the first kind with parameters: ";
for (unsigned int ii = 0; ii < params.size(); ++ii) {
cout << params[ii] << " ";
for (double param : params) {
cout << param << " ";
}
cout << endl << endl;
for (double x = -1.0; x < 1.1; x += 0.2) {
Expand Down
2 changes: 1 addition & 1 deletion examples/convolveLinear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(int argc, char **argv) {
LOG_CONFIG();
LOG_SET_LVL("TRACE5.afw.math.convolve", LOG_LVL_INFO);

typedef float ImagePixel;
using ImagePixel = float;
unsigned int const KernelCols = 19;
unsigned int const KernelRows = 19;
double const MinSigma = 1.5;
Expand Down
2 changes: 1 addition & 1 deletion examples/fixedKernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
using namespace std;

int main() {
typedef lsst::afw::math::Kernel::Pixel Pixel;
using Pixel = lsst::afw::math::Kernel::Pixel;

double majorSigma = 2.5;
double minorSigma = 2.0;
Expand Down
10 changes: 5 additions & 5 deletions examples/forEachPixel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@
namespace afwImage = lsst::afw::image;
template <typename T>
struct erase : public afwImage::pixelOp0<T> {
T operator()() const { return 0; }
T operator()() const override { return 0; }
};

template <typename T>
struct setVal
: public afwImage::pixelOp0<T> { // don't call it fill as people like to say using namespace std
setVal(T val) : _val(val) {}
T operator()() const { return _val; }
T operator()() const override { return _val; }

private:
T _val;
};

template <typename T>
struct addOne : public afwImage::pixelOp1<T> {
T operator()(T val) const { return val + 1; }
T operator()(T val) const override { return val + 1; }
};

template <typename T1, typename T2>
struct divide : public afwImage::pixelOp2<T1, T2> {
T1 operator()(T1 lhs, T2 rhs) const { return lhs / rhs; }
T1 operator()(T1 lhs, T2 rhs) const override { return lhs / rhs; }
};

template <typename T>
struct Gaussian : public afwImage::pixelOp1XY<T> {
Gaussian(float a, float xc, float yc, float alpha) : _a(a), _xc(xc), _yc(yc), _alpha(alpha) {}
T operator()(int x, int y, T val) const {
T operator()(int x, int y, T val) const override {
float const dx = x - _xc;
float const dy = y - _yc;
return val + _a * ::exp(-(dx * dx + dy * dy) / (2 * _alpha * _alpha));
Expand Down
2 changes: 1 addition & 1 deletion examples/gaussianFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using namespace std;

int main() {
typedef double FuncReturn;
using FuncReturn = double;
double sigma = 2.0;
lsst::afw::math::GaussianFunction1<FuncReturn> gaussFunc(sigma);

Expand Down
4 changes: 2 additions & 2 deletions examples/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace afwImage = lsst::afw::image;

template <typename PixelT>
void print(afwImage::Image<PixelT>& src, const std::string& title = "") {
typedef typename afwImage::Image<PixelT>::x_iterator XIter;
using XIter = typename afwImage::Image<PixelT>::x_iterator;
if (title.size() > 0) {
printf("%s:\n", title.c_str());
}
Expand Down Expand Up @@ -89,7 +89,7 @@ template <typename PixelT>
void y_gradient(const afwImage::Image<PixelT>& src, const afwImage::Image<PixelT>& dst) {
assert(src.getDimensions() == dst.getDimensions());

typedef typename afwImage::Image<PixelT>::const_xy_locator xy_loc;
using xy_loc = typename afwImage::Image<PixelT>::const_xy_locator;
xy_loc src_loc = src.xy_at(0, 1);

#define USE_CACHE_LOCATION 1
Expand Down
2 changes: 1 addition & 1 deletion examples/image1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Note: only specific types are supported; for the list of available types
// see the explicit instantiation code at the end of lsst/afw/image/src/Image.cc
namespace afwImage = lsst::afw::image;
typedef afwImage::Image<int> ImageT;
using ImageT = afwImage::Image<int>;

int main() {
// Declare an Image; its pixels are not yet initialized.
Expand Down
4 changes: 2 additions & 2 deletions examples/image2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "lsst/afw/image/Image.h"

namespace image = lsst::afw::image;
typedef image::Image<int> ImageT;
using ImageT = image::Image<int>;

int main() {
ImageT in(lsst::geom::Extent2I(10, 6));
Expand Down Expand Up @@ -57,7 +57,7 @@ int main() {
std::shared_ptr<ImageT> out2(new ImageT(in.getDimensions()));
out2->assign(in);

typedef ImageT::const_xy_locator xy_loc;
using xy_loc = ImageT::const_xy_locator;

for (int y = 1; y != in.getHeight() - 1; ++y) {
// "dot" means "cursor location" in emacs
Expand Down
2 changes: 1 addition & 1 deletion examples/imageBackground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace std;
namespace image = lsst::afw::image;
namespace math = lsst::afw::math;

typedef image::Image<float> ImageF;
using ImageF = image::Image<float>;

int main() {
// set the parameters for a fake image.
Expand Down
8 changes: 4 additions & 4 deletions examples/imageStatistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
namespace image = lsst::afw::image;
namespace math = lsst::afw::math;

typedef image::Image<float> ImageF;
typedef image::MaskedImage<float> MaskedImageF;
typedef math::Statistics ImgStat;
typedef math::MaskedVector<float> MaskedVectorF;
using ImageF = image::Image<float>;
using MaskedImageF = image::MaskedImage<float>;
using ImgStat = math::Statistics;
using MaskedVectorF = math::MaskedVector<float>;

/*
* An example of how to use the Statistics class
Expand Down
2 changes: 1 addition & 1 deletion examples/lanczosFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
using namespace std;

int main() {
typedef double FuncReturn;
using FuncReturn = double;

unsigned int order = 2;
lsst::afw::math::LanczosFunction2<FuncReturn> lancFunc(order);
Expand Down
2 changes: 1 addition & 1 deletion examples/lanczosKernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using namespace std;

int main() {
typedef lsst::afw::math::Kernel::Pixel Pixel;
using Pixel = lsst::afw::math::Kernel::Pixel;

unsigned int kernelCols = 6;
unsigned int kernelRows = 5;
Expand Down
2 changes: 1 addition & 1 deletion examples/maskIo2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace afwImage = lsst::afw::image;
* of memory management
*/
void test(char *name, char *masterName) {
typedef afwImage::MaskPixel MaskPixel;
using MaskPixel = afwImage::MaskPixel;

afwImage::Mask<afwImage::MaskPixel> testMask(name);

Expand Down
4 changes: 2 additions & 2 deletions examples/maskedImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
namespace image = lsst::afw::image;
using namespace std;

typedef double ImagePixelT;
using ImagePixelT = double;

template <typename PixelT>
void y_gradient(image::MaskedImage<PixelT>& src, image::MaskedImage<PixelT>& dst) {
assert(src.getDimensions() == dst.getDimensions());

#define CONST 1
#if CONST
typedef typename image::MaskedImage<PixelT>::const_xy_locator xyl;
using xyl = typename image::MaskedImage<PixelT>::const_xy_locator;
#else
typedef typename image::MaskedImage<PixelT>::xy_locator xyl;
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/maskedImage1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Note: only specific types are supported; for the list of available types
// see the explicit instantiation code at the end of lsst/afw/image/src/MaskedImage.cc
namespace afwImage = lsst::afw::image;
typedef afwImage::MaskedImage<int> ImageT;
using ImageT = afwImage::MaskedImage<int>;

int main() {
// Declare a MaskedImage; its pixels are not yet initialized.
Expand Down
4 changes: 2 additions & 2 deletions examples/maskedImage2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "lsst/afw/image/MaskedImage.h"

namespace image = lsst::afw::image;
typedef image::MaskedImage<int> ImageT;
using ImageT = image::MaskedImage<int>;

int main() {
ImageT in(lsst::geom::Extent2I(10, 6));
Expand Down Expand Up @@ -55,7 +55,7 @@ int main() {
std::shared_ptr<ImageT> out2(new ImageT(in.getDimensions()));
out2->assign(in);

typedef ImageT::const_xy_locator xy_loc;
using xy_loc = ImageT::const_xy_locator;

for (int y = 1; y != in.getHeight() - 1; ++y) {
// "dot" means "cursor location" in emacs
Expand Down
2 changes: 1 addition & 1 deletion examples/minimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void printVector(std::vector<T> v) {
}

int main(int argc, char** argv) {
typedef double FuncReturn;
using FuncReturn = double;
const unsigned int order = 3;
const unsigned int npts = 10;

Expand Down
6 changes: 3 additions & 3 deletions examples/polynomialFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
using namespace std;

int main() {
typedef double FuncReturn;
using FuncReturn = double;
const unsigned int order = 2;
vector<double> params(order + 1);
lsst::afw::math::PolynomialFunction1<FuncReturn> polyFunc(order);
Expand All @@ -41,8 +41,8 @@ int main() {
polyFunc.setParameters(params);

cout << "Polynomial function with parameters: ";
for (unsigned int ii = 0; ii < params.size(); ++ii) {
cout << params[ii] << " ";
for (double param : params) {
cout << param << " ";
}
cout << endl << endl;

Expand Down
15 changes: 8 additions & 7 deletions examples/rowColumnStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*
*/
#include <iostream>
#include <memory>

#include "lsst/geom.h"
#include "lsst/afw/image/Image.h"
Expand All @@ -35,17 +36,17 @@

namespace image = lsst::afw::image;
namespace math = lsst::afw::math;
typedef image::Image<float> ImageF;
typedef image::ImageSlice<float> ImageSliceF;
typedef image::MaskedImage<float> MImageF;
using ImageF = image::Image<float>;
using ImageSliceF = image::ImageSlice<float>;
using MImageF = image::MaskedImage<float>;

int main(int argc, char **argv) {
int const nX = 8;
int const nY = 8;

// fill an image with a gradient
// - we want something different in x and y so we can see the different projections
std::shared_ptr<ImageF> img = std::shared_ptr<ImageF>(new ImageF(lsst::geom::Extent2I(nX, nY), 0));
std::shared_ptr<ImageF> img = std::make_shared<ImageF>(lsst::geom::Extent2I(nX, nY), 0);
for (int y = 0; y < img->getHeight(); ++y) {
int x = 0;
for (ImageF::x_iterator ptr = img->row_begin(y), end = img->row_end(y); ptr != end; ++ptr, ++x) {
Expand Down Expand Up @@ -75,10 +76,10 @@ int main(int argc, char **argv) {

// output the pixel values and show the statistics projections

for (unsigned int i = 0; i < rows.size(); ++i) {
ImageF::x_iterator end = rows[i]->row_end(0);
for (auto const &row : rows) {
ImageF::x_iterator end = row->row_end(0);
printf("%26s", " ");
for (ImageF::x_iterator ptr = rows[i]->row_begin(0); ptr != end; ++ptr) {
for (ImageF::x_iterator ptr = row->row_begin(0); ptr != end; ++ptr) {
printf("%5.2f ", static_cast<float>(*ptr));
}
std::cout << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/simpleConvolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace afwImage = lsst::afw::image;
namespace afwMath = lsst::afw::math;

int main(int argc, char **argv) {
typedef afwMath::Kernel::Pixel Pixel;
using Pixel = afwMath::Kernel::Pixel;
unsigned int kernelCols = 6;
unsigned int kernelRows = 5;

Expand Down
11 changes: 6 additions & 5 deletions examples/simpleStacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* An example executable which calls the example 'stack' code
*/
#include <iostream>
#include <memory>

#include "lsst/geom.h"
#include "lsst/afw/image/Image.h"
Expand All @@ -34,9 +35,9 @@
namespace image = lsst::afw::image;
namespace math = lsst::afw::math;

typedef image::Image<float> ImageF;
typedef image::MaskedImage<float> MImageF;
typedef std::vector<float> VecF;
using ImageF = image::Image<float>;
using MImageF = image::MaskedImage<float>;
using VecF = std::vector<float>;

int main(int argc, char **argv) {
int const nImg = 10;
Expand All @@ -61,7 +62,7 @@ int main(int argc, char **argv) {
// regular image
std::vector<std::shared_ptr<ImageF>> imgList;
for (int iImg = 0; iImg < nImg; ++iImg) {
std::shared_ptr<ImageF> img = std::shared_ptr<ImageF>(new ImageF(lsst::geom::Extent2I(nX, nY), iImg));
std::shared_ptr<ImageF> img = std::make_shared<ImageF>(lsst::geom::Extent2I(nX, nY), iImg);
imgList.push_back(img);
}
std::shared_ptr<ImageF> imgStack = math::statisticsStack<float>(imgList, math::MEAN);
Expand All @@ -72,7 +73,7 @@ int main(int argc, char **argv) {
// masked image
std::vector<std::shared_ptr<MImageF>> mimgList;
for (int iImg = 0; iImg < nImg; ++iImg) {
std::shared_ptr<MImageF> mimg = std::shared_ptr<MImageF>(new MImageF(lsst::geom::Extent2I(nX, nY)));
std::shared_ptr<MImageF> mimg = std::make_shared<MImageF>(lsst::geom::Extent2I(nX, nY));
*mimg->getImage() = iImg;
*mimg->getMask() = 0x0;
*mimg->getVariance() = iImg;
Expand Down

0 comments on commit 184b6e4

Please sign in to comment.