Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/test_compare.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/test_compare.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4410, Fri Aug 12 18:28:32 2016 UTC revision 4411, Fri Aug 12 18:28:57 2016 UTC
# Line 2  Line 2 
2  from obj_ty import *  from obj_ty import *
3  from obj_operator import *  from obj_operator import *
4  import math  import math
5    import numbers
6  divConstant=7.2  divConstant=7.2
7    
8  def toStr(name, var, maxdiff, sumdiff, per, s):  def toStr(name, var, maxdiff, sumdiff, per, s):
# Line 18  Line 18 
18      rst_terrible= 0      rst_terrible= 0
19      rst_compile = 0      rst_compile = 0
20      if (maxdiff<=0.0001):      if (maxdiff<=0.0001):
21          rtn = "Results: "+var+": V-0 A"+s          rtn = "Results: "+var+": V-0 A"
22          rst_good = 1          rst_good = 1
23          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
24      elif (maxdiff<=0.001):      elif (maxdiff<=0.001):
# Line 35  Line 35 
35              rst_good = 1              rst_good = 1
36              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
37          else:          else:
38              rtn = "Results: "+var+": W-0 A"+s              rtn = "Results: "+var+": W-0 A"
39              rst_good = 1              rst_good = 1
40              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
41      elif (maxdiff<=0.01):      elif (maxdiff<=0.01):
# Line 52  Line 52 
52              rst_eh = 1              rst_eh = 1
53              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
54          else:          else:
55              rtn = "Results: "+var+": X-0 A"+s              rtn = "Results: "+var+": X-0 A"
56              rst_good = 1              rst_good = 1
57              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)              return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
58      elif(maxdiff<=0.1):      elif(maxdiff<=0.1):
# Line 108  Line 108 
108              break              break
109          else:          else:
110              if(abs(o-divConstant)<0.01):              if(abs(o-divConstant)<0.01):
111                  print "used div constant"                  # print "used div constant"
112                  break                  break
113              else:              else:
114                  diff=abs(c-o)                  diff=abs(c-o)
# Line 140  Line 140 
140      per= 0.0      per= 0.0
141      size =len(obv[0])      size =len(obv[0])
142      #print "no ",no," size: ",size      #print "no ",no," size: ",size
143        pre =""
144      for i in range(no):      for i in range(no):
145          for j in range(size):          for j in range(size):
146              length+=1              length+=1
147              o1=obv[i][j]              o1=obv[i][j]
148              if(o1=="nan"):              if(o1=="nan"):
                 print"found nan"  
149                  rtn = "results is nan sumdiff up to now "+str(round(sumdiff/length,4))                  rtn = "results is nan sumdiff up to now "+str(round(sumdiff/length,4))
150                  return (rtn,0,0,1,0)                  return (rtn,0,0,1,0)
151    
# Line 154  Line 153 
153              c1= cor[i][j]              c1= cor[i][j]
154              if (o1==0):              if (o1==0):
155                  break                  break
156                if(isinstance(o1, float)):
157              if(abs(o1-divConstant)<0.01):              if(abs(o1-divConstant)<0.01):
158                  print "used div constant"                  print "used div constant"
159                  break                  break
160              else:              else:
161                  diff=abs(o1-c1)                  diff=abs(o1-c1)
162                  sumdiff += diff                  sumdiff += diff
163    
164                  if(diff > maxdiff):                  if(diff > maxdiff):
165                      maxdiff = diff                      maxdiff = diff
166                      o6 = o1                      o6 = o1
167                      c6 = c1                      c6 = c1
168                else:
169                    maxdiff=999999999.7
170                    pre ="NAN"
171                    return
172      if(o6==0):      if(o6==0):
173          per = 0.0          per = 0.0
174      else:      else:
175          per  = abs(100*(maxdiff/o6))          per  = abs(100*(maxdiff/o6))
176      avg = sumdiff/length      avg = sumdiff/length
177      s=" max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(avg,4))+" "+ str(round(per,4))+"% c:"+str( c6)+ " o:"+str(o6)      s=" max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(avg,4))+" "+ str(round(per,4))+"% c:"+str( c6)+ " o:"+str(o6)+pre
178      return toStr(name,"x0", maxdiff,avg, per ,s)      return toStr(name,"x0", maxdiff,avg, per ,s)
179    
180  #chose function based on length of output  #chose function based on length of output
181  def compare(app, obv, cor):  def compare(app, obv, cor):
182      ex_otype = fty.get_tensorType(app.oty)      ex_otype = fty.get_tensorType(app.oty)
     print "inside compare"  
183      if(ty_scalarT==ex_otype):      if(ty_scalarT==ex_otype):
184          return checkdiff_1(app.name, obv, cor)          return checkdiff_1(app.name, obv, cor)
185      else:      else:

Legend:
Removed from v.4410  
changed lines
  Added in v.4411

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0