From 4684e3e32338a91c88f9187ac7bfb2381d55aaea Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Fri, 7 Aug 2015 14:38:56 +0000
Subject: [PATCH] [fuzzy] Apply zeroThreshold only if the values in both lists
 are under threshold.

Otherwise we compare non-zero with zero values.

Review by bernd


git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@15258 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 bin/fuzzycomparevtu.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/fuzzycomparevtu.py b/bin/fuzzycomparevtu.py
index 4d2e50c75e..f1984b0281 100644
--- a/bin/fuzzycomparevtu.py
+++ b/bin/fuzzycomparevtu.py
@@ -143,9 +143,13 @@ def is_fuzzy_equal_text(text1, text2, parameter, numComp, absolute, relative, ze
 
         # manipulate the data set for the sake of sensible comparison
         # if the parameter is listed in the zeroThreshold dictionary replace all float under threshold with zero.
+        # only replace them with zero if the parameters in both lists are under the threshold. Otherwise we
+        # compare a non-zero value with 0 later.
         if parameter in zeroValueThreshold:
-            floatList1 = [0.0 if abs(i) < float(zeroValueThreshold[parameter]) else i for i in floatList1]
-            floatList2 = [0.0 if abs(i) < float(zeroValueThreshold[parameter]) else i for i in floatList2]
+            floatList1 = [0.0 if abs(i) < float(zeroValueThreshold[parameter]) and abs(j) < float(zeroValueThreshold[parameter])
+                          else i for i, j in zip(floatList1, floatList2)]
+            floatList2 = [0.0 if abs(i) < float(zeroValueThreshold[parameter]) and abs(j) < float(zeroValueThreshold[parameter])
+                          else j for i, j in zip(floatList1, floatList2)]
 
         absFloatList1 = [abs(i) for i in floatList1]
         absFloatList2 = [abs(i) for i in floatList2]
-- 
GitLab