From 87af8ac5feb3b7fc8810ececba75eede0217573c Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Tue, 19 Nov 2024 20:45:10 +0000 Subject: [PATCH] MIR-678 improved weight matrix validation, integration test ported from Metview regrid testing, tests fix --- src/mir/method/WeightMatrix.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mir/method/WeightMatrix.cc b/src/mir/method/WeightMatrix.cc index 3bb3ca2eb..ac425ea44 100644 --- a/src/mir/method/WeightMatrix.cc +++ b/src/mir/method/WeightMatrix.cc @@ -13,6 +13,7 @@ #include "mir/method/WeightMatrix.h" #include +#include #include #include @@ -131,7 +132,9 @@ void WeightMatrix::validate(const char* when, Check check) const { check_duplicates &= cols.insert(it.col()).second; } - auto check_sum = eckit::types::is_approximately_equal(sum, 0.) || eckit::types::is_approximately_equal(sum, 1.); + constexpr auto EPS = 1.e2 * std::numeric_limits::epsilon(); + auto check_sum = + eckit::types::is_approximately_equal(sum, 0., EPS) || eckit::types::is_approximately_equal(sum, 1., EPS); // ignore checks as required check_duplicates |= !check.duplicates;