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,26 +148,34 @@ class Test():
process.wait()
def compare_Array(self,ref,cur):
def compare_Array(self,File1,File2):
import numpy
refName = self.fileInReference (ref)
curName = self.fileInCurrent(cur)
refFile = open(refName)
refFile = open(File1)
table = damask.ASCIItable(refFile)
table.head_read()
refFile.close()
refArray = numpy.genfromtxt(refName,missing_values='n/a',skip_header = len(table.info)+1)
curArray = numpy.genfromtxt(curName,missing_values='n/a',skip_header = len(table.info)+1)
err = abs((refArray/curArray)-1.) # relative tolerance
refNaN=len(numpy.isnan(refArray))
curNaN=len(numpy.isnan(curArray))
if curNaN == refNaN:
err[numpy.isnan(err)]=0.0
refArray = numpy.nan_to_num(numpy.genfromtxt(File1,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))
print len(refArray)
print refArray
print len(curArray)
print curArray
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)
print ' ********\n * maximum relative error',max_err,'\n ********'
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):
if culprit < 0:
print '%s passed.'%({False: 'The test',