From 4ac9ef602e55f2e0a0a636d81ae700a9a7da36ad Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 29 Oct 2015 21:51:57 +0000 Subject: [PATCH] still trying to find a stable solution on all machines --- lib/damask/test/test.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index e1292477d..65babcb04 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -383,8 +383,14 @@ class Test(): return maxError - def compare_Table2(self,file0,file1,headings0=None,headings1=None,rtol=1e-5,atol=1e-8): + def compare_Table2(self,file0,file1,headings0=None,headings1=None,rtol=1e-5,atol=1e-8,threshold = -1.0,debug=False): + ''' + compare two tables with np.allclose + threshold can be used to ignore small values (put any negative number to disable) + table will be row-wise normalized + ''' + #http://stackoverflow.com/questions/8904694/how-to-normalize-a-2-dimensional-numpy-array-in-python-less-verbose import numpy as np logging.info('comparing ASCII Tables\n %s \n %s'%(file0,file1)) @@ -393,11 +399,24 @@ class Test(): table0 = damask.ASCIItable(file0,readonly=True) table0.head_read() table0.data_readArray(headings0) + row_sums0 = table0.data.sum(axis=1)*table0.data.shape[0] + table0.data /= row_sums0[:,np.newaxis] + table1 = damask.ASCIItable(file1,readonly=True) table1.head_read() table1.data_readArray(headings1) + row_sums1 = table1.data.sum(axis=1)*table1.data.shape[0] + table1.data /= row_sums1[:,np.newaxis] + + if debug: + t0 = np.where(np.abs(table0.data)