Skip to content

Commit 401492e

Browse files
author
Michael McLeod
committed
Set tolerance to 5% of brightest
1 parent d516eb7 commit 401492e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

cpp/tests/algo_factory.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ TEST_CASE("primal_dual_factory") {
125125
const Image<t_complex> image = Image<t_complex>::Map(diagnostic.x.data(), imsizey, imsizex);
126126
// pfitsio::write2d(image.real(), result_path);
127127

128-
double average_solution = solution.real().cwiseAbs().sum() / solution.size();
128+
double brightness = solution.real().cwiseAbs().maxCoeff();
129129
double mse = (Vector<t_complex>::Map(solution.data(), solution.size()) - diagnostic.x)
130130
.real()
131131
.squaredNorm() /
132132
solution.size();
133133
double rms = sqrt(mse);
134-
CHECK(rms <= average_solution * 1e-3);
134+
CHECK(rms <= brightness * 5e-2);
135135
}
136136

137137
TEST_CASE("fb_factory") {
@@ -167,9 +167,11 @@ TEST_CASE("fb_factory") {
167167
std::make_tuple("DB6", 3u), std::make_tuple("DB7", 3u), std::make_tuple("DB8", 3u)};
168168
auto const wavelets = factory::wavelet_operator_factory<Vector<t_complex>>(
169169
factory::distributed_wavelet_operator::serial, sara, imsizey, imsizex);
170+
170171
t_real const sigma = 0.016820222945913496 * std::sqrt(2); // see test_parameters file
171172
t_real const beta = sigma * sigma;
172173
t_real const gamma = 0.0001;
174+
173175
auto const fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
174176
factory::algo_distribution::serial, measurements_transform, wavelets, uv_data, sigma, beta,
175177
gamma, imsizey, imsizex, sara.size(), 1000, true, true, false, 1e-2, 1e-3, 50);
@@ -179,13 +181,13 @@ TEST_CASE("fb_factory") {
179181
pfitsio::write2d(image.real(), result_path);
180182
// pfitsio::write2d(residual_image.real(), expected_residual_path);
181183

182-
double average_solution = solution.real().cwiseAbs().sum() / solution.size();
184+
double brightness = solution.real().cwiseAbs().maxCoeff();
183185
double mse = (Vector<t_complex>::Map(solution.data(), solution.size()) - diagnostic.x)
184186
.real()
185187
.squaredNorm() /
186188
solution.size();
187189
double rms = sqrt(mse);
188-
CHECK(rms <= average_solution * 1e-3);
190+
CHECK(rms <= brightness * 5e-2);
189191
}
190192

191193
#ifdef PURIFY_H5
@@ -289,11 +291,11 @@ TEST_CASE("fb_factory_stochastic") {
289291
// pfitsio::write2d(residual_image.real(), expected_residual_path);
290292

291293
auto soln_flat = Vector<t_complex>::Map(solution.data(), solution.size());
292-
double average_intensity = soln_flat.real().sum() / soln_flat.size();
294+
double brightness = soln_flat.real().cwiseAbs().maxCoeff();
293295
SOPT_HIGH_LOG("Average intensity = {}", average_intensity);
294296
double mse = (soln_flat - diagnostic.x).real().squaredNorm() / solution.size();
295297
SOPT_HIGH_LOG("MSE = {}", mse);
296-
CHECK(mse <= average_intensity * 1e-3);
298+
CHECK(mse <= average_intensity * 5e-2);
297299
}
298300
#endif
299301

@@ -347,13 +349,13 @@ TEST_CASE("tf_fb_factory") {
347349
// pfitsio::write2d(image.real(), result_path);
348350
// pfitsio::write2d(residual_image.real(), expected_residual_path);
349351

350-
double average_solution = solution.real().cwiseAbs().sum() / solution.size();
352+
double brightness = solution.real().cwiseAbs().maxCoeff();
351353
double mse = (Vector<t_complex>::Map(solution.data(), solution.size()) - diagnostic.x)
352354
.real()
353355
.squaredNorm() /
354356
solution.size();
355357
double rms = sqrt(mse);
356-
CHECK(rms <= average_solution * 1e-3);
358+
CHECK(rms <= brightness * 5e-2);
357359
}
358360

359361
TEST_CASE("onnx_fb_factory") {
@@ -410,13 +412,13 @@ TEST_CASE("onnx_fb_factory") {
410412
// pfitsio::write2d(image.real(), result_path);
411413
// pfitsio::write2d(residual_image.real(), expected_residual_path);
412414

413-
double average_solution = solution.real().cwiseAbs().sum() / solution.size();
415+
double brightness = solution.real().cwiseAbs().maxCoeff();
414416
double mse = (Vector<t_complex>::Map(solution.data(), solution.size()) - diagnostic.x)
415417
.real()
416418
.squaredNorm() /
417419
solution.size();
418420
double rms = sqrt(mse);
419-
CHECK(rms <= average_solution * 1e-3);
421+
CHECK(rms <= brightness * 5e-2);
420422
}
421423
#endif
422424

0 commit comments

Comments
 (0)