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 4356, Wed Aug 3 16:22:02 2016 UTC revision 4363, Thu Aug 4 22:42:10 2016 UTC
# Line 5  Line 5 
5    
6  divConstant=7.2  divConstant=7.2
7    
8  def toStr(name,var, maxdiff,sumdiff):  def toStr(name, var, maxdiff, sumdiff, per, s):
9      # f = open("results_tmp.txt", 'a+')      # f = open("results_tmp.txt", 'a+')
10      #f.write("\n\n **********")      #f.write("\n\n **********")
11      #print (name)      #print (name)
12      x= " max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(sumdiff,4))      x= " max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(sumdiff,4))
13      #print "x",x      #print "x",x
14      #f.write(name)      #f.write(name)
15        rst_good = 0
16        rst_eh = 0
17        rst_check = 0
18        rst_terrible= 0
19        rst_compile = 0
20    
21      if (maxdiff<=0.01):      if (maxdiff<=0.01):
22          rtn = "Results: "+var+": good"          rtn = "Results: "+var+": good"
23          #   f.write("\n\t\t"+rtn)          rst_good = 1
24          #f.close()          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
         #print rtn  
         return (rtn,1,0,0,0)  
25      elif (maxdiff<=0.1):      elif (maxdiff<=0.1):
26          rtn = "Results: "+var+": eh "+x          rtn = "Results: "+var+": eh "+x
27          #f.write("\n\t\t"+rtn)          rst_eh = 1
28          #f.close()          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
29          #print rtn      elif(per>10 and maxdiff>0.1):
30          return (rtn,0,1,0,0)          rtn = "Results: "+var+": terrible "+s
31      else:          rst_terrible = 1
32          rtn = "Results: "+var+": terrible "+x          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
33          #f.write("\n\t\t"+rtn)      elif(per>1 and maxdiff>1.0):
34          #f.close()          rtn = "Results: "+var+": terrible "+s
35          #print rtn          rst_terrible = 1
36          return (rtn,0,0,1,0)          return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
37        else:
38            rtn = "Results: "+var+": check "+s
39            rst_check = 1
40            return (rtn, rst_good, rst_eh, rst_check, rst_terrible, rst_compile)
41    
42  #difference and error between observed data and correct data  #difference and error between observed data and correct data
43  #output is length 1  #output is length 1
44  def checkdiff_1(name, obv, cor):  def checkdiff_1(name, obv, cor):
45      maxdiff = 0      maxdiff = 0
46      sumdiff = 0      sumdiff = 0
47      length = 0      length = 0
48        obs=0.0
49        o6 = 0.0
50        c6 = 0.0
51        per = 0.0
52      for (o,c) in zip(obv,cor):      for (o,c) in zip(obv,cor):
53          #print ("observed:",o,"correct:",c)          #print ("observed:",o,"correct:",c)
54          length+=1          length+=1
# Line 50  Line 63 
63                  sumdiff+=diff                  sumdiff+=diff
64                  if(diff>maxdiff):                  if(diff>maxdiff):
65                      maxdiff=diff                      maxdiff=diff
66                        o6 = o
67                        c6 = c
68        if(o6==0):
69            per = 0.0
70        else:
71            per  = 100*(maxdiff/o6)
72        avg = sumdiff/length
73        s=" max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(avg,4))+" "+ str(round(per,4))+"% c:"+str( c6)+ " o:"+str(o6)
74          #print("current maximal difference", maxdiff, "c: ", c, " o:",o)          #print("current maximal difference", maxdiff, "c: ", c, " o:",o)
75      return toStr(name,"x", maxdiff,sumdiff/length)      return toStr(name,"x0", maxdiff,avg, per ,s)
76    
77  def checkdiff(name, obv, cor):  def checkdiff(name, obv, cor):
78      no = len(obv)      no = len(obv)
# Line 61  Line 82 
82      maxdiff=0      maxdiff=0
83      sumdiff = 0      sumdiff = 0
84      length = 0      length = 0
85        s=""
86        o6 = 0.0
87        c6 = 0.0
88        per= 0.0
89      size =len(obv[0])      size =len(obv[0])
90      #print "no ",no," size: ",size      #print "no ",no," size: ",size
91    
# Line 86  Line 110 
110                  sumdiff += diff                  sumdiff += diff
111                  if(diff > maxdiff):                  if(diff > maxdiff):
112                      maxdiff = diff                      maxdiff = diff
113                  print("current maximal difference", maxdiff, "c: ", c1, " o:",o1)                      o6 = o1
114                        c6 = c1
115      print "made it here"      if(o6==0):
116      return toStr(name,"x0", maxdiff,sumdiff/length)          per = 0.0
117        else:
118            per  = 100*(maxdiff/o6)
119        avg = sumdiff/length
120        s=" max diff: "+str(round(maxdiff,4))+" sumdiff: "+str(round(avg,4))+" "+ str(round(per,4))+"% c:"+str( c6)+ " o:"+str(o6)
121        return toStr(name,"x0", maxdiff,avg, per ,s)
122    
123  #chose function based on length of output  #chose function based on length of output
124  def compare(app, obv, cor):  def compare(app, obv, cor):

Legend:
Removed from v.4356  
changed lines
  Added in v.4363

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