From f8ec2ed4a3b1a46def81441b155078b67f4f358b Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Fri, 26 May 2017 14:57:12 +0100
Subject: [PATCH] Output the particle ID if a difference is found instead of
 the line in the file and print the particle property that differs.

---
 tests/difffloat.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/difffloat.py b/tests/difffloat.py
index 0bdc706a1c..8c8713a8d2 100644
--- a/tests/difffloat.py
+++ b/tests/difffloat.py
@@ -46,7 +46,13 @@ if len(sys.argv) == 6:
     ignoreSmallRhoDh = int(sys.argv[5])
 else:
     ignoreSmallRhoDh = 0
-    
+
+# Get the particle properties being compared from the header.
+with open(file1, 'r') as f:
+  line = f.readline()
+  if 'ID' in line:
+    part_props = line.split()[1:]
+
 data1 = loadtxt(file1)
 data2 = loadtxt(file2)
 if fileTol != "":
@@ -100,7 +106,7 @@ for i in range(n_lines_to_check):
             rel_diff = 0.
 
         if( abs_diff > 1.1*absTol[j]):
-            print "Absolute difference larger than tolerance (%e) for particle %d, column %d:"%(absTol[j], i,j)
+            print "Absolute difference larger than tolerance (%e) for particle %d, column %s:"%(absTol[j], data1[i,0], part_props[j])
             print "%10s:           a = %e"%("File 1", data1[i,j])
             print "%10s:           b = %e"%("File 2", data2[i,j])
             print "%10s:       |a-b| = %e"%("Difference", abs_diff)
@@ -113,7 +119,7 @@ for i in range(n_lines_to_check):
         if ignoreSmallRhoDh and j == 8 and abs(data1[i,j]) < 2e-4: continue
         
         if( rel_diff > 1.1*relTol[j]):
-            print "Relative difference larger than tolerance (%e) for particle %d, column %d:"%(relTol[j], i,j)
+            print "Relative difference larger than tolerance (%e) for particle %d, column %s:"%(relTol[j], data1[i,0], part_props[j])
             print "%10s:           a = %e"%("File 1", data1[i,j])
             print "%10s:           b = %e"%("File 2", data2[i,j])
             print "%10s: |a-b|/|a+b| = %e"%("Difference", rel_diff)
-- 
GitLab