mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-06-05 23:38:43 +02:00
formatting
This commit is contained in:
@@ -108,7 +108,8 @@ void PixelHistogramImpl<T, StorageType>::fill_unchecked(int row, int col,
|
||||
bin = m_n_bins - 1;
|
||||
}
|
||||
if constexpr (std::is_integral_v<StorageType>) {
|
||||
if (m_values(row, col, bin) >= std::numeric_limits<StorageType>::max()) {
|
||||
if (m_values(row, col, bin) >=
|
||||
std::numeric_limits<StorageType>::max()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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<double, uint8_t> 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<double, int8_t> 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<double, double> 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<double, double> 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user