This commit is contained in:
Mahesh Balasubramaniam 2012-07-05 11:21:06 +00:00
parent 0fdd43b54b
commit ca83c6082a
1 changed files with 19 additions and 11 deletions

View File

@ -148,25 +148,33 @@ class Test():
process.wait() process.wait()
def compare_Array(self,ref,cur): def compare_Array(self,File1,File2):
import numpy import numpy
refName = self.fileInReference (ref)
curName = self.fileInCurrent(cur)
refFile = open(refName) refFile = open(File1)
table = damask.ASCIItable(refFile) table = damask.ASCIItable(refFile)
table.head_read() table.head_read()
refFile.close() refFile.close()
refArray = numpy.genfromtxt(refName,missing_values='n/a',skip_header = len(table.info)+1) refArray = numpy.nan_to_num(numpy.genfromtxt(File1,missing_values='n/a',skip_header = len(table.info)+1))
curArray = numpy.genfromtxt(curName,missing_values='n/a',skip_header = len(table.info)+1) curArray = numpy.nan_to_num(numpy.genfromtxt(File2,missing_values='n/a',skip_header = len(table.info)+1))
err = abs((refArray/curArray)-1.) # relative tolerance print len(refArray)
refNaN=len(numpy.isnan(refArray)) print refArray
curNaN=len(numpy.isnan(curArray)) print len(curArray)
if curNaN == refNaN: print curArray
err[numpy.isnan(err)]=0.0 refNonZero = refArray[refArray.nonzero()]
curNonZero = curArray[curArray.nonzero()]
print refNonZero
print curNonZero
err = abs((refNonZero/curNonZero)-1.) # relative tolerance
print err
max_err = numpy.max(err) max_err = numpy.max(err)
print ' ********\n * maximum relative error',max_err,'\n ********' print ' ********\n * maximum relative error',max_err,'\n ********'
return max_err return max_err
def compare_ArrayRefCur(self,ref,cur):
refName = self.fileInReference(ref)
curName = self.fileInCurrent(cur)
return compare_Array(refName,curName)
def report_Success(self,culprit): def report_Success(self,culprit):
if culprit < 0: if culprit < 0: