Skip to content
Snippets Groups Projects
Commit 0d3c29ae authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

SymmetryTest: report worst case only

parent 56dc21f7
No related branches found
No related tags found
1 merge request!1185MultiQTest: detailed report for worst case only
Pipeline #82876 failed
......@@ -12,9 +12,8 @@ protected:
void run_test(IFormFactor* p0, IFormFactor* p1, double eps, double qmag1, double qmag2)
{
int failures = formfactorTest::run_test2_for_many_q(
[&](C3 q, bool report) -> double {
return test_ff_eq(q, p0, p1, eps, report); }, qmag1,
qmag2, eps);
[&](C3 q, bool report) -> double { return test_ff_eq(q, p0, p1, eps, report); }, qmag1,
qmag2, eps);
EXPECT_EQ(failures, 0);
}
......@@ -28,12 +27,12 @@ private:
const double result = abserr / avge * std::min(1., eps * avge / 1e-16);
if (report) {
std::cout << "Deviation at q = " << q << ":\n";
std::cout << " Re(f0) = " << std::setprecision(16)
<< real(f0) << ", Im(f0) = " << imag(f0) << "\n";
std::cout << " Re(f0) = " << std::setprecision(16) << real(f0)
<< ", Im(f0) = " << imag(f0) << "\n";
std::cout << " Re(f1) = " << real(f1) << ", Im(f1) = " << imag(f1) << "\n";
std::cout << " abs dev = " << std::setprecision(8)
<< abserr << ", rel dev = " << abserr / avge
<< ", score = " << result << ", limit = " << eps << "\n";
std::cout << " abs dev = " << std::setprecision(8) << abserr
<< ", rel dev = " << abserr / avge << ", score = " << result
<< ", limit = " << eps << "\n";
}
return result;
}
......
......@@ -8,15 +8,17 @@
class FFSymmetryTest : public testing::Test {
protected:
void run_test(IFormFactor* ff, std::function<C3(const C3&)> trafo,
double eps, double qmag1, double qmag2)
void run_test(IFormFactor* ff, std::function<C3(const C3&)> trafo, double eps, double qmag1,
double qmag2)
{
formfactorTest::run_test_for_many_q([&](C3 q) { test_qq_eq(ff, q, trafo(q), eps); }, qmag1,
qmag2);
int failures = formfactorTest::run_test2_for_many_q(
[&](C3 q, bool report) -> double { return test_qq_eq(ff, q, trafo(q), eps, report); },
qmag1, qmag2, eps);
EXPECT_EQ(failures, 0);
}
private:
void test_qq_eq(IFormFactor* ff, C3 q, C3 p, double eps)
double test_qq_eq(IFormFactor* ff, C3 q, C3 p, double eps, bool report)
{
complex_t f0 = ff->formfactor(q);
#ifdef ALGORITHM_DIAGNOSTIC
......@@ -24,21 +26,19 @@ private:
#endif
const complex_t f1 = ff->formfactor(p);
const double avge = (std::abs(f0) + std::abs(f1)) / 2;
const double precision = std::max(1e-16, eps * avge);
EXPECT_NEAR(real(f0), real(f1), precision)
<< "q=" << q << ", p=" << p
#ifdef ALGORITHM_DIAGNOSTIC
<< "\n msg(q): " << msg0 << "\n"
<< "\n msg(p): " << polyhedralDiagnosis.message() << "\n"
#endif
;
EXPECT_NEAR(imag(f0), imag(f1), precision)
<< "q=" << q << ", p=" << p
#ifdef ALGORITHM_DIAGNOSTIC
<< "\n msg(q): " << msg0 << "\n"
<< "\n msg(p): " << polyhedralDiagnosis.message() << "\n"
#endif
;
const double abserr = std::max(fabs(real(f0) - real(f1)), fabs(imag(f0) - imag(f1)));
const double result = abserr / avge * std::min(1., eps * avge / 1e-16);
if (report) {
std::cout << "Deviation of q0 = " << q << "\n";
std::cout << " and q1 = " << p << ":\n";
std::cout << " Re(f0) = " << std::setprecision(16) << real(f0)
<< ", Im(f0) = " << imag(f0) << "\n";
std::cout << " Re(f1) = " << real(f1) << ", Im(f1) = " << imag(f1) << "\n";
std::cout << " abs dev = " << std::setprecision(8) << abserr
<< ", rel dev = " << abserr / avge << ", score = " << result
<< ", limit = " << eps << "\n";
}
return result;
}
};
......@@ -99,7 +99,7 @@ TEST_F(FFSymmetryTest, TruncatedSphere)
{
TruncatedSphere ff(.79, .34, 0);
run_test(
&ff, [](const C3& q) -> C3 { return q.rotatedZ(M_PI / 3.13698); }, 1e-12, 1e-99, 2e2);
&ff, [](const C3& q) -> C3 { return q.rotatedZ(M_PI / 3.13698); }, 2e-13, 1e-99, 2e2);
}
TEST_F(FFSymmetryTest, Spheroid)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment