diff --git a/include/aare/hist/PixelHistogramImpl.hpp b/include/aare/hist/PixelHistogramImpl.hpp index f324eaa..715537f 100644 --- a/include/aare/hist/PixelHistogramImpl.hpp +++ b/include/aare/hist/PixelHistogramImpl.hpp @@ -108,7 +108,8 @@ void PixelHistogramImpl::fill_unchecked(int row, int col, bin = m_n_bins - 1; } if constexpr (std::is_integral_v) { - if (m_values(row, col, bin) >= std::numeric_limits::max()) { + if (m_values(row, col, bin) >= + std::numeric_limits::max()) { return; } } diff --git a/src/hist/PedestalTrackingPixelHistogram.cpp b/src/hist/PedestalTrackingPixelHistogram.cpp index 6684fd0..93a7521 100644 --- a/src/hist/PedestalTrackingPixelHistogram.cpp +++ b/src/hist/PedestalTrackingPixelHistogram.cpp @@ -18,7 +18,7 @@ PedestalTrackingPixelHistogram::PedestalTrackingPixelHistogram( : rows_(rows), cols_(cols), n_threads_(n_threads), xmin_(xmin), xmax_(xmax), current_work_kind_(WorkKind::FillWithThreshold), current_image_(nullptr), current_images_(nullptr), completed_threads_(0), stop_workers_(false), - work_generation_(0), max_batch_size_(max_pending/3), n_sigma_(n_sigma) { + work_generation_(0), max_batch_size_(max_pending / 3), n_sigma_(n_sigma) { if (rows_ < 1 || cols_ < 1 || n_bins < 1) { throw std::invalid_argument("PedestalTrackingPixelHistogram requires " "positive rows, cols and bins"); diff --git a/src/hist/PixelHistogramImpl.test.cpp b/src/hist/PixelHistogramImpl.test.cpp index d2fc88b..3cc2842 100644 --- a/src/hist/PixelHistogramImpl.test.cpp +++ b/src/hist/PixelHistogramImpl.test.cpp @@ -72,14 +72,14 @@ TEST_CASE("Fill a small histogram from an NDArray") { REQUIRE(v(1, 1, 4) == 1); } -TEST_CASE("Check that pixel histogram does not overflow"){ +TEST_CASE("Check that pixel histogram does not overflow") { int rows = 1; int cols = 1; int n_bins = 10; double xmin = 0.0; double xmax = 1.0; aare::PixelHistogramImpl hist_u8(rows, cols, n_bins, xmin, - xmax); + xmax); for (int i = 0; i < 255; ++i) { hist_u8.fill(0, 0, 0.05); @@ -92,7 +92,7 @@ TEST_CASE("Check that pixel histogram does not overflow"){ REQUIRE(v0(0, 0, 0) == 255); aare::PixelHistogramImpl hist_i8(rows, cols, n_bins, xmin, - xmax); + xmax); for (int i = 0; i < 350; ++i) { hist_i8.fill(0, 0, 0.05); @@ -100,7 +100,6 @@ TEST_CASE("Check that pixel histogram does not overflow"){ auto v1 = hist_i8.view(); REQUIRE(v1(0, 0, 0) == 127); - } TEST_CASE("Check that values outside the range do not affect the histogram") { @@ -110,15 +109,14 @@ TEST_CASE("Check that values outside the range do not affect the histogram") { double xmin = 0.0; double xmax = 1.0; aare::PixelHistogramImpl hist(rows, cols, n_bins, xmin, - xmax); + xmax); hist.fill(0, 0, -0.1); // below range hist.fill(0, 0, 1.0); // at upper edge (should be out of range) hist.fill(0, 0, 1.1); // above range - + auto v = hist.view(); auto total = std::accumulate(v.begin(), v.end(), 0); REQUIRE(total == 0); - } TEST_CASE("Check that row and column bounds are checked") { @@ -128,15 +126,15 @@ TEST_CASE("Check that row and column bounds are checked") { double xmin = 0.0; double xmax = 1.0; aare::PixelHistogramImpl hist(rows, cols, n_bins, xmin, - xmax); - REQUIRE_THROWS_AS(hist.fill(0, 1, -0.1), std::out_of_range); // col out of range - REQUIRE_THROWS_AS(hist.fill(1, 0, 1.0), std::out_of_range); // row out of range - REQUIRE_THROWS_AS(hist.fill(58, -1, 1.1), std::out_of_range); // both out of range + xmax); + REQUIRE_THROWS_AS(hist.fill(0, 1, -0.1), + std::out_of_range); // col out of range + REQUIRE_THROWS_AS(hist.fill(1, 0, 1.0), + std::out_of_range); // row out of range + REQUIRE_THROWS_AS(hist.fill(58, -1, 1.1), + std::out_of_range); // both out of range auto v = hist.view(); auto total = std::accumulate(v.begin(), v.end(), 0); REQUIRE(total == 0); - } - -