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

SCM Repository

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

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

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

revision 4209, Thu Jul 14 17:37:50 2016 UTC revision 4210, Thu Jul 14 18:01:19 2016 UTC
# Line 14  Line 14 
14  # unu grid -i inputfile.nrrd | unu save -f text  # unu grid -i inputfile.nrrd | unu save -f text
15  # ^ where all the points are.  # ^ where all the points are.
16    
17  opr_max = 11  opr_max = 17
18    layer = int(sys.argv[1])
19    args = int(sys.argv[2])
20    
21  cnnt=0  cnnt=0
22  vispath = "/Users/chariseechiw/diderot/vis15/bin/diderotc --exec "  vispath = "/Users/chariseechiw/diderot/vis15/bin/diderotc --exec "
# Line 31  Line 33 
33  branch = pathToString()  branch = pathToString()
34  if isVis15:  if isVis15:
35      runtimepath  = vispath      runtimepath  = vispath
36      fld="tues"      fld="weds"
37  else:  else:
38      runtimepath  = einpath      runtimepath  = einpath
39      fld="tues"      fld="weds"
   
 todo = sys.argv[2]  
40    
41  def clean():  def clean():
42      # Clean up      # Clean up
# Line 54  Line 54 
54  # f = open("results_tmp.txt", 'a+')  # f = open("results_tmp.txt", 'a+')
55  #f.write(e)  #f.write(e)
56  #f.close()  #f.close()
57  def write2(e):  def writeall(e):
58      print (e)      print (e)
59      # if it works continue      # if it works continue
60      f = open("results_Final.txt", 'a+')      f = open("results_Final.txt", 'a+')
61      f.write(e)      f.write(e)
62      f.close()      f.close()
63  def pnt1(pre, cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile):  def writesummary(e):
64      x= "\n"+pre+" "+branch +" A:"+str(rst_good)+" B:"+str( rst_eh)+" D:"+str(rst_terrible)+" NA:"+str(rst_compile)      print (e)
65      print (x)      # if it works continue
66      write2(x)      f = open("results_summary.txt", 'a+')
67        f.write(e)
68        f.close()
69    
70    def writetys(e):
71        print (e)
72        # if it works continue
73        f = open("results_tys.txt", 'a+')
74        f.write(e)
75        f.close()
76    
77  def pnt2(pre, cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile):  def pnt2(pre, cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile):
78      x= "\n"      x= "\n"
79      if(rst_good==cnt):      if(rst_good==cnt):
# Line 82  Line 92 
92      x+= " #ran: "+str(cnt)+"|" +str(total)      x+= " #ran: "+str(cnt)+"|" +str(total)
93      x+="\n***************************************************\n"      x+="\n***************************************************\n"
94      print (x)      print (x)
95      write2(x)      writeall(x)
96  def pnt3(pre, cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile):      writesummary(x)
     x= "\n"+pre+" A:"+str(rst_good)+" B:"+str( rst_eh)+" D:"+str(rst_terrible)+" NA:"+str(rst_compile)  
     x+= " #ran: "+str(cnt)+" #iterations:" +str(total)  
     print (x)  
     write2(x)  
97    
98  #get all the names  ##################################################################################################
99  def get_names():  # iterate over ty2
100      for ex_opr in range(opr_max+1):  def is_unary():
101          ex = get_ex(ex_opr)      if(layer==2):
102          n = len(ex.tys)          return true
103          print ("cmd:(1 "+str(ex_opr)+") opr "+example.get_oprname(ex))      else:
104          for ex_num  in range(n):          return false
105              print ("\tcmd:(-1 "+str(ex_opr)+","+str(ex_num)+")"+example.toStr(ex,ex_num))  # get outer operator
106    def get_outer(ex_outer):
107        if(is_unary()):
108            return op_unary[ex_outer]
109        else:
110            return op_binary[ex_outer]
111    # length of operators
112    def getN():
113        if(is_unary()):
114            return len(op_unary)
115        else:
116            return 6 #len(op_binary)
117    
118    # get specific outer operator
119    def get_fty(ex_ty2):
120        if(is_unary()):
121            print "found unary"
122            return []
123        else:
124            print "not unary"
125            fty =l_all_F[ex_ty2]
126            return [fty]
127    
128    def idToOpr_outer(ex_outer):
129        return get_outer(ex_outer).name
130    
131    def idToOpr_inner(ex_opr):
132        print "idToOpr_inner ex_opr",ex_opr
133        return get_single_exampleName(ex_opr)
134    
135    ##################################################################################################
136  # already created app object  # already created app object
137  def central(app, coeffs, dimF,ex_opr, ex_num ,id):  def central(app, coeffs, dimF,ex_opr, ex_num ,id):
138      print "inside central"      print "inside central"
139      os.system("rm data/*.txt")      os.system("rm data/*.txt")
140      print app.name      names= "t_"+str(ex_opr)+"_"+str(id)+"_"+str(ex_num)#+"_"+str(app.oty.id)
141        #apply.oprToStr(app)
142        writetys("\n\t-"+apply.get_all_FieldTys(app)+"|"+  names)
143      # testing positions      # testing positions
144      positions = get_positions(dimF)      positions = get_positions(dimF)
145      #print "positions",positions      #print "positions",positions
# Line 117  Line 154 
154      else:      else:
155          #read observed data          #read observed data
156          observed_data = observed(app, output)          observed_data = observed(app, output)
157          print "observed data from python",observed_data          #print "observed data from python",observed_data
158          if (len(observed_data)<2):          if (len(observed_data)<2):
159              print "fail did not find data"              #print "fail did not find data"
160              return   ("diderot could not handle program",0,0,0,1)              return   ("diderot could not handle program",0,0,0,1)
161          #correct values from python          #correct values from python
162          correct_data = eval(app , positions)          correct_data = eval(app , positions)
# Line 128  Line 165 
165          #compare observed and correct data          #compare observed and correct data
166          rtn = compare(app, observed_data, correct_data)          rtn = compare(app, observed_data, correct_data)
167          (rtn_1, rst_good, rst_eh, rst_terrible, rst_compile) =  rtn          (rtn_1, rst_good, rst_eh, rst_terrible, rst_compile) =  rtn
168            x = ("\n\t-"+rtn_1+" "+names)
169            writeall(x)
170          if (rst_terrible!=1):          if (rst_terrible==1):
171              names= "t_"+str(ex_opr)+"_"+str(ex_num)+"_"+str(id)+"_"+str(app.oty.id)              writesummary(x)
             write2("\n\t-"+rtn_1+" "+names)  
172              path = fld+"/"+names              path = fld+"/"+names
173              os.system("mkdir "+path)              os.system("mkdir "+path)
174              os.system("cp data/output5_p_observ.diderot "+path+"/"+names+".diderot")              os.system("cp data/output5_p_observ.diderot "+path+"/"+names+".diderot")
# Line 151  Line 187 
187          clean()          clean()
188          return rtn          return rtn
189    
190    ########################################### specific ex. #######################################################
191  # get example from list of examples  # get example from list of examples
192  def single1_specific_ex(ex_opr, ex_num):  def single_specific_ex(ex_opr, ex_num):
193      #print "single specific ex"      #print "single specific ex"
194      (name,opr,ishape)= get_single_example(int(ex_opr), int(ex_num))      (name,opr,ishape)= get_single_example(int(ex_opr), int(ex_num))
     print name  
     print "ishape"  
     for i in ishape:  
         print i.name  
     print "opr",opr  
195      #create app object      #create app object
     print "AAA"  
196      (app, coeffs, dimF,_) = mkApply_fld(name, opr, ishape, inputfile)      (app, coeffs, dimF,_) = mkApply_fld(name, opr, ishape, inputfile)
197      # main      # main
     print "BBB"  
198      x = central(app, coeffs, dimF,ex_opr, ex_num,0)      x = central(app, coeffs, dimF,ex_opr, ex_num,0)
     print "CCC"  
199      return x      return x
 #run all examples for a specific operator  
 def single1_all_ops(ex_opr):  
     print "single all ops"  
     ex = get_ex(ex_opr)  
   
     #print(example.get_oprname(ex))  
     n = len(ex.tys)  
   
     rtn = [str(ex_opr)+": length "+str(n)]  
   
     print rtn  
     cnt = 0  
     total = n  
     rst_good = 0  
     rst_eh = 0  
     rst_terrible = 0  
     rst_compile = 0  
     for ex_num  in range(n):  
         #print (example.toStr(ex,ex_num))  
         print "\n----------------------*****************------------------------------\n"  
         x =  example.toStr(ex,ex_num)+" "+str(ex_opr)+"-"+str(ex_num)+":"  
         #print x  
         print "starting"+str(ex_num)  
         (rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = single1_specific_ex(ex_opr, ex_num)  
         rtn.append(rtn1)  
         rst_good +=rst_good1  
         rst_eh +=  rst_eh1  
         rst_terrible += rst_terrible1  
         rst_compile += rst_compile1  
             #if (rst_terrible1==1):  
             #raise "found terrible"  
     return (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n)  
200    
201  #run all possible examples  # checks to see if specific ex works
202  def depth1_all_exs():  def embed_base_specific_ex(ex_opr, ex_outer, ex_num, ex_ty2):
203      rtn = []      print ("embed_base_specific_ex: ex_opr,",ex_opr, " ex_outer:",ex_outer,"  ex_num: ", ex_num, " ex_ty2:", ex_ty2)
204      for ex_opr in range(opr_max+1):      opr_outer = get_outer(ex_outer)
205          (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n) = single1_all_ops(ex_opr)      fty= get_fty(ex_ty2)
206      for i in rtn:      id = ex_outer
207          print i      print "tree-A"
   
 ##################################################################################################  
208  # get result after applying operators  # get result after applying operators
209  def get_tshape(opr_inner,ishape):      def get_tshape(opr1, ishape):
210      arity=opr_inner.arity          print "tshape-A"
211            arity=opr1.arity
212      #print "checking for first time in rum.py"      #print "checking for first time in rum.py"
213      #print ("checking second layers", opr_inner.name,"ishape",ishape[0].name)      #print ("checking second layers", opr_inner.name,"ishape",ishape[0].name)
214            print "tshape-B"
215      if(arity==1):      if(arity==1):
216          return applyUnaryOp(opr_inner,ishape)              print "tshape-C"
217                print (opr1.name,ishape[0])
218                return applyUnaryOp(opr1,ishape)
219      elif(arity==2):      elif(arity==2):
220                print "tshape-D"
221          #print ("-", ishape[1].name)          #print ("-", ishape[1].name)
222          return applyBinaryOp(opr_inner,ishape)              return applyBinaryOp(opr1, ishape)
   
 # checks to see if specific ex works  
 def embed2_specific_ex(ex_opr, ex_num, opr_outer, fty,id):  
223      # current example      # current example
224        print "tree-B"
225      (name,opr_inner,ishape)= get_single_example(ex_opr, ex_num)      (name,opr_inner,ishape)= get_single_example(ex_opr, ex_num)
226      #print ("name:", name, "outer",opr_outer.name)      #print ("name:", name, "outer",opr_outer.name)
227      # first layer      # first layer
228      (_, tshape) = get_tshape(opr_inner,ishape)      print "tree-C"
229        (tf, tshape) = get_tshape(opr_inner,ishape)
230        if(tf==false):
231            return (0, "", 0, 0, 0,0)
232      #second layer, adds second field type      #second layer, adds second field type
233        print "tf",tf, "tshape",tshape
234        print "tree-D"
235      ishape = ishape+fty      ishape = ishape+fty
236        print "tree-E"
237      (tf, _) = get_tshape(opr_outer,[tshape]+fty)      (tf, _) = get_tshape(opr_outer,[tshape]+fty)
238      #print ("checking second layers", opr_outer.name,"ishape",ishape[0].name,ishape[1].name)      print "tree-F"
239        # checks to see if specific ex works
240      if(tf==true):# if it works continue      if(tf==true):# if it works continue
241          write("\n\t\tpassed ")          print "tf-T"
242            write("\n\t\t typechecks ")
243          #create app object          #create app object
244            print "mark -a"
245          name  = opr_outer.name+"("+opr_inner.name+")"          name  = opr_outer.name+"("+opr_inner.name+")"
246            print "mark -b"
247          #print "before mkapply twice"          #print "before mkapply twice"
248          (app, coeffs, dimF) = mkApply_twice(name, opr_inner,opr_outer, ishape, inputfile)          (app, coeffs, dimF) = mkApply_twice(name, opr_inner,opr_outer, ishape, inputfile)
249            print "mark -c"
250          #print "\nafter mk apply twice:\n",apply.toStr(app,0 )          #print "\nafter mk apply twice:\n",apply.toStr(app,0 )
251          # main part          # main part
252          (rtn0, rst_good, rst_eh, rst_terrible, rst_compile) =  central(app, coeffs, dimF,ex_opr, ex_num,id)          (rtn0, rst_good, rst_eh, rst_terrible, rst_compile) =  central(app, coeffs, dimF,ex_opr, ex_num,id)
253            print "mark d"
254          rtn = str(ex_opr)+"-"+str( ex_num)+"-"+str(  opr_outer.name)+"-"+name+":"+rtn0          rtn = str(ex_opr)+"-"+str( ex_num)+"-"+str(  opr_outer.name)+"-"+name+":"+rtn0
255            print "mark e"
256          return (1, rtn, rst_good, rst_eh, rst_terrible, rst_compile)          return (1, rtn, rst_good, rst_eh, rst_terrible, rst_compile)
257      else:      else:
258            print "tf-F"
259          x = "\n\t\tskipped did not apply "+opr_outer.name+" to ("+tshape.name+","          x = "\n\t\tskipped did not apply "+opr_outer.name+" to ("+tshape.name+","
260          write(x)          write(x)
261          return (0, x, 0, 0, 0,0)          return (0, x, 0, 0, 0,0)
262    
263  #apply all possible unary operators to a specific inside example  ################################################## iterating ###############################################
264  def embed2_outer(ex_opr, ex_num, opr_outer,ftyname, es, ex_outer):  #iterating ex_num from 0...n
265      #write("\n*******:"+name+" len("+str(n)+")******")  def embed_base_iter_num(ex_opr, ex_outer, ex_ty2, n):
266      x = "-i_opr#("+idToStr(ex_opr)      print ("embed_base_iter_num: ex_opr,",ex_opr, " ex_outer:",ex_outer, " ex_ty2:", ex_ty2, " n:", n)
     x +=")type#("+str(ex_num)+","+ftyname  
     x+=")o_opr#("+opr_outer.name  
     x+=" between that and "+ftyname  
     write("\n"+x)  
     return embed2_specific_ex(ex_opr, ex_num, opr_outer, es,ex_outer)  
   
 def embed2_apply_outer(ex_opr, ex_num, ex_outer, gty):  
     if(gty==-1):  
         print "found uanry"  
         #apply all possible unary operators to a specific inside example  
         opr_outer = op_unary[ex_outer]  
         return  embed2_outer(ex_opr, ex_num, opr_outer, "_",[],ex_outer)  
     else:  
         #apply all possible binary operators to a specific inside example  
         fty =l_all_F[gty]  
         opr_outer= op_binary[ex_outer]  
         return embed2_outer(ex_opr, ex_num, opr_outer, fty.name, [fty],ex_outer)  
   
 #apply all possible unary operators to a specific inside example  
 def embed2_iter_outer(ex_opr, ex_num, gty):  
     def getN():  
         if(gty==-1):  
             return len(op_unary)  
         else:  
             return len(op_binary)  
     n = getN()  
267      rtn = []      rtn = []
268      cnt = 0      cnt = 0
269      total = n      total = 0
270      rst_good = 0      rst_good = 0
271      rst_eh = 0      rst_eh = 0
272      rst_terrible = 0      rst_terrible = 0
273      rst_compile = 0      rst_compile = 0
274      for  ex_outer in range(n):      for ex_num  in range(n):
275          print ("current_cat :"+str(ex_opr)+"_"+str(ex_num)+"_"+str(ex_outer))          print ("embed_base_iter_num_inside loop: ex_opr,",ex_opr, " ex_outer:",ex_outer, " ex_ty2:", ex_ty2, " n:", n,"ex_num:",ex_num)
276          (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = embed2_apply_outer(ex_opr, ex_num, ex_outer, gty)          (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1) =  embed_base_specific_ex(ex_opr, ex_outer, ex_num, ex_ty2)
277            print "post embed_base_specific_ex"
278          rtn.append(rtn1)          rtn.append(rtn1)
279          cnt+=int(cnt1)          cnt+=int(cnt1)
280          rst_good +=rst_good1          rst_good +=rst_good1
# Line 296  Line 283 
283          rst_compile += rst_compile1          rst_compile += rst_compile1
284      return (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)      return (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)
285    
286  #run all examples for a specific operator  def embed_base_iter_ty2(ex_opr, ex_outer):
287  def embed2_iter_tys(ex_opr, gty):      print "embed_base_iter_ty2: ex_opr",ex_opr, " ex_outer:",ex_outer
288      n = len(get_ex(ex_opr).tys)      if(is_unary()):
289            gty=-1
290            nn = len(get_ex(ex_opr).tys)
291            return embed_base_iter_num(ex_opr, ex_outer, gty, nn)
292        else:
293      rtn = []      rtn = []
294      cnt = 0      cnt = 0
295      total = 0      total = 0
# Line 306  Line 297 
297      rst_eh = 0      rst_eh = 0
298      rst_terrible = 0      rst_terrible = 0
299      rst_compile = 0      rst_compile = 0
300      for ex_num  in range(n):          rst_total = 0
301          print ("\n\n*************************** ex_num"+str(ex_num)+" ***************************")          ex = get_ex(ex_opr)
302          (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1, total1) = embed2_iter_outer(ex_opr, ex_num, gty)          n = len(ex.tys)
303          rtn.append(rtn1)          m = len(l_all_F) # use all field types as extra types
304            for ex_ty2 in range(m):  #extra type
305                print "embed_base_iter_ty2: ex_opr",ex_opr, " ex_outer:",ex_outer," ex_ty2: ", ex_ty2
306                (cnt1, _, rst_good1, rst_eh1, rst_terrible1, rst_compile1, rst_total1) = embed_base_iter_num(ex_opr, ex_outer, ex_ty2, n)
307          cnt+=int(cnt1)          cnt+=int(cnt1)
308          total +=total1              total +=1
309          rst_good +=rst_good1          rst_good +=rst_good1
310          rst_eh +=  rst_eh1          rst_eh +=  rst_eh1
311          rst_terrible += rst_terrible1          rst_terrible += rst_terrible1
312          rst_compile += rst_compile1          rst_compile += rst_compile1
313                rst_total+=rst_total1
314      return  (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)      return  (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)
315    
316  #run all possible examples  #iterating ex_outer from 0...n
317  def embed2_iter_inner(gty):  def embed_base_iter_outer(ex_opr):
318      n = opr_max+1      print "\nembed_base_iter_outer: ex_opr",ex_opr
319        n = getN()
320      rtn = []      rtn = []
321      cnt = 0      cnt = 0
322      total = 0      total = 0
# Line 328  Line 324 
324      rst_eh = 0      rst_eh = 0
325      rst_terrible = 0      rst_terrible = 0
326      rst_compile = 0      rst_compile = 0
327      for ex_opr in range(n):      #have ex_opr iterating over ex_outer
328          (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1, total1) = embed2_iter_tys(ex_opr, gty)      for  ex_outer in range(n):
329            y = "\n\n"+idToOpr_outer(ex_outer)+ "_"+idToOpr_inner(ex_opr)+" |"+str(ex_opr)+"_"+str(ex_outer)
330            writetys(y)
331            (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1, total1) = embed_base_iter_ty2(ex_opr, ex_outer)
332          rtn.append(rtn1)          rtn.append(rtn1)
333          cnt+=int(cnt1)          cnt+=int(cnt1)
334          total +=total1          total +=total1
# Line 339  Line 338 
338          rst_compile += rst_compile1          rst_compile += rst_compile1
339      return (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)      return (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)
340    
341    #run all possible examples
342  n = int(todo) #command  def embed2_iter_inner():
343  if (n==0):      n = opr_max+1
     #write all the names  
     get_names()  
 elif (n==1):  
     #run all the programs  
     depth1_all_exs()  
 elif (n==-1):  
     #run all the programs  
     gty = -1  
     (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed2_iter_inner(gty)  
     pnt2("-1 cmd:", cnt, total, rst_good,  rst_eh, rst_terrible, rst_compile)  
     for i in rtn:  
         for j in i:  
             for k in j:  
                 print k  
 elif (n==2):  
     #run specific operators  
     ex_opr = int(sys.argv[3])  
     (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n)  = single1_all_ops(ex_opr)  
     pnt2("2 opr:"+str(ex_opr)+"("+get_exname(ex_opr)+")--" ,n, n, rst_good,  rst_eh, rst_terrible, rst_compile)  
     get_ex(ex_opr)  
     j=0  
     for i in rtn:  
   
         print (j,":",i)  
         j=j+1  
   
 elif(n==-2):  
     ex_opr = int(sys.argv[3])  
     gty = -1  
     (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed2_iter_tys(ex_opr, gty)  
     pnt2("-2 opr:"+str(ex_opr)+"("+get_exname(ex_opr)+")--", cnt, total, rst_good,  rst_eh, rst_terrible, rst_compile)  
     for i in rtn:  
         for j in i:  
             print (str(ex_opr)+":"+j)  
 elif (n==3):  
     # run one example  
     # with a specific operator  
     # number from generated list of types (not type id).  
     ex_opr = int(sys.argv[3])  
     ex_num = int(sys.argv[4])  
     (rtn, rst_good, rst_eh, rst_terrible, rst_compile) = single1_specific_ex(ex_opr, ex_num)  
     print rtn  
 elif (n==-3):  
     # run n examples  
     # with a specific operator,  
     # number from generated list of types (not type id.)  
     # and all possible outer operators  
     ex_opr = int(sys.argv[3])  
     ex_num = int(sys.argv[4])  
     gty = -1  
     (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed2_iter_outer(ex_opr, ex_num, gty)  
     for i in rtn:  
         print i  
 elif (n==4): # run a specific single layer example with type and opr  
     raise "unsupported"  
 elif(n==-4):  
     # run a specific double layer example  
     #str(ex_opr)+"-"+str( ex_num)+"-"+str(  opr_outer.name)  
     ex_opr = int(sys.argv[3])  
     ex_num = int(sys.argv[4])  
     ex_outer= int(sys.argv[5])  
     opr_outer= op_unary[ex_outer]  
     rtn = embed2_specific_ex(ex_opr, ex_num,  opr_outer,[], ex_outer)  
     print rtn  
 elif (n==-5):  
     #ex_opr)+","+str(ex_outer2)+","+str(ex_ty2)+","+str( ex_num  
     # run n examples  
     # with a specific operator,  
     # number from generated list of types (not type id.)  
     # and all possible outer operators  
     ex_opr = int(sys.argv[3])   #inside operator  
     ex_outer = int(sys.argv[4])#outer binary operator  
     ex_num = int(sys.argv[6])#inside type on list  
     ex_ty2 = int(sys.argv[5]) #extra type  
     (cnt, rtn, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = embed2_apply_outer(ex_opr, ex_num, ex_outer, ex_ty2)  
     print rtn  
 elif (n==-6):  
     # run n examples  
     # with a specific operator,  
     # number from generated list of types (not type id.)  
     # and all possible outer operators  
     ex_opr = int(sys.argv[3])   #inside operator  
     #ex_num = int(sys.argv[3])#inside type on list  
     ex_outer2 = int(sys.argv[4])#outer binary operator  
     if(ex_outer2>len(op_binary )):  
         raise Exception ("outer2 needs to be less than "+str(len(op_binary)))  
     #  ex_ty2 = int(sys.argv[5])  
344      rtn=[]      rtn=[]
     #ex_opr=10  
345      cnt = 0      cnt = 0
346      total = 0      total = 0
347      rst_good = 0      rst_good = 0
348      rst_eh = 0      rst_eh = 0
349      rst_terrible = 0      rst_terrible = 0
350      rst_compile = 0      rst_compile = 0
351      #for ex_opr in range(len(op_binary)):      for ex_opr in range(n):
352      ex = get_ex(ex_opr)          (cnt1, rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1, total1) = embed_base_iter_outer(ex_opr)
353      n = len(ex.tys)          rtn.append(rtn1)
     m = len(l_all_F)  
     write2("\n\n starting: " +str(ex_opr)+" outer range: 6, allF: "+str(m)+ " n: "+str(n))  
     for ex_ty2 in range(m):  #extra type  
         rst_good2 = 0  
         rst_eh2 = 0  
         rst_terrible2 = 0  
         rst_compile2 = 0  
         for  ex_num  in range(n):  
             print("current : "+str(ex_opr)+" "+str(ex_outer2)+" "+str(ex_ty2)+" "+str( ex_num))  
             #write2("\n"+str(ex_opr)+","+str(ex_outer2)+","+str(ex_ty2)+","+str( ex_num))  
             (cnt1, _, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = embed2_apply_outer(ex_opr, ex_num, ex_outer2, ex_ty2)  
             # rtn.append(rtn1)  
354              cnt+=int(cnt1)              cnt+=int(cnt1)
355              total +=1          total +=total1
356              rst_good +=rst_good1              rst_good +=rst_good1
357              rst_eh +=  rst_eh1              rst_eh +=  rst_eh1
358              rst_terrible += rst_terrible1              rst_terrible += rst_terrible1
359              rst_compile += rst_compile1              rst_compile += rst_compile1
360              rst_good2 +=rst_good1      return (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)
361              rst_eh2 +=  rst_eh1  
362              rst_terrible2 += rst_terrible1  
363              rst_compile2 += rst_compile1  #run all examples for a specific operator
364          pnt1("onerun:"+str(ex_opr)+","+str(ex_outer2)+","+str(ex_ty2),cnt, total,rst_good2,  rst_eh2, rst_terrible2, rst_compile2)  def single_all_ops(ex_opr):
365      pnt2(str(ex_opr)+":", cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile)      ex = get_ex(ex_opr)
366  elif (n==-7):      #print(example.get_oprname(ex))
367      # run n examples      n = len(ex.tys)
368      # with a specific operator,      if (n==0):
369      # number from generated list of types (not type id.)          return ("none", 0,0,0,0,0)
370      # and all possible outer operators      rtn = [str(ex_opr)+": length "+str(n)]
     ex_opr = int(sys.argv[3])   #inside operator  
     #ex_num = int(sys.argv[3])#inside type on list  
     # ex_outer2 = int(sys.argv[4])#outer binary operator  
     #  ex_ty2 = int(sys.argv[5])  
     rtn=[]  
     #ex_opr=10  
371      cnt = 0      cnt = 0
372      total = 0      total = n
373      rst_good = 0      rst_good = 0
374      rst_eh = 0      rst_eh = 0
375      rst_terrible = 0      rst_terrible = 0
376      rst_compile = 0      rst_compile = 0
377      #for ex_opr in range(len(op_binary)):      y = "\n\n"+idToOpr_inner(ex_opr)+" |"+str(ex_opr)
378      ex = get_ex(ex_opr)      writetys(y)
     n = len(ex.tys)  
     m = len(l_all_F)  
     #write2("\n\n starting: " +str(ex_opr)+" outer range: 6, allF: "+str(m)+ " n: "+str(n))  
     for ex_outer2 in range(6):  
         #write2("outer op"+str(ex_outer2)+"-"+idToStr(ex_outer2+6))  
         for ex_ty2 in range(m):  #extra type  
             rst_good2 = 0  
             rst_eh2 = 0  
             rst_terrible2 = 0  
             rst_compile2 = 0  
379              for  ex_num  in range(n):              for  ex_num  in range(n):
380                  print("current : "+str(ex_opr)+" "+str(ex_outer2)+" "+str(ex_ty2)+" "+str( ex_num))          (rtn1, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = single_specific_ex(ex_opr, ex_num)
381                  #write2("\n"+str(ex_opr)+","+str(ex_outer2)+","+str(ex_ty2)+","+str( ex_num))          rtn.append(rtn1)
                 (cnt1, _, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = embed2_apply_outer(ex_opr, ex_num, ex_outer2, ex_ty2)  
                 # rtn.append(rtn1)  
                 cnt+=int(cnt1)  
                 total +=1  
382                  rst_good +=rst_good1                  rst_good +=rst_good1
383                  rst_eh +=  rst_eh1                  rst_eh +=  rst_eh1
384                  rst_terrible += rst_terrible1                  rst_terrible += rst_terrible1
385                  rst_compile += rst_compile1                  rst_compile += rst_compile1
386                  rst_good2 +=rst_good1      return (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n)
387                  rst_eh2 +=  rst_eh1  
388                  rst_terrible2 += rst_terrible1  ##################################################################################################
389                  rst_compile2 += rst_compile1  ##################################################################################################
390      #       pnt1("onerun:"+str(ex_opr)+","+str(ex_outer2)+","+str(ex_ty2),cnt, total,rst_good2,  rst_eh2, rst_terrible2, rst_compile2)  cmd = "cmd: "+str(layer)+" "+str(args)+" "
391      #pnt2("cumulative:"+str(ex_opr)+","+sstr(ex_outer2),cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile)  if (layer==1):
392      pnt2("-2 opr:"+str(ex_opr)+"("+get_exname(ex_opr)+")--", cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile)      if(args==0):
393            # iterate over single layer
394            rtn = []
395            for ex_opr in range(opr_max+1):
396                (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n) = single_all_ops(ex_opr)
397                pnt2(cmd +str(ex_opr)+"("+get_exname(ex_opr)+")--" ,n, n, rst_good,  rst_eh, rst_terrible, rst_compile)
398        elif (args==1):
399            # iterate over single layer
400            ex_opr = int(sys.argv[3])
401            (rtn, rst_good, rst_eh, rst_terrible, rst_compile, n)  = single_all_ops(ex_opr)
402            pnt2(cmd +str(ex_opr)+"("+get_exname(ex_opr)+")--" ,n, n, rst_good,  rst_eh, rst_terrible, rst_compile)
403    elif (layer==2):
404        if(args==0):
405            #run all the programs
406            (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed2_iter_inner()
407            pnt2(cmd, cnt, total, rst_good,  rst_eh, rst_terrible, rst_compile)
408        elif(args==1):
409            # iterate over double layer with unary operator
410            ex_opr = int(sys.argv[3])
411            (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed_base_iter_outer(ex_opr)
412            pnt2(cmd+str(ex_opr)+"("+get_exname(ex_opr)+")--", cnt, total, rst_good,  rst_eh, rst_terrible, rst_compile)
413        elif(args==3):
414            #  run a specific iterate over double layer with unary operator
415            ex_opr = int(sys.argv[3])
416            ex_outer= int(sys.argv[4])
417            if((ex_outer)> 10):
418                raise Exception("not unary id:"+str(ex_outer))
419            ex_num = int(sys.argv[5])
420            ex_ty2 = None
421            rtn = embed_base_specific_ex(ex_opr, ex_outer, ex_num, ex_ty2)
422            print rtn
423    elif (layer==3):
424        # number from generated list of types (not type id.)
425        ex_opr = int(sys.argv[3])   #inside operator
426        if(args==0):
427            raise Exception("not possible to iterate over all binary operators")
428        elif (args==1):
429            # and all possible outer operators
430            (cnt, rtn, rst_good, rst_eh, rst_terrible, rst_compile, total)=  embed_base_iter_outer(ex_opr)
431            pnt2(cmd+str(ex_opr)+":", cnt, total,rst_good,  rst_eh, rst_terrible, rst_compile)
432        elif (args==2):
433            ex_outer = int(sys.argv[4])#outer binary operator
434            if(ex_outer>len(op_binary )):
435                raise Exception ("outer2 needs to be less than "+str(len(op_binary)))
436            y = "\n\n"+idToOpr_outer(ex_outer)+ "_"+idToOpr_inner(ex_opr)+" |"+str(ex_opr)+"_"+str(ex_outer)
437            writetys(y)
438            writeall(y)
439            (cnt, _, rst_good, rst_eh, rst_terrible, rst_compile, total) = embed_base_iter_ty2(ex_opr, ex_outer)
440            pnt2(cmd+str(ex_opr)+" "+str(ex_outer)+":", cnt, total, rst_good,  rst_eh, rst_terrible, rst_compile)
441        elif (args==4):
442            ex_outer = int(sys.argv[4]) # outer binary operator
443            ex_num = int(sys.argv[5])   # inside type on list
444            ex_ty2 = int(sys.argv[6])   # extra type (not in text file)
445            (cnt, rtn, rst_good1, rst_eh1, rst_terrible1, rst_compile1) = embed_base_specific_ex(ex_opr, ex_outer, ex_num, ex_ty2)
446            pnt2(cmd+str(ex_opr)+" "+str(ex_outer)+" "+str(ex_num)+" "+str(ex_ty2)+":", cnt, cnt, rst_good1,  rst_eh1, rst_terrible1, rst_compile1)
447  else:  else:
448    raise "unsupported"    raise "unsupported"

Legend:
Removed from v.4209  
changed lines
  Added in v.4210

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