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 3946, Sat Jun 11 00:39:19 2016 UTC revision 4188, Mon Jul 11 23:21:11 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    
5  def toStr(name,var, maxdiff,maxerr):  def toStr(name,var, maxdiff):
6      # f = open("results_tmp.txt", 'a+')      # f = open("results_tmp.txt", 'a+')
7      #f.write("\n\n **********")      #f.write("\n\n **********")
8      #print (name)      #print (name)
# Line 31  Line 31 
31  #output is length 1  #output is length 1
32  def checkdiff_1(name, obv, cor):  def checkdiff_1(name, obv, cor):
33      maxdiff = 0      maxdiff = 0
34      maxerr = 0  
35      for (o,c) in zip(obv,cor):      for (o,c) in zip(obv,cor):
36          #print ("observed:",o,"correct:",c)          #print ("observed:",o,"correct:",c)
37          if (o==0):          if (o==0):
# Line 41  Line 41 
41              if(diff>maxdiff):              if(diff>maxdiff):
42                  maxdiff=diff                  maxdiff=diff
43          #print("current maximal difference", maxdiff, "c: ", c, " o:",o)          #print("current maximal difference", maxdiff, "c: ", c, " o:",o)
44          if (c==0):      return toStr(name,"x",maxdiff)
             break  
         else:  
             err=(diff/c)*100  
             if(err>maxerr):  
                 maxerr=err  
     return toStr(name,"x",maxdiff,maxerr)  
45    
46  def checkdiff(name, obv, cor):  def checkdiff(name, obv, cor):
47      no = len(obv)      no = len(obv)
# Line 55  Line 49 
49      if(no!=nc):      if(no!=nc):
50          raise ("different size for data- observed: "+str(n0)+"correct: "+str(nc))          raise ("different size for data- observed: "+str(n0)+"correct: "+str(nc))
51      maxdiff=0      maxdiff=0
     maxerr=0  
52      size =len(obv[0])      size =len(obv[0])
53      #print "no ",no," size: ",size      #print "no ",no," size: ",size
54    
55      for i in range(no):      for i in range(no):
56          for j in range(size):          for j in range(size):
57              o1=obv[i][j]              o1=obv[i][j]
# Line 68  Line 62 
62              diff=abs(o1-c1)              diff=abs(o1-c1)
63              if(diff > maxdiff):              if(diff > maxdiff):
64                  maxdiff = diff                  maxdiff = diff
65              #print("current maximal difference", maxdiff, "c: ", c1, " o:",o1)              print("current maximal difference", maxdiff, "c: ", c1, " o:",o1)
66              if(c1==0):              if(c1==0):
67                  break                  break
68              err=(diff/c1)*100      return toStr(name,"x0",maxdiff)
             if(err>maxerr):  
                 maxerr=err  
     return toStr(name,"x0",maxdiff, maxerr)  
69    
70  #chose function based on length of output  #chose function based on length of output
71  def compare(app, obv, cor):  def compare(app, obv, cor):

Legend:
Removed from v.3946  
changed lines
  Added in v.4188

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